From e8ab55641148cfc24bba621a21bab937c1605e32 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Mon, 8 Apr 2024 09:24:40 -0400 Subject: [PATCH] Fix eslint warnings --- src/js/cachestorage.js | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/js/cachestorage.js b/src/js/cachestorage.js index 19f2daee9..78049a9b9 100644 --- a/src/js/cachestorage.js +++ b/src/js/cachestorage.js @@ -19,17 +19,14 @@ Home: https://github.com/gorhill/uBlock */ -/* global indexedDB */ - -'use strict'; - /******************************************************************************/ +import * as s14e from './s14e-serializer.js'; + import lz4Codec from './lz4.js'; +import { ubolog } from './console.js'; import webext from './webext.js'; import µb from './background.js'; -import { ubolog } from './console.js'; -import * as s14e from './s14e-serializer.js'; /******************************************************************************/ @@ -47,6 +44,10 @@ const keysFromGetArg = arg => { let fastCache = 'indexedDB'; +// https://eslint.org/docs/latest/rules/no-prototype-builtins +const hasOwnProperty = (o, p) => + Object.prototype.hasOwnProperty.call(o, p); + /******************************************************************************* * * Extension storage @@ -65,7 +66,7 @@ const cacheStorage = (( ) => { if ( found.length === wanted.length ) { return; } const missing = []; for ( const key of wanted ) { - if ( outbin.hasOwnProperty(key) ) { continue; } + if ( hasOwnProperty(outbin, key) ) { continue; } missing.push(key); } return missing; @@ -107,7 +108,7 @@ const cacheStorage = (( ) => { if ( argbin instanceof Object === false ) { return; } if ( Array.isArray(argbin) ) { return; } for ( const key of wanted ) { - if ( argbin.hasOwnProperty(key) === false ) { continue; } + if ( hasOwnProperty(argbin, key) === false ) { continue; } outbin[key] = argbin[key]; } }).then(( ) => { @@ -165,7 +166,7 @@ const cacheStorage = (( ) => { }, select(api) { - if ( cacheAPIs.hasOwnProperty(api) === false ) { return fastCache; } + if ( hasOwnProperty(cacheAPIs, api) === false ) { return fastCache; } fastCache = api; for ( const k of Object.keys(cacheAPIs) ) { if ( k === api ) { continue; } @@ -591,7 +592,7 @@ const idbStorage = (( ) => { const transaction = db.transaction(STORAGE_NAME, 'readonly'); transaction.oncomplete = transaction.onerror = - transaction.onabort = ( ) => { + transaction.onabort = ( ) => { resolve(Promise.all(entries)); }; const table = transaction.objectStore(STORAGE_NAME); @@ -673,7 +674,7 @@ const idbStorage = (( ) => { } if ( argbin instanceof Object && Array.isArray(argbin) === false ) { for ( const key of keys ) { - if ( outbin.hasOwnProperty(key) ) { continue; } + if ( hasOwnProperty(outbin, key) ) { continue; } outbin[key] = argbin[key]; } } @@ -695,7 +696,7 @@ const idbStorage = (( ) => { }, clear() { - return getDb().then(db => { + return getDb().then(db => { if ( db === null ) { return; } db.close(); indexedDB.deleteDatabase(STORAGE_NAME);