From d2ea9c1b2fe664b4bf32ca5aa91904ff7cebb007 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Sat, 30 Mar 2024 13:24:27 -0400 Subject: [PATCH] Fix eslint warnings --- platform/common/vapi-background.js | 39 +++++++++++++++--------------- platform/common/vapi-common.js | 9 ++----- platform/common/vapi.js | 4 --- 3 files changed, 21 insertions(+), 31 deletions(-) diff --git a/platform/common/vapi-background.js b/platform/common/vapi-background.js index 2ff99ac12..283ffe6ef 100644 --- a/platform/common/vapi-background.js +++ b/platform/common/vapi-background.js @@ -22,14 +22,10 @@ // For background page -/* globals browser */ - -'use strict'; - /******************************************************************************/ -import webext from './webext.js'; import { ubolog } from './console.js'; +import webext from './webext.js'; /******************************************************************************/ @@ -47,6 +43,9 @@ if ( vAPI.canWASM === false ) { vAPI.supportsUserStylesheets = vAPI.webextFlavor.soup.has('user_stylesheet'); +const hasOwnProperty = (o, p) => + Object.prototype.hasOwnProperty.call(o, p); + /******************************************************************************/ vAPI.app = { @@ -191,9 +190,9 @@ vAPI.browserSettings = (( ) => { set: function(details) { for ( const setting in details ) { - if ( details.hasOwnProperty(setting) === false ) { continue; } + if ( hasOwnProperty(details, setting) === false ) { continue; } switch ( setting ) { - case 'prefetching': + case 'prefetching': { const enabled = !!details[setting]; if ( enabled ) { bp.network.networkPredictionEnabled.clear({ @@ -209,9 +208,9 @@ vAPI.browserSettings = (( ) => { vAPI.prefetching(enabled); } break; - - case 'hyperlinkAuditing': - if ( !!details[setting] ) { + } + case 'hyperlinkAuditing': { + if ( details[setting] ) { bp.websites.hyperlinkAuditingEnabled.clear({ scope: 'regular', }); @@ -222,7 +221,7 @@ vAPI.browserSettings = (( ) => { }); } break; - + } case 'webrtcIPAddress': { // https://github.com/uBlockOrigin/uBlock-issues/issues/1928 // https://www.reddit.com/r/uBlockOrigin/comments/sl7p74/ @@ -314,7 +313,7 @@ vAPI.Tabs = class { } this.onRemovedHandler(tabId, details); }); - } + } async executeScript(...args) { let result; @@ -869,8 +868,8 @@ if ( webext.browserAction instanceof Object ) { const hasUnprocessedRequest = vAPI.net && vAPI.net.hasUnprocessedRequest(tabId); const { parts, state } = details; const { badge, color } = hasUnprocessedRequest - ? { badge: '!', color: '#FC0' } - : details; + ? { badge: '!', color: '#FC0' } + : details; if ( browserAction.setIcon !== undefined ) { if ( parts === undefined || (parts & 0b0001) !== 0 ) { @@ -1029,7 +1028,7 @@ vAPI.messaging = { }); break; } - case 'userCSS': + case 'userCSS': { if ( tabId === undefined ) { break; } const promises = []; if ( msg.add ) { @@ -1060,6 +1059,9 @@ vAPI.messaging = { }); break; } + default: + break; + } }, // Use a wrapper to avoid closure and to allow reuse. @@ -1217,7 +1219,7 @@ vAPI.Net = class { { const wrrt = browser.webRequest.ResourceType; for ( const typeKey in wrrt ) { - if ( wrrt.hasOwnProperty(typeKey) ) { + if ( hasOwnProperty(wrrt, typeKey) ) { this.validTypes.add(wrrt[typeKey]); } } @@ -1520,10 +1522,7 @@ vAPI.localStorage = { if ( this.cache instanceof Promise ) { return this.cache; } if ( this.cache instanceof Object ) { return this.cache; } this.cache = vAPI.storage.get('localStorage').then(bin => { - this.cache = bin instanceof Object && - bin.localStorage instanceof Object - ? bin.localStorage - : {}; + this.cache = bin && bin.localStorage || {}; }); return this.cache; }, diff --git a/platform/common/vapi-common.js b/platform/common/vapi-common.js index 3b7482074..b2b047bc0 100644 --- a/platform/common/vapi-common.js +++ b/platform/common/vapi-common.js @@ -22,19 +22,14 @@ // For background page or non-background pages -/* global browser */ - -'use strict'; - -/******************************************************************************/ /******************************************************************************/ vAPI.T0 = Date.now(); -/******************************************************************************/ - vAPI.setTimeout = vAPI.setTimeout || self.setTimeout.bind(self); +/******************************************************************************/ + vAPI.defer = { create(callback) { return new this.Client(callback); diff --git a/platform/common/vapi.js b/platform/common/vapi.js index d10ae6621..69eb539c6 100644 --- a/platform/common/vapi.js +++ b/platform/common/vapi.js @@ -19,10 +19,6 @@ Home: https://github.com/gorhill/uBlock */ -'use strict'; - -/* global HTMLDocument, XMLDocument */ - // For background page, auxiliary pages, and content scripts. /******************************************************************************/