Enable no-prototype-builtins lint

This commit is contained in:
valadaptive 2023-12-02 10:21:57 -05:00
parent b023312117
commit c893e2165e
12 changed files with 15 additions and 15 deletions

View File

@ -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}]
}

View File

@ -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;
}

View File

@ -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];
}
}

View File

@ -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];
}
}

View File

@ -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];
}

View File

@ -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);
}

View File

@ -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);
}
}

View File

@ -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];
}
}

View File

@ -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!');
}

View File

@ -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] = {};
}

View File

@ -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');

View File

@ -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;
}