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

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