mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Enable no-useless-escape lint
This commit is contained in:
@ -51,7 +51,6 @@ module.exports = {
|
|||||||
// linting passes.
|
// linting passes.
|
||||||
rules: {
|
rules: {
|
||||||
'no-unused-vars': 'off',
|
'no-unused-vars': 'off',
|
||||||
'no-useless-escape': 'off',
|
|
||||||
'no-control-regex': 'off',
|
'no-control-regex': 'off',
|
||||||
'no-redeclare': 'off',
|
'no-redeclare': 'off',
|
||||||
'no-async-promise-executor': 'off',
|
'no-async-promise-executor': 'off',
|
||||||
|
@ -1460,9 +1460,9 @@ function messageFormatting(mes, ch_name, isSystem, isUser) {
|
|||||||
.replace(/\*\*(.+?)\*\*/g, "<b>$1</b>")
|
.replace(/\*\*(.+?)\*\*/g, "<b>$1</b>")
|
||||||
.replace(/\n/g, "<br/>");
|
.replace(/\n/g, "<br/>");
|
||||||
} else if (!isSystem) {
|
} 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) {
|
if (p1) {
|
||||||
return '<q>"' + p1.replace(/\"/g, "") + '"</q>';
|
return '<q>"' + p1.replace(/"/g, "") + '"</q>';
|
||||||
} else if (p2) {
|
} else if (p2) {
|
||||||
return '<q>“' + p2.replace(/\u201C|\u201D/g, "") + '”</q>';
|
return '<q>“' + p2.replace(/\u201C|\u201D/g, "") + '”</q>';
|
||||||
} else {
|
} else {
|
||||||
|
@ -1818,7 +1818,7 @@ const chatCompletionDefaultPrompts = {
|
|||||||
"identifier": "enhanceDefinitions",
|
"identifier": "enhanceDefinitions",
|
||||||
"role": "system",
|
"role": "system",
|
||||||
"name": "Enhance Definitions",
|
"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,
|
"system_prompt": true,
|
||||||
"marker": false,
|
"marker": false,
|
||||||
},
|
},
|
||||||
|
@ -763,7 +763,7 @@ function sampleClassifyText(text) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Remove asterisks and quotes
|
// Remove asterisks and quotes
|
||||||
let result = text.replace(/[\*\"]/g, '');
|
let result = text.replace(/[*"]/g, '');
|
||||||
|
|
||||||
const SAMPLE_THRESHOLD = 500;
|
const SAMPLE_THRESHOLD = 500;
|
||||||
const HALF_SAMPLE_THRESHOLD = SAMPLE_THRESHOLD / 2;
|
const HALF_SAMPLE_THRESHOLD = SAMPLE_THRESHOLD / 2;
|
||||||
|
@ -492,7 +492,7 @@ async function processTtsQueue() {
|
|||||||
currentTtsJob = ttsJobQueue.shift()
|
currentTtsJob = ttsJobQueue.shift()
|
||||||
let text = extension_settings.tts.narrate_translated_only ? (currentTtsJob?.extra?.display_text || currentTtsJob.mes) : currentTtsJob.mes
|
let text = extension_settings.tts.narrate_translated_only ? (currentTtsJob?.extra?.display_text || currentTtsJob.mes) : currentTtsJob.mes
|
||||||
text = extension_settings.tts.narrate_dialogues_only
|
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
|
: text.replaceAll('*', '').trim() // remove just the asterisks
|
||||||
|
|
||||||
if (extension_settings.tts.narrate_quoted_only) {
|
if (extension_settings.tts.narrate_quoted_only) {
|
||||||
|
@ -655,7 +655,7 @@ function calculateLogitBias() {
|
|||||||
* @returns Processed prompt
|
* @returns Processed prompt
|
||||||
*/
|
*/
|
||||||
export function adjustNovelInstructionPrompt(prompt) {
|
export function adjustNovelInstructionPrompt(prompt) {
|
||||||
const stripedPrompt = prompt.replace(/[\[\]]/g, '').trim();
|
const stripedPrompt = prompt.replace(/[[\]]/g, '').trim();
|
||||||
if (!stripedPrompt.includes('{ ')) {
|
if (!stripedPrompt.includes('{ ')) {
|
||||||
return `{ ${stripedPrompt} }`;
|
return `{ ${stripedPrompt} }`;
|
||||||
}
|
}
|
||||||
|
@ -340,7 +340,7 @@ function collapseNewlines(x) {
|
|||||||
*/
|
*/
|
||||||
function fixMarkdown(text, forDisplay) {
|
function fixMarkdown(text, forDisplay) {
|
||||||
// Find pairs of formatting characters and capture the text in between them
|
// 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 matches = [];
|
||||||
let match;
|
let match;
|
||||||
while ((match = format.exec(text)) !== null) {
|
while ((match = format.exec(text)) !== null) {
|
||||||
|
@ -694,7 +694,7 @@ export function splitRecursive(input, length, delimiters = ['\n\n', '\n', ' ', '
|
|||||||
* isDataURL('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA...'); // true
|
* isDataURL('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA...'); // true
|
||||||
*/
|
*/
|
||||||
export function isDataURL(str) {
|
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);
|
return regex.test(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ function checkAssetFileName(inputFilename) {
|
|||||||
return '';
|
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.");
|
console.debug("Bad request: illegal character in filename, only alphanumeric, '_', '-' are accepted.");
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user