Fix eslint warnings

This commit is contained in:
Raymond Hill 2024-03-30 13:24:27 -04:00
parent 0579d14d52
commit d2ea9c1b2f
No known key found for this signature in database
GPG key ID: 25E1490B761470C2
3 changed files with 21 additions and 31 deletions

View file

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

View file

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

View file

@ -19,10 +19,6 @@
Home: https://github.com/gorhill/uBlock
*/
'use strict';
/* global HTMLDocument, XMLDocument */
// For background page, auxiliary pages, and content scripts.
/******************************************************************************/