From f8975e3a6a67af2818eee09671b02655ce2a851b Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Thu, 9 Jan 2025 09:33:22 -0500 Subject: [PATCH] Better integrate latest eslint version --- .eslintrc.yml | 30 - .jshintrc | 22 - Makefile | 7 +- eslint.config.mjs | 51 + package-lock.json | 1146 +++++++++++++++++ package.json | 32 + platform/browser/main.js | 123 -- platform/browser/test.html | 71 - platform/chromium/is-webrtc-supported.html | 2 +- platform/chromium/is-webrtc-supported.js | 6 +- platform/chromium/vapi-background-ext.js | 2 +- platform/common/vapi-background.js | 46 +- platform/common/vapi-client.js | 2 +- platform/dig/snfe.js | 14 +- platform/firefox/vapi-background-ext.js | 4 +- platform/firefox/webext.js | 2 - platform/mv3/make-rulesets.js | 2 +- platform/mv3/safe-replace.js | 4 - platform/nodejs/build.js | 5 - platform/nodejs/index.js | 6 +- platform/npm/.eslintrc.json | 38 - platform/npm/demo.js | 2 +- platform/npm/package.json | 2 - platform/npm/test.js | 7 +- src/js/about.js | 2 - src/js/advanced-settings.js | 2 - src/js/asset-viewer.js | 6 +- src/js/assets.js | 6 +- src/js/base64-custom.js | 2 - src/js/benchmarks.js | 4 +- src/js/cachestorage.js | 2 +- src/js/click2load.js | 2 - src/js/cloud-ui.js | 6 +- src/js/code-viewer.js | 44 +- src/js/codemirror/search-thread.js | 9 +- src/js/codemirror/search.js | 2 +- src/js/codemirror/ubo-dynamic-filtering.js | 4 +- src/js/commands.js | 6 +- src/js/console.js | 2 - src/js/contentscript-extra.js | 2 +- src/js/contentscript.js | 8 +- src/js/contextmenu.js | 2 +- src/js/dashboard-common.js | 2 - src/js/dashboard.js | 4 +- src/js/diff-updater.js | 7 +- src/js/document-blocked.js | 4 +- src/js/dom-inspector.js | 31 +- src/js/dyna-rules.js | 19 +- src/js/dynamic-net-filtering.js | 12 +- src/js/fa-icons.js | 2 - src/js/filtering-engines.js | 4 - src/js/hnswitches.js | 11 +- src/js/html-filtering.js | 10 +- src/js/httpheader-filtering.js | 14 +- src/js/logger-ui-inspector.js | 2 +- src/js/logger-ui.js | 4 +- src/js/logger.js | 4 - src/js/lz4.js | 4 - src/js/messaging.js | 2 +- src/js/mrucache.js | 2 - src/js/pagestore.js | 2 +- src/js/popup-fenix.js | 96 +- src/js/redirect-engine.js | 6 +- src/js/resources/attribute.js | 4 +- src/js/resources/cookie.js | 2 +- src/js/resources/href-sanitizer.js | 8 +- src/js/resources/localstorage.js | 2 +- src/js/resources/parse-replace.js | 2 +- src/js/resources/replace-argument.js | 6 +- src/js/resources/safe-self.js | 4 +- src/js/resources/scriptlets.js | 32 +- src/js/resources/set-constant.js | 4 +- src/js/reverselookup-worker.js | 3 +- src/js/reverselookup.js | 13 +- src/js/scriptlet-filtering-core.js | 6 +- src/js/scriptlet-filtering.js | 2 +- src/js/scriptlets/cosmetic-logger.js | 10 +- src/js/scriptlets/cosmetic-off.js | 2 - src/js/scriptlets/cosmetic-on.js | 2 - src/js/scriptlets/cosmetic-report.js | 6 +- src/js/scriptlets/dom-inspector.js | 6 +- src/js/scriptlets/dom-survey-elements.js | 2 - src/js/scriptlets/dom-survey-scripts.js | 2 - src/js/scriptlets/epicker.js | 10 +- src/js/scriptlets/load-3p-css.js | 4 +- src/js/scriptlets/load-large-media-all.js | 2 - src/js/scriptlets/noscript-spoof.js | 10 +- src/js/scriptlets/scriptlet-loglevel-1.js | 2 - src/js/scriptlets/scriptlet-loglevel-2.js | 2 - .../scriptlets/should-inject-contentscript.js | 2 +- src/js/scriptlets/subscriber.js | 6 +- src/js/scriptlets/updater.js | 6 +- src/js/settings.js | 6 +- src/js/start.js | 34 +- src/js/static-ext-filtering-db.js | 2 - src/js/static-ext-filtering.js | 6 +- src/js/static-filtering-io.js | 2 - src/js/static-filtering-parser.js | 26 +- src/js/static-net-filtering.js | 4 +- src/js/storage.js | 2 +- src/js/support.js | 6 +- src/js/tab.js | 35 +- src/js/tasks.js | 6 - src/js/text-encode.js | 98 +- src/js/text-utils.js | 2 - src/js/theme.js | 6 +- src/js/ublock.js | 95 +- src/js/uri-utils.js | 10 +- src/js/url-net-filtering.js | 4 - src/js/urlskip.js | 2 +- src/js/utils.js | 6 +- src/js/whitelist.js | 6 +- 112 files changed, 1618 insertions(+), 881 deletions(-) delete mode 100644 .eslintrc.yml delete mode 100644 .jshintrc create mode 100644 eslint.config.mjs create mode 100644 package-lock.json create mode 100644 package.json delete mode 100644 platform/browser/main.js delete mode 100644 platform/browser/test.html delete mode 100644 platform/npm/.eslintrc.json diff --git a/.eslintrc.yml b/.eslintrc.yml deleted file mode 100644 index d7db6e4e4..000000000 --- a/.eslintrc.yml +++ /dev/null @@ -1,30 +0,0 @@ -env: - browser: true - es2022: true -extends: eslint:recommended -parserOptions: - sourceType: module -rules: - eqeqeq: - - warn - - always - indent: - - error - - 4 - - ignoredNodes: - - Program > BlockStatement - - Program > ExpressionStatement > CallExpression > ArrowFunctionExpression > BlockStatement - - Program > ExpressionStatement > CallExpression > FunctionExpression > BlockStatement - - Program > IfStatement > BlockStatement - - Program > VariableDeclaration > VariableDeclarator > CallExpression > ArrowFunctionExpression > BlockStatement - - CallExpression > MemberExpression - - ArrayExpression > * - - ObjectExpression > * - no-control-regex: off - no-empty: off - sort-imports: warn - strict: warn -globals: - browser: readonly - chrome: readonly - vAPI: readonly diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index 46c0d2e57..000000000 --- a/.jshintrc +++ /dev/null @@ -1,22 +0,0 @@ -{ - "browser": true, - "devel": true, - "eqeqeq": true, - "esversion": 11, - "globals": { - "chrome": false, // global variable in Chromium, Chrome, Opera - "globalThis": false, - "self": false, - "vAPI": false, - "URLSearchParams": false, - "WebAssembly": false - }, - "laxbreak": true, - "newcap": false, - "nonew": false, - "strict": "global", - "sub": true, - "undef": true, - "unused": true, - "validthis": true -} diff --git a/Makefile b/Makefile index b308dc4be..0ff5e3306 100644 --- a/Makefile +++ b/Makefile @@ -32,11 +32,12 @@ firefox: dist/build/uBlock0.firefox dist/build/uBlock0.npm: tools/make-nodejs.sh $(sources) $(platform) $(assets) tools/make-npm.sh -# Build the Node.js package. -npm: dist/build/uBlock0.npm +# Dev tools +npm: node_modules/ + npm install lint: npm - cd dist/build/uBlock0.npm && npm run lint + npm run lint test: npm cd dist/build/uBlock0.npm && npm run test diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 000000000..f9bdca1ca --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,51 @@ +import js from "@eslint/js"; +import globals from "globals"; +import json from "@eslint/json"; + +import { includeIgnoreFile } from "@eslint/compat"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); +const gitignorePath = path.resolve(__dirname, ".gitignore"); + +export default [ includeIgnoreFile(gitignorePath), { + files: ["**/*.js", "**/*.mjs"], + ...js.configs.recommended, +}, { + files: ["**/*.js", "**/*.mjs"], + languageOptions: { + globals: { + ...globals.browser, + browser: "readonly", + chrome: "readonly", + vAPI: "readonly", + }, + sourceType: "module", + }, + rules: { + eqeqeq: ["warn", "always"], + indent: ["error", 4, { + ignoredNodes: [ + "Program > BlockStatement", + "Program > ExpressionStatement > CallExpression > ArrowFunctionExpression > BlockStatement", + "Program > ExpressionStatement > CallExpression > FunctionExpression > BlockStatement", + "Program > IfStatement > BlockStatement", + "Program > VariableDeclaration > VariableDeclarator > CallExpression > ArrowFunctionExpression > BlockStatement", + "CallExpression > MemberExpression", + "ArrayExpression > *", + "ObjectExpression > *", + ], + }], + "no-control-regex": "off", + "no-empty": "off", + "sort-imports": "error", + "strict": "error", + }, +}, { + files: ["**/*.json"], + ignores: ["package-lock.json"], + language: "json/json", + ...json.configs.recommended, +} ]; diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 000000000..18b1c50b9 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,1146 @@ +{ + "name": "uBlock", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "uBlock", + "version": "1.0.0", + "license": "GPLv3", + "devDependencies": { + "@eslint/compat": "^1.2.4", + "@eslint/js": "^9.17.0", + "@eslint/json": "^0.9.0", + "eslint": "^9.17.0", + "eslint-formatter-compact": "^8.40.0", + "globals": "^15.14.0" + }, + "engines": { + "node": ">=22", + "npm": ">=11" + } + }, + "node_modules/@eslint-community/eslint-utils": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.1.tgz", + "integrity": "sha512-s3O3waFUrMV8P/XaF/+ZTp1X9XBZW1a4B97ZnjQF2KYWaFD2A8KyFBsrsfSjEmjn3RGWAIuvlneuZm3CUK3jbA==", + "dev": true, + "license": "MIT", + "dependencies": { + "eslint-visitor-keys": "^3.4.3" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + }, + "peerDependencies": { + "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" + } + }, + "node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@eslint-community/regexpp": { + "version": "4.12.1", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.12.1.tgz", + "integrity": "sha512-CCZCDJuduB9OUkFkY2IgppNZMi2lBQgD2qzwXkEia16cge2pijY/aXi96CJMquDMn3nJdlPV1A5KrJEXwfLNzQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^12.0.0 || ^14.0.0 || >=16.0.0" + } + }, + "node_modules/@eslint/compat": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@eslint/compat/-/compat-1.2.4.tgz", + "integrity": "sha512-S8ZdQj/N69YAtuqFt7653jwcvuUj131+6qGLUyDqfDg1OIoBQ66OCuXC473YQfO2AaxITTutiRQiDwoo7ZLYyg==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "peerDependencies": { + "eslint": "^9.10.0" + }, + "peerDependenciesMeta": { + "eslint": { + "optional": true + } + } + }, + "node_modules/@eslint/config-array": { + "version": "0.19.1", + "resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.19.1.tgz", + "integrity": "sha512-fo6Mtm5mWyKjA/Chy1BYTdn5mGJoDNjC7C64ug20ADsRDGrA85bN3uK3MaKbeRkRuuIEAR5N33Jr1pbm411/PA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@eslint/object-schema": "^2.1.5", + "debug": "^4.3.1", + "minimatch": "^3.1.2" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@eslint/core": { + "version": "0.9.1", + "resolved": "https://registry.npmjs.org/@eslint/core/-/core-0.9.1.tgz", + "integrity": "sha512-GuUdqkyyzQI5RMIWkHhvTWLCyLo1jNK3vzkSyaExH5kHPDHcuL2VOpHjmMY+y3+NC69qAKToBqldTBgYeLSr9Q==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@types/json-schema": "^7.0.15" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@eslint/eslintrc": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-3.2.0.tgz", + "integrity": "sha512-grOjVNN8P3hjJn/eIETF1wwd12DdnwFDoyceUJLYYdkpbwq3nLi+4fqrTAONx7XDALqlL220wC/RHSC/QTI/0w==", + "dev": true, + "license": "MIT", + "dependencies": { + "ajv": "^6.12.4", + "debug": "^4.3.2", + "espree": "^10.0.1", + "globals": "^14.0.0", + "ignore": "^5.2.0", + "import-fresh": "^3.2.1", + "js-yaml": "^4.1.0", + "minimatch": "^3.1.2", + "strip-json-comments": "^3.1.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@eslint/eslintrc/node_modules/globals": { + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz", + "integrity": "sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@eslint/js": { + "version": "9.17.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.17.0.tgz", + "integrity": "sha512-Sxc4hqcs1kTu0iID3kcZDW3JHq2a77HO9P8CP6YEA/FpH3Ll8UXE2r/86Rz9YJLKme39S9vU5OWNjC6Xl0Cr3w==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@eslint/json": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/@eslint/json/-/json-0.9.0.tgz", + "integrity": "sha512-PTLD0Kp7+BKhTthodns+hFbuZZ+hjb3lc/iVAg7mtBAnW5hLJhkST9O4m21oMkxG94GR2+GGZQNNurG9KP8pNA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@eslint/plugin-kit": "^0.2.3", + "@humanwhocodes/momoa": "^3.3.4" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@eslint/object-schema": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/@eslint/object-schema/-/object-schema-2.1.5.tgz", + "integrity": "sha512-o0bhxnL89h5Bae5T318nFoFzGy+YE5i/gGkoPAgkmTVdRKTiv3p8JHevPiPaMwoloKfEiiaHlawCqaZMqRm+XQ==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@eslint/plugin-kit": { + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.2.4.tgz", + "integrity": "sha512-zSkKow6H5Kdm0ZUQUB2kV5JIXqoG0+uH5YADhaEHswm664N9Db8dXSi0nMJpacpMf+MyyglF1vnZohpEg5yUtg==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "levn": "^0.4.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@humanfs/core": { + "version": "0.19.1", + "resolved": "https://registry.npmjs.org/@humanfs/core/-/core-0.19.1.tgz", + "integrity": "sha512-5DyQ4+1JEUzejeK1JGICcideyfUbGixgS9jNgex5nqkW+cY7WZhxBigmieN5Qnw9ZosSNVC9KQKyb+GUaGyKUA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18.18.0" + } + }, + "node_modules/@humanfs/node": { + "version": "0.16.6", + "resolved": "https://registry.npmjs.org/@humanfs/node/-/node-0.16.6.tgz", + "integrity": "sha512-YuI2ZHQL78Q5HbhDiBA1X4LmYdXCKCMQIfw0pw7piHJwyREFebJUvrQN4cMssyES6x+vfUbx1CIpaQUKYdQZOw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@humanfs/core": "^0.19.1", + "@humanwhocodes/retry": "^0.3.0" + }, + "engines": { + "node": ">=18.18.0" + } + }, + "node_modules/@humanfs/node/node_modules/@humanwhocodes/retry": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/retry/-/retry-0.3.1.tgz", + "integrity": "sha512-JBxkERygn7Bv/GbN5Rv8Ul6LVknS+5Bp6RgDC/O8gEBU/yeH5Ui5C/OlWrTb6qct7LjjfT6Re2NxB0ln0yYybA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18.18" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, + "node_modules/@humanwhocodes/module-importer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", + "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=12.22" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, + "node_modules/@humanwhocodes/momoa": { + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/@humanwhocodes/momoa/-/momoa-3.3.6.tgz", + "integrity": "sha512-7/sAGm3YsT6xG1bDkTSHvOpQB+cR4I2InfMVw110nuOCrxZvOQHgRqBMxSoTeUQrk9RS4OU9Aw2MBMZVJgLZMg==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18" + } + }, + "node_modules/@humanwhocodes/retry": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/retry/-/retry-0.4.1.tgz", + "integrity": "sha512-c7hNEllBlenFTHBky65mhq8WD2kbN9Q6gk0bTk8lSBvc554jpXSkST1iePudpt7+A/AQvuHs9EMqjHDXMY1lrA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18.18" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, + "node_modules/@types/estree": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.6.tgz", + "integrity": "sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/json-schema": { + "version": "7.0.15", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", + "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", + "dev": true, + "license": "MIT" + }, + "node_modules/acorn": { + "version": "8.14.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.14.0.tgz", + "integrity": "sha512-cl669nCJTZBsL97OF4kUQm5g5hC2uihk0NxY3WENAC0TYdILVkAyHymAntgxGkl7K+t0cXIrH5siy5S4XkFycA==", + "dev": true, + "license": "MIT", + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/acorn-jsx": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", + "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" + } + }, + "node_modules/ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "dev": true, + "license": "MIT", + "dependencies": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true, + "license": "Python-2.0" + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true, + "license": "MIT" + }, + "node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/callsites": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true, + "license": "MIT" + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "dev": true, + "license": "MIT" + }, + "node_modules/cross-spawn": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", + "dev": true, + "license": "MIT", + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/debug": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz", + "integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/deep-is": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", + "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint": { + "version": "9.17.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.17.0.tgz", + "integrity": "sha512-evtlNcpJg+cZLcnVKwsai8fExnqjGPicK7gnUtlNuzu+Fv9bI0aLpND5T44VLQtoMEnI57LoXO9XAkIXwohKrA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/eslint-utils": "^4.2.0", + "@eslint-community/regexpp": "^4.12.1", + "@eslint/config-array": "^0.19.0", + "@eslint/core": "^0.9.0", + "@eslint/eslintrc": "^3.2.0", + "@eslint/js": "9.17.0", + "@eslint/plugin-kit": "^0.2.3", + "@humanfs/node": "^0.16.6", + "@humanwhocodes/module-importer": "^1.0.1", + "@humanwhocodes/retry": "^0.4.1", + "@types/estree": "^1.0.6", + "@types/json-schema": "^7.0.15", + "ajv": "^6.12.4", + "chalk": "^4.0.0", + "cross-spawn": "^7.0.6", + "debug": "^4.3.2", + "escape-string-regexp": "^4.0.0", + "eslint-scope": "^8.2.0", + "eslint-visitor-keys": "^4.2.0", + "espree": "^10.3.0", + "esquery": "^1.5.0", + "esutils": "^2.0.2", + "fast-deep-equal": "^3.1.3", + "file-entry-cache": "^8.0.0", + "find-up": "^5.0.0", + "glob-parent": "^6.0.2", + "ignore": "^5.2.0", + "imurmurhash": "^0.1.4", + "is-glob": "^4.0.0", + "json-stable-stringify-without-jsonify": "^1.0.1", + "lodash.merge": "^4.6.2", + "minimatch": "^3.1.2", + "natural-compare": "^1.4.0", + "optionator": "^0.9.3" + }, + "bin": { + "eslint": "bin/eslint.js" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://eslint.org/donate" + }, + "peerDependencies": { + "jiti": "*" + }, + "peerDependenciesMeta": { + "jiti": { + "optional": true + } + } + }, + "node_modules/eslint-formatter-compact": { + "version": "8.40.0", + "resolved": "https://registry.npmjs.org/eslint-formatter-compact/-/eslint-formatter-compact-8.40.0.tgz", + "integrity": "sha512-cwGUs113TgmTQXecx5kfRjB7m0y2wkDLSadPTE2pK6M/wO4N8PjmUaoWOFNCP9MHgsiZwgqd5bZFnDCnszC56Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + } + }, + "node_modules/eslint-scope": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-8.2.0.tgz", + "integrity": "sha512-PHlWUfG6lvPc3yvP5A4PNyBL1W8fkDUccmI21JUu/+GKZBoH/W5u6usENXUrWFRsyoW5ACUjFGgAFQp5gUlb/A==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "esrecurse": "^4.3.0", + "estraverse": "^5.2.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint-visitor-keys": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.0.tgz", + "integrity": "sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/espree": { + "version": "10.3.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-10.3.0.tgz", + "integrity": "sha512-0QYC8b24HWY8zjRnDTL6RiHfDbAWn63qb4LMj1Z4b076A4une81+z03Kg7l7mn/48PUTqoLptSXez8oknU8Clg==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "acorn": "^8.14.0", + "acorn-jsx": "^5.3.2", + "eslint-visitor-keys": "^4.2.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/esquery": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.6.0.tgz", + "integrity": "sha512-ca9pw9fomFcKPvFLXhBKUK90ZvGibiGOvRJNbjljY7s7uq/5YO4BOzcYtJqExdx99rF6aAcnRxHmcUHcz6sQsg==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "estraverse": "^5.1.0" + }, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/esrecurse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", + "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "estraverse": "^5.2.0" + }, + "engines": { + "node": ">=4.0" + } + }, + "node_modules/estraverse": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=4.0" + } + }, + "node_modules/esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true, + "license": "MIT" + }, + "node_modules/fast-json-stable-stringify": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", + "dev": true, + "license": "MIT" + }, + "node_modules/fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", + "dev": true, + "license": "MIT" + }, + "node_modules/file-entry-cache": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-8.0.0.tgz", + "integrity": "sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "flat-cache": "^4.0.0" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "dev": true, + "license": "MIT", + "dependencies": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/flat-cache": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-4.0.1.tgz", + "integrity": "sha512-f7ccFPK3SXFHpx15UIGyRJ/FJQctuKZ0zVuN3frBo4HnK3cay9VEW0R6yPYFHC0AgqhukPzKjq22t5DmAyqGyw==", + "dev": true, + "license": "MIT", + "dependencies": { + "flatted": "^3.2.9", + "keyv": "^4.5.4" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/flatted": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.3.2.tgz", + "integrity": "sha512-AiwGJM8YcNOaobumgtng+6NHuOqC3A7MixFeDafM3X9cIUM+xUXoS5Vfgf+OihAYe20fxqNM9yPBXJzRtZ/4eA==", + "dev": true, + "license": "ISC" + }, + "node_modules/glob-parent": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", + "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", + "dev": true, + "license": "ISC", + "dependencies": { + "is-glob": "^4.0.3" + }, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/globals": { + "version": "15.14.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-15.14.0.tgz", + "integrity": "sha512-OkToC372DtlQeje9/zHIo5CT8lRP/FUgEOKBEhU4e0abL7J7CD24fD9ohiLN5hagG/kWCYj4K5oaxxtj2Z0Dig==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/ignore": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz", + "integrity": "sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 4" + } + }, + "node_modules/import-fresh": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", + "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", + "dev": true, + "license": "MIT", + "dependencies": { + "parent-module": "^1.0.0", + "resolve-from": "^4.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.8.19" + } + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true, + "license": "ISC" + }, + "node_modules/js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "dev": true, + "license": "MIT", + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/json-buffer": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", + "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true, + "license": "MIT" + }, + "node_modules/json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", + "dev": true, + "license": "MIT" + }, + "node_modules/keyv": { + "version": "4.5.4", + "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", + "integrity": "sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==", + "dev": true, + "license": "MIT", + "dependencies": { + "json-buffer": "3.0.1" + } + }, + "node_modules/levn": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", + "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "prelude-ls": "^1.2.1", + "type-check": "~0.4.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-locate": "^5.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/lodash.merge": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", + "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true, + "license": "MIT" + }, + "node_modules/natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", + "dev": true, + "license": "MIT" + }, + "node_modules/optionator": { + "version": "0.9.4", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz", + "integrity": "sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==", + "dev": true, + "license": "MIT", + "dependencies": { + "deep-is": "^0.1.3", + "fast-levenshtein": "^2.0.6", + "levn": "^0.4.1", + "prelude-ls": "^1.2.1", + "type-check": "^0.4.0", + "word-wrap": "^1.2.5" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "yocto-queue": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-limit": "^3.0.2" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/parent-module": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", + "dev": true, + "license": "MIT", + "dependencies": { + "callsites": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/prelude-ls": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", + "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/punycode": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/resolve-from": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "license": "MIT", + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/type-check": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", + "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", + "dev": true, + "license": "MIT", + "dependencies": { + "prelude-ls": "^1.2.1" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/uri-js": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "punycode": "^2.1.0" + } + }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "license": "ISC", + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/word-wrap": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", + "integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/yocto-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", + "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 000000000..5e992ba9d --- /dev/null +++ b/package.json @@ -0,0 +1,32 @@ +{ + "name": "uBlock", + "version": "1.0.0", + "description": "npm dev tools", + "main": "index.js", + "scripts": { + "lint": "eslint ./src/js/*.js ./src/js/**/*.js ./**/*.json ./platform/**/*.js ", + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/gorhill/uBlock.git" + }, + "author": "Raymond Hill", + "license": "GPLv3", + "bugs": { + "url": "https://github.com/gorhill/uBlock/issues" + }, + "homepage": "https://github.com/gorhill/uBlock#readme", + "engines": { + "node": ">=22", + "npm": ">=11" + }, + "devDependencies": { + "@eslint/compat": "^1.2.4", + "@eslint/js": "^9.17.0", + "@eslint/json": "^0.9.0", + "eslint": "^9.17.0", + "eslint-formatter-compact": "^8.40.0", + "globals": "^15.14.0" + } +} diff --git a/platform/browser/main.js b/platform/browser/main.js deleted file mode 100644 index d6f6acb9c..000000000 --- a/platform/browser/main.js +++ /dev/null @@ -1,123 +0,0 @@ -/******************************************************************************* - - uBlock Origin - a browser extension to block requests. - Copyright (C) 2014-present Raymond Hill - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see {http://www.gnu.org/licenses/}. - - Home: https://github.com/gorhill/uBlock -*/ - -'use strict'; - -/******************************************************************************/ - -import publicSuffixList from './lib/publicsuffixlist/publicsuffixlist.js'; -import punycode from './lib/punycode.js'; - -import staticNetFilteringEngine from './js/static-net-filtering.js'; -import { FilteringContext } from './js/filtering-context.js'; -import { LineIterator } from './js/text-utils.js'; -import * as sfp from './js/static-filtering-parser.js'; - -import { - CompiledListReader, - CompiledListWriter -} from './js/static-filtering-io.js'; - -/******************************************************************************/ - -function compileList(rawText, writer) { - const lineIter = new LineIterator(rawText); - const parser = new sfp.AstFilterParser({ - interactive: true, - maxTokenLength: staticNetFilteringEngine.MAX_TOKEN_LENGTH, - }); - const compiler = staticNetFilteringEngine.createCompiler(); - - while ( lineIter.eot() === false ) { - let line = lineIter.next(); - - while ( line.endsWith(' \\') ) { - if ( lineIter.peek(4) !== ' ' ) { break; } - line = line.slice(0, -2).trim() + lineIter.next().trim(); - } - parser.parse(line); - - if ( parser.isFilter() === false ) { continue; } - if ( parser.isNetworkFilter() === false ) { continue; } - if ( compiler.compile(parser, writer) ) { continue; } - if ( compiler.error !== undefined ) { - console.info(JSON.stringify({ - realm: 'message', - type: 'error', - text: compiler.error - })); - } - } - - return writer.toString(); -} - -function applyList(name, raw) { - const writer = new CompiledListWriter(); - writer.properties.set('name', name); - const compiled = compileList(raw, writer); - const reader = new CompiledListReader(compiled); - staticNetFilteringEngine.fromCompiled(reader); -} - -function enableWASM(path) { - return Promise.all([ - publicSuffixList.enableWASM(`${path}/lib/publicsuffixlist`), - staticNetFilteringEngine.enableWASM(`${path}/js`), - ]); -} - -function pslInit(raw) { - if ( typeof raw !== 'string' || raw.trim() === '' ) { - console.info('Unable to populate public suffix list'); - return; - } - publicSuffixList.parse(raw, punycode.toASCII); - console.info('Public suffix list populated'); -} - -function restart(lists) { - // Remove all filters - reset(); - - if ( Array.isArray(lists) && lists.length !== 0 ) { - // Populate filtering engine with filter lists - for ( const { name, raw } of lists ) { - applyList(name, raw); - } - // Commit changes - staticNetFilteringEngine.freeze(); - staticNetFilteringEngine.optimize(); - } - - return staticNetFilteringEngine; -} - -function reset() { - staticNetFilteringEngine.reset(); -} - -export { - FilteringContext, - enableWASM, - pslInit, - restart, -}; diff --git a/platform/browser/test.html b/platform/browser/test.html deleted file mode 100644 index 32b1aba8e..000000000 --- a/platform/browser/test.html +++ /dev/null @@ -1,71 +0,0 @@ - - - - -uBO Static Network Filtering Engine - - - - - diff --git a/platform/chromium/is-webrtc-supported.html b/platform/chromium/is-webrtc-supported.html index d30b674b1..58238b946 100644 --- a/platform/chromium/is-webrtc-supported.html +++ b/platform/chromium/is-webrtc-supported.html @@ -3,7 +3,7 @@ - + diff --git a/platform/chromium/is-webrtc-supported.js b/platform/chromium/is-webrtc-supported.js index 8841370a1..263bb686b 100644 --- a/platform/chromium/is-webrtc-supported.js +++ b/platform/chromium/is-webrtc-supported.js @@ -30,11 +30,9 @@ // collected. (function() { - 'use strict'; - - var pc = null; + let pc = null; try { - var PC = self.RTCPeerConnection || self.webkitRTCPeerConnection; + const PC = self.RTCPeerConnection || self.webkitRTCPeerConnection; if ( PC ) { pc = new PC(null); } diff --git a/platform/chromium/vapi-background-ext.js b/platform/chromium/vapi-background-ext.js index acbdc3e9d..34367a76b 100644 --- a/platform/chromium/vapi-background-ext.js +++ b/platform/chromium/vapi-background-ext.js @@ -224,7 +224,7 @@ vAPI.scriptletsInjector = (( ) => { script.appendChild(doc.createTextNode(details.scriptlets)); (doc.head || doc.documentElement).appendChild(script); self.uBO_scriptletsInjected = details.filters; - } catch (ex) { + } catch { } if ( script ) { script.remove(); diff --git a/platform/common/vapi-background.js b/platform/common/vapi-background.js index fac5121c0..5fcff01f8 100644 --- a/platform/common/vapi-background.js +++ b/platform/common/vapi-background.js @@ -320,7 +320,7 @@ vAPI.Tabs = class { try { result = await webext.tabs.executeScript(...args); } - catch(reason) { + catch { } return Array.isArray(result) ? result : []; } @@ -334,7 +334,7 @@ vAPI.Tabs = class { try { tab = await webext.tabs.get(tabId); } - catch(reason) { + catch { } return tab instanceof Object ? tab : null; } @@ -351,7 +351,7 @@ vAPI.Tabs = class { try { await webext.tabs.insertCSS(...arguments); } - catch(reason) { + catch { } } @@ -360,7 +360,7 @@ vAPI.Tabs = class { try { tabs = await webext.tabs.query(queryInfo); } - catch(reason) { + catch { } return Array.isArray(tabs) ? tabs : []; } @@ -372,7 +372,7 @@ vAPI.Tabs = class { try { await webext.tabs.removeCSS(...arguments); } - catch(reason) { + catch { } } @@ -530,7 +530,7 @@ vAPI.Tabs = class { try { tab = await webext.tabs.update(...arguments); } - catch (reason) { + catch { } return tab instanceof Object ? tab : null; } @@ -556,7 +556,7 @@ vAPI.Tabs = class { try { await webext.tabs.remove(tabId); } - catch (reason) { + catch { } } @@ -569,7 +569,7 @@ vAPI.Tabs = class { { bypassCache: bypassCache === true } ); } - catch (reason) { + catch { } } @@ -668,7 +668,7 @@ if ( webext.windows instanceof Object ) { try { win = await webext.windows.get(...arguments); } - catch (reason) { + catch { } return win instanceof Object ? win : null; }, @@ -677,7 +677,7 @@ if ( webext.windows instanceof Object ) { try { win = await webext.windows.create(...arguments); } - catch (reason) { + catch { } return win instanceof Object ? win : null; }, @@ -686,7 +686,7 @@ if ( webext.windows instanceof Object ) { try { win = await webext.windows.update(...arguments); } - catch (reason) { + catch { } return win instanceof Object ? win : null; }, @@ -702,7 +702,7 @@ if ( webext.browserAction instanceof Object ) { try { await webext.browserAction.setTitle(...arguments); } - catch (reason) { + catch { } }, }; @@ -712,28 +712,28 @@ if ( webext.browserAction instanceof Object ) { try { await webext.browserAction.setBadgeTextColor(...arguments); } - catch (reason) { + catch { } }; vAPI.browserAction.setBadgeBackgroundColor = async function() { try { await webext.browserAction.setBadgeBackgroundColor(...arguments); } - catch (reason) { + catch { } }; vAPI.browserAction.setBadgeText = async function() { try { await webext.browserAction.setBadgeText(...arguments); } - catch (reason) { + catch { } }; vAPI.browserAction.setIcon = async function() { try { await webext.browserAction.setIcon(...arguments); } - catch (reason) { + catch { } }; } @@ -807,7 +807,7 @@ if ( webext.browserAction instanceof Object ) { let data; try { data = ctx.getImageData(0, 0, w, h); - } catch(ex) { + } catch { } return data; }; @@ -1084,7 +1084,7 @@ vAPI.messaging = { msgId: this.msgId, msg: response !== undefined ? response : null, }); - } catch (ex) { + } catch { this.messaging.onPortDisconnect(this.port); } // Store for reuse @@ -1473,7 +1473,7 @@ vAPI.adminStorage = (( ) => { let store; try { store = await webext.storage.managed.get(); - } catch(ex) { + } catch { } vAPI.storage.set({ cachedManagedStorage: store || {} }); }; @@ -1488,7 +1488,7 @@ vAPI.adminStorage = (( ) => { } else { bin = bin.cachedManagedStorage; } - } catch(ex) { + } catch { bin = {}; } cacheManagedStorage(); @@ -1688,7 +1688,7 @@ vAPI.cloud = (( ) => { // operation to fail. try { await deleteChunks(datakey, chunkCount + 1); - } catch (reason) { + } catch { } // Push the data to browser-provided cloud storage. @@ -1742,7 +1742,7 @@ vAPI.cloud = (( ) => { if ( typeof entry === 'string' ) { entry = JSON.parse(entry); } - } catch(_) { + } catch { } return entry; }; @@ -1763,7 +1763,7 @@ vAPI.cloud = (( ) => { webext.storage.sync.getBytesInUse(keys), webext.storage.sync.getBytesInUse(null), ]); - } catch(ex) { + } catch { } if ( Array.isArray(results) === false ) { return; } return { used: results[0], total: results[1], max: QUOTA_BYTES }; diff --git a/platform/common/vapi-client.js b/platform/common/vapi-client.js index a6d46c625..afa939d1a 100644 --- a/platform/common/vapi-client.js +++ b/platform/common/vapi-client.js @@ -165,7 +165,7 @@ vAPI.messaging = { } try { this.port = browser.runtime.connect({name: vAPI.sessionId}) || null; - } catch (ex) { + } catch { this.port = null; } // Not having a valid port at this point means the main process is diff --git a/platform/dig/snfe.js b/platform/dig/snfe.js index 70908285b..f0b4e55ab 100644 --- a/platform/dig/snfe.js +++ b/platform/dig/snfe.js @@ -19,22 +19,12 @@ Home: https://github.com/gorhill/uBlock */ -/* eslint-disable-next-line no-redeclare */ /* globals process */ -'use strict'; - -/******************************************************************************/ - -import { strict as assert } from 'assert'; +import { StaticNetFilteringEngine, enableWASM } from './index.js'; +import { mkdir, readFile, writeFile } from 'fs/promises'; import { createRequire } from 'module'; -import { readFile, writeFile, mkdir } from 'fs/promises'; import { dirname } from 'path'; -import { fileURLToPath } from 'url'; - -const __dirname = dirname(fileURLToPath(import.meta.url)); - -import { enableWASM, StaticNetFilteringEngine } from './index.js'; /******************************************************************************/ diff --git a/platform/firefox/vapi-background-ext.js b/platform/firefox/vapi-background-ext.js index 5710224a3..9e0d8d357 100644 --- a/platform/firefox/vapi-background-ext.js +++ b/platform/firefox/vapi-background-ext.js @@ -373,7 +373,7 @@ vAPI.scriptletsInjector = (( ) => { script = doc.createElement('script'); script.appendChild(doc.createTextNode(code)); (doc.head || doc.documentElement).appendChild(script); - } catch (ex) { + } catch { } if ( script ) { script.remove(); @@ -400,7 +400,7 @@ vAPI.scriptletsInjector = (( ) => { script.src = url; (doc.head || doc.documentElement || doc).append(script); self.uBO_scriptletsInjected = details.filters; - } catch (ex) { + } catch { } if ( url ) { if ( script ) { script.remove(); } diff --git a/platform/firefox/webext.js b/platform/firefox/webext.js index e9bff7630..67ad05dd3 100644 --- a/platform/firefox/webext.js +++ b/platform/firefox/webext.js @@ -19,6 +19,4 @@ Home: https://github.com/gorhill/uBlock */ -'use strict'; - export default browser; diff --git a/platform/mv3/make-rulesets.js b/platform/mv3/make-rulesets.js index 3c4660f08..6df89f918 100644 --- a/platform/mv3/make-rulesets.js +++ b/platform/mv3/make-rulesets.js @@ -125,7 +125,7 @@ const fetchText = (url, cacheDir) => { const content = data.join(''); try { writeFile(`${cacheDir}/${fname}`, content); - } catch (ex) { + } catch { } resolve({ url, content }); }); diff --git a/platform/mv3/safe-replace.js b/platform/mv3/safe-replace.js index b56e5e5af..6f417b20b 100644 --- a/platform/mv3/safe-replace.js +++ b/platform/mv3/safe-replace.js @@ -19,10 +19,6 @@ Home: https://github.com/gorhill/uBlock */ -'use strict'; - -/******************************************************************************/ - export function safeReplace(text, pattern, replacement, count = 1) { const rePattern = typeof pattern === 'string' ? new RegExp(pattern.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')) diff --git a/platform/nodejs/build.js b/platform/nodejs/build.js index dbc08437c..eb22693ff 100644 --- a/platform/nodejs/build.js +++ b/platform/nodejs/build.js @@ -19,12 +19,7 @@ Home: https://github.com/gorhill/uBlock */ -'use strict'; - -/******************************************************************************/ - import fs from 'fs'; - import { pslInit } from './index.js'; /******************************************************************************/ diff --git a/platform/nodejs/index.js b/platform/nodejs/index.js index 56aa74f42..3b82cb9ab 100644 --- a/platform/nodejs/index.js +++ b/platform/nodejs/index.js @@ -19,6 +19,8 @@ Home: https://github.com/gorhill/uBlock */ +/* globals process */ + import * as s14e from './js/s14e-serializer.js'; import * as sfp from './js/static-filtering-parser.js'; @@ -188,7 +190,7 @@ async function useLists(lists, options = {}) { useLists.promise = Promise.all(promises); await useLists.promise; - useLists.promise = null; // eslint-disable-line require-atomic-updates + useLists.promise = null; // Commit changes snfe.freeze(); @@ -283,7 +285,7 @@ class StaticNetFilteringEngine { // module.exports. Once all included files are written like ES modules, using // export statements, this should no longer be necessary. if ( typeof module !== 'undefined' && typeof exports !== 'undefined' ) { - module.exports = exports; + module.exports = exports; // eslint-disable-line no-undef } export { diff --git a/platform/npm/.eslintrc.json b/platform/npm/.eslintrc.json deleted file mode 100644 index 5f7c6b58c..000000000 --- a/platform/npm/.eslintrc.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "root": true, - "env": { - "es2021": true, - "node": true - }, - "extends": "eslint:recommended", - "parserOptions": { - "ecmaVersion": 12, - "sourceType": "module" - }, - "rules": { - "eqeqeq": [ "warn", "always" ], - "indent": [ - "warn", - 4, - { - "ArrayExpression": "first", - "CallExpression": { "arguments": "first" }, - "MemberExpression": "off", - "ObjectExpression": "off", - "ignoreComments": true, - "ignoredNodes": [ - "AssignmentExpression:has(Literal)" - ] - } - ], - "getter-return": "off", - "no-control-regex": "off", - "no-empty": [ "error", { "allowEmptyCatch": true } ], - "no-promise-executor-return": [ "error" ], - "no-template-curly-in-string": [ "error" ], - "no-unreachable-loop": [ "error" ], - "no-useless-backreference": [ "error" ], - "no-useless-escape": "off", - "require-atomic-updates": [ "warn" ] - } -} diff --git a/platform/npm/demo.js b/platform/npm/demo.js index bc0ca87a1..8baec24e4 100644 --- a/platform/npm/demo.js +++ b/platform/npm/demo.js @@ -31,8 +31,8 @@ * * */ -import fs from 'fs/promises'; import { StaticNetFilteringEngine } from '@gorhill/ubo-core'; +import fs from 'fs/promises'; /******************************************************************************/ diff --git a/platform/npm/package.json b/platform/npm/package.json index 6430bec8e..190d7e857 100644 --- a/platform/npm/package.json +++ b/platform/npm/package.json @@ -6,7 +6,6 @@ "main": "index.js", "scripts": { "build": "node build.js", - "lint": "eslint js/ *.js tests/*.js", "test": "c8 --include=index.js --include=js/**/*.js node test.js --mocha", "test-full-battery": "c8 --include=index.js --include=js/**/*.js node test.js --mocha --full-battery", "check-leaks": "mocha --check-leaks tests/leaks.js" @@ -36,7 +35,6 @@ }, "devDependencies": { "c8": "^7.12.0", - "eslint": "^8.29.0", "esm-world": "0.1.3", "mocha": "^10.2.0", "scaling-palm-tree": "github:mjethani/scaling-palm-tree#15cf1ab37e038771e1ff8005edc46d95f176739f" diff --git a/platform/npm/test.js b/platform/npm/test.js index 5b4401e59..25ff9e743 100644 --- a/platform/npm/test.js +++ b/platform/npm/test.js @@ -19,15 +19,10 @@ Home: https://github.com/gorhill/uBlock */ -/* eslint-disable-next-line no-redeclare */ /* globals process */ -'use strict'; - -/******************************************************************************/ - -import { spawn } from "child_process"; import { promisify } from 'util'; +import { spawn } from "child_process"; /******************************************************************************/ diff --git a/src/js/about.js b/src/js/about.js index 680fab146..202f3489b 100644 --- a/src/js/about.js +++ b/src/js/about.js @@ -19,8 +19,6 @@ Home: https://github.com/gorhill/uBlock */ -'use strict'; - import { dom } from './dom.js'; /******************************************************************************/ diff --git a/src/js/advanced-settings.js b/src/js/advanced-settings.js index c21346f58..de7da56b2 100644 --- a/src/js/advanced-settings.js +++ b/src/js/advanced-settings.js @@ -21,8 +21,6 @@ /* global CodeMirror, uBlockDashboard */ -'use strict'; - import { dom, qs$ } from './dom.js'; /******************************************************************************/ diff --git a/src/js/asset-viewer.js b/src/js/asset-viewer.js index 351531b62..62f90d279 100644 --- a/src/js/asset-viewer.js +++ b/src/js/asset-viewer.js @@ -21,12 +21,8 @@ /* global CodeMirror, uBlockDashboard */ -'use strict'; - -/******************************************************************************/ - -import { dom, qs$ } from './dom.js'; import './codemirror/ubo-static-filtering.js'; +import { dom, qs$ } from './dom.js'; /******************************************************************************/ diff --git a/src/js/assets.js b/src/js/assets.js index 4f02700f8..778af87f0 100644 --- a/src/js/assets.js +++ b/src/js/assets.js @@ -319,7 +319,7 @@ assets.fetch = function(url, options = {}) { xhr.responseType = options.responseType || 'text'; xhr.send(); timeoutTimer.on({ sec: timeoutAfter }); - } catch (e) { + } catch { onErrorEvent.call(xhr); } @@ -396,7 +396,7 @@ assets.fetchFilterList = async function(mainlistURL) { const toParsedURL = url => { try { return new URL(url.trim()); - } catch (ex) { + } catch { } }; @@ -622,7 +622,7 @@ function updateAssetSourceRegistry(json, silent = false) { Array.from(Object.entries(newDict)) .filter(a => a[1].content === 'filters' && a[1].off === undefined) .map(a => a[0]); - } catch (ex) { + } catch { } if ( newDict instanceof Object === false ) { return; } diff --git a/src/js/base64-custom.js b/src/js/base64-custom.js index 0d9a43fa2..9d15d7182 100644 --- a/src/js/base64-custom.js +++ b/src/js/base64-custom.js @@ -19,8 +19,6 @@ Home: https://github.com/gorhill/uBlock */ -'use strict'; - /******************************************************************************/ // Custom base64 codecs. These codecs are meant to encode/decode typed arrays diff --git a/src/js/benchmarks.js b/src/js/benchmarks.js index 59996b0f6..f9875694e 100644 --- a/src/js/benchmarks.js +++ b/src/js/benchmarks.js @@ -89,7 +89,7 @@ const loadBenchmarkDataset = (( ) => { if ( details.content.startsWith('[') ) { try { requests = JSON.parse(details.content); - } catch(ex) { + } catch { } } else { const lineIter = new LineIterator(details.content); @@ -99,7 +99,7 @@ const loadBenchmarkDataset = (( ) => { if ( line === '' ) { continue; } try { parsed.push(JSON.parse(line)); - } catch(ex) { + } catch { parsed.length = 0; break; } diff --git a/src/js/cachestorage.js b/src/js/cachestorage.js index f946bc73b..97b8b6f05 100644 --- a/src/js/cachestorage.js +++ b/src/js/cachestorage.js @@ -480,7 +480,7 @@ const idbStorage = (( ) => { try { const db = ev.target.result; db.createObjectStore(STORAGE_NAME, { keyPath: 'key' }); - } catch(ex) { + } catch { req.onerror(); } }; diff --git a/src/js/click2load.js b/src/js/click2load.js index b441d973e..4a9f489eb 100644 --- a/src/js/click2load.js +++ b/src/js/click2load.js @@ -19,8 +19,6 @@ Home: https://github.com/gorhill/uBlock */ -'use strict'; - /******************************************************************************/ /******************************************************************************/ diff --git a/src/js/cloud-ui.js b/src/js/cloud-ui.js index 228f1140b..26bcd03a3 100644 --- a/src/js/cloud-ui.js +++ b/src/js/cloud-ui.js @@ -19,12 +19,8 @@ Home: https://github.com/gorhill/uBlock */ -/* global faIconsInit */ - -'use strict'; - -import { i18n, i18n$ } from './i18n.js'; import { dom, qs$ } from './dom.js'; +import { i18n, i18n$ } from './i18n.js'; import { faIconsInit } from './fa-icons.js'; /******************************************************************************/ diff --git a/src/js/code-viewer.js b/src/js/code-viewer.js index f11289ad0..83d5de98a 100644 --- a/src/js/code-viewer.js +++ b/src/js/code-viewer.js @@ -21,10 +21,6 @@ /* globals CodeMirror, uBlockDashboard, beautifier */ -'use strict'; - -/******************************************************************************/ - import { dom, qs$ } from './dom.js'; import { getActualTheme } from './theme.js'; @@ -117,25 +113,25 @@ async function fetchResource(url) { } }; switch ( mime ) { - case 'text/css': - text = beautifier.css(text, beautifierOptions); - break; - case 'text/html': - case 'application/xhtml+xml': - case 'application/xml': - case 'image/svg+xml': - text = beautifier.html(text, beautifierOptions); - break; - case 'text/javascript': - case 'application/javascript': - case 'application/x-javascript': - text = beautifier.js(text, beautifierOptions); - break; - case 'application/json': - text = beautifier.js(text, beautifierOptions); - break; - default: - break; + case 'text/css': + text = beautifier.css(text, beautifierOptions); + break; + case 'text/html': + case 'application/xhtml+xml': + case 'application/xml': + case 'image/svg+xml': + text = beautifier.html(text, beautifierOptions); + break; + case 'text/javascript': + case 'application/javascript': + case 'application/x-javascript': + text = beautifier.js(text, beautifierOptions); + break; + case 'application/json': + text = beautifier.js(text, beautifierOptions); + break; + default: + break; } return { mime, text }; } @@ -182,7 +178,7 @@ async function setURL(resourceURL) { const url = new URL(resourceURL, currentURL || undefined); url.hash = ''; afterURL = url.href; - } catch(ex) { + } catch { } if ( afterURL === undefined ) { return; } } else { diff --git a/src/js/codemirror/search-thread.js b/src/js/codemirror/search-thread.js index 3a4416ff8..6697d508c 100644 --- a/src/js/codemirror/search-thread.js +++ b/src/js/codemirror/search-thread.js @@ -19,8 +19,6 @@ Home: https://github.com/gorhill/uBlock */ -'use strict'; - /******************************************************************************/ (( ) => { @@ -43,7 +41,7 @@ if ( let reSearch; try { reSearch = new RegExp(details.pattern, details.flags); - } catch(ex) { + } catch { return; } @@ -88,11 +86,14 @@ if ( content = msg.content; break; - case 'doSearch': + case 'doSearch': { const response = doSearch(msg); self.postMessage({ id: msg.id, response }); break; } + default: + break; + } }; return; diff --git a/src/js/codemirror/search.js b/src/js/codemirror/search.js index 7ee5b3389..dabc5c191 100644 --- a/src/js/codemirror/search.js +++ b/src/js/codemirror/search.js @@ -226,7 +226,7 @@ import { i18n$ } from '../i18n.js'; query = re.source; flags = re.flags; } - catch (e) { + catch { reParsed = null; } } diff --git a/src/js/codemirror/ubo-dynamic-filtering.js b/src/js/codemirror/ubo-dynamic-filtering.js index d0709a4f8..6a6e18ac9 100644 --- a/src/js/codemirror/ubo-dynamic-filtering.js +++ b/src/js/codemirror/ubo-dynamic-filtering.js @@ -21,8 +21,6 @@ /* global CodeMirror */ -'use strict'; - CodeMirror.defineMode('ubo-dynamic-filtering', ( ) => { const validSwitches = new Set([ @@ -69,7 +67,7 @@ CodeMirror.defineMode('ubo-dynamic-filtering', ( ) => { hnValidator.hostname = '_'; try { hnValidator.hostname = hnin; - } catch(_) { + } catch { return false; } const hnout = hnValidator.hostname; diff --git a/src/js/commands.js b/src/js/commands.js index 2f29b23d9..34e6312f5 100644 --- a/src/js/commands.js +++ b/src/js/commands.js @@ -19,12 +19,8 @@ Home: https://github.com/gorhill/uBlock */ -'use strict'; - -/******************************************************************************/ - -import µb from './background.js'; import { hostnameFromURI } from './uri-utils.js'; +import µb from './background.js'; /******************************************************************************/ diff --git a/src/js/console.js b/src/js/console.js index 410abbd84..255fb6383 100644 --- a/src/js/console.js +++ b/src/js/console.js @@ -19,8 +19,6 @@ Home: https://github.com/gorhill/uBlock */ -'use strict'; - /******************************************************************************/ function ubologSet(state = false) { diff --git a/src/js/contentscript-extra.js b/src/js/contentscript-extra.js index 21feb1d39..9a60dabf7 100644 --- a/src/js/contentscript-extra.js +++ b/src/js/contentscript-extra.js @@ -508,7 +508,7 @@ class PSelectorRoot extends PSelector { prime(input) { try { return super.prime(input); - } catch (ex) { + } catch { } return []; } diff --git a/src/js/contentscript.js b/src/js/contentscript.js index 46df837be..1f6a97111 100644 --- a/src/js/contentscript.js +++ b/src/js/contentscript.js @@ -125,7 +125,7 @@ vAPI.contentScript = true; ) { context = context.parent; } - } catch(ex) { + } catch { } vAPI.effectiveSelf = context; } @@ -360,7 +360,7 @@ vAPI.SafeAnimationFrame = class { if ( addedNodes.length === 0 && removedNodes === false ) { return; } for ( const listener of getListenerIterator() ) { try { listener.onDOMChanged(addedNodes, removedNodes); } - catch (ex) { } + catch { } } addedNodes.length = 0; removedNodes = false; @@ -422,7 +422,7 @@ vAPI.SafeAnimationFrame = class { listenerIteratorDirty = true; if ( domLayoutObserver === undefined ) { return; } try { listener.onDOMCreated(); } - catch (ex) { } + catch { } startMutationObserver(); }; @@ -450,7 +450,7 @@ vAPI.SafeAnimationFrame = class { const start = function() { for ( const listener of getListenerIterator() ) { try { listener.onDOMCreated(); } - catch (ex) { } + catch { } } startMutationObserver(); }; diff --git a/src/js/contextmenu.js b/src/js/contextmenu.js index a2b01e9a1..a158f2408 100644 --- a/src/js/contextmenu.js +++ b/src/js/contextmenu.js @@ -91,7 +91,7 @@ const onSubscribeToList = function(details) { try { parsedURL = new URL(details.linkUrl); } - catch(ex) { + catch { } if ( parsedURL instanceof URL === false ) { return; } const url = parsedURL.searchParams.get('location'); diff --git a/src/js/dashboard-common.js b/src/js/dashboard-common.js index feceb1f62..b761fa9b9 100644 --- a/src/js/dashboard-common.js +++ b/src/js/dashboard-common.js @@ -19,8 +19,6 @@ Home: https://github.com/gorhill/uBlock */ -'use strict'; - import { dom } from './dom.js'; /******************************************************************************/ diff --git a/src/js/dashboard.js b/src/js/dashboard.js index 3ba16f0e4..3975a039e 100644 --- a/src/js/dashboard.js +++ b/src/js/dashboard.js @@ -19,8 +19,6 @@ Home: https://github.com/gorhill/uBlock */ -'use strict'; - import { dom, qs$ } from './dom.js'; /******************************************************************************/ @@ -118,7 +116,7 @@ if ( self.location.hash.slice(1) === 'no-dashboard.html' ) { if ( iframe.src !== '' ) { iframe.src = ''; } - } catch(ex) { + } catch { } vAPI.defer.once(250).then(( ) => check()); }; diff --git a/src/js/diff-updater.js b/src/js/diff-updater.js index 4e6ece155..8a3c5e9e3 100644 --- a/src/js/diff-updater.js +++ b/src/js/diff-updater.js @@ -19,15 +19,13 @@ Home: https://github.com/gorhill/uBlock */ -'use strict'; - // This module can be dynamically loaded or spun off as a worker. /******************************************************************************/ const patches = new Map(); const encoder = new TextEncoder(); -const reFileName = /([^\/]+?)(?:#.+)?$/; +const reFileName = /([^/]+?)(?:#.+)?$/; const EMPTYLINE = ''; /******************************************************************************/ @@ -50,8 +48,7 @@ const basename = url => { const resolveURL = (path, url) => { try { return new URL(path, url); - } - catch(_) { + } catch { } }; diff --git a/src/js/document-blocked.js b/src/js/document-blocked.js index 0bccb06a2..2d7f28a7a 100644 --- a/src/js/document-blocked.js +++ b/src/js/document-blocked.js @@ -85,7 +85,7 @@ const urlToFragment = raw => { b.append(hn); fragment.append(raw.slice(0,i), b, raw.slice(i+hn.length)); return fragment; - } catch(_) { + } catch { } return raw; }; @@ -157,7 +157,7 @@ if ( typeof details.to === 'string' && details.to.length !== 0 ) { let url; try { url = new URL(rawURL); - } catch(ex) { + } catch { return false; } diff --git a/src/js/dom-inspector.js b/src/js/dom-inspector.js index a0d334b76..a6ef77570 100644 --- a/src/js/dom-inspector.js +++ b/src/js/dom-inspector.js @@ -19,9 +19,6 @@ Home: https://github.com/gorhill/uBlock */ -'use strict'; - -/******************************************************************************/ /******************************************************************************/ const svgRoot = document.querySelector('svg'); @@ -36,20 +33,20 @@ const shutdown = ( ) => { const contentInspectorChannel = ev => { const msg = ev.data || {}; switch ( msg.what ) { - case 'quitInspector': { - shutdown(); - break; - } - case 'svgPaths': { - const paths = svgRoot.children; - paths[0].setAttribute('d', msg.paths[0]); - paths[1].setAttribute('d', msg.paths[1]); - paths[2].setAttribute('d', msg.paths[2]); - paths[3].setAttribute('d', msg.paths[3]); - break; - } - default: - break; + case 'quitInspector': { + shutdown(); + break; + } + case 'svgPaths': { + const paths = svgRoot.children; + paths[0].setAttribute('d', msg.paths[0]); + paths[1].setAttribute('d', msg.paths[1]); + paths[2].setAttribute('d', msg.paths[2]); + paths[3].setAttribute('d', msg.paths[3]); + break; + } + default: + break; } }; diff --git a/src/js/dyna-rules.js b/src/js/dyna-rules.js index 69eef8519..1bb1d097b 100644 --- a/src/js/dyna-rules.js +++ b/src/js/dyna-rules.js @@ -21,15 +21,11 @@ /* global CodeMirror, diff_match_patch, uBlockDashboard */ -'use strict'; - -import publicSuffixList from '../lib/publicsuffixlist/publicsuffixlist.js'; - +import './codemirror/ubo-dynamic-filtering.js'; +import { dom, qs$, qsa$ } from './dom.js'; import { hostnameFromURI } from './uri-utils.js'; import { i18n$ } from './i18n.js'; -import { dom, qs$, qsa$ } from './dom.js'; - -import './codemirror/ubo-dynamic-filtering.js'; +import publicSuffixList from '../lib/publicsuffixlist/publicsuffixlist.js'; /******************************************************************************/ @@ -327,7 +323,7 @@ function handleImportFilePicker() { // https://github.com/chrisaljoudi/uBlock/issues/757 // Support RequestPolicy rule syntax let result = this.result; - let matches = /\[origins-to-destinations\]([^\[]+)/.exec(result); + let matches = /\[origins-to-destinations\]([^[]+)/.exec(result); if ( matches && matches.length === 2 ) { result = matches[1].trim() .replace(/\|/g, ' ') @@ -459,13 +455,12 @@ const onPresentationChanged = (( ) => { thePanes.orig.modified.join('\n'), thePanes.edit.modified.join('\n') ); - const ll = []; let il = 0, lellipsis = false; - const rr = []; let ir = 0, rellipsis = false; + const ll = []; let lellipsis = false; + const rr = []; let rellipsis = false; for ( let i = 0; i < diffs.length; i++ ) { const diff = diffs[i]; if ( diff[0] === 0 ) { lellipsis = rellipsis = true; - il += 1; ir += 1; continue; } if ( diff[0] < 0 ) { @@ -475,7 +470,6 @@ const onPresentationChanged = (( ) => { lellipsis = rellipsis = false; } ll.push(diff[1].trim()); - il += 1; continue; } /* diff[0] > 0 */ @@ -485,7 +479,6 @@ const onPresentationChanged = (( ) => { lellipsis = rellipsis = false; } rr.push(diff[1].trim()); - ir += 1; } if ( lellipsis ) { ll.push('...'); } if ( rellipsis ) { rr.push('...'); } diff --git a/src/js/dynamic-net-filtering.js b/src/js/dynamic-net-filtering.js index ec7a7c906..4bc53e1a7 100644 --- a/src/js/dynamic-net-filtering.js +++ b/src/js/dynamic-net-filtering.js @@ -19,18 +19,12 @@ Home: https://github.com/gorhill/uBlock */ -'use strict'; - -/******************************************************************************/ - -import punycode from '../lib/punycode.js'; - -import { LineIterator } from './text-utils.js'; - import { decomposeHostname, domainFromHostname, } from './uri-utils.js'; +import { LineIterator } from './text-utils.js'; +import punycode from '../lib/punycode.js'; /******************************************************************************/ @@ -73,7 +67,7 @@ const intToActionMap = new Map([ ]); // For performance purpose, as simple tests as possible -const reBadHostname = /[^0-9a-z_.\[\]:%-]/; +const reBadHostname = /[^0-9a-z_.[\]:%-]/; const reNotASCII = /[^\x20-\x7F]/; const decomposedSource = []; const decomposedDestination = []; diff --git a/src/js/fa-icons.js b/src/js/fa-icons.js index 08fee8557..82ec1510e 100644 --- a/src/js/fa-icons.js +++ b/src/js/fa-icons.js @@ -19,8 +19,6 @@ Home: https://github.com/gorhill/uMatrix */ -'use strict'; - /******************************************************************************/ export const faIconsInit = (( ) => { diff --git a/src/js/filtering-engines.js b/src/js/filtering-engines.js index d72ff9d64..64198b9f3 100644 --- a/src/js/filtering-engines.js +++ b/src/js/filtering-engines.js @@ -19,10 +19,6 @@ Home: https://github.com/gorhill/uBlock */ -'use strict'; - -/******************************************************************************/ - import DynamicHostRuleFiltering from './dynamic-net-filtering.js'; import DynamicSwitchRuleFiltering from './hnswitches.js'; import DynamicURLRuleFiltering from './url-net-filtering.js'; diff --git a/src/js/hnswitches.js b/src/js/hnswitches.js index 9e94a8ee0..126b7e4a6 100644 --- a/src/js/hnswitches.js +++ b/src/js/hnswitches.js @@ -19,16 +19,9 @@ Home: https://github.com/gorhill/uBlock */ -/* jshint bitwise: false */ - -'use strict'; - -/******************************************************************************/ - -import punycode from '../lib/punycode.js'; - -import { decomposeHostname } from './uri-utils.js'; import { LineIterator } from './text-utils.js'; +import { decomposeHostname } from './uri-utils.js'; +import punycode from '../lib/punycode.js'; /******************************************************************************/ diff --git a/src/js/html-filtering.js b/src/js/html-filtering.js index 81d66ee1d..ac6dee23c 100644 --- a/src/js/html-filtering.js +++ b/src/js/html-filtering.js @@ -19,15 +19,11 @@ Home: https://github.com/gorhill/uBlock */ -'use strict'; - -/******************************************************************************/ - -import logger from './logger.js'; -import µb from './background.js'; -import { sessionFirewall } from './filtering-engines.js'; import { StaticExtFilteringHostnameDB } from './static-ext-filtering-db.js'; import { entityFromDomain } from './uri-utils.js'; +import logger from './logger.js'; +import { sessionFirewall } from './filtering-engines.js'; +import µb from './background.js'; /******************************************************************************/ diff --git a/src/js/httpheader-filtering.js b/src/js/httpheader-filtering.js index 522ea2157..58781fb61 100644 --- a/src/js/httpheader-filtering.js +++ b/src/js/httpheader-filtering.js @@ -19,16 +19,12 @@ Home: https://github.com/gorhill/uBlock */ -'use strict'; - -/******************************************************************************/ - -import logger from './logger.js'; -import µb from './background.js'; -import { entityFromDomain } from './uri-utils.js'; -import { sessionFirewall } from './filtering-engines.js'; -import { StaticExtFilteringHostnameDB } from './static-ext-filtering-db.js'; import * as sfp from './static-filtering-parser.js'; +import { StaticExtFilteringHostnameDB } from './static-ext-filtering-db.js'; +import { entityFromDomain } from './uri-utils.js'; +import logger from './logger.js'; +import { sessionFirewall } from './filtering-engines.js'; +import µb from './background.js'; /******************************************************************************/ diff --git a/src/js/logger-ui-inspector.js b/src/js/logger-ui-inspector.js index d90d44a43..a45fc5789 100644 --- a/src/js/logger-ui-inspector.js +++ b/src/js/logger-ui-inspector.js @@ -88,7 +88,7 @@ const contentInspectorChannel = (( ) => { toContentPort = browser.tabs.connect(tabId, { frameId }); toContentPort.onMessage.addListener(onContentMessage); toContentPort.onDisconnect.addListener(onContentDisconnect); - } catch(_) { + } catch { } }; diff --git a/src/js/logger-ui.js b/src/js/logger-ui.js index 0b9c31dd9..19270a2be 100644 --- a/src/js/logger-ui.js +++ b/src/js/logger-ui.js @@ -2156,7 +2156,7 @@ const rowFilterer = (( ) => { reStr = rawPart.slice(1, -1); try { new RegExp(reStr); - } catch(ex) { + } catch { reStr = ''; } } @@ -2937,7 +2937,7 @@ const loggerSettings = (( ) => { if ( Array.isArray(stored.columns) ) { settings.columns = stored.columns; } - } catch(_) { + } catch { } }); diff --git a/src/js/logger.js b/src/js/logger.js index 766188e54..aa6755d5c 100644 --- a/src/js/logger.js +++ b/src/js/logger.js @@ -19,10 +19,6 @@ Home: https://github.com/gorhill/uBlock */ -'use strict'; - -/******************************************************************************/ - import { broadcast, broadcastToAll } from './broadcast.js'; /******************************************************************************/ diff --git a/src/js/lz4.js b/src/js/lz4.js index 608cdd853..f89d7436f 100644 --- a/src/js/lz4.js +++ b/src/js/lz4.js @@ -21,10 +21,6 @@ /* global lz4BlockCodec */ -'use strict'; - -/******************************************************************************/ - import µb from './background.js'; /******************************************************************************* diff --git a/src/js/messaging.js b/src/js/messaging.js index b24a9a5a2..2a5e7da95 100644 --- a/src/js/messaging.js +++ b/src/js/messaging.js @@ -918,7 +918,7 @@ const fromBase64 = function(encoded) { let u8array; try { u8array = denseBase64.decode(encoded); - } catch(ex) { + } catch { } return Promise.resolve(u8array !== undefined ? u8array : encoded); }; diff --git a/src/js/mrucache.js b/src/js/mrucache.js index 9a16047fa..266783adf 100644 --- a/src/js/mrucache.js +++ b/src/js/mrucache.js @@ -19,8 +19,6 @@ Home: https://github.com/gorhill/uBlock */ -'use strict'; - export class MRUCache { constructor(maxSize) { this.maxSize = maxSize; diff --git a/src/js/pagestore.js b/src/js/pagestore.js index 7adca8482..5d67f86f1 100644 --- a/src/js/pagestore.js +++ b/src/js/pagestore.js @@ -549,7 +549,7 @@ const PageStore = class { entries = await webext.webNavigation.getAllFrames({ tabId: this.tabId }); - } catch(ex) { + } catch { } if ( Array.isArray(entries) === false ) { return; } const toKeep = new Set(); diff --git a/src/js/popup-fenix.js b/src/js/popup-fenix.js index 9f2af084d..c4ffc7fd7 100644 --- a/src/js/popup-fenix.js +++ b/src/js/popup-fenix.js @@ -19,11 +19,9 @@ Home: https://github.com/gorhill/uBlock */ -'use strict'; - -import punycode from '../lib/punycode.js'; -import { i18n$ } from './i18n.js'; import { dom, qs$, qsa$ } from './dom.js'; +import { i18n$ } from './i18n.js'; +import punycode from '../lib/punycode.js'; /******************************************************************************/ @@ -178,11 +176,11 @@ const formatNumber = function(count) { // a poor's man compact form, which unfortunately is not i18n-friendly. count /= 1000000; if ( count >= 100 ) { - count = Math.floor(count * 10) / 10; + count = Math.floor(count * 10) / 10; } else if ( count > 10 ) { - count = Math.floor(count * 100) / 100; + count = Math.floor(count * 100) / 100; } else { - count = Math.floor(count * 1000) / 1000; + count = Math.floor(count * 1000) / 1000; } return (count).toLocaleString(undefined) + '\u2009M'; }; @@ -469,27 +467,27 @@ function filterFirewallRows() { for ( const elem of elems ) { const on = dom.cl.has(elem, 'on'); switch ( elem.dataset.expr ) { - case 'not': - not = on; - break; - case 'blocked': - dom.cl.toggle(firewallElem, 'showBlocked', !not && on); - dom.cl.toggle(firewallElem, 'hideBlocked', not && on); - break; - case 'allowed': - dom.cl.toggle(firewallElem, 'showAllowed', !not && on); - dom.cl.toggle(firewallElem, 'hideAllowed', not && on); - break; - case 'script': - dom.cl.toggle(firewallElem, 'show3pScript', !not && on); - dom.cl.toggle(firewallElem, 'hide3pScript', not && on); - break; - case 'frame': - dom.cl.toggle(firewallElem, 'show3pFrame', !not && on); - dom.cl.toggle(firewallElem, 'hide3pFrame', not && on); - break; - default: - break; + case 'not': + not = on; + break; + case 'blocked': + dom.cl.toggle(firewallElem, 'showBlocked', !not && on); + dom.cl.toggle(firewallElem, 'hideBlocked', not && on); + break; + case 'allowed': + dom.cl.toggle(firewallElem, 'showAllowed', !not && on); + dom.cl.toggle(firewallElem, 'hideAllowed', not && on); + break; + case 'script': + dom.cl.toggle(firewallElem, 'show3pScript', !not && on); + dom.cl.toggle(firewallElem, 'hide3pScript', not && on); + break; + case 'frame': + dom.cl.toggle(firewallElem, 'show3pFrame', !not && on); + dom.cl.toggle(firewallElem, 'hide3pFrame', not && on); + break; + default: + break; } } } @@ -498,14 +496,14 @@ dom.on('#firewall .filterExpressions', 'click', 'span[data-expr]', ev => { const target = ev.target; dom.cl.toggle(target, 'on'); switch ( target.dataset.expr ) { - case 'blocked': - if ( dom.cl.has(target, 'on') === false ) { break; } - dom.cl.remove('#firewall .filterExpressions span[data-expr="allowed"]', 'on'); - break; - case 'allowed': - if ( dom.cl.has(target, 'on') === false ) { break; } - dom.cl.remove('#firewall .filterExpressions span[data-expr="blocked"]', 'on'); - break; + case 'blocked': + if ( dom.cl.has(target, 'on') === false ) { break; } + dom.cl.remove('#firewall .filterExpressions span[data-expr="allowed"]', 'on'); + break; + case 'allowed': + if ( dom.cl.has(target, 'on') === false ) { break; } + dom.cl.remove('#firewall .filterExpressions span[data-expr="blocked"]', 'on'); + break; } filterFirewallRows(); const elems = qsa$('#firewall .filterExpressions span[data-expr]'); @@ -1194,18 +1192,18 @@ dom.on(document, 'keydown', ev => { if ( ev.isComposing ) { return; } let bypassCache = false; switch ( ev.key ) { - case 'F5': - bypassCache = ev.ctrlKey || ev.metaKey || ev.shiftKey; - break; - case 'r': - if ( (ev.ctrlKey || ev.metaKey) !== true ) { return; } - break; - case 'R': - if ( (ev.ctrlKey || ev.metaKey) !== true ) { return; } - bypassCache = true; - break; - default: - return; + case 'F5': + bypassCache = ev.ctrlKey || ev.metaKey || ev.shiftKey; + break; + case 'r': + if ( (ev.ctrlKey || ev.metaKey) !== true ) { return; } + break; + case 'R': + if ( (ev.ctrlKey || ev.metaKey) !== true ) { return; } + bypassCache = true; + break; + default: + return; } reloadTab(bypassCache); ev.preventDefault(); @@ -1223,7 +1221,7 @@ vAPI.localStorage.getItemAsync('popupExpandExceptions').then(exceptions => { expandExceptions.add(exception); } } - catch(ex) { + catch { } }); diff --git a/src/js/redirect-engine.js b/src/js/redirect-engine.js index d768db546..5e7a55884 100644 --- a/src/js/redirect-engine.js +++ b/src/js/redirect-engine.js @@ -19,12 +19,8 @@ Home: https://github.com/gorhill/uBlock */ -'use strict'; - -/******************************************************************************/ - -import redirectableResources from './redirect-resources.js'; import { LineIterator, orphanizeString } from './text-utils.js'; +import redirectableResources from './redirect-resources.js'; /******************************************************************************/ diff --git a/src/js/resources/attribute.js b/src/js/resources/attribute.js index ed735eecd..3b33a5061 100644 --- a/src/js/resources/attribute.js +++ b/src/js/resources/attribute.js @@ -49,7 +49,7 @@ export function setAttrFn( let elems; try { elems = document.querySelectorAll(selector); - } catch(_) { + } catch { return false; } for ( const elem of elems ) { @@ -259,7 +259,7 @@ export function removeAttr( safe.uboLog(logPrefix, `Removed attribute '${attr}'`); } } - } catch(ex) { + } catch { } }; const mutationHandler = mutations => { diff --git a/src/js/resources/cookie.js b/src/js/resources/cookie.js index 571514ed8..8a7a97076 100644 --- a/src/js/resources/cookie.js +++ b/src/js/resources/cookie.js @@ -142,7 +142,7 @@ export function setCookieFn( try { document.cookie = cookieParts.join(''); - } catch(_) { + } catch { } const done = getCookieFn(name) === value; diff --git a/src/js/resources/href-sanitizer.js b/src/js/resources/href-sanitizer.js index 82a9a95c8..eb88c27c3 100644 --- a/src/js/resources/href-sanitizer.js +++ b/src/js/resources/href-sanitizer.js @@ -73,7 +73,7 @@ function hrefSanitizer( try { elems = document.querySelectorAll(`a[href="${href}"`); } - catch(ex) { + catch { } for ( const elem of elems ) { elem.setAttribute('href', text); @@ -87,7 +87,7 @@ function hrefSanitizer( try { const url = new URL(text, document.location); return url.href; - } catch(ex) { + } catch { } return ''; }; @@ -101,7 +101,7 @@ function hrefSanitizer( if ( value === null ) { return href } if ( recursive ) { return extractParam(value, source.slice(end)); } return value; - } catch(x) { + } catch { } return href; }; @@ -128,7 +128,7 @@ function hrefSanitizer( try { elems = document.querySelectorAll(selector); } - catch(ex) { + catch { return false; } for ( const elem of elems ) { diff --git a/src/js/resources/localstorage.js b/src/js/resources/localstorage.js index 73e41546e..8a6b76293 100644 --- a/src/js/resources/localstorage.js +++ b/src/js/resources/localstorage.js @@ -102,7 +102,7 @@ export function setLocalStorageItemFn( } else { storage.setItem(key, `${value}`); } - } catch(ex) { + } catch { } } registerScriptlet(setLocalStorageItemFn, { diff --git a/src/js/resources/parse-replace.js b/src/js/resources/parse-replace.js index da638735f..e7fd488e9 100644 --- a/src/js/resources/parse-replace.js +++ b/src/js/resources/parse-replace.js @@ -43,7 +43,7 @@ export function parseReplaceFn(s) { const flags = s.slice(parser.separatorEnd); try { return { re: new RegExp(pattern, flags), replacement }; - } catch(_) { + } catch { } } registerScriptlet(parseReplaceFn, { diff --git a/src/js/resources/replace-argument.js b/src/js/resources/replace-argument.js index a53991790..638eaeee6 100644 --- a/src/js/resources/replace-argument.js +++ b/src/js/resources/replace-argument.js @@ -95,8 +95,10 @@ export function trustedReplaceArgument( return context.reflect(); } const argBefore = getArg(context); - if ( safe.RegExp_test.call(reCondition, argBefore) === false ) { - return context.reflect(); + if ( extraArgs.condition !== undefined ) { + if ( safe.RegExp_test.call(reCondition, argBefore) === false ) { + return context.reflect(); + } } const argAfter = replacer && typeof argBefore === 'string' ? argBefore.replace(replacer.re, replacer.replacement) diff --git a/src/js/resources/safe-self.js b/src/js/resources/safe-self.js index afb987221..3766f3e19 100644 --- a/src/js/resources/safe-self.js +++ b/src/js/resources/safe-self.js @@ -127,7 +127,7 @@ export function safeSelf() { try { return new RegExp(match[1], match[2] || undefined); } - catch(ex) { + catch { } return /^/; }, @@ -205,7 +205,7 @@ export function safeSelf() { } }; bc.postMessage('areyouready?'); - } catch(_) { + } catch { safe.sendToLogger = (type, ...args) => { const text = safe.toLogText(type, ...args); if ( text === undefined ) { return; } diff --git a/src/js/resources/scriptlets.js b/src/js/resources/scriptlets.js index 37a332425..20a34f30e 100755 --- a/src/js/resources/scriptlets.js +++ b/src/js/resources/scriptlets.js @@ -231,7 +231,7 @@ function abortCurrentScriptCore( text = self.decodeURIComponent(content); break; } - } catch(ex) { + } catch { } scriptTexts.set(elem, text); return text; @@ -644,7 +644,7 @@ function matchObjectProperties(propNeedles, ...objs) { if ( value === undefined ) { continue; } if ( typeof value !== 'string' ) { try { value = safe.JSON_stringify(value); } - catch(ex) { } + catch { } if ( typeof value !== 'string' ) { continue; } } if ( safe.testPattern(details, value) ) { continue; } @@ -853,7 +853,7 @@ function preventXhrFn( const safeDispatchEvent = (xhr, type) => { try { xhr.dispatchEvent(new Event(type)); - } catch(_) { + } catch { } }; const XHRBefore = XMLHttpRequest.prototype; @@ -1295,7 +1295,7 @@ function addEventListenerDefuser( } else { h = String(callArgs[1]); } - } catch(ex) { + } catch { } if ( type === '' && pattern === '' ) { safe.uboLog(logPrefix, `Called: ${t}\n${h}\n${elementDetails(thisArg)}`); @@ -1429,7 +1429,7 @@ function jsonPruneXhrResponse( } else if ( typeof innerResponse === 'string' ) { try { objBefore = safe.JSON_parse(innerResponse); - } catch(ex) { + } catch { } } if ( typeof objBefore !== 'object' ) { @@ -1681,7 +1681,7 @@ function noFetchIf( responseProps[p] = { value: v }; }); } - catch(ex) {} + catch { } } else if ( responseType !== '' ) { if ( validResponseProps.type.includes(responseType) ) { responseProps.type = { value: responseType }; @@ -1699,7 +1699,7 @@ function noFetchIf( let v = details[prop]; if ( typeof v !== 'string' ) { try { v = safe.JSON_stringify(v); } - catch(ex) { } + catch { } } if ( typeof v !== 'string' ) { continue; } props.set(prop, v); @@ -1721,7 +1721,7 @@ function noFetchIf( break; } } - } catch(ex) { + } catch { } if ( proceed ) { return context.reflect(); @@ -1823,7 +1823,7 @@ function removeClass( node.classList.remove(...tokens); safe.uboLog(logPrefix, 'Removed class(es)'); } - } catch(ex) { + } catch { } if ( mustStay ) { return; } if ( document.readyState !== 'complete' ) { return; } @@ -2342,7 +2342,7 @@ function xmlPrune( pruneFromDoc(xmlDoc); const serializer = new XMLSerializer(); text = serializer.serializeToString(xmlDoc); - } catch(ex) { + } catch { } return text; }; @@ -2636,7 +2636,7 @@ function callNothrow( let r; try { r = Reflect.apply(...args); - } catch(ex) { + } catch { } return r; }, @@ -3023,7 +3023,7 @@ function trustedClickElement( .filter(s => { try { void querySelectorEx(s); - } catch(_) { + } catch { return false; } return true; @@ -3170,7 +3170,7 @@ function trustedPruneInboundObject( if ( extraArgs.dontOverwrite ) { try { objBefore = safe.JSON_parse(safe.JSON_stringify(targetArg)); - } catch(_) { + } catch { objBefore = undefined; } } @@ -3255,7 +3255,7 @@ function trustedReplaceOutboundText( let textBefore = encodedTextBefore; if ( extraArgs.encoding === 'base64' ) { try { textBefore = self.atob(encodedTextBefore); } - catch(ex) { return encodedTextBefore; } + catch { return encodedTextBefore; } } if ( rawPattern === '' ) { safe.uboLog(logPrefix, 'Decoded outbound text:\n', textBefore); @@ -3456,7 +3456,7 @@ function trustedPreventDomBypass( Object.defineProperty(elem, 'contentWindow', { value: self }); } safe.uboLog(logPrefix, 'Bypass prevented'); - } catch(_) { + } catch { } } return r; @@ -3511,7 +3511,7 @@ function trustedOverrideElementMethod( const { thisArg } = context; try { override = thisArg.closest(selector) === thisArg; - } catch(_) { + } catch { } } if ( override === false ) { diff --git a/src/js/resources/set-constant.js b/src/js/resources/set-constant.js index 127f27bbb..9ee985914 100644 --- a/src/js/resources/set-constant.js +++ b/src/js/resources/set-constant.js @@ -57,9 +57,9 @@ export function validateConstantFn(trusted, raw, extraArgs = {}) { if ( Math.abs(raw) > 0x7FFF ) { return; } } else if ( trusted ) { if ( raw.startsWith('json:') ) { - try { value = safe.JSON_parse(raw.slice(5)); } catch(ex) { return; } + try { value = safe.JSON_parse(raw.slice(5)); } catch { return; } } else if ( raw.startsWith('{') && raw.endsWith('}') ) { - try { value = safe.JSON_parse(raw).value; } catch(ex) { return; } + try { value = safe.JSON_parse(raw).value; } catch { return; } } } else { return; diff --git a/src/js/reverselookup-worker.js b/src/js/reverselookup-worker.js index 37b8b652a..ffdf56686 100644 --- a/src/js/reverselookup-worker.js +++ b/src/js/reverselookup-worker.js @@ -19,8 +19,6 @@ Home: https://github.com/gorhill/uBlock */ -'use strict'; - /******************************************************************************/ let listEntries = Object.create(null); @@ -212,6 +210,7 @@ const fromExtendedFilter = function(details) { case 8: // HTML filtering // Response header filtering + /* fallthrough */ case 64: { if ( exception !== ((fargs[2] & 0b001) !== 0) ) { break; } const isProcedural = (fargs[2] & 0b010) !== 0; diff --git a/src/js/reverselookup.js b/src/js/reverselookup.js index e7bf24e94..e1fa006d4 100644 --- a/src/js/reverselookup.js +++ b/src/js/reverselookup.js @@ -19,20 +19,15 @@ Home: https://github.com/gorhill/uBlock */ -'use strict'; - -/******************************************************************************/ - -import staticNetFilteringEngine from './static-net-filtering.js'; -import µb from './background.js'; -import { CompiledListWriter } from './static-filtering-io.js'; -import { i18n$ } from './i18n.js'; import * as sfp from './static-filtering-parser.js'; - import { domainFromHostname, hostnameFromURI, } from './uri-utils.js'; +import { CompiledListWriter } from './static-filtering-io.js'; +import { i18n$ } from './i18n.js'; +import staticNetFilteringEngine from './static-net-filtering.js'; +import µb from './background.js'; /******************************************************************************/ diff --git a/src/js/scriptlet-filtering-core.js b/src/js/scriptlet-filtering-core.js index 0fec05c2b..a585f119e 100644 --- a/src/js/scriptlet-filtering-core.js +++ b/src/js/scriptlet-filtering-core.js @@ -19,12 +19,8 @@ Home: https://github.com/gorhill/uBlock */ -'use strict'; - -/******************************************************************************/ - -import { redirectEngine as reng } from './redirect-engine.js'; import { StaticExtFilteringHostnameDB } from './static-ext-filtering-db.js'; +import { redirectEngine as reng } from './redirect-engine.js'; /******************************************************************************/ diff --git a/src/js/scriptlet-filtering.js b/src/js/scriptlet-filtering.js index b7a061772..722a6fe34 100644 --- a/src/js/scriptlet-filtering.js +++ b/src/js/scriptlet-filtering.js @@ -166,7 +166,7 @@ const onScriptletMessageInjector = (( ) => { }; bcSecret.postMessage('iamready!'); self.uBO_bcSecret = bcSecret; - } catch(_) { + } catch { } }.toString(), ')(', diff --git a/src/js/scriptlets/cosmetic-logger.js b/src/js/scriptlets/cosmetic-logger.js index 5d1f1b99a..912c18eb7 100644 --- a/src/js/scriptlets/cosmetic-logger.js +++ b/src/js/scriptlets/cosmetic-logger.js @@ -19,10 +19,6 @@ Home: https://github.com/gorhill/uBlock */ -/* globals browser */ - -'use strict'; - /******************************************************************************/ (( ) => { @@ -53,7 +49,7 @@ function hasSelector(selector, context = document) { try { return context.querySelector(selector) !== null; } - catch(ex) { + catch { } return false; } @@ -65,7 +61,7 @@ function safeMatchSelector(selector, context) { try { return context.matches(safeSelector); } - catch(ex) { + catch { } return false; } @@ -77,7 +73,7 @@ function safeQuerySelector(selector, context = document) { try { return context.querySelector(safeSelector); } - catch(ex) { + catch { } return null; } diff --git a/src/js/scriptlets/cosmetic-off.js b/src/js/scriptlets/cosmetic-off.js index f1301e259..e38de4efe 100644 --- a/src/js/scriptlets/cosmetic-off.js +++ b/src/js/scriptlets/cosmetic-off.js @@ -19,8 +19,6 @@ Home: https://github.com/gorhill/uBlock */ -'use strict'; - /******************************************************************************/ if ( typeof vAPI === 'object' && vAPI.domFilterer ) { diff --git a/src/js/scriptlets/cosmetic-on.js b/src/js/scriptlets/cosmetic-on.js index 7b3097613..cb10270cf 100644 --- a/src/js/scriptlets/cosmetic-on.js +++ b/src/js/scriptlets/cosmetic-on.js @@ -19,8 +19,6 @@ Home: https://github.com/gorhill/uBlock */ -'use strict'; - /******************************************************************************/ if ( typeof vAPI === 'object' && vAPI.domFilterer ) { diff --git a/src/js/scriptlets/cosmetic-report.js b/src/js/scriptlets/cosmetic-report.js index a968d4de0..83b8b62bf 100644 --- a/src/js/scriptlets/cosmetic-report.js +++ b/src/js/scriptlets/cosmetic-report.js @@ -19,8 +19,6 @@ Home: https://github.com/gorhill/uBlock */ -'use strict'; - /******************************************************************************/ (( ) => { @@ -40,7 +38,7 @@ const hasSelector = selector => { try { return document.querySelector(selector) !== null; } - catch(ex) { + catch { } return false; }; @@ -52,7 +50,7 @@ const safeQuerySelector = selector => { try { return document.querySelector(safeSelector); } - catch(ex) { + catch { } return null; }; diff --git a/src/js/scriptlets/dom-inspector.js b/src/js/scriptlets/dom-inspector.js index a1be15005..1536d8ac4 100644 --- a/src/js/scriptlets/dom-inspector.js +++ b/src/js/scriptlets/dom-inspector.js @@ -431,7 +431,7 @@ const elementsFromSelector = function(selector, context) { // plain CSS selector try { return context.querySelectorAll(selector); - } catch (ex) { + } catch { } return []; }; @@ -443,7 +443,7 @@ const elementsFromSpecialSelector = function(selector) { let nodes; try { nodes = document.querySelectorAll(matches[1]); - } catch(ex) { + } catch { nodes = []; } for ( const node of nodes ) { @@ -772,7 +772,7 @@ const contentInspectorChannel = (( ) => { if ( toLoggerPort === undefined ) { return; } try { toLoggerPort.postMessage(msg); - } catch(_) { + } catch { shutdownInspector(); } }; diff --git a/src/js/scriptlets/dom-survey-elements.js b/src/js/scriptlets/dom-survey-elements.js index 15825967f..85270ce62 100644 --- a/src/js/scriptlets/dom-survey-elements.js +++ b/src/js/scriptlets/dom-survey-elements.js @@ -19,8 +19,6 @@ Home: https://github.com/gorhill/uBlock */ -'use strict'; - /******************************************************************************/ // https://github.com/uBlockOrigin/uBlock-issues/issues/756 diff --git a/src/js/scriptlets/dom-survey-scripts.js b/src/js/scriptlets/dom-survey-scripts.js index e5300ffdc..30ef66e46 100644 --- a/src/js/scriptlets/dom-survey-scripts.js +++ b/src/js/scriptlets/dom-survey-scripts.js @@ -19,8 +19,6 @@ Home: https://github.com/gorhill/uBlock */ -'use strict'; - /******************************************************************************/ // Scriptlets to count the number of script tags in a document. diff --git a/src/js/scriptlets/epicker.js b/src/js/scriptlets/epicker.js index 106941a2b..5dd23da71 100644 --- a/src/js/scriptlets/epicker.js +++ b/src/js/scriptlets/epicker.js @@ -52,7 +52,7 @@ const safeQuerySelectorAll = function(node, selector) { if ( node !== null ) { try { return node.querySelectorAll(selector); - } catch (e) { + } catch { } } return []; @@ -672,8 +672,7 @@ const filterToDOMInterface = (( ) => { let reFilter = null; try { reFilter = new RegExp(reStr, 'i'); - } - catch (e) { + } catch { return out; } @@ -727,8 +726,7 @@ const filterToDOMInterface = (( ) => { elems = document.querySelectorAll( raw.replace(rePseudoElements, '') ); - } - catch (e) { + } catch { return; } const out = []; @@ -762,7 +760,7 @@ const filterToDOMInterface = (( ) => { default: break; } - } catch(ex) { + } catch { return; } if ( !elems ) { return; } diff --git a/src/js/scriptlets/load-3p-css.js b/src/js/scriptlets/load-3p-css.js index bb7d542dc..315e17c65 100644 --- a/src/js/scriptlets/load-3p-css.js +++ b/src/js/scriptlets/load-3p-css.js @@ -19,8 +19,6 @@ Home: https://github.com/gorhill/uBlock */ -'use strict'; - /******************************************************************************/ (( ) => { @@ -34,7 +32,7 @@ let loaded = false; try { loaded = sheet.rules.length !== 0; - } catch(ex) { + } catch { } if ( loaded ) { continue; } const link = sheet.ownerNode || null; diff --git a/src/js/scriptlets/load-large-media-all.js b/src/js/scriptlets/load-large-media-all.js index a44539e70..cf375774e 100644 --- a/src/js/scriptlets/load-large-media-all.js +++ b/src/js/scriptlets/load-large-media-all.js @@ -19,8 +19,6 @@ Home: https://github.com/gorhill/uBlock */ -'use strict'; - /******************************************************************************/ (( ) => { diff --git a/src/js/scriptlets/noscript-spoof.js b/src/js/scriptlets/noscript-spoof.js index 49e9093b9..a897df3c5 100644 --- a/src/js/scriptlets/noscript-spoof.js +++ b/src/js/scriptlets/noscript-spoof.js @@ -22,8 +22,6 @@ // Code below has been imported from uMatrix and modified to fit uBO: // https://github.com/gorhill/uMatrix/blob/3f8794dd899a05e066c24066c6c0a2515d5c60d2/src/js/contentscript.js#L464-L531 -'use strict'; - /******************************************************************************/ // https://github.com/gorhill/uMatrix/issues/232 @@ -46,15 +44,13 @@ let url; try { url = new URL(refreshURL, document.baseURI); - } catch(ex) { + } catch { return; } if ( reSafeURL.test(url.href) === false ) { return; } redirectTimer = setTimeout(( ) => { - location.assign(url.href); - }, - parseInt(match[1], 10) * 1000 + 1 - ); + location.assign(url.href); + }, parseInt(match[1], 10) * 1000 + 1); meta.parentNode.removeChild(meta); }; diff --git a/src/js/scriptlets/scriptlet-loglevel-1.js b/src/js/scriptlets/scriptlet-loglevel-1.js index bc5f4bb28..ad84ffae8 100644 --- a/src/js/scriptlets/scriptlet-loglevel-1.js +++ b/src/js/scriptlets/scriptlet-loglevel-1.js @@ -19,8 +19,6 @@ Home: https://github.com/gorhill/uBlock */ -'use strict'; - /******************************************************************************/ (( ) => { diff --git a/src/js/scriptlets/scriptlet-loglevel-2.js b/src/js/scriptlets/scriptlet-loglevel-2.js index d8afefdcf..6047919a0 100644 --- a/src/js/scriptlets/scriptlet-loglevel-2.js +++ b/src/js/scriptlets/scriptlet-loglevel-2.js @@ -19,8 +19,6 @@ Home: https://github.com/gorhill/uBlock */ -'use strict'; - /******************************************************************************/ (( ) => { diff --git a/src/js/scriptlets/should-inject-contentscript.js b/src/js/scriptlets/should-inject-contentscript.js index 2317e2068..1b6787338 100644 --- a/src/js/scriptlets/should-inject-contentscript.js +++ b/src/js/scriptlets/should-inject-contentscript.js @@ -32,7 +32,7 @@ self.requestIdleCallback(( ) => vAPI?.bootstrap?.()); } return status; - } catch(ex) { + } catch { } return true; })(); diff --git a/src/js/scriptlets/subscriber.js b/src/js/scriptlets/subscriber.js index ea7b20946..5d9234d08 100644 --- a/src/js/scriptlets/subscriber.js +++ b/src/js/scriptlets/subscriber.js @@ -19,10 +19,6 @@ Home: https://github.com/gorhill/uBlock */ -/* global HTMLDocument */ - -'use strict'; - /******************************************************************************/ // Injected into specific web pages, those which have been pre-selected @@ -70,7 +66,7 @@ const onMaybeSubscriptionLinkClicked = function(target) { title, }); return true; - } catch (_) { + } catch { } }; diff --git a/src/js/scriptlets/updater.js b/src/js/scriptlets/updater.js index 006b663a0..908121c3a 100644 --- a/src/js/scriptlets/updater.js +++ b/src/js/scriptlets/updater.js @@ -19,10 +19,6 @@ Home: https://github.com/gorhill/uBlock */ -/* global HTMLDocument */ - -'use strict'; - /******************************************************************************/ // Injected into specific webpages, those which have been pre-selected @@ -75,7 +71,7 @@ function updateStockLists(target) { auto, }); return true; - } catch (_) { + } catch { } } diff --git a/src/js/settings.js b/src/js/settings.js index fc0ea684b..521dad44b 100644 --- a/src/js/settings.js +++ b/src/js/settings.js @@ -19,11 +19,9 @@ Home: https://github.com/gorhill/uBlock */ -'use strict'; - -import { i18n$ } from './i18n.js'; import { dom, qs$, qsa$ } from './dom.js'; import { setAccentColor, setTheme } from './theme.js'; +import { i18n$ } from './i18n.js'; /******************************************************************************/ @@ -69,7 +67,7 @@ function handleImportFilePicker() { throw 'Invalid'; } } - catch (e) { + catch { userData = undefined; } if ( userData === undefined ) { diff --git a/src/js/start.js b/src/js/start.js index 18e7dbdb4..df7ce0528 100644 --- a/src/js/start.js +++ b/src/js/start.js @@ -19,12 +19,6 @@ Home: https://github.com/gorhill/uBlock */ -/* globals browser */ - -'use strict'; - -/******************************************************************************/ - import './vapi-common.js'; import './vapi-background.js'; import './vapi-background-ext.js'; @@ -39,27 +33,27 @@ import './tab.js'; import './ublock.js'; import './utils.js'; -import io from './assets.js'; -import µb from './background.js'; -import { filteringBehaviorChanged } from './broadcast.js'; -import cacheStorage from './cachestorage.js'; -import { ubolog } from './console.js'; -import contextMenu from './contextmenu.js'; -import { redirectEngine } from './redirect-engine.js'; -import staticFilteringReverseLookup from './reverselookup.js'; -import staticExtFilteringEngine from './static-ext-filtering.js'; -import staticNetFilteringEngine from './static-net-filtering.js'; -import webRequest from './traffic.js'; - import { permanentFirewall, - sessionFirewall, permanentSwitches, - sessionSwitches, permanentURLFiltering, + sessionFirewall, + sessionSwitches, sessionURLFiltering, } from './filtering-engines.js'; +import cacheStorage from './cachestorage.js'; +import contextMenu from './contextmenu.js'; +import { filteringBehaviorChanged } from './broadcast.js'; +import io from './assets.js'; +import { redirectEngine } from './redirect-engine.js'; +import staticExtFilteringEngine from './static-ext-filtering.js'; +import staticFilteringReverseLookup from './reverselookup.js'; +import staticNetFilteringEngine from './static-net-filtering.js'; +import { ubolog } from './console.js'; +import webRequest from './traffic.js'; +import µb from './background.js'; + /******************************************************************************/ let lastVersionInt = 0; diff --git a/src/js/static-ext-filtering-db.js b/src/js/static-ext-filtering-db.js index e669c1e11..2d25c83bd 100644 --- a/src/js/static-ext-filtering-db.js +++ b/src/js/static-ext-filtering-db.js @@ -19,8 +19,6 @@ Home: https://github.com/gorhill/uBlock */ -'use strict'; - /******************************************************************************/ const StaticExtFilteringHostnameDB = class { diff --git a/src/js/static-ext-filtering.js b/src/js/static-ext-filtering.js index e616e6350..8a3309322 100644 --- a/src/js/static-ext-filtering.js +++ b/src/js/static-ext-filtering.js @@ -19,15 +19,11 @@ Home: https://github.com/gorhill/uBlock */ -'use strict'; - -/******************************************************************************/ - import cosmeticFilteringEngine from './cosmetic-filtering.js'; import htmlFilteringEngine from './html-filtering.js'; import httpheaderFilteringEngine from './httpheader-filtering.js'; -import scriptletFilteringEngine from './scriptlet-filtering.js'; import logger from './logger.js'; +import scriptletFilteringEngine from './scriptlet-filtering.js'; /******************************************************************************* diff --git a/src/js/static-filtering-io.js b/src/js/static-filtering-io.js index 3f016ab0e..db8478f62 100644 --- a/src/js/static-filtering-io.js +++ b/src/js/static-filtering-io.js @@ -19,8 +19,6 @@ Home: https://github.com/gorhill/uBlock */ -'use strict'; - /******************************************************************************/ // https://www.reddit.com/r/uBlockOrigin/comments/oq6kt5/ubo_loads_generic_filter_instead_of_specific/ diff --git a/src/js/static-filtering-parser.js b/src/js/static-filtering-parser.js index d3b4ca484..73507cc6b 100644 --- a/src/js/static-filtering-parser.js +++ b/src/js/static-filtering-parser.js @@ -19,8 +19,6 @@ Home: https://github.com/gorhill/uBlock */ -/******************************************************************************/ - import * as cssTree from '../lib/csstree/css-tree.js'; import { ArglistParser } from './arglist-parser.js'; import Regex from '../lib/regexanalyzer/regex.js'; @@ -1315,7 +1313,7 @@ export class AstFilterParser { const value = this.getNetOptionValue(NODE_TYPE_NET_OPTION_NAME_IPADDRESS); if ( /^\/.+\/$/.test(value) ) { try { void new RegExp(value); } - catch(_) { realBad = true; } + catch { realBad = true; } } break; } @@ -1849,7 +1847,7 @@ export class AstFilterParser { normal = normal.replace(this.reUnicodeChars, s => encodeURIComponent(s).toLowerCase() ); - } catch (ex) { + } catch { return; } return normal; @@ -2827,7 +2825,7 @@ export class AstFilterParser { try { this.punycoder.hostname = hn; hn = this.punycoder.hostname; - } catch (_) { + } catch { return ''; } if ( hn === '_' || hn === '' ) { return ''; } @@ -2951,7 +2949,7 @@ export function parseQueryPruneValue(arg) { try { out.re = new RegExp(match[1], match[2] || ''); } - catch(ex) { + catch { out.bad = true; } return out; @@ -2960,7 +2958,7 @@ export function parseQueryPruneValue(arg) { if ( s.startsWith('|') ) { try { out.re = new RegExp('^' + s.slice(1), 'i'); - } catch(ex) { + } catch { out.bad = true; } return out; @@ -2990,7 +2988,7 @@ export function parseHeaderValue(arg) { try { out.re = new RegExp(match[1], match[2] || ''); } - catch(ex) { + catch { out.bad = true; } } @@ -3022,7 +3020,7 @@ export function parseReplaceValue(s) { const flags = s.slice(parser.separatorEnd); try { return { re: new RegExp(pattern, flags), replacement }; - } catch(_) { + } catch { } } @@ -4056,7 +4054,7 @@ class ExtSelectorCompiler { try { const expr = doc.createExpression(r.s, null); expr.evaluate(doc, XPathResult.ANY_UNORDERED_NODE_TYPE); - } catch (e) { + } catch { return; } return r.s; @@ -4212,7 +4210,7 @@ export const utils = (( ) => { regexAnalyzer(reStr, false).tree() ); } - } catch(ex) { + } catch { return false; } return true; @@ -4223,7 +4221,7 @@ export const utils = (( ) => { let tree; try { tree = regexAnalyzer(reStr, false).tree(); - } catch(ex) { + } catch { return; } const isRE2 = node => { @@ -4254,7 +4252,7 @@ export const utils = (( ) => { s = this.tokenizableStrFromNode( regexAnalyzer(reStr, false).tree() ); - } catch(ex) { + } catch { } // Process optional sequences const reOptional = /[\x02\x03]+/; @@ -4316,7 +4314,7 @@ export const utils = (( ) => { const toURL = url => { try { return new URL(url.trim()); - } catch (ex) { + } catch { } }; diff --git a/src/js/static-net-filtering.js b/src/js/static-net-filtering.js index 58b657070..34909d92c 100644 --- a/src/js/static-net-filtering.js +++ b/src/js/static-net-filtering.js @@ -3453,7 +3453,7 @@ class FilterCompiler { try { const re = new RegExp(s); return re.source; - } catch (ex) { + } catch { } return ''; } @@ -5503,7 +5503,7 @@ StaticNetFilteringEngine.prototype.filterQuery = function(fctxt, out = []) { for ( const [ key, raw ] of params ) { let value = raw; try { value = decodeURIComponent(value); } - catch(ex) { } + catch { } if ( re.test(`${key}=${value}`) === not ) { continue; } if ( isException === false ) { params.delete(key); } filtered = true; diff --git a/src/js/storage.js b/src/js/storage.js index c3b541bd3..8d1696515 100644 --- a/src/js/storage.js +++ b/src/js/storage.js @@ -435,7 +435,7 @@ onBroadcast(msg => { try { const url = new URL(prefix); if ( url.hostname.length > 0 ) { return url.href; } - } catch(_) { + } catch { } }).filter(prefix => prefix !== undefined); } diff --git a/src/js/support.js b/src/js/support.js index 9bfd7cbe3..c6b45d4f1 100644 --- a/src/js/support.js +++ b/src/js/support.js @@ -21,10 +21,8 @@ /* global CodeMirror, uBlockDashboard */ -'use strict'; - -import { onBroadcast } from './broadcast.js'; import { dom, qs$ } from './dom.js'; +import { onBroadcast } from './broadcast.js'; /******************************************************************************/ @@ -220,7 +218,7 @@ const reportedPage = (( ) => { hostname: parsedURL.hostname.replace(/^(m|mobile|www)\./, ''), popupPanel: JSON.parse(url.searchParams.get('popupPanel')), }; - } catch(ex) { + } catch { } return null; })(); diff --git a/src/js/tab.js b/src/js/tab.js index c505e5abc..eeba9a528 100644 --- a/src/js/tab.js +++ b/src/js/tab.js @@ -19,18 +19,11 @@ Home: https://github.com/gorhill/uBlock */ -'use strict'; - -/******************************************************************************/ - -import contextMenu from './contextmenu.js'; -import logger from './logger.js'; -import scriptletFilteringEngine from './scriptlet-filtering.js'; -import staticNetFilteringEngine from './static-net-filtering.js'; -import µb from './background.js'; -import webext from './webext.js'; -import { PageStore } from './pagestore.js'; -import { i18n$ } from './i18n.js'; +import { + domainFromHostname, + hostnameFromURI, + originFromURI, +} from './uri-utils.js'; import { sessionFirewall, @@ -38,11 +31,14 @@ import { sessionURLFiltering, } from './filtering-engines.js'; -import { - domainFromHostname, - hostnameFromURI, - originFromURI, -} from './uri-utils.js'; +import { PageStore } from './pagestore.js'; +import contextMenu from './contextmenu.js'; +import { i18n$ } from './i18n.js'; +import logger from './logger.js'; +import scriptletFilteringEngine from './scriptlet-filtering.js'; +import staticNetFilteringEngine from './static-net-filtering.js'; +import webext from './webext.js'; +import µb from './background.js'; /******************************************************************************/ /******************************************************************************/ @@ -65,7 +61,7 @@ import { } try { tabURLNormalizer.href = tabURL; - } catch(ex) { + } catch { return tabURL; } const protocol = tabURLNormalizer.protocol.slice(0, -1); @@ -574,8 +570,7 @@ housekeep itself. frameId: sourceFrameId, }), ]); - } - catch (reason) { + } catch { return; } if ( diff --git a/src/js/tasks.js b/src/js/tasks.js index 8358fd883..ece860621 100644 --- a/src/js/tasks.js +++ b/src/js/tasks.js @@ -19,12 +19,6 @@ Home: https://github.com/gorhill/uBlock */ -/* globals requestIdleCallback, cancelIdleCallback */ - -'use strict'; - -/******************************************************************************/ - export function queueTask(func, timeout = 5000) { if ( typeof requestIdleCallback === 'undefined' ) { return setTimeout(func, 1); diff --git a/src/js/text-encode.js b/src/js/text-encode.js index 06c7b2c9a..8e5ad81ae 100644 --- a/src/js/text-encode.js +++ b/src/js/text-encode.js @@ -19,10 +19,6 @@ Home: https://github.com/gorhill/uBlock */ -'use strict'; - -/******************************************************************************/ - import µb from './background.js'; /******************************************************************************/ @@ -67,64 +63,64 @@ const textEncode = (( ) => { // http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1250.TXT const cp1250_range0 = new Uint8Array([ - /* 0x0100 */ 0x00, 0x00, 0xC3, 0xE3, 0xA5, 0xB9, 0xC6, 0xE6, - /* 0x0108 */ 0x00, 0x00, 0x00, 0x00, 0xC8, 0xE8, 0xCF, 0xEF, - /* 0x0110 */ 0xD0, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* 0x0118 */ 0xCA, 0xEA, 0xCC, 0xEC, 0x00, 0x00, 0x00, 0x00, - /* 0x0120 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* 0x0128 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* 0x0130 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* 0x0138 */ 0x00, 0xC5, 0xE5, 0x00, 0x00, 0xBC, 0xBE, 0x00, - /* 0x0140 */ 0x00, 0xA3, 0xB3, 0xD1, 0xF1, 0x00, 0x00, 0xD2, - /* 0x0148 */ 0xF2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* 0x0150 */ 0xD5, 0xF5, 0x00, 0x00, 0xC0, 0xE0, 0x00, 0x00, - /* 0x0158 */ 0xD8, 0xF8, 0x8C, 0x9C, 0x00, 0x00, 0xAA, 0xBA, - /* 0x0160 */ 0x8A, 0x9A, 0xDE, 0xFE, 0x8D, 0x9D, 0x00, 0x00, - /* 0x0168 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xD9, 0xF9, - /* 0x0170 */ 0xDB, 0xFB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* 0x0178 */ 0x00, 0x8F, 0x9F, 0xAF, 0xBF, 0x8E, 0x9E, 0x00 + /* 0x0100 */ 0x00, 0x00, 0xC3, 0xE3, 0xA5, 0xB9, 0xC6, 0xE6, + /* 0x0108 */ 0x00, 0x00, 0x00, 0x00, 0xC8, 0xE8, 0xCF, 0xEF, + /* 0x0110 */ 0xD0, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* 0x0118 */ 0xCA, 0xEA, 0xCC, 0xEC, 0x00, 0x00, 0x00, 0x00, + /* 0x0120 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* 0x0128 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* 0x0130 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* 0x0138 */ 0x00, 0xC5, 0xE5, 0x00, 0x00, 0xBC, 0xBE, 0x00, + /* 0x0140 */ 0x00, 0xA3, 0xB3, 0xD1, 0xF1, 0x00, 0x00, 0xD2, + /* 0x0148 */ 0xF2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* 0x0150 */ 0xD5, 0xF5, 0x00, 0x00, 0xC0, 0xE0, 0x00, 0x00, + /* 0x0158 */ 0xD8, 0xF8, 0x8C, 0x9C, 0x00, 0x00, 0xAA, 0xBA, + /* 0x0160 */ 0x8A, 0x9A, 0xDE, 0xFE, 0x8D, 0x9D, 0x00, 0x00, + /* 0x0168 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xD9, 0xF9, + /* 0x0170 */ 0xDB, 0xFB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* 0x0178 */ 0x00, 0x8F, 0x9F, 0xAF, 0xBF, 0x8E, 0x9E, 0x00 ]); // http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1251.TXT const cp1251_range0 = new Uint8Array([ - /* 0x0400 */ 0x00, 0xA8, 0x80, 0x81, 0xAA, 0xBD, 0xB2, 0xAF, - /* 0x0408 */ 0xA3, 0x8A, 0x8C, 0x8E, 0x8D, 0x00, 0xA1, 0x8F, - /* 0x0410 */ 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, - /* 0x0418 */ 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, - /* 0x0420 */ 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, - /* 0x0428 */ 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, - /* 0x0430 */ 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, - /* 0x0438 */ 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, - /* 0x0440 */ 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, - /* 0x0448 */ 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF, - /* 0x0450 */ 0x00, 0xB8, 0x90, 0x83, 0xBA, 0xBE, 0xB3, 0xBF, - /* 0x0458 */ 0xBC, 0x9A, 0x9C, 0x9E, 0x9D, 0x00, 0xA2, 0x9F, - /* 0x0460 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* 0x0468 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* 0x0470 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* 0x0478 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* 0x0480 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* 0x0488 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* 0x0490 */ 0xA5, 0xB4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + /* 0x0400 */ 0x00, 0xA8, 0x80, 0x81, 0xAA, 0xBD, 0xB2, 0xAF, + /* 0x0408 */ 0xA3, 0x8A, 0x8C, 0x8E, 0x8D, 0x00, 0xA1, 0x8F, + /* 0x0410 */ 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, + /* 0x0418 */ 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, + /* 0x0420 */ 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, + /* 0x0428 */ 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, + /* 0x0430 */ 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, + /* 0x0438 */ 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, + /* 0x0440 */ 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, + /* 0x0448 */ 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF, + /* 0x0450 */ 0x00, 0xB8, 0x90, 0x83, 0xBA, 0xBE, 0xB3, 0xBF, + /* 0x0458 */ 0xBC, 0x9A, 0x9C, 0x9E, 0x9D, 0x00, 0xA2, 0x9F, + /* 0x0460 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* 0x0468 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* 0x0470 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* 0x0478 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* 0x0480 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* 0x0488 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* 0x0490 */ 0xA5, 0xB4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ]); // https://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1252.TXT const cp1252_range0 = new Uint8Array([ - /* 0x0150 */ 0x00, 0x00, 0x8C, 0x9C, 0x00, 0x00, 0x00, 0x00, - /* 0x0158 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* 0x0160 */ 0x8A, 0x9A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* 0x0168 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* 0x0170 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* 0x0178 */ 0x9F, 0x00, 0x00, 0x00, 0x00, 0x8E, 0x9E, 0x00 + /* 0x0150 */ 0x00, 0x00, 0x8C, 0x9C, 0x00, 0x00, 0x00, 0x00, + /* 0x0158 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* 0x0160 */ 0x8A, 0x9A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* 0x0168 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* 0x0170 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* 0x0178 */ 0x9F, 0x00, 0x00, 0x00, 0x00, 0x8E, 0x9E, 0x00 ]); const cp125x_range0 = new Uint8Array([ - /* 0x2010 */ 0x00, 0x00, 0x00, 0x96, 0x97, 0x00, 0x00, 0x00, - /* 0x2018 */ 0x91, 0x92, 0x82, 0x00, 0x93, 0x94, 0x84, 0x00, - /* 0x2020 */ 0x86, 0x87, 0x95, 0x00, 0x00, 0x00, 0x85, 0x00, - /* 0x2028 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* 0x2030 */ 0x89, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* 0x2038 */ 0x00, 0x8B, 0x9B, 0x00, 0x00, 0x00, 0x00, 0x00 + /* 0x2010 */ 0x00, 0x00, 0x00, 0x96, 0x97, 0x00, 0x00, 0x00, + /* 0x2018 */ 0x91, 0x92, 0x82, 0x00, 0x93, 0x94, 0x84, 0x00, + /* 0x2020 */ 0x86, 0x87, 0x95, 0x00, 0x00, 0x00, 0x85, 0x00, + /* 0x2028 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* 0x2030 */ 0x89, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* 0x2038 */ 0x00, 0x8B, 0x9B, 0x00, 0x00, 0x00, 0x00, 0x00 ]); const encoders = { diff --git a/src/js/text-utils.js b/src/js/text-utils.js index 198a433dd..8b2bb5265 100644 --- a/src/js/text-utils.js +++ b/src/js/text-utils.js @@ -19,8 +19,6 @@ Home: https://github.com/gorhill/uBlock */ -'use strict'; - /******************************************************************************/ // https://bugs.chromium.org/p/v8/issues/detail?id=2869 diff --git a/src/js/theme.js b/src/js/theme.js index d3f9b0009..111272f10 100644 --- a/src/js/theme.js +++ b/src/js/theme.js @@ -19,8 +19,6 @@ Home: https://github.com/gorhill/uBlock */ -'use strict'; - function getActualTheme(nominalTheme) { let theme = nominalTheme || 'light'; if ( nominalTheme === 'auto' ) { @@ -51,7 +49,7 @@ function setTheme(theme, propagate = false) { if ( propagate === false ) { break; } if ( w === w.parent ) { break; } w = w.parent; - try { void w.document; } catch(ex) { return; } + try { void w.document; } catch { return; } } } @@ -110,7 +108,7 @@ function setAccentColor( if ( propagate === false ) { break; } if ( w === w.parent ) { break; } w = w.parent; - try { void w.document; } catch(ex) { break; } + try { void w.document; } catch { break; } } } diff --git a/src/js/ublock.js b/src/js/ublock.js index cfc63497a..0ac05d08d 100644 --- a/src/js/ublock.js +++ b/src/js/ublock.js @@ -19,27 +19,28 @@ Home: https://github.com/gorhill/uBlock */ -'use strict'; - -/******************************************************************************/ - -import io from './assets.js'; -import µb from './background.js'; -import { broadcast, filteringBehaviorChanged, onBroadcast } from './broadcast.js'; -import contextMenu from './contextmenu.js'; -import cosmeticFilteringEngine from './cosmetic-filtering.js'; -import { redirectEngine } from './redirect-engine.js'; -import { hostnameFromURI } from './uri-utils.js'; +import { + broadcast, + filteringBehaviorChanged, + onBroadcast, +} from './broadcast.js'; import { permanentFirewall, - sessionFirewall, permanentSwitches, - sessionSwitches, permanentURLFiltering, + sessionFirewall, + sessionSwitches, sessionURLFiltering, } from './filtering-engines.js'; +import contextMenu from './contextmenu.js'; +import cosmeticFilteringEngine from './cosmetic-filtering.js'; +import { hostnameFromURI } from './uri-utils.js'; +import io from './assets.js'; +import { redirectEngine } from './redirect-engine.js'; +import µb from './background.js'; + /******************************************************************************/ /******************************************************************************/ @@ -47,7 +48,7 @@ import { // Be more flexible with whitelist syntax // Any special regexp char will be escaped -const whitelistDirectiveEscape = /[-\/\\^$+?.()|[\]{}]/g; +const whitelistDirectiveEscape = /[-/\\^$+?.()|[\]{}]/g; // All `*` will be expanded into `.*` const whitelistDirectiveEscapeAsterisk = /\*/g; @@ -254,7 +255,7 @@ const matchBucket = function(url, hostname, bucket, start) { try { const re = new RegExp(directive.slice(1, -1)); directiveToRegexpMap.set(directive, re); - } catch(ex) { + } catch { key = '#'; directive = '# ' + line; } @@ -294,8 +295,8 @@ const matchBucket = function(url, hostname, bucket, start) { }; // https://github.com/gorhill/uBlock/issues/3717 -µb.reWhitelistBadHostname = /[^a-z0-9.\-_\[\]:]/; -µb.reWhitelistHostnameExtractor = /([a-z0-9.\-_\[\]]+)(?::[\d*]+)?\/(?:[^\x00-\x20\/]|$)[^\x00-\x20]*$/; +µb.reWhitelistBadHostname = /[^a-z0-9.\-_[\]:]/; +µb.reWhitelistHostnameExtractor = /([a-z0-9.\-_[\]]+)(?::[\d*]+)?\/(?:[^\x00-\x20/]|$)[^\x00-\x20]*$/; /******************************************************************************/ @@ -369,7 +370,7 @@ const matchBucket = function(url, hostname, bucket, start) { case 'noLargeMedia': case 'noRemoteFonts': case 'noScripting': - case 'noCSPReports': + case 'noCSPReports': { let switchName; switch ( name ) { case 'noCosmeticFiltering': @@ -392,6 +393,7 @@ const matchBucket = function(url, hostname, bucket, start) { this.saveHostnameSwitches(); } break; + } case 'prefetchingDisabled': if ( this.privacySettingsSupported ) { vAPI.browserSettings.set({ 'prefetching': !value }); @@ -588,39 +590,40 @@ const matchBucket = function(url, hostname, bucket, start) { // Take per-switch action if needed switch ( details.name ) { - case 'no-scripting': - this.updateToolbarIcon(details.tabId, 0b100); - break; - case 'no-cosmetic-filtering': { - const scriptlet = newState ? 'cosmetic-off' : 'cosmetic-on'; - vAPI.tabs.executeScript(details.tabId, { - file: `/js/scriptlets/${scriptlet}.js`, - allFrames: true, - }); - break; + case 'no-scripting': + this.updateToolbarIcon(details.tabId, 0b100); + break; + case 'no-cosmetic-filtering': { + const scriptlet = newState ? 'cosmetic-off' : 'cosmetic-on'; + vAPI.tabs.executeScript(details.tabId, { + file: `/js/scriptlets/${scriptlet}.js`, + allFrames: true, + }); + break; + } + case 'no-large-media': { + const pageStore = this.pageStoreFromTabId(details.tabId); + if ( pageStore !== null ) { + pageStore.temporarilyAllowLargeMediaElements(!newState); } - case 'no-large-media': - const pageStore = this.pageStoreFromTabId(details.tabId); - if ( pageStore !== null ) { - pageStore.temporarilyAllowLargeMediaElements(!newState); - } - break; - default: - break; + break; + } + default: + break; } // Flush caches if needed if ( newState ) { switch ( details.name ) { - case 'no-scripting': - case 'no-remote-fonts': - filteringBehaviorChanged({ - direction: details.state ? 1 : 0, - hostname: details.hostname, - }); - break; - default: - break; + case 'no-scripting': + case 'no-remote-fonts': + filteringBehaviorChanged({ + direction: details.state ? 1 : 0, + hostname: details.hostname, + }); + break; + default: + break; } } @@ -691,7 +694,7 @@ const matchBucket = function(url, hostname, bucket, start) { try { const url = new URL(pageURL); return JSON.parse(url.searchParams.get('details')).url; - } catch(ex) { + } catch { } } return pageURL; diff --git a/src/js/uri-utils.js b/src/js/uri-utils.js index 273b1511f..aa9dca934 100644 --- a/src/js/uri-utils.js +++ b/src/js/uri-utils.js @@ -19,10 +19,6 @@ Home: https://github.com/gorhill/uBlock */ -'use strict'; - -/******************************************************************************/ - import publicSuffixList from '../lib/publicsuffixlist/publicsuffixlist.js'; import punycode from '../lib/punycode.js'; @@ -34,7 +30,7 @@ import punycode from '../lib/punycode.js'; const reHostnameFromCommonURL = /^https:\/\/[0-9a-z._-]+[0-9a-z]\//; const reAuthorityFromURI = - /^(?:[^:\/?#]+:)?(\/\/[^\/?#]+)/; + /^(?:[^:/?#]+:)?(\/\/[^/?#]+)/; const reHostFromNakedAuthority = /^[0-9a-z._-]+[0-9a-z]$/i; const reHostFromAuthority = @@ -44,7 +40,7 @@ const reIPv6FromAuthority = const reMustNormalizeHostname = /[^0-9a-z._-]/; const reOriginFromURI = - /^[^:\/?#]+:\/\/[^\/?#]+/; + /^[^:/?#]+:\/\/[^/?#]+/; const reHostnameFromNetworkURL = /^(?:http|ws|ftp)s?:\/\/([0-9a-z_][0-9a-z._-]*[0-9a-z])(?::\d+)?\//; const reIPAddressNaive = @@ -54,7 +50,7 @@ const reNetworkURI = // For performance purpose, as simple tests as possible const reIPv4VeryCoarse = /\.\d+$/; -const reHostnameVeryCoarse = /[g-z_\-]/; +const reHostnameVeryCoarse = /[g-z_-]/; /******************************************************************************/ diff --git a/src/js/url-net-filtering.js b/src/js/url-net-filtering.js index 39befc7dc..43831cf52 100644 --- a/src/js/url-net-filtering.js +++ b/src/js/url-net-filtering.js @@ -19,10 +19,6 @@ Home: https://github.com/gorhill/uBlock */ -'use strict'; - -/******************************************************************************/ - import { LineIterator } from './text-utils.js'; import { decomposeHostname } from './uri-utils.js'; diff --git a/src/js/urlskip.js b/src/js/urlskip.js index b0d396623..85c396e67 100644 --- a/src/js/urlskip.js +++ b/src/js/urlskip.js @@ -161,6 +161,6 @@ export function urlSkip(url, blocked, steps, directive = {}) { } if ( blocked && redirectBlocked !== true ) { return; } return urlout; - } catch(x) { + } catch { } } diff --git a/src/js/utils.js b/src/js/utils.js index e48e963e1..8b12244fd 100644 --- a/src/js/utils.js +++ b/src/js/utils.js @@ -19,10 +19,6 @@ Home: https://github.com/gorhill/uBlock */ -'use strict'; - -/******************************************************************************/ - import µb from './background.js'; /******************************************************************************/ @@ -72,7 +68,7 @@ import µb from './background.js'; popupLoggerBox = JSON.parse( vAPI.localStorage.getItem('popupLoggerBox') ); - } catch(ex) { + } catch { } if ( popupLoggerBox !== undefined ) { details.box = popupLoggerBox; diff --git a/src/js/whitelist.js b/src/js/whitelist.js index b8f0eaaa5..6d9e951c1 100644 --- a/src/js/whitelist.js +++ b/src/js/whitelist.js @@ -21,10 +21,8 @@ /* global CodeMirror, uBlockDashboard */ -'use strict'; - -import { i18n$ } from './i18n.js'; import { dom, qs$ } from './dom.js'; +import { i18n$ } from './i18n.js'; /******************************************************************************/ @@ -62,7 +60,7 @@ CodeMirror.defineMode("ubo-whitelist-directives", function() { if ( reRegex.test(line) ) { try { new RegExp(line.slice(1, -1)); - } catch(ex) { + } catch { return 'error'; } return null;