diff --git a/.eslintrc.js b/.eslintrc.js index 6e926dee..981379f2 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -60,6 +60,8 @@ module.exports = { 'no-trailing-spaces': 'error', 'object-curly-spacing': ['error', 'always'], 'space-infix-ops': 'error', + 'no-unused-expressions': ['error', { allowShortCircuit: true, allowTernary: true }], + 'no-cond-assign': 'error', // These rules should eventually be enabled. 'no-async-promise-executor': 'off', diff --git a/public/scripts/extensions/expressions/index.js b/public/scripts/extensions/expressions/index.js index 629ff44d..426be18b 100644 --- a/public/scripts/extensions/expressions/index.js +++ b/public/scripts/extensions/expressions/index.js @@ -47,7 +47,7 @@ const EXPRESSION_API = { local: 0, extras: 1, llm: 2, -} +}; let expressionsList = null; let lastCharacter = undefined; @@ -979,25 +979,25 @@ function sampleClassifyText(text) { function onTextGenSettingsReady(args) { // Only call if inside an API call if (inApiCall) { - const emotions = DEFAULT_EXPRESSIONS.filter((e) => e != 'talkinghead') + const emotions = DEFAULT_EXPRESSIONS.filter((e) => e != 'talkinghead'); Object.assign(args, { top_k: 1, stop: [], stopping_strings: [], custom_token_bans: [], json_schema: { - $schema: "http://json-schema.org/draft-04/schema#", - type: "object", + $schema: 'http://json-schema.org/draft-04/schema#', + type: 'object', properties: { emotion: { - type: "string", - enum: emotions - } + type: 'string', + enum: emotions, + }, }, required: [ - "emotion" - ] - } + 'emotion', + ], + }, }); } } @@ -1055,7 +1055,7 @@ async function getExpressionLabel(text) { } } } catch (error) { - toastr.info("Could not classify expression. Check the console or your backend for more information.") + toastr.info('Could not classify expression. Check the console or your backend for more information.'); console.error(error); return getFallbackExpression(); } @@ -1236,7 +1236,7 @@ async function getExpressionsList() { const data = await apiResult.json(); expressionsList = data.labels; return expressionsList; - } + } } else { const apiResult = await fetch('/api/extra/classify/labels', { method: 'POST', @@ -1754,7 +1754,7 @@ async function fetchImagesNoCache() { function migrateSettings() { if (Object.keys(extension_settings.expressions).includes('local')) { if (extension_settings.expressions.local) { - extension_settings.expressions.api == EXPRESSION_API.local; + extension_settings.expressions.api = EXPRESSION_API.local; } delete extension_settings.expressions.local; @@ -1811,7 +1811,7 @@ function migrateSettings() { }); await renderAdditionalExpressionSettings(); - $('#expression_api').val(extension_settings.expressions.api || 0); + $('#expression_api').val(extension_settings.expressions.api || EXPRESSION_API.extras); $('#expression_custom_add').on('click', onClickExpressionAddCustom); $('#expression_custom_remove').on('click', onClickExpressionRemoveCustom);