Enable no-useless-escape lint

This commit is contained in:
valadaptive 2023-12-02 10:17:31 -05:00
parent 97c49a405b
commit b023312117
9 changed files with 9 additions and 10 deletions

View File

@ -51,7 +51,6 @@ module.exports = {
// linting passes.
rules: {
'no-unused-vars': 'off',
'no-useless-escape': 'off',
'no-control-regex': 'off',
'no-redeclare': 'off',
'no-async-promise-executor': 'off',

View File

@ -1460,9 +1460,9 @@ function messageFormatting(mes, ch_name, isSystem, isUser) {
.replace(/\*\*(.+?)\*\*/g, "<b>$1</b>")
.replace(/\n/g, "<br/>");
} else if (!isSystem) {
mes = mes.replace(/```[\s\S]*?```|``[\s\S]*?``|`[\s\S]*?`|(\".+?\")|(\u201C.+?\u201D)/gm, function (match, p1, p2) {
mes = mes.replace(/```[\s\S]*?```|``[\s\S]*?``|`[\s\S]*?`|(".+?")|(\u201C.+?\u201D)/gm, function (match, p1, p2) {
if (p1) {
return '<q>"' + p1.replace(/\"/g, "") + '"</q>';
return '<q>"' + p1.replace(/"/g, "") + '"</q>';
} else if (p2) {
return '<q>“' + p2.replace(/\u201C|\u201D/g, "") + '”</q>';
} else {

View File

@ -1818,7 +1818,7 @@ const chatCompletionDefaultPrompts = {
"identifier": "enhanceDefinitions",
"role": "system",
"name": "Enhance Definitions",
"content": "If you have more knowledge of {{char}}, add to the character\'s lore and personality to enhance them but keep the Character Sheet\'s definitions absolute.",
"content": "If you have more knowledge of {{char}}, add to the character's lore and personality to enhance them but keep the Character Sheet's definitions absolute.",
"system_prompt": true,
"marker": false,
},

View File

@ -763,7 +763,7 @@ function sampleClassifyText(text) {
}
// Remove asterisks and quotes
let result = text.replace(/[\*\"]/g, '');
let result = text.replace(/[*"]/g, '');
const SAMPLE_THRESHOLD = 500;
const HALF_SAMPLE_THRESHOLD = SAMPLE_THRESHOLD / 2;

View File

@ -492,7 +492,7 @@ async function processTtsQueue() {
currentTtsJob = ttsJobQueue.shift()
let text = extension_settings.tts.narrate_translated_only ? (currentTtsJob?.extra?.display_text || currentTtsJob.mes) : currentTtsJob.mes
text = extension_settings.tts.narrate_dialogues_only
? text.replace(/\*[^\*]*?(\*|$)/g, '').trim() // remove asterisks content
? text.replace(/\*[^*]*?(\*|$)/g, '').trim() // remove asterisks content
: text.replaceAll('*', '').trim() // remove just the asterisks
if (extension_settings.tts.narrate_quoted_only) {

View File

@ -655,7 +655,7 @@ function calculateLogitBias() {
* @returns Processed prompt
*/
export function adjustNovelInstructionPrompt(prompt) {
const stripedPrompt = prompt.replace(/[\[\]]/g, '').trim();
const stripedPrompt = prompt.replace(/[[\]]/g, '').trim();
if (!stripedPrompt.includes('{ ')) {
return `{ ${stripedPrompt} }`;
}

View File

@ -340,7 +340,7 @@ function collapseNewlines(x) {
*/
function fixMarkdown(text, forDisplay) {
// Find pairs of formatting characters and capture the text in between them
const format = /([\*_]{1,2})([\s\S]*?)\1/gm;
const format = /([*_]{1,2})([\s\S]*?)\1/gm;
let matches = [];
let match;
while ((match = format.exec(text)) !== null) {

View File

@ -694,7 +694,7 @@ export function splitRecursive(input, length, delimiters = ['\n\n', '\n', ' ', '
* isDataURL('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA...'); // true
*/
export function isDataURL(str) {
const regex = /^data:([a-z]+\/[a-z0-9-+.]+(;[a-z-]+=[a-z0-9-]+)*;?)?(base64)?,([a-z0-9!$&',()*+;=\-_%.~:@\/?#]+)?$/i;
const regex = /^data:([a-z]+\/[a-z0-9-+.]+(;[a-z-]+=[a-z0-9-]+)*;?)?(base64)?,([a-z0-9!$&',()*+;=\-_%.~:@/?#]+)?$/i;
return regex.test(str);
}

View File

@ -20,7 +20,7 @@ function checkAssetFileName(inputFilename) {
return '';
}
if (!/^[a-zA-Z0-9_\-\.]+$/.test(inputFilename)) {
if (!/^[a-zA-Z0-9_\-.]+$/.test(inputFilename)) {
console.debug("Bad request: illegal character in filename, only alphanumeric, '_', '-' are accepted.");
return '';
}