diff --git a/.eslintrc.js b/.eslintrc.js index 45acee758..6aa30b437 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -56,7 +56,6 @@ module.exports = { 'no-async-promise-executor': 'off', 'no-inner-declarations': 'off', 'no-undef': 'off', - 'no-prototype-builtins': 'off', 'require-yield': 'off', 'no-constant-condition': ['error', {checkLoops: false}] } diff --git a/public/scripts/PromptManager.js b/public/scripts/PromptManager.js index 6734e5a60..3132972c8 100644 --- a/public/scripts/PromptManager.js +++ b/public/scripts/PromptManager.js @@ -1643,7 +1643,7 @@ PromptManagerModule.prototype.import = function (importData) { */ PromptManagerModule.prototype.validateObject = function (controlObj, object) { for (let key in controlObj) { - if (!object.hasOwnProperty(key)) { + if (!Object.hasOwn(object, key)) { if (controlObj[key] === null) continue; else return false; } diff --git a/public/scripts/extensions/translate/index.js b/public/scripts/extensions/translate/index.js index dad4dcd40..61e5b03b3 100644 --- a/public/scripts/extensions/translate/index.js +++ b/public/scripts/extensions/translate/index.js @@ -151,7 +151,7 @@ function showKeysButton() { function loadSettings() { for (const key in defaultSettings) { - if (!extension_settings.translate.hasOwnProperty(key)) { + if (!Object.hasOwn(extension_settings.translate, key)) { extension_settings.translate[key] = defaultSettings[key]; } } diff --git a/public/scripts/extensions/tts/system.js b/public/scripts/extensions/tts/system.js index b87aa2aad..9c1af3b7e 100644 --- a/public/scripts/extensions/tts/system.js +++ b/public/scripts/extensions/tts/system.js @@ -46,7 +46,7 @@ var speechUtteranceChunker = function (utt, settings, callback) { newUtt = new SpeechSynthesisUtterance(chunk); var x; for (x in utt) { - if (utt.hasOwnProperty(x) && x !== 'text') { + if (Object.hasOwn(utt, x) && x !== 'text') { newUtt[x] = utt[x]; } } diff --git a/public/scripts/extensions/vectors/index.js b/public/scripts/extensions/vectors/index.js index 93eaf5303..5e243616c 100644 --- a/public/scripts/extensions/vectors/index.js +++ b/public/scripts/extensions/vectors/index.js @@ -145,7 +145,7 @@ const hashCache = {}; */ function getStringHash(str) { // Check if the hash is already in the cache - if (hashCache.hasOwnProperty(str)) { + if (Object.hasOwn(hashCache, str)) { return hashCache[str]; } diff --git a/public/scripts/kai-settings.js b/public/scripts/kai-settings.js index 96bf8502e..80f9e3852 100644 --- a/public/scripts/kai-settings.js +++ b/public/scripts/kai-settings.js @@ -87,11 +87,11 @@ export function loadKoboldSettings(preset) { $(slider.counterId).val(formattedValue); } - if (preset.hasOwnProperty('streaming_kobold')) { + if (Object.hasOwn(preset, 'streaming_kobold')) { kai_settings.streaming_kobold = preset.streaming_kobold; $('#streaming_kobold').prop('checked', kai_settings.streaming_kobold); } - if (preset.hasOwnProperty('use_default_badwordsids')) { + if (Object.hasOwn(preset, 'use_default_badwordsids')) { kai_settings.use_default_badwordsids = preset.use_default_badwordsids; $('#use_default_badwordsids').prop('checked', kai_settings.use_default_badwordsids); } diff --git a/public/scripts/openai.js b/public/scripts/openai.js index 622754841..d3de0660d 100644 --- a/public/scripts/openai.js +++ b/public/scripts/openai.js @@ -2832,7 +2832,8 @@ async function onLogitBiasPresetImportFileChange(e) { for (const entry of importedFile) { if (typeof entry == 'object' && entry !== null) { - if (entry.hasOwnProperty('text') && entry.hasOwnProperty('value')) { + if (Object.hasOwn(entry, 'text') && + Object.hasOwn(entry, 'value')) { validEntries.push(entry); } } diff --git a/public/scripts/preset-manager.js b/public/scripts/preset-manager.js index 27eec79b6..f2320b149 100644 --- a/public/scripts/preset-manager.js +++ b/public/scripts/preset-manager.js @@ -270,7 +270,7 @@ class PresetManager { const settings = Object.assign({}, getSettingsByApiId(this.apiId)); for (const key of filteredKeys) { - if (settings.hasOwnProperty(key)) { + if (Object.hasOwn(settings, key)) { delete settings[key]; } } diff --git a/public/scripts/slash-commands.js b/public/scripts/slash-commands.js index d13e84221..8db07a93f 100644 --- a/public/scripts/slash-commands.js +++ b/public/scripts/slash-commands.js @@ -58,7 +58,7 @@ class SlashCommandParser { addCommand(command, callback, aliases, helpString = '', interruptsGeneration = false, purgeFromMessage = true) { const fnObj = { callback, helpString, interruptsGeneration, purgeFromMessage }; - if ([command, ...aliases].some(x => this.commands.hasOwnProperty(x))) { + if ([command, ...aliases].some(x => Object.hasOwn(this.commands, x))) { console.trace('WARN: Duplicate slash command registered!'); } diff --git a/public/scripts/world-info.js b/public/scripts/world-info.js index 6404ec4e3..1330593bd 100644 --- a/public/scripts/world-info.js +++ b/public/scripts/world-info.js @@ -778,7 +778,7 @@ function setOriginalDataValue(data, uid, key, value) { for (let i = 0; i < keyParts.length - 1; i++) { const part = keyParts[i]; - if (!currentObject.hasOwnProperty(part)) { + if (!Object.hasOwn(currentObject, part)) { currentObject[part] = {}; } diff --git a/src/classify.js b/src/classify.js index d9a5a72a7..8773deb28 100644 --- a/src/classify.js +++ b/src/classify.js @@ -24,7 +24,7 @@ function registerEndpoints(app, jsonParser) { const { text } = req.body; async function getResult(text) { - if (cacheObject.hasOwnProperty(text)) { + if (Object.hasOwn(cacheObject, text)) { return cacheObject[text]; } else { const module = await import('./transformers.mjs'); diff --git a/src/validator/TavernCardValidator.js b/src/validator/TavernCardValidator.js index dabd0b595..b3093b1de 100644 --- a/src/validator/TavernCardValidator.js +++ b/src/validator/TavernCardValidator.js @@ -48,7 +48,7 @@ class TavernCardValidator { validateV1() { const requiredFields = ['name', 'description', 'personality', 'scenario', 'first_mes', 'mes_example']; return requiredFields.every(field => { - if (!this.card.hasOwnProperty(field)) { + if (!Object.hasOwn(this.card, field)) { this.#lastValidationError = field; return false; } @@ -94,7 +94,7 @@ class TavernCardValidator { const requiredFields = ['name', 'description', 'personality', 'scenario', 'first_mes', 'mes_example', 'creator_notes', 'system_prompt', 'post_history_instructions', 'alternate_greetings', 'tags', 'creator', 'character_version', 'extensions']; const isAllRequiredFieldsPresent = requiredFields.every(field => { - if (!data.hasOwnProperty(field)) { + if (!Object.hasOwn(data, field)) { this.#lastValidationError = `data.${field}`; return false; } @@ -113,7 +113,7 @@ class TavernCardValidator { const requiredFields = ['extensions', 'entries']; const isAllRequiredFieldsPresent = requiredFields.every(field => { - if (!characterBook.hasOwnProperty(field)) { + if (!Object.hasOwn(characterBook, field)) { this.#lastValidationError = `data.character_book.${field}`; return false; }