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 -26Showing whitespace changes
.eslintrc.cjs+1 -1
@@ -98,7 +98,7 @@ module.exports = {
9898 'no-cond-assign': 'error',
9999 'no-unneeded-ternary': 'error',
100100 'no-irregular-whitespace': ['error', { skipStrings: true, skipTemplates: true }],
101-
101+ 'dot-notation': ['error', { 'allowPattern': '[A-Z]\\w*$' }],
102102 // These rules should eventually be enabled.
103103 'no-async-promise-executor': 'off',
104104 'no-inner-declarations': 'off',
public/script.js+2 -2
@@ -5170,7 +5170,7 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
51705170 chatInjects: injectedIndices?.map(index => arrMes[arrMes.length - index - 1])?.join('') || '',
51715171 summarizeString: (extension_prompts['1_memory']?.value || ''),
51725172 authorsNoteString: (extension_prompts['2_floating_prompt']?.value || ''),
51735173 smartContextString: (extension_prompts['.chromadb']?.value || ''),
51745174 chatVectorsString: (extension_prompts['3_vectors']?.value || ''),
51755175 dataBankVectorsString: (extension_prompts['4_vectors_data_bank']?.value || ''),
51765176 worldInfoString: worldInfoString,
@@ -9726,7 +9726,7 @@ export async function swipe(event, direction, { source, repeated, message = chat
97269726 console.error(`Message #${mesId}'s DOM element is not valid.`);
97279727 return;
97289728 }
97299729 const originalSwipeId = Number(chat[mesId]?.['swipe_id'] ?? 0);
97309730 let newSwipeId = Number(forceSwipeId ?? originalSwipeId);
97319731
97329732 /**
public/scripts/extensions/tts/coqui.js+10 -10
@@ -527,9 +527,9 @@ class CoquiTtsProvider {
527527 // Check if already installed and propose to do it otherwise
528528 const model_id = modelDict[model_language][model_dataset][model_name].id;
529529 console.debug(DEBUG_PREFIX,'Check if model is already installed',model_id);
530530 letconst result = await CoquiTtsProvider.checkmodel_state(model_id);
531531 resultconst resultJSON = await result.json();
532532 const model_state = result['resultJSON.model_state'];
533533
534534 console.debug(DEBUG_PREFIX, ' Model state:', model_state);
535535
@@ -556,18 +556,18 @@ class CoquiTtsProvider {
556556 $('#coqui_api_model_install_status').text('Downloading model...');
557557 $('#coqui_api_model_install_button').hide();
558558 //toastr.info("For model "+model_id, DEBUG_PREFIX+" Started "+action, { timeOut: 10000, extendedTimeOut: 20000, preventDuplicates: true });
559559 letconst apiResult = await CoquiTtsProvider.installModel(model_id, action);
560560 apiResultconst apiResultJSON = await apiResult.json();
561561
562562 console.debug(DEBUG_PREFIX, 'Response:', apiResult);
563563
564564 if (apiResult['apiResultJSON.status'] == 'done') {
565565 $('#coqui_api_model_install_status').text('Model installed and ready to use!');
566566 $('#coqui_api_model_install_button').hide();
567567 onModelNameChange_pointer();
568568 }
569569
570570 if (apiResult['apiResultJSON.status'] == 'downloading') {
571571 toastr.error('Check extras console for progress', DEBUG_PREFIX + ' already downloading', { timeOut: 10000, extendedTimeOut: 20000, preventDuplicates: true });
572572 $('#coqui_api_model_install_status').text('Already downloading a model, check extras console!');
573573 $('#coqui_api_model_install_button').show();
@@ -750,10 +750,10 @@ async function initLocalModels() {
750750
751751 // Initialized local model once
752752 if (!coquiLocalModelsReceived) {
753753 letconst result = await CoquiTtsProvider.getLocalModelList();
754754 resultconst resultJSON = await result.json();
755755
756756 coquiLocalModels = result['resultJSON.models_list'];
757757
758758 $('#coqui_local_model_name').show();
759759 $('#coqui_local_model_name')
public/scripts/openai.js+1 -1
@@ -1312,7 +1312,7 @@ async function preparePromptsForChatCompletion({ scenario, charPersonality, name
13121312 });
13131313
13141314 // Smart Context (ChromaDB)
13151315 const smartContext = extensionPrompts['.chromadb'];
13161316 if (smartContext && smartContext.value) systemPrompts.push({
13171317 role: 'system',
13181318 content: smartContext.value,
public/scripts/preset-manager.js+3 -2
@@ -727,6 +727,7 @@ class PresetManager {
727727 'show_hidden',
728728 'max_additions',
729729 ];
730+ /** @type {Record<string, any>} */
730731 const settings = Object.assign({}, getSettingsByApiId(this.apiId));
731732
732733 for (const key of filteredKeys) {
@@ -736,8 +737,8 @@ class PresetManager {
736737 }
737738
738739 if (!this.isAdvancedFormatting() && this.apiId !== 'openai') {
739740 settings['.genamt'] = amount_gen;
740741 settings['.max_length'] = max_context;
741742 }
742743
743744 return settings;
public/scripts/slash-commands/SlashCommandParser.js+6 -6
@@ -1405,7 +1405,7 @@ export class SlashCommandParser {
14051405 const pipeName = `_PARSER_PIPE_${uuidv4()}`;
14061406 const storePipe = new SlashCommandExecutor(startIdx); {
14071407 storePipe.end = endIdx;
14081408 storePipe.command = this.commands['.let'];
14091409 storePipe.name = 'let';
14101410 const nameAss = new SlashCommandUnnamedArgumentAssignment();
14111411 nameAss.value = pipeName;
@@ -1428,7 +1428,7 @@ export class SlashCommandParser {
14281428 const varName = `_PARSER_VAR_${uuidv4()}`;
14291429 const setvar = new SlashCommandExecutor(startIdx); {
14301430 setvar.end = endIdx;
14311431 setvar.command = this.commands['.let'];
14321432 setvar.name = 'let';
14331433 const nameAss = new SlashCommandUnnamedArgumentAssignment();
14341434 nameAss.value = varName;
@@ -1440,7 +1440,7 @@ export class SlashCommandParser {
14401440 // return pipe
14411441 const returnPipe = new SlashCommandExecutor(startIdx); {
14421442 returnPipe.end = endIdx;
14431443 returnPipe.command = this.commands['.return'];
14441444 returnPipe.name = 'return';
14451445 const varAss = new SlashCommandUnnamedArgumentAssignment();
14461446 varAss.value = `{{var::${pipeName}}}`;
@@ -1565,7 +1565,7 @@ export class SlashCommandParser {
15651565 parseBreakPoint() {
15661566 const cmd = new SlashCommandBreakPoint();
15671567 cmd.name = 'breakpoint';
15681568 cmd.command = this.commands['.breakpoint'];
15691569 cmd.start = this.index + 1;
15701570 this.take('/breakpoint'.length);
15711571 cmd.end = this.index;
@@ -1580,7 +1580,7 @@ export class SlashCommandParser {
15801580 parseBreak() {
15811581 const cmd = new SlashCommandBreak();
15821582 cmd.name = 'break';
15831583 cmd.command = this.commands['.break'];
15841584 cmd.start = this.index + 1;
15851585 this.take('/break'.length);
15861586 this.discardWhitespace();
@@ -1683,7 +1683,7 @@ export class SlashCommandParser {
16831683 const cmd = new SlashCommandExecutor(start);
16841684 cmd.name = ':';
16851685 cmd.unnamedArgumentList = [];
16861686 cmd.command = this.commands['.run'];
16871687 this.commandIndex.push(cmd);
16881688 this.scopeIndex.push(this.scope.getCopy());
16891689 this.take(2); //discard "/:"
public/scripts/utils.js+1 -1
@@ -2456,7 +2456,7 @@ export async function fetchFaFile(name) {
24562456 const sheet = style.sheet;
24572457 style.remove();
24582458 return [...sheet.cssRules]
24592459 .filter(rule => (rule[' instanceof CSSStyleRule && rule.style']?.content))
24602460 .map(rule => rule['selectorText'].split(/,\s*/).map(selector => selector.split('::').shift().slice(1)))
24612461 ;
24622462}
src/endpoints/backends/chat-completions.js+1 -0
@@ -1,3 +1,4 @@
1+/* eslint-disable dot-notation */
12import process from 'node:process';
23import util from 'node:util';
34import express from 'express';
src/endpoints/openai.js+2 -2
@@ -400,9 +400,9 @@ router.post('/electronhub/models', async (request, response) => {
400400 console.warn('ElectronHub models request failed', result.statusText, text);
401401 return response.status(500).send(text);
402402 }
403-
403+ /** @type {any} */
404404 const data = await result.json();
405405 const models = data && Array.isArray(data['.data']) ? data['.data'] : [];
406406 return response.json(models);
407407 } catch (error) {
408408 console.error('ElectronHub models fetch failed', error);
src/endpoints/search.js+1 -1
@@ -51,7 +51,7 @@ async function extractTranscript(videoPageBody, lang) {
5151 } catch (e) {
5252 return undefined;
5353 }
5454 })()?.['playerCaptionsTracklistRenderer'];
5555
5656 if (!captions) {
5757 throw new Error('Transcript disabled');