tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit f58b6480b80aaafdc44e48c63ca840cbc63f0843
parent d13084d7ecb72fb2ed82483b2792818d361d5c66
Author: Mark Banner <standard8@mozilla.com>
Date:   Fri, 28 Nov 2025 09:08:58 +0000

Bug 2002659 - Switch to use @eslint/json rather than eslint-plugin-json for linting JSON files. r=frontend-codestyle-reviewers,Gijs

Differential Revision: https://phabricator.services.mozilla.com/D274212

Diffstat:
M.prettierignore | 2+-
Meslint-ignores.config.mjs | 11++++++-----
Meslint.config.mjs | 18++++++++++++++++--
Mpackage-lock.json | 91++++++++++++++++++++++++-------------------------------------------------------
Mpackage.json | 2+-
Mtools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.mjs | 6------
Mtools/lint/eslint/eslint-plugin-mozilla/lib/helpers.mjs | 6+++++-
Mtools/rewriting/Generated.txt | 2+-
8 files changed, 57 insertions(+), 81 deletions(-)

diff --git a/.prettierignore b/.prettierignore @@ -1791,8 +1791,8 @@ toolkit/components/uniffi-bindgen-gecko-js/fixtures/generated tools/@types/generated/ tools/@types/subs/ tools/browsertime/package.json -tools/browsertime/package-lock.json tools/ts/error_list.json tools/ts/test/baselines/ try_task_config.json xpcom/idl-parser/xpidl/fixtures/xpctest.d.json +**/package-lock.json diff --git a/eslint-ignores.config.mjs b/eslint-ignores.config.mjs @@ -248,11 +248,11 @@ export default [ "servo/", // Rust/Cargo output from running `cargo` directly - "/target/", - "/servo/ports/geckolib/target/", - "/dom/base/rust/target/", - "/servo/components/style/target/", - "/dom/webgpu/tests/cts/vendor/target/", + "target/", + "servo/ports/geckolib/target/", + "dom/base/rust/target/", + "servo/components/style/target/", + "dom/webgpu/tests/cts/vendor/target/", // Test files that we don't want to lint (preprocessed, minified etc) "testing/condprofile/condprof/tests/profile", @@ -275,6 +275,7 @@ export default [ // Intentionally invalid files "toolkit/components/workerloader/tests/moduleF-syntax-error.js", "toolkit/components/enterprisepolicies/tests/browser/config_broken_json.json", + "toolkit/components/normandy/test/unit/mock_api/api/v1/extension/index.json", "toolkit/mozapps/extensions/test/xpcshell/data/test_AddonRepository_fail.json", // Built files diff --git a/eslint.config.mjs b/eslint.config.mjs @@ -6,7 +6,7 @@ import sdl from "@microsoft/eslint-plugin-sdl"; import eslintConfigPrettier from "eslint-config-prettier/flat"; import html from "eslint-plugin-html"; import importPlugin from "eslint-plugin-import"; -import json from "eslint-plugin-json"; +import json from "@eslint/json"; import lit from "eslint-plugin-lit"; import mozilla from "eslint-plugin-mozilla"; import reactHooks from "eslint-plugin-react-hooks"; @@ -147,7 +147,21 @@ let config = [ { name: "json-recommended-with-comments", files: ["**/*.json"], - ...json.configs["recommended-with-comments"], + language: "json/jsonc", + ...json.configs.recommended, + }, + { + name: "json-recommended-no-comments", + files: ["**/package.json"], + language: "json/json", + ...json.configs.recommended, + }, + { + name: "json-empty-keys-off-for-image_builder", + files: ["taskcluster/docker/image_builder/policy.json"], + rules: { + "json/no-empty-keys": "off", + }, }, { name: "eslint-plugin-html", diff --git a/package-lock.json b/package-lock.json @@ -6,6 +6,7 @@ "": { "license": "MPL-2.0", "devDependencies": { + "@eslint/json": "0.14.0", "@microsoft/eslint-plugin-sdl": "1.1.0", "@stylistic/stylelint-plugin": "3.1.1", "@types/gecko": "file:tools/@types", @@ -16,7 +17,6 @@ "eslint-plugin-import": "2.32.0", "eslint-plugin-jest": "29.2.1", "eslint-plugin-jsdoc": "61.4.1", - "eslint-plugin-json": "4.0.1", "eslint-plugin-jsx-a11y": "6.10.2", "eslint-plugin-lit": "2.1.1", "eslint-plugin-mozilla": "file:tools/lint/eslint/eslint-plugin-mozilla", @@ -564,6 +564,22 @@ "url": "https://eslint.org/donate" } }, + "node_modules/@eslint/json": { + "version": "0.14.0", + "resolved": "https://registry.npmjs.org/@eslint/json/-/json-0.14.0.tgz", + "integrity": "sha512-rvR/EZtvUG3p9uqrSmcDJPYSH7atmWr0RnFWN6m917MAPx82+zQgPUmDu0whPFG6XTyM0vB/hR6c1Q63OaYtCQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@eslint/core": "^0.17.0", + "@eslint/plugin-kit": "^0.4.1", + "@humanwhocodes/momoa": "^3.3.10", + "natural-compare": "^1.4.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, "node_modules/@eslint/object-schema": { "version": "2.1.7", "resolved": "https://registry.npmjs.org/@eslint/object-schema/-/object-schema-2.1.7.tgz", @@ -626,6 +642,16 @@ "url": "https://github.com/sponsors/nzakas" } }, + "node_modules/@humanwhocodes/momoa": { + "version": "3.3.10", + "resolved": "https://registry.npmjs.org/@humanwhocodes/momoa/-/momoa-3.3.10.tgz", + "integrity": "sha512-KWiFQpSAqEIyrTXko3hFNLeQvSK8zXlJQzhhxsyVn58WFRYXST99b3Nqnu+ttOtjds2Pl2grUHGpe2NzhPynuQ==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18" + } + }, "node_modules/@humanwhocodes/retry": { "version": "0.4.3", "resolved": "https://registry.npmjs.org/@humanwhocodes/retry/-/retry-0.4.3.tgz", @@ -2824,20 +2850,6 @@ "node": ">=10" } }, - "node_modules/eslint-plugin-json": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-json/-/eslint-plugin-json-4.0.1.tgz", - "integrity": "sha512-3An5ISV5dq/kHfXdNyY5TUe2ONC3yXFSkLX2gu+W8xAhKhfvrRvkSAeKXCxZqZ0KJLX15ojBuLPyj+UikQMkOA==", - "dev": true, - "license": "MIT", - "dependencies": { - "lodash": "^4.17.21", - "vscode-json-languageservice": "^4.1.6" - }, - "engines": { - "node": ">=18.0" - } - }, "node_modules/eslint-plugin-jsx-a11y": { "version": "6.10.2", "resolved": "https://registry.npmjs.org/eslint-plugin-jsx-a11y/-/eslint-plugin-jsx-a11y-6.10.2.tgz", @@ -4600,13 +4612,6 @@ "node": ">=6" } }, - "node_modules/jsonc-parser": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.3.1.tgz", - "integrity": "sha512-HUgH65KyejrUFPvHFPbqOY0rsFip3Bo5wb4ngvdi1EpCYWUQDC5V+Y7mZws+DLkr4M//zQJoanu1SP+87Dv1oQ==", - "dev": true, - "license": "MIT" - }, "node_modules/jsx-ast-utils": { "version": "3.3.5", "resolved": "https://registry.npmjs.org/jsx-ast-utils/-/jsx-ast-utils-3.3.5.tgz", @@ -7730,48 +7735,6 @@ "spdx-license-ids": "^3.0.0" } }, - "node_modules/vscode-json-languageservice": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/vscode-json-languageservice/-/vscode-json-languageservice-4.2.1.tgz", - "integrity": "sha512-xGmv9QIWs2H8obGbWg+sIPI/3/pFgj/5OWBhNzs00BkYQ9UaB2F6JJaGB/2/YOZJ3BvLXQTC4Q7muqU25QgAhA==", - "dev": true, - "license": "MIT", - "dependencies": { - "jsonc-parser": "^3.0.0", - "vscode-languageserver-textdocument": "^1.0.3", - "vscode-languageserver-types": "^3.16.0", - "vscode-nls": "^5.0.0", - "vscode-uri": "^3.0.3" - } - }, - "node_modules/vscode-languageserver-textdocument": { - "version": "1.0.12", - "resolved": "https://registry.npmjs.org/vscode-languageserver-textdocument/-/vscode-languageserver-textdocument-1.0.12.tgz", - "integrity": "sha512-cxWNPesCnQCcMPeenjKKsOCKQZ/L6Tv19DTRIGuLWe32lyzWhihGVJ/rcckZXJxfdKCFvRLS3fpBIsV/ZGX4zA==", - "dev": true, - "license": "MIT" - }, - "node_modules/vscode-languageserver-types": { - "version": "3.17.5", - "resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.17.5.tgz", - "integrity": "sha512-Ld1VelNuX9pdF39h2Hgaeb5hEZM2Z3jUrrMgWQAu82jMtZp7p3vJT3BzToKtZI7NgQssZje5o0zryOrhQvzQAg==", - "dev": true, - "license": "MIT" - }, - "node_modules/vscode-nls": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/vscode-nls/-/vscode-nls-5.2.0.tgz", - "integrity": "sha512-RAaHx7B14ZU04EU31pT+rKz2/zSl7xMsfIZuo8pd+KZO6PXtQmpevpq3vxvWNcrGbdmhM/rr5Uw5Mz+NBfhVng==", - "dev": true, - "license": "MIT" - }, - "node_modules/vscode-uri": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/vscode-uri/-/vscode-uri-3.1.0.tgz", - "integrity": "sha512-/BpdSx+yCQGnCvecbyXdxHDkuk55/G3xwnC0GqY4gmQ3j+A+g8kzzgB4Nk/SINjqn6+waqw3EgbVF2QKExkRxQ==", - "dev": true, - "license": "MIT" - }, "node_modules/which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", diff --git a/package.json b/package.json @@ -5,6 +5,7 @@ "repository": {}, "license": "MPL-2.0", "devDependencies": { + "@eslint/json": "0.14.0", "@microsoft/eslint-plugin-sdl": "1.1.0", "@stylistic/stylelint-plugin": "3.1.1", "@types/gecko": "file:tools/@types", @@ -15,7 +16,6 @@ "eslint-plugin-import": "2.32.0", "eslint-plugin-jest": "29.2.1", "eslint-plugin-jsdoc": "61.4.1", - "eslint-plugin-json": "4.0.1", "eslint-plugin-jsx-a11y": "6.10.2", "eslint-plugin-lit": "2.1.1", "eslint-plugin-mozilla": "file:tools/lint/eslint/eslint-plugin-mozilla", diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.mjs b/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.mjs @@ -369,10 +369,4 @@ export default [ }, name: "mozilla/recommended/serviceworker", }, - { - // This rule isn't needed for JSON files, so turn it off. - files: ["**/*.json"], - name: "mozilla/recommended/import-globals-off-for-json", - rules: { "mozilla/import-globals": "off" }, - }, ]; diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/helpers.mjs b/tools/lint/eslint/eslint-plugin-mozilla/lib/helpers.mjs @@ -27,8 +27,12 @@ export default { * * TypeScript (ts) is not listed here, as we currently only format that with * Prettier. + * + * JSON is not listed here, as we don't want to apply most rules to the JSON + * files, but only the json ones. These are managed in the main configuration + * for firefox-main. */ - allFileExtensions: ["mjs", "js", "json", "jsx", "html", "sjs", "xhtml"], + allFileExtensions: ["mjs", "js", "jsx", "html", "sjs", "xhtml"], /** * Can be used to change a group of rules or globals, so that all the items diff --git a/tools/rewriting/Generated.txt b/tools/rewriting/Generated.txt @@ -222,8 +222,8 @@ toolkit/components/uniffi-bindgen-gecko-js/tests/generated tools/@types/generated/ tools/@types/subs/ tools/browsertime/package.json -tools/browsertime/package-lock.json tools/ts/error_list.json tools/ts/test/baselines/ try_task_config.json xpcom/idl-parser/xpidl/fixtures/xpctest.d.json +**/package-lock.json