diff --git a/.eslintrc.js b/.eslintrc.js index 4cf54ff58..58ad08dbf 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -59,19 +59,9 @@ module.exports = { 'no-extra-semi': 'off', 'no-undef': 'off', 'no-prototype-builtins': 'off', - 'no-unused-labels': 'off', 'no-extra-boolean-cast': 'off', 'require-yield': 'off', 'no-case-declarations': 'off', - 'use-isnan': 'off', - 'no-self-assign': 'off', - 'no-unsafe-negation': 'off', - 'no-constant-condition': 'off', - 'no-empty': 'off', - 'no-unsafe-finally': 'off', - 'no-dupe-keys': 'off', - 'no-irregular-whitespace': 'off', - 'no-regex-spaces': 'off', - 'no-fallthrough': 'off' + 'no-constant-condition': ['error', {checkLoops: false}] } }; diff --git a/public/scripts/RossAscends-mods.js b/public/scripts/RossAscends-mods.js index bb73fac9d..87bc323aa 100644 --- a/public/scripts/RossAscends-mods.js +++ b/public/scripts/RossAscends-mods.js @@ -1,5 +1,3 @@ -esversion: 6 - import { Generate, characters, diff --git a/public/scripts/extensions/regex/index.js b/public/scripts/extensions/regex/index.js index bce655efb..97870a158 100644 --- a/public/scripts/extensions/regex/index.js +++ b/public/scripts/extensions/regex/index.js @@ -178,7 +178,7 @@ async function onRegexEditorOpenClick(existingId) { .filter(":checked") .map(function () { return parseInt($(this).val()) }) .get() - .filter((e) => e !== NaN) || [], + .filter((e) => !isNaN(e)) || [], disabled: editorHtml .find(`input[name="disabled"]`) diff --git a/public/scripts/extensions/tts/elevenlabs.js b/public/scripts/extensions/tts/elevenlabs.js index 4cb7813fe..032b1c9df 100644 --- a/public/scripts/extensions/tts/elevenlabs.js +++ b/public/scripts/extensions/tts/elevenlabs.js @@ -115,7 +115,6 @@ class ElevenLabsTtsProvider { await this.fetchTtsVoiceObjects().catch(error => { throw `TTS API key validation failed` }) - this.settings.apiKey = this.settings.apiKey console.debug(`Saved new API_KEY: ${this.settings.apiKey}`) $('#tts_status').text('') this.onSettingsChange() diff --git a/public/scripts/extensions/tts/index.js b/public/scripts/extensions/tts/index.js index a1f6b7a07..f43e192ff 100644 --- a/public/scripts/extensions/tts/index.js +++ b/public/scripts/extensions/tts/index.js @@ -421,12 +421,12 @@ function completeCurrentAudioJob() { /** * Accepts an HTTP response containing audio/mpeg data, and puts the data as a Blob() on the queue for playback - * @param {*} response + * @param {Response} response */ async function addAudioJob(response) { const audioData = await response.blob() - if (!audioData.type in ['audio/mpeg', 'audio/wav', 'audio/x-wav', 'audio/wave', 'audio/webm']) { - throw `TTS received HTTP response with invalid data format. Expecting audio/mpeg, got ${audioData.type}` + if (!audioData.type.startsWith('audio/')) { + throw `TTS received HTTP response with invalid data format. Expecting audio/*, got ${audioData.type}` } audioJobQueue.push(audioData) console.debug('Pushed audio job to queue.') diff --git a/public/scripts/group-chats.js b/public/scripts/group-chats.js index 89244f0f3..e3441fe12 100644 --- a/public/scripts/group-chats.js +++ b/public/scripts/group-chats.js @@ -1604,9 +1604,7 @@ export async function getGroupPastChats(groupId) { } catch (err) { console.error(err); } - finally { - return chats; - } + return chats; } export async function openGroupChat(groupId, chatId) { diff --git a/public/scripts/kai-settings.js b/public/scripts/kai-settings.js index 75c0fc10c..96bf8502e 100644 --- a/public/scripts/kai-settings.js +++ b/public/scripts/kai-settings.js @@ -66,7 +66,9 @@ export function formatKoboldUrl(value) { url.pathname = '/api'; } return url.toString(); - } catch { } // Just using URL as a validation check + } catch { + // Just using URL as a validation check + } return null; } diff --git a/public/scripts/openai.js b/public/scripts/openai.js index 3adccfe6b..21f643572 100644 --- a/public/scripts/openai.js +++ b/public/scripts/openai.js @@ -1696,9 +1696,7 @@ async function calculateLogitBias() { result = {}; console.error(err); } - finally { - return result; - } + return result; } class TokenHandler { diff --git a/public/scripts/slash-commands.js b/public/scripts/slash-commands.js index ba4a717ea..d13e84221 100644 --- a/public/scripts/slash-commands.js +++ b/public/scripts/slash-commands.js @@ -1281,7 +1281,7 @@ export async function promptQuietForLoudResponse(who, text) { } else if (who === 'char') { text = characters[character_id].name + ": " + text; } else if (who === 'raw') { - text = text; + // We don't need to modify the text } //text = `${text}${power_user.instruct.enabled ? '' : '\n'}${(power_user.always_force_name2 && who != 'raw') ? characters[character_id].name + ":" : ""}` diff --git a/public/scripts/stats.js b/public/scripts/stats.js index e62b6e883..938704377 100644 --- a/public/scripts/stats.js +++ b/public/scripts/stats.js @@ -288,7 +288,6 @@ async function statMesProcess(line, type, characters, this_chid, oldMesssage) { user_word_count: 0, non_user_msg_count: 0, user_msg_count: 0, - non_user_msg_count: 0, total_swipe_count: 0, date_first_chat: Date.now(), date_last_chat: Date.now(), diff --git a/public/scripts/textgen-settings.js b/public/scripts/textgen-settings.js index a23bec16f..427a289a1 100644 --- a/public/scripts/textgen-settings.js +++ b/public/scripts/textgen-settings.js @@ -174,7 +174,9 @@ function formatTextGenURL(value) { url.pathname = '/api'; } return url.toString(); - } catch { } // Just using URL as a validation check + } catch { + // Just using URL as a validation check + } return null; } diff --git a/public/scripts/world-info.js b/public/scripts/world-info.js index 437ce3df7..a267378b3 100644 --- a/public/scripts/world-info.js +++ b/public/scripts/world-info.js @@ -1908,6 +1908,7 @@ async function checkWorldInfo(chat, maxContext) { entries: [entry.content] }); } + break; default: break; } diff --git a/server.js b/server.js index 9ff08178e..7fa66ed9d 100644 --- a/server.js +++ b/server.js @@ -118,7 +118,9 @@ if (fs.existsSync(whitelistPath)) { try { let whitelistTxt = fs.readFileSync(whitelistPath, 'utf-8'); whitelist = whitelistTxt.split("\n").filter(ip => ip).map(ip => ip.trim()); - } catch (e) { } + } catch (e) { + // Ignore errors that may occur when reading the whitelist (e.g. permissions) + } } const whitelistMode = getConfigValue('whitelistMode', true); @@ -781,7 +783,7 @@ app.post("/getchat", jsonParser, function (request, response) { const lines = data.split('\n'); // Iterate through the array of strings and parse each line as JSON - const jsonData = lines.map((l) => { try { return JSON.parse(l); } catch (_) { } }).filter(x => x); + const jsonData = lines.map((l) => { try { return JSON.parse(l); } catch (_) { return; } }).filter(x => x); return response.send(jsonData); } catch (error) { console.error(error); @@ -1285,10 +1287,10 @@ async function charaWrite(img_url, data, target_img, response = undefined, mes = for (let tEXtChunk of tEXtChunks) { chunks.splice(chunks.indexOf(tEXtChunk), 1); } - // Add new chunks before the IEND chunk + // Add new chunks before the IEND chunk const base64EncodedData = Buffer.from(data, 'utf8').toString('base64'); chunks.splice(-1, 0, PNGtext.encode('chara', base64EncodedData)); - //chunks.splice(-1, 0, text.encode('lorem', 'ipsum')); + //chunks.splice(-1, 0, text.encode('lorem', 'ipsum')); writeFileAtomicSync(charactersPath + target_img + '.png', Buffer.from(encode(chunks))); if (response !== undefined) response.send(mes); diff --git a/src/assets.js b/src/assets.js index 572de8765..832eeb7b0 100644 --- a/src/assets.js +++ b/src/assets.js @@ -118,9 +118,7 @@ function registerEndpoints(app, jsonParser) { catch (err) { console.log(err); } - finally { - return response.send(output); - } + return response.send(output); }); /** diff --git a/src/sprites.js b/src/sprites.js index d51adfc8a..ba25eee2c 100644 --- a/src/sprites.js +++ b/src/sprites.js @@ -133,9 +133,7 @@ function registerEndpoints(app, jsonParser, urlencodedParser) { catch (err) { console.log(err); } - finally { - return response.send(sprites); - } + return response.send(sprites); }); app.post('/api/sprites/delete', jsonParser, async (request, response) => { diff --git a/src/stable-diffusion.js b/src/stable-diffusion.js index fd6a9c8fb..049685280 100644 --- a/src/stable-diffusion.js +++ b/src/stable-diffusion.js @@ -12,9 +12,7 @@ const writeFileAtomicSync = require('write-file-atomic').sync; */ function safeStr(x) { x = String(x); - for (let i = 0; i < 16; i++) { - x = x.replace(/ /g, ' '); - } + x = x.replace(/ +/g, ' '); x = x.trim(); x = x.replace(/^[\s,.]+|[\s,.]+$/g, ''); return x;