Added `'dot-notation': ['error']` to `.eslint.cjs` (#5042) * Added 'dot-notation': ['error'], to `.eslint.cjs` * Ran `eslint --fix` to correct `dot-notation` errors. * Added `eslint-disable dot-notation` anywhere errors were caused. * Allowed dot-notation for uppercase properties: 'allowPattern': '[A-Z]\\w*$' * Check if `rule instanceof CSSStyleRule` https://github.com/SillyTavern/SillyTavern/pull/5042#discussion_r2711827148 * Fixed `await result.json();` types. * refactor: update dot-notation usage in CoquiTtsProvider and PresetManager --------- Co-authored-by: user <user@exmaple.com> Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>

a09c1a7a8405a4dc27cf787203da29ff1d5f738d

DeclineThyself <235079501+DeclineThyself@users.noreply.github.com>

Signed
10 files changed, +28 -26Ignore whitespace
.eslintrc.cjs+1 -1
@@ -98,7 +98,7 @@ module.exports = {
98 'no-cond-assign': 'error',98 'no-cond-assign': 'error',
99 'no-unneeded-ternary': 'error',99 'no-unneeded-ternary': 'error',
100 'no-irregular-whitespace': ['error', { skipStrings: true, skipTemplates: true }],100 'no-irregular-whitespace': ['error', { skipStrings: true, skipTemplates: true }],
101101 'dot-notation': ['error', { 'allowPattern': '[A-Z]\\w*$' }],
102 // These rules should eventually be enabled.102 // These rules should eventually be enabled.
103 'no-async-promise-executor': 'off',103 'no-async-promise-executor': 'off',
104 'no-inner-declarations': 'off',104 'no-inner-declarations': 'off',
public/script.js+2 -2
@@ -5170,7 +5170,7 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
5170 chatInjects: injectedIndices?.map(index => arrMes[arrMes.length - index - 1])?.join('') || '',5170 chatInjects: injectedIndices?.map(index => arrMes[arrMes.length - index - 1])?.join('') || '',
5171 summarizeString: (extension_prompts['1_memory']?.value || ''),5171 summarizeString: (extension_prompts['1_memory']?.value || ''),
5172 authorsNoteString: (extension_prompts['2_floating_prompt']?.value || ''),5172 authorsNoteString: (extension_prompts['2_floating_prompt']?.value || ''),
5173 smartContextString: (extension_prompts['chromadb']?.value || ''),5173 smartContextString: (extension_prompts.chromadb?.value || ''),
5174 chatVectorsString: (extension_prompts['3_vectors']?.value || ''),5174 chatVectorsString: (extension_prompts['3_vectors']?.value || ''),
5175 dataBankVectorsString: (extension_prompts['4_vectors_data_bank']?.value || ''),5175 dataBankVectorsString: (extension_prompts['4_vectors_data_bank']?.value || ''),
5176 worldInfoString: worldInfoString,5176 worldInfoString: worldInfoString,
@@ -9726,7 +9726,7 @@ export async function swipe(event, direction, { source, repeated, message = chat
9726 console.error(`Message #${mesId}'s DOM element is not valid.`);9726 console.error(`Message #${mesId}'s DOM element is not valid.`);
9727 return;9727 return;
9728 }9728 }
9729 const originalSwipeId = Number(chat[mesId]?.['swipe_id'] ?? 0);9729 const originalSwipeId = Number(chat[mesId]?.swipe_id ?? 0);
9730 let newSwipeId = Number(forceSwipeId ?? originalSwipeId);9730 let newSwipeId = Number(forceSwipeId ?? originalSwipeId);
97319731
9732 /**9732 /**
public/scripts/extensions/tts/coqui.js+10 -10
@@ -527,9 +527,9 @@ class CoquiTtsProvider {
527 // Check if already installed and propose to do it otherwise527 // Check if already installed and propose to do it otherwise
528 const model_id = modelDict[model_language][model_dataset][model_name].id;528 const model_id = modelDict[model_language][model_dataset][model_name].id;
529 console.debug(DEBUG_PREFIX,'Check if model is already installed',model_id);529 console.debug(DEBUG_PREFIX,'Check if model is already installed',model_id);
530 let result = await CoquiTtsProvider.checkmodel_state(model_id);530 const result = await CoquiTtsProvider.checkmodel_state(model_id);
531 result = await result.json();531 const resultJSON = await result.json();
532 const model_state = result['model_state'];532 const model_state = resultJSON.model_state;
533533
534 console.debug(DEBUG_PREFIX, ' Model state:', model_state);534 console.debug(DEBUG_PREFIX, ' Model state:', model_state);
535535
@@ -556,18 +556,18 @@ class CoquiTtsProvider {
556 $('#coqui_api_model_install_status').text('Downloading model...');556 $('#coqui_api_model_install_status').text('Downloading model...');
557 $('#coqui_api_model_install_button').hide();557 $('#coqui_api_model_install_button').hide();
558 //toastr.info("For model "+model_id, DEBUG_PREFIX+" Started "+action, { timeOut: 10000, extendedTimeOut: 20000, preventDuplicates: true });558 //toastr.info("For model "+model_id, DEBUG_PREFIX+" Started "+action, { timeOut: 10000, extendedTimeOut: 20000, preventDuplicates: true });
559 let apiResult = await CoquiTtsProvider.installModel(model_id, action);559 const apiResult = await CoquiTtsProvider.installModel(model_id, action);
560 apiResult = await apiResult.json();560 const apiResultJSON = await apiResult.json();
561561
562 console.debug(DEBUG_PREFIX, 'Response:', apiResult);562 console.debug(DEBUG_PREFIX, 'Response:', apiResult);
563563
564 if (apiResult['status'] == 'done') {564 if (apiResultJSON.status == 'done') {
565 $('#coqui_api_model_install_status').text('Model installed and ready to use!');565 $('#coqui_api_model_install_status').text('Model installed and ready to use!');
566 $('#coqui_api_model_install_button').hide();566 $('#coqui_api_model_install_button').hide();
567 onModelNameChange_pointer();567 onModelNameChange_pointer();
568 }568 }
569569
570 if (apiResult['status'] == 'downloading') {570 if (apiResultJSON.status == 'downloading') {
571 toastr.error('Check extras console for progress', DEBUG_PREFIX + ' already downloading', { timeOut: 10000, extendedTimeOut: 20000, preventDuplicates: true });571 toastr.error('Check extras console for progress', DEBUG_PREFIX + ' already downloading', { timeOut: 10000, extendedTimeOut: 20000, preventDuplicates: true });
572 $('#coqui_api_model_install_status').text('Already downloading a model, check extras console!');572 $('#coqui_api_model_install_status').text('Already downloading a model, check extras console!');
573 $('#coqui_api_model_install_button').show();573 $('#coqui_api_model_install_button').show();
@@ -750,10 +750,10 @@ async function initLocalModels() {
750750
751 // Initialized local model once751 // Initialized local model once
752 if (!coquiLocalModelsReceived) {752 if (!coquiLocalModelsReceived) {
753 let result = await CoquiTtsProvider.getLocalModelList();753 const result = await CoquiTtsProvider.getLocalModelList();
754 result = await result.json();754 const resultJSON = await result.json();
755755
756 coquiLocalModels = result['models_list'];756 coquiLocalModels = resultJSON.models_list;
757757
758 $('#coqui_local_model_name').show();758 $('#coqui_local_model_name').show();
759 $('#coqui_local_model_name')759 $('#coqui_local_model_name')
public/scripts/openai.js+1 -1
@@ -1312,7 +1312,7 @@ async function preparePromptsForChatCompletion({ scenario, charPersonality, name
1312 });1312 });
13131313
1314 // Smart Context (ChromaDB)1314 // Smart Context (ChromaDB)
1315 const smartContext = extensionPrompts['chromadb'];1315 const smartContext = extensionPrompts.chromadb;
1316 if (smartContext && smartContext.value) systemPrompts.push({1316 if (smartContext && smartContext.value) systemPrompts.push({
1317 role: 'system',1317 role: 'system',
1318 content: smartContext.value,1318 content: smartContext.value,
public/scripts/preset-manager.js+3 -2
@@ -727,6 +727,7 @@ class PresetManager {
727 'show_hidden',727 'show_hidden',
728 'max_additions',728 'max_additions',
729 ];729 ];
730 /** @type {Record<string, any>} */
730 const settings = Object.assign({}, getSettingsByApiId(this.apiId));731 const settings = Object.assign({}, getSettingsByApiId(this.apiId));
731732
732 for (const key of filteredKeys) {733 for (const key of filteredKeys) {
@@ -736,8 +737,8 @@ class PresetManager {
736 }737 }
737738
738 if (!this.isAdvancedFormatting() && this.apiId !== 'openai') {739 if (!this.isAdvancedFormatting() && this.apiId !== 'openai') {
739 settings['genamt'] = amount_gen;740 settings.genamt = amount_gen;
740 settings['max_length'] = max_context;741 settings.max_length = max_context;
741 }742 }
742743
743 return settings;744 return settings;
public/scripts/slash-commands/SlashCommandParser.js+6 -6
@@ -1405,7 +1405,7 @@ export class SlashCommandParser {
1405 const pipeName = `_PARSER_PIPE_${uuidv4()}`;1405 const pipeName = `_PARSER_PIPE_${uuidv4()}`;
1406 const storePipe = new SlashCommandExecutor(startIdx); {1406 const storePipe = new SlashCommandExecutor(startIdx); {
1407 storePipe.end = endIdx;1407 storePipe.end = endIdx;
1408 storePipe.command = this.commands['let'];1408 storePipe.command = this.commands.let;
1409 storePipe.name = 'let';1409 storePipe.name = 'let';
1410 const nameAss = new SlashCommandUnnamedArgumentAssignment();1410 const nameAss = new SlashCommandUnnamedArgumentAssignment();
1411 nameAss.value = pipeName;1411 nameAss.value = pipeName;
@@ -1428,7 +1428,7 @@ export class SlashCommandParser {
1428 const varName = `_PARSER_VAR_${uuidv4()}`;1428 const varName = `_PARSER_VAR_${uuidv4()}`;
1429 const setvar = new SlashCommandExecutor(startIdx); {1429 const setvar = new SlashCommandExecutor(startIdx); {
1430 setvar.end = endIdx;1430 setvar.end = endIdx;
1431 setvar.command = this.commands['let'];1431 setvar.command = this.commands.let;
1432 setvar.name = 'let';1432 setvar.name = 'let';
1433 const nameAss = new SlashCommandUnnamedArgumentAssignment();1433 const nameAss = new SlashCommandUnnamedArgumentAssignment();
1434 nameAss.value = varName;1434 nameAss.value = varName;
@@ -1440,7 +1440,7 @@ export class SlashCommandParser {
1440 // return pipe1440 // return pipe
1441 const returnPipe = new SlashCommandExecutor(startIdx); {1441 const returnPipe = new SlashCommandExecutor(startIdx); {
1442 returnPipe.end = endIdx;1442 returnPipe.end = endIdx;
1443 returnPipe.command = this.commands['return'];1443 returnPipe.command = this.commands.return;
1444 returnPipe.name = 'return';1444 returnPipe.name = 'return';
1445 const varAss = new SlashCommandUnnamedArgumentAssignment();1445 const varAss = new SlashCommandUnnamedArgumentAssignment();
1446 varAss.value = `{{var::${pipeName}}}`;1446 varAss.value = `{{var::${pipeName}}}`;
@@ -1565,7 +1565,7 @@ export class SlashCommandParser {
1565 parseBreakPoint() {1565 parseBreakPoint() {
1566 const cmd = new SlashCommandBreakPoint();1566 const cmd = new SlashCommandBreakPoint();
1567 cmd.name = 'breakpoint';1567 cmd.name = 'breakpoint';
1568 cmd.command = this.commands['breakpoint'];1568 cmd.command = this.commands.breakpoint;
1569 cmd.start = this.index + 1;1569 cmd.start = this.index + 1;
1570 this.take('/breakpoint'.length);1570 this.take('/breakpoint'.length);
1571 cmd.end = this.index;1571 cmd.end = this.index;
@@ -1580,7 +1580,7 @@ export class SlashCommandParser {
1580 parseBreak() {1580 parseBreak() {
1581 const cmd = new SlashCommandBreak();1581 const cmd = new SlashCommandBreak();
1582 cmd.name = 'break';1582 cmd.name = 'break';
1583 cmd.command = this.commands['break'];1583 cmd.command = this.commands.break;
1584 cmd.start = this.index + 1;1584 cmd.start = this.index + 1;
1585 this.take('/break'.length);1585 this.take('/break'.length);
1586 this.discardWhitespace();1586 this.discardWhitespace();
@@ -1683,7 +1683,7 @@ export class SlashCommandParser {
1683 const cmd = new SlashCommandExecutor(start);1683 const cmd = new SlashCommandExecutor(start);
1684 cmd.name = ':';1684 cmd.name = ':';
1685 cmd.unnamedArgumentList = [];1685 cmd.unnamedArgumentList = [];
1686 cmd.command = this.commands['run'];1686 cmd.command = this.commands.run;
1687 this.commandIndex.push(cmd);1687 this.commandIndex.push(cmd);
1688 this.scopeIndex.push(this.scope.getCopy());1688 this.scopeIndex.push(this.scope.getCopy());
1689 this.take(2); //discard "/:"1689 this.take(2); //discard "/:"
public/scripts/utils.js+1 -1
@@ -2456,7 +2456,7 @@ export async function fetchFaFile(name) {
2456 const sheet = style.sheet;2456 const sheet = style.sheet;
2457 style.remove();2457 style.remove();
2458 return [...sheet.cssRules]2458 return [...sheet.cssRules]
2459 .filter(rule => rule['style']?.content)2459 .filter(rule => (rule instanceof CSSStyleRule && rule.style?.content))
2460 .map(rule => rule['selectorText'].split(/,\s*/).map(selector => selector.split('::').shift().slice(1)))2460 .map(rule => rule['selectorText'].split(/,\s*/).map(selector => selector.split('::').shift().slice(1)))
2461 ;2461 ;
2462}2462}
src/endpoints/backends/chat-completions.js+1 -0
@@ -1,3 +1,4 @@
1/* eslint-disable dot-notation */
1import process from 'node:process';2import process from 'node:process';
2import util from 'node:util';3import util from 'node:util';
3import express from 'express';4import express from 'express';
src/endpoints/openai.js+2 -2
@@ -400,9 +400,9 @@ router.post('/electronhub/models', async (request, response) => {
400 console.warn('ElectronHub models request failed', result.statusText, text);400 console.warn('ElectronHub models request failed', result.statusText, text);
401 return response.status(500).send(text);401 return response.status(500).send(text);
402 }402 }
403403 /** @type {any} */
404 const data = await result.json();404 const data = await result.json();
405 const models = data && Array.isArray(data['data']) ? data['data'] : [];405 const models = data && Array.isArray(data.data) ? data.data : [];
406 return response.json(models);406 return response.json(models);
407 } catch (error) {407 } catch (error) {
408 console.error('ElectronHub models fetch failed', error);408 console.error('ElectronHub models fetch failed', error);
src/endpoints/search.js+1 -1
@@ -51,7 +51,7 @@ async function extractTranscript(videoPageBody, lang) {
51 } catch (e) {51 } catch (e) {
52 return undefined;52 return undefined;
53 }53 }
54 })()?.['playerCaptionsTracklistRenderer'];54 })()?.playerCaptionsTracklistRenderer;
5555
56 if (!captions) {56 if (!captions) {
57 throw new Error('Transcript disabled');57 throw new Error('Transcript disabled');