diff --git a/package.json b/package.json index 63e5b7da3..fd65ac4cb 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "npm dev tools", "main": "index.js", "scripts": { - "lint": "eslint --no-warn-ignored -- ./src/js/*.js ./src/js/**/*.js ./**/*.json ./platform/**/*.js ", + "lint": "eslint --no-warn-ignored -- \"./src/js/*.js\" \"./src/js/**/*.js\" \"./**/*.json\" \"./platform/**/*.js\"", "test": "echo \"Error: no test specified\" && exit 1" }, "repository": { diff --git a/platform/mv3/extension/js/ext.js b/platform/mv3/extension/js/ext.js index cd63abc67..2f3285388 100644 --- a/platform/mv3/extension/js/ext.js +++ b/platform/mv3/extension/js/ext.js @@ -64,7 +64,7 @@ export async function localRead(key) { const bin = await browser.storage.local.get(key); if ( bin instanceof Object === false ) { return; } return bin[key] ?? undefined; - } catch(ex) { + } catch { } } @@ -89,7 +89,7 @@ export async function sessionRead(key) { const bin = await browser.storage.session.get(key); if ( bin instanceof Object === false ) { return; } return bin[key] ?? undefined; - } catch(ex) { + } catch { } } @@ -114,7 +114,7 @@ export async function adminRead(key) { const bin = await browser.storage.managed.get(key); if ( bin instanceof Object === false ) { return; } return bin[key] ?? undefined; - } catch(ex) { + } catch { } } diff --git a/platform/mv3/extension/js/fetch.js b/platform/mv3/extension/js/fetch.js index 5570159fd..675a37eba 100644 --- a/platform/mv3/extension/js/fetch.js +++ b/platform/mv3/extension/js/fetch.js @@ -19,10 +19,6 @@ Home: https://github.com/gorhill/uBlock */ -/* jshint esversion:11 */ - -'use strict'; - /******************************************************************************/ function fetchJSON(path) { diff --git a/platform/mv3/extension/js/popup.js b/platform/mv3/extension/js/popup.js index 98b4d54ce..761f82032 100644 --- a/platform/mv3/extension/js/popup.js +++ b/platform/mv3/extension/js/popup.js @@ -79,7 +79,7 @@ async function commitFilteringMode() { granted = await browser.permissions.request({ origins: [ `*://*.${targetHostname}/*` ], }); - } catch(ex) { + } catch { } if ( granted !== true ) { setFilteringMode(beforeLevel); @@ -287,7 +287,7 @@ dom.on('[data-i18n-title="popupTipReport"]', 'click', ev => { let url; try { url = new URL(currentTab.url); - } catch(_) { + } catch { } if ( url === undefined ) { return; } const reportURL = new URL(runtime.getURL('/report.html')); @@ -325,7 +325,7 @@ async function init() { url = new URL(url.hash.slice(1)); } tabURL.href = url.href || ''; - } catch(ex) { + } catch { } if ( url !== undefined ) { @@ -393,7 +393,7 @@ async function init() { async function tryInit() { try { await init(); - } catch(ex) { + } catch { setTimeout(tryInit, 100); } } diff --git a/platform/mv3/extension/js/report.js b/platform/mv3/extension/js/report.js index 35c3a8509..3ce29bad1 100644 --- a/platform/mv3/extension/js/report.js +++ b/platform/mv3/extension/js/report.js @@ -52,7 +52,7 @@ const reportedPage = (( ) => { hostname: parsedURL.hostname.replace(/^(m|mobile|www)\./, ''), mode: url.searchParams.get('mode'), }; - } catch(ex) { + } catch { } return null; })(); diff --git a/platform/mv3/extension/js/scripting/css-declarative.js b/platform/mv3/extension/js/scripting/css-declarative.js index d5c55552f..539c97d51 100644 --- a/platform/mv3/extension/js/scripting/css-declarative.js +++ b/platform/mv3/extension/js/scripting/css-declarative.js @@ -19,12 +19,6 @@ Home: https://github.com/gorhill/uBlock */ -/* jshint esversion:11 */ - -'use strict'; - -/******************************************************************************/ - // Important! // Isolate from global scope (function uBOL_cssDeclarative() { @@ -39,7 +33,7 @@ delete self.declarativeImports; const hnParts = []; try { hnParts.push(...document.location.hostname.split('.')); } -catch(ex) { } +catch { } const hnpartslen = hnParts.length; if ( hnpartslen === 0 ) { return; } diff --git a/platform/mv3/extension/js/scripting/css-procedural.js b/platform/mv3/extension/js/scripting/css-procedural.js index 58fd4d6d7..da27a6d22 100644 --- a/platform/mv3/extension/js/scripting/css-procedural.js +++ b/platform/mv3/extension/js/scripting/css-procedural.js @@ -19,10 +19,6 @@ Home: https://github.com/gorhill/uBlock */ -/* jshint esversion:11 */ - -/******************************************************************************/ - // Important! // Isolate from global scope (function uBOL_cssProcedural() { @@ -37,7 +33,7 @@ delete self.proceduralImports; const hnParts = []; try { hnParts.push(...document.location.hostname.split('.')); } -catch(ex) { } +catch { } const hnpartslen = hnParts.length; if ( hnpartslen === 0 ) { return; } @@ -621,14 +617,14 @@ class PSelectorRoot extends PSelector { prime(input) { try { return super.prime(input); - } catch (ex) { + } catch { } return []; } exec(input) { try { return super.exec(input); - } catch (ex) { + } catch { } return []; } diff --git a/platform/mv3/extension/js/scripting/css-specific.js b/platform/mv3/extension/js/scripting/css-specific.js index faf997cc0..c58ebd9ac 100644 --- a/platform/mv3/extension/js/scripting/css-specific.js +++ b/platform/mv3/extension/js/scripting/css-specific.js @@ -19,12 +19,6 @@ Home: https://github.com/gorhill/uBlock */ -/* jshint esversion:11 */ - -'use strict'; - -/******************************************************************************/ - // Important! // Isolate from global scope (function uBOL_cssSpecific() { @@ -39,7 +33,7 @@ delete self.specificImports; const hnParts = []; try { hnParts.push(...document.location.hostname.split('.')); } -catch(ex) { } +catch { } const hnpartslen = hnParts.length; if ( hnpartslen === 0 ) { return; } diff --git a/platform/mv3/extension/js/settings.js b/platform/mv3/extension/js/settings.js index d924d6f59..51ba0414a 100644 --- a/platform/mv3/extension/js/settings.js +++ b/platform/mv3/extension/js/settings.js @@ -195,7 +195,7 @@ function getStagedTrustedSites() { return punycode.toASCII( (new URL(`https://${hn}/`)).hostname ); - } catch(_) { + } catch { } return ''; }).filter(hn => hn !== ''); @@ -292,7 +292,7 @@ sendMessage({ renderFilterLists(cachedRulesetData); renderWidgets(); dom.cl.remove(dom.body, 'loading'); - } catch(ex) { + } catch { } listen(); }).catch(reason => { diff --git a/platform/mv3/extension/js/strictblock.js b/platform/mv3/extension/js/strictblock.js index 3ba92aae7..eb4c25371 100644 --- a/platform/mv3/extension/js/strictblock.js +++ b/platform/mv3/extension/js/strictblock.js @@ -42,7 +42,7 @@ function urlToFragment(raw) { b.append(hn); fragment.append(raw.slice(0,i), b, raw.slice(i+hn.length)); return fragment; - } catch(_) { + } catch { } return raw; } @@ -55,7 +55,7 @@ const toFinalURL = new URL('about:blank'); try { toURL.href = self.location.hash.slice(1); toFinalURL.href = toURL.href; -} catch(_) { +} catch { } dom.clear('#theURL > p > span:first-of-type'); @@ -144,7 +144,7 @@ function fragmentFromTemplate(template, placeholder, text, details) { let url; try { url = new URL(rawURL); - } catch(ex) { + } catch { return false; } diff --git a/platform/mv3/extension/js/theme.js b/platform/mv3/extension/js/theme.js index a61384e4a..bab0fbfd0 100644 --- a/platform/mv3/extension/js/theme.js +++ b/platform/mv3/extension/js/theme.js @@ -19,10 +19,6 @@ Home: https://github.com/gorhill/uBlock */ -/* jshint esversion:11 */ - -'use strict'; - import { dom } from './dom.js'; /******************************************************************************/ diff --git a/platform/mv3/extension/js/utils.js b/platform/mv3/extension/js/utils.js index 7bf6e1350..dfbe235f3 100644 --- a/platform/mv3/extension/js/utils.js +++ b/platform/mv3/extension/js/utils.js @@ -24,7 +24,7 @@ function parsedURLromOrigin(origin) { try { return new URL(origin); - } catch(ex) { + } catch { } } diff --git a/platform/mv3/scriptlets/css-declarative.template.js b/platform/mv3/scriptlets/css-declarative.template.js index c1f480fab..a4ac2a280 100644 --- a/platform/mv3/scriptlets/css-declarative.template.js +++ b/platform/mv3/scriptlets/css-declarative.template.js @@ -19,14 +19,8 @@ Home: https://github.com/gorhill/uBlock */ -/* jshint esversion:11 */ - -'use strict'; - // ruleset: $rulesetId$ -/******************************************************************************/ - // Important! // Isolate from global scope (function uBOL_cssDeclarativeImport() { diff --git a/platform/mv3/scriptlets/css-generic.template.js b/platform/mv3/scriptlets/css-generic.template.js index a1f1d6c04..5c06ead0c 100644 --- a/platform/mv3/scriptlets/css-generic.template.js +++ b/platform/mv3/scriptlets/css-generic.template.js @@ -19,11 +19,7 @@ Home: https://github.com/gorhill/uBlock */ -/* jshint esversion:11 */ - -'use strict'; - -/******************************************************************************/ +// $rulesetId$ // Important! // Isolate from global scope @@ -31,8 +27,6 @@ /******************************************************************************/ -// $rulesetId$ - const toImport = self.$genericSelectorMap$; const genericSelectorMap = self.genericSelectorMap || new Map(); diff --git a/platform/mv3/scriptlets/css-procedural.template.js b/platform/mv3/scriptlets/css-procedural.template.js index 61c95e606..f9f5682d5 100644 --- a/platform/mv3/scriptlets/css-procedural.template.js +++ b/platform/mv3/scriptlets/css-procedural.template.js @@ -19,14 +19,8 @@ Home: https://github.com/gorhill/uBlock */ -/* jshint esversion:11 */ - -'use strict'; - // ruleset: $rulesetId$ -/******************************************************************************/ - // Important! // Isolate from global scope (function uBOL_cssProceduralImport() { diff --git a/platform/mv3/scriptlets/css-specific.template.js b/platform/mv3/scriptlets/css-specific.template.js index 68589312f..e164e2e58 100644 --- a/platform/mv3/scriptlets/css-specific.template.js +++ b/platform/mv3/scriptlets/css-specific.template.js @@ -19,14 +19,8 @@ Home: https://github.com/gorhill/uBlock */ -/* jshint esversion:11 */ - -'use strict'; - // ruleset: $rulesetId$ -/******************************************************************************/ - // Important! // Isolate from global scope (function uBOL_cssSpecificImports() { diff --git a/platform/mv3/scriptlets/scriptlet.template.js b/platform/mv3/scriptlets/scriptlet.template.js index 19560c8ae..4cef174f6 100644 --- a/platform/mv3/scriptlets/scriptlet.template.js +++ b/platform/mv3/scriptlets/scriptlet.template.js @@ -24,8 +24,6 @@ // ruleset: $rulesetId$ -/******************************************************************************/ - // Important! // Isolate from global scope @@ -66,8 +64,8 @@ try { const pos = origin.lastIndexOf('://'); if ( pos === -1 ) { return; } hnParts.push(...origin.slice(pos+3).split('.')); +} catch { } -catch(ex) { } const hnpartslen = hnParts.length; if ( hnpartslen === 0 ) { return; } @@ -124,7 +122,7 @@ if ( entitiesMap.size !== 0 ) { // Apply scriplets for ( const i of todoIndices ) { try { $scriptletName$(...argsList[i]); } - catch(ex) {} + catch { } } argsList.length = 0;