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>
This commit is contained in:
+1
-1
@@ -98,7 +98,7 @@ module.exports = {
|
||||
'no-cond-assign': 'error',
|
||||
'no-unneeded-ternary': 'error',
|
||||
'no-irregular-whitespace': ['error', { skipStrings: true, skipTemplates: true }],
|
||||
|
||||
'dot-notation': ['error', { 'allowPattern': '[A-Z]\\w*$' }],
|
||||
// These rules should eventually be enabled.
|
||||
'no-async-promise-executor': 'off',
|
||||
'no-inner-declarations': 'off',
|
||||
|
||||
+2
-2
@@ -5170,7 +5170,7 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
|
||||
chatInjects: injectedIndices?.map(index => arrMes[arrMes.length - index - 1])?.join('') || '',
|
||||
summarizeString: (extension_prompts['1_memory']?.value || ''),
|
||||
authorsNoteString: (extension_prompts['2_floating_prompt']?.value || ''),
|
||||
smartContextString: (extension_prompts['chromadb']?.value || ''),
|
||||
smartContextString: (extension_prompts.chromadb?.value || ''),
|
||||
chatVectorsString: (extension_prompts['3_vectors']?.value || ''),
|
||||
dataBankVectorsString: (extension_prompts['4_vectors_data_bank']?.value || ''),
|
||||
worldInfoString: worldInfoString,
|
||||
@@ -9726,7 +9726,7 @@ export async function swipe(event, direction, { source, repeated, message = chat
|
||||
console.error(`Message #${mesId}'s DOM element is not valid.`);
|
||||
return;
|
||||
}
|
||||
const originalSwipeId = Number(chat[mesId]?.['swipe_id'] ?? 0);
|
||||
const originalSwipeId = Number(chat[mesId]?.swipe_id ?? 0);
|
||||
let newSwipeId = Number(forceSwipeId ?? originalSwipeId);
|
||||
|
||||
/**
|
||||
|
||||
@@ -527,9 +527,9 @@ class CoquiTtsProvider {
|
||||
// Check if already installed and propose to do it otherwise
|
||||
const model_id = modelDict[model_language][model_dataset][model_name].id;
|
||||
console.debug(DEBUG_PREFIX,'Check if model is already installed',model_id);
|
||||
let result = await CoquiTtsProvider.checkmodel_state(model_id);
|
||||
result = await result.json();
|
||||
const model_state = result['model_state'];
|
||||
const result = await CoquiTtsProvider.checkmodel_state(model_id);
|
||||
const resultJSON = await result.json();
|
||||
const model_state = resultJSON.model_state;
|
||||
|
||||
console.debug(DEBUG_PREFIX, ' Model state:', model_state);
|
||||
|
||||
@@ -556,18 +556,18 @@ class CoquiTtsProvider {
|
||||
$('#coqui_api_model_install_status').text('Downloading model...');
|
||||
$('#coqui_api_model_install_button').hide();
|
||||
//toastr.info("For model "+model_id, DEBUG_PREFIX+" Started "+action, { timeOut: 10000, extendedTimeOut: 20000, preventDuplicates: true });
|
||||
let apiResult = await CoquiTtsProvider.installModel(model_id, action);
|
||||
apiResult = await apiResult.json();
|
||||
const apiResult = await CoquiTtsProvider.installModel(model_id, action);
|
||||
const apiResultJSON = await apiResult.json();
|
||||
|
||||
console.debug(DEBUG_PREFIX, 'Response:', apiResult);
|
||||
|
||||
if (apiResult['status'] == 'done') {
|
||||
if (apiResultJSON.status == 'done') {
|
||||
$('#coqui_api_model_install_status').text('Model installed and ready to use!');
|
||||
$('#coqui_api_model_install_button').hide();
|
||||
onModelNameChange_pointer();
|
||||
}
|
||||
|
||||
if (apiResult['status'] == 'downloading') {
|
||||
if (apiResultJSON.status == 'downloading') {
|
||||
toastr.error('Check extras console for progress', DEBUG_PREFIX + ' already downloading', { timeOut: 10000, extendedTimeOut: 20000, preventDuplicates: true });
|
||||
$('#coqui_api_model_install_status').text('Already downloading a model, check extras console!');
|
||||
$('#coqui_api_model_install_button').show();
|
||||
@@ -750,10 +750,10 @@ async function initLocalModels() {
|
||||
|
||||
// Initialized local model once
|
||||
if (!coquiLocalModelsReceived) {
|
||||
let result = await CoquiTtsProvider.getLocalModelList();
|
||||
result = await result.json();
|
||||
const result = await CoquiTtsProvider.getLocalModelList();
|
||||
const resultJSON = await result.json();
|
||||
|
||||
coquiLocalModels = result['models_list'];
|
||||
coquiLocalModels = resultJSON.models_list;
|
||||
|
||||
$('#coqui_local_model_name').show();
|
||||
$('#coqui_local_model_name')
|
||||
|
||||
@@ -1312,7 +1312,7 @@ async function preparePromptsForChatCompletion({ scenario, charPersonality, name
|
||||
});
|
||||
|
||||
// Smart Context (ChromaDB)
|
||||
const smartContext = extensionPrompts['chromadb'];
|
||||
const smartContext = extensionPrompts.chromadb;
|
||||
if (smartContext && smartContext.value) systemPrompts.push({
|
||||
role: 'system',
|
||||
content: smartContext.value,
|
||||
|
||||
@@ -727,6 +727,7 @@ class PresetManager {
|
||||
'show_hidden',
|
||||
'max_additions',
|
||||
];
|
||||
/** @type {Record<string, any>} */
|
||||
const settings = Object.assign({}, getSettingsByApiId(this.apiId));
|
||||
|
||||
for (const key of filteredKeys) {
|
||||
@@ -736,8 +737,8 @@ class PresetManager {
|
||||
}
|
||||
|
||||
if (!this.isAdvancedFormatting() && this.apiId !== 'openai') {
|
||||
settings['genamt'] = amount_gen;
|
||||
settings['max_length'] = max_context;
|
||||
settings.genamt = amount_gen;
|
||||
settings.max_length = max_context;
|
||||
}
|
||||
|
||||
return settings;
|
||||
|
||||
@@ -1405,7 +1405,7 @@ export class SlashCommandParser {
|
||||
const pipeName = `_PARSER_PIPE_${uuidv4()}`;
|
||||
const storePipe = new SlashCommandExecutor(startIdx); {
|
||||
storePipe.end = endIdx;
|
||||
storePipe.command = this.commands['let'];
|
||||
storePipe.command = this.commands.let;
|
||||
storePipe.name = 'let';
|
||||
const nameAss = new SlashCommandUnnamedArgumentAssignment();
|
||||
nameAss.value = pipeName;
|
||||
@@ -1428,7 +1428,7 @@ export class SlashCommandParser {
|
||||
const varName = `_PARSER_VAR_${uuidv4()}`;
|
||||
const setvar = new SlashCommandExecutor(startIdx); {
|
||||
setvar.end = endIdx;
|
||||
setvar.command = this.commands['let'];
|
||||
setvar.command = this.commands.let;
|
||||
setvar.name = 'let';
|
||||
const nameAss = new SlashCommandUnnamedArgumentAssignment();
|
||||
nameAss.value = varName;
|
||||
@@ -1440,7 +1440,7 @@ export class SlashCommandParser {
|
||||
// return pipe
|
||||
const returnPipe = new SlashCommandExecutor(startIdx); {
|
||||
returnPipe.end = endIdx;
|
||||
returnPipe.command = this.commands['return'];
|
||||
returnPipe.command = this.commands.return;
|
||||
returnPipe.name = 'return';
|
||||
const varAss = new SlashCommandUnnamedArgumentAssignment();
|
||||
varAss.value = `{{var::${pipeName}}}`;
|
||||
@@ -1565,7 +1565,7 @@ export class SlashCommandParser {
|
||||
parseBreakPoint() {
|
||||
const cmd = new SlashCommandBreakPoint();
|
||||
cmd.name = 'breakpoint';
|
||||
cmd.command = this.commands['breakpoint'];
|
||||
cmd.command = this.commands.breakpoint;
|
||||
cmd.start = this.index + 1;
|
||||
this.take('/breakpoint'.length);
|
||||
cmd.end = this.index;
|
||||
@@ -1580,7 +1580,7 @@ export class SlashCommandParser {
|
||||
parseBreak() {
|
||||
const cmd = new SlashCommandBreak();
|
||||
cmd.name = 'break';
|
||||
cmd.command = this.commands['break'];
|
||||
cmd.command = this.commands.break;
|
||||
cmd.start = this.index + 1;
|
||||
this.take('/break'.length);
|
||||
this.discardWhitespace();
|
||||
@@ -1683,7 +1683,7 @@ export class SlashCommandParser {
|
||||
const cmd = new SlashCommandExecutor(start);
|
||||
cmd.name = ':';
|
||||
cmd.unnamedArgumentList = [];
|
||||
cmd.command = this.commands['run'];
|
||||
cmd.command = this.commands.run;
|
||||
this.commandIndex.push(cmd);
|
||||
this.scopeIndex.push(this.scope.getCopy());
|
||||
this.take(2); //discard "/:"
|
||||
|
||||
@@ -2456,7 +2456,7 @@ export async function fetchFaFile(name) {
|
||||
const sheet = style.sheet;
|
||||
style.remove();
|
||||
return [...sheet.cssRules]
|
||||
.filter(rule => rule['style']?.content)
|
||||
.filter(rule => (rule instanceof CSSStyleRule && rule.style?.content))
|
||||
.map(rule => rule['selectorText'].split(/,\s*/).map(selector => selector.split('::').shift().slice(1)))
|
||||
;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/* eslint-disable dot-notation */
|
||||
import process from 'node:process';
|
||||
import util from 'node:util';
|
||||
import express from 'express';
|
||||
|
||||
@@ -400,9 +400,9 @@ router.post('/electronhub/models', async (request, response) => {
|
||||
console.warn('ElectronHub models request failed', result.statusText, text);
|
||||
return response.status(500).send(text);
|
||||
}
|
||||
|
||||
/** @type {any} */
|
||||
const data = await result.json();
|
||||
const models = data && Array.isArray(data['data']) ? data['data'] : [];
|
||||
const models = data && Array.isArray(data.data) ? data.data : [];
|
||||
return response.json(models);
|
||||
} catch (error) {
|
||||
console.error('ElectronHub models fetch failed', error);
|
||||
|
||||
@@ -51,7 +51,7 @@ async function extractTranscript(videoPageBody, lang) {
|
||||
} catch (e) {
|
||||
return undefined;
|
||||
}
|
||||
})()?.['playerCaptionsTracklistRenderer'];
|
||||
})()?.playerCaptionsTracklistRenderer;
|
||||
|
||||
if (!captions) {
|
||||
throw new Error('Transcript disabled');
|
||||
|
||||
Reference in New Issue
Block a user