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