summaryrefslogtreecommitdiffstats
path: root/tools/lint/eslint/eslint-plugin-mozilla/lib/configs
diff options
context:
space:
mode:
Diffstat (limited to 'tools/lint/eslint/eslint-plugin-mozilla/lib/configs')
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/configs/.eslintrc.js8
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/configs/browser-test.js95
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/configs/chrome-test.js65
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/configs/mochitest-test.js66
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js351
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/configs/require-jsdoc.js41
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/configs/valid-jsdoc.js34
-rw-r--r--tools/lint/eslint/eslint-plugin-mozilla/lib/configs/xpcshell-test.js54
8 files changed, 714 insertions, 0 deletions
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/.eslintrc.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/.eslintrc.js
new file mode 100644
index 0000000000..76df4134f5
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/.eslintrc.js
@@ -0,0 +1,8 @@
+"use strict";
+
+module.exports = {
+ rules: {
+ // Require object keys to be sorted.
+ "sort-keys": "error",
+ },
+};
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/browser-test.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/browser-test.js
new file mode 100644
index 0000000000..08747a3f88
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/browser-test.js
@@ -0,0 +1,95 @@
+// Parent config file for all browser-chrome files.
+"use strict";
+
+module.exports = {
+ env: {
+ browser: true,
+ "mozilla/browser-window": true,
+ "mozilla/simpletest": true,
+ // "node": true
+ },
+
+ // All globals made available in the test environment.
+ globals: {
+ // `$` is defined in SimpleTest.js
+ $: false,
+ Assert: false,
+ BrowserTestUtils: false,
+ ContentTask: false,
+ ContentTaskUtils: false,
+ EventUtils: false,
+ IOUtils: false,
+ PathUtils: false,
+ PromiseDebugging: false,
+ SpecialPowers: false,
+ TestUtils: false,
+ addLoadEvent: false,
+ add_setup: false,
+ add_task: false,
+ content: false,
+ executeSoon: false,
+ expectUncaughtException: false,
+ export_assertions: false,
+ extractJarToTmp: false,
+ finish: false,
+ gTestPath: false,
+ getChromeDir: false,
+ getJar: false,
+ getResolvedURI: false,
+ getRootDirectory: false,
+ getTestFilePath: false,
+ ignoreAllUncaughtExceptions: false,
+ info: false,
+ is: false,
+ isnot: false,
+ ok: false,
+ record: false,
+ registerCleanupFunction: false,
+ requestLongerTimeout: false,
+ setExpectedFailuresForSelfTest: false,
+ stringContains: false,
+ stringMatches: false,
+ todo: false,
+ todo_is: false,
+ todo_isnot: false,
+ waitForClipboard: false,
+ waitForExplicitFinish: false,
+ waitForFocus: false,
+ },
+
+ plugins: ["mozilla", "@microsoft/sdl"],
+
+ rules: {
+ // No using of insecure url, so no http urls
+ "@microsoft/sdl/no-insecure-url": [
+ "error",
+ {
+ exceptions: [
+ "^http:\\/\\/mochi\\.test?.*",
+ "^http:\\/\\/localhost?.*",
+ "^http:\\/\\/127\\.0\\.0\\.1?.*",
+ // Exempt xmlns urls
+ "^http:\\/\\/www\\.w3\\.org?.*",
+ "^http:\\/\\/www\\.mozilla\\.org\\/keymaster\\/gatekeeper?.*",
+ // Exempt urls that start with ftp or ws.
+ "^ws:?.*",
+ "^ftp:?.*",
+ ],
+ varExceptions: ["insecure?.*"],
+ },
+ ],
+ "mozilla/import-content-task-globals": "error",
+ "mozilla/import-headjs-globals": "error",
+ "mozilla/mark-test-function-used": "error",
+ "mozilla/no-addtask-setup": "error",
+ "mozilla/no-arbitrary-setTimeout": "error",
+ "mozilla/no-redeclare-with-import-autofix": [
+ "error",
+ { errorForNonImports: false },
+ ],
+ // Turn off no-unsanitized for tests, as we do want to be able to use
+ // these for testing.
+ "no-unsanitized/method": "off",
+ "no-unsanitized/property": "off",
+ },
+};
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/chrome-test.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/chrome-test.js
new file mode 100644
index 0000000000..3b5bbc06e2
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/chrome-test.js
@@ -0,0 +1,65 @@
+// Parent config file for all mochitest files.
+"use strict";
+
+module.exports = {
+ env: {
+ browser: true,
+ "mozilla/browser-window": true,
+ },
+
+ // All globals made available in the test environment.
+ globals: {
+ // SpecialPowers is injected into the window object via SimpleTest.js
+ SpecialPowers: false,
+ extractJarToTmp: false,
+ getChromeDir: false,
+ getJar: false,
+ getResolvedURI: false,
+ getRootDirectory: false,
+ },
+
+ overrides: [
+ {
+ env: {
+ // Ideally we wouldn't be using the simpletest env here, but our uses of
+ // js files mean we pick up everything from the global scope, which could
+ // be any one of a number of html files. So we just allow the basics...
+ "mozilla/simpletest": true,
+ },
+ files: ["*.js"],
+ },
+ ],
+
+ plugins: ["mozilla", "@microsoft/sdl"],
+
+ rules: {
+ // No using of insecure url, so no http urls
+ "@microsoft/sdl/no-insecure-url": [
+ "error",
+ {
+ exceptions: [
+ "^http:\\/\\/mochi\\.test?.*",
+ "^http:\\/\\/localhost?.*",
+ "^http:\\/\\/127\\.0\\.0\\.1?.*",
+ // Exempt xmlns urls
+ "^http:\\/\\/www\\.w3\\.org?.*",
+ "^http:\\/\\/www\\.mozilla\\.org\\/keymaster\\/gatekeeper?.*",
+ // Exempt urls that start with ftp or ws.
+ "^ws:?.*",
+ "^ftp:?.*",
+ ],
+ varExceptions: ["insecure?.*"],
+ },
+ ],
+ "mozilla/import-content-task-globals": "error",
+ "mozilla/import-headjs-globals": "error",
+ "mozilla/mark-test-function-used": "error",
+ // We mis-predict globals for HTML test files in directories shared
+ // with browser tests.
+ "mozilla/no-redeclare-with-import-autofix": "off",
+ // Turn off no-unsanitized for tests, as we do want to be able to use
+ // these for testing.
+ "no-unsanitized/method": "off",
+ "no-unsanitized/property": "off",
+ },
+};
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/mochitest-test.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/mochitest-test.js
new file mode 100644
index 0000000000..ceca2beec4
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/mochitest-test.js
@@ -0,0 +1,66 @@
+// Parent config file for all mochitest files.
+"use strict";
+
+module.exports = {
+ env: {
+ browser: true,
+ },
+
+ // All globals made available in the test environment.
+ globals: {
+ // SpecialPowers is injected into the window object via SimpleTest.js
+ SpecialPowers: false,
+ },
+
+ overrides: [
+ {
+ env: {
+ // Ideally we wouldn't be using the simpletest env here, but our uses of
+ // js files mean we pick up everything from the global scope, which could
+ // be any one of a number of html files. So we just allow the basics...
+ "mozilla/simpletest": true,
+ },
+ files: ["*.js"],
+ },
+ ],
+ plugins: ["mozilla", "@microsoft/sdl"],
+
+ rules: {
+ // No using of insecure url, so no http urls
+ "@microsoft/sdl/no-insecure-url": [
+ "error",
+ {
+ exceptions: [
+ "^http:\\/\\/mochi\\.test?.*",
+ "^http:\\/\\/mochi\\.xorigin-test?.*",
+ "^http:\\/\\/localhost?.*",
+ "^http:\\/\\/127\\.0\\.0\\.1?.*",
+ // Exempt xmlns urls
+ "^http:\\/\\/www\\.w3\\.org?.*",
+ "^http:\\/\\/www\\.mozilla\\.org\\/keymaster\\/gatekeeper?.*",
+ // Exempt urls that start with ftp or ws.
+ "^ws:?.*",
+ "^ftp:?.*",
+ ],
+ varExceptions: ["insecure?.*"],
+ },
+ ],
+ "mozilla/import-content-task-globals": "error",
+ "mozilla/import-headjs-globals": "error",
+ "mozilla/mark-test-function-used": "error",
+ // Turn off no-define-cc-etc for mochitests as these don't have Cc etc defined in the
+ // global scope.
+ "mozilla/no-define-cc-etc": "off",
+ // We mis-predict globals for HTML test files in directories shared
+ // with browser tests, so don't try to "fix" imports that are needed.
+ "mozilla/no-redeclare-with-import-autofix": "off",
+ // Turn off use-chromeutils-generateqi as these tests don't have ChromeUtils
+ // available.
+ "mozilla/use-chromeutils-generateqi": "off",
+ "no-shadow": "error",
+ // Turn off no-unsanitized for tests, as we do want to be able to use
+ // these for testing.
+ "no-unsanitized/method": "off",
+ "no-unsanitized/property": "off",
+ },
+};
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js
new file mode 100644
index 0000000000..db7a0dc731
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js
@@ -0,0 +1,351 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+/**
+ * The configuration is based on eslint:recommended config. The details for all
+ * the ESLint rules, and which ones are in the recommended configuration can
+ * be found here:
+ *
+ * https://eslint.org/docs/rules/
+ *
+ * Rules that we've explicitly decided not to enable:
+ *
+ * require-await - bug 1381030.
+ * no-prototype-builtins - bug 1551829.
+ * require-atomic-updates - bug 1551829.
+ * - This generates too many false positives that are not easy to work
+ * around, and false positives seem to be inherent in the rule.
+ */
+module.exports = {
+ env: {
+ browser: true,
+ es2022: true,
+ "mozilla/privileged": true,
+ "mozilla/specific": true,
+ },
+
+ // The prettier configuration here comes from eslint-config-prettier and
+ // turns off all of ESLint's rules related to formatting.
+ extends: [
+ "eslint:recommended",
+ "prettier",
+ "plugin:json/recommended-with-comments",
+ ],
+
+ overrides: [
+ {
+ // System mjs files and jsm files are not loaded in the browser scope,
+ // so we turn that off for those. Though we do have our own special
+ // environment for them.
+ env: {
+ browser: false,
+ "mozilla/jsm": true,
+ },
+ files: ["**/*.sys.mjs", "**/*.jsm"],
+ rules: {
+ "mozilla/lazy-getter-object-name": "error",
+ "mozilla/reject-eager-module-in-lazy-getter": "error",
+ "mozilla/reject-global-this": "error",
+ "mozilla/reject-globalThis-modification": "error",
+ // For all system modules, we expect no properties to need importing,
+ // hence reject everything.
+ "mozilla/reject-importGlobalProperties": ["error", "everything"],
+ "mozilla/reject-mixing-eager-and-lazy": "error",
+ "mozilla/reject-top-level-await": "error",
+ // TODO: Bug 1575506 turn `builtinGlobals` on here.
+ // We can enable builtinGlobals for jsms due to their scopes.
+ "no-redeclare": ["error", { builtinGlobals: false }],
+ },
+ },
+ {
+ files: ["**/*.mjs", "**/*.jsx", "**/*.jsm", "**/?(*.)worker.?(m)js"],
+ rules: {
+ // Modules and workers are far easier to check for no-unused-vars on a
+ // global scope, than our content files. Hence we turn that on here.
+ "no-unused-vars": [
+ "error",
+ {
+ args: "none",
+ vars: "all",
+ },
+ ],
+ },
+ },
+ {
+ excludedFiles: ["**/*.sys.mjs"],
+ files: ["**/*.mjs"],
+ rules: {
+ "mozilla/reject-import-system-module-from-non-system": "error",
+ "mozilla/reject-lazy-imports-into-globals": "error",
+ "no-shadow": ["error", { allow: ["event"], builtinGlobals: true }],
+ },
+ },
+ {
+ files: ["**/*.mjs", "**/*.jsx"],
+ parserOptions: {
+ sourceType: "module",
+ },
+ rules: {
+ "mozilla/use-static-import": "error",
+ // This rule defaults to not allowing "use strict" in module files since
+ // they are always loaded in strict mode.
+ strict: "error",
+ },
+ },
+ {
+ files: ["**/*.jsm"],
+ rules: {
+ "mozilla/mark-exported-symbols-as-used": "error",
+ },
+ },
+ {
+ env: {
+ browser: false,
+ "mozilla/privileged": false,
+ "mozilla/sjs": true,
+ "mozilla/specific": false,
+ },
+ files: ["**/*.sjs"],
+ rules: {
+ // For sjs files, reject everything as we should update the sandbox
+ // to include the globals we need, as these are test-only files.
+ "mozilla/reject-importGlobalProperties": ["error", "everything"],
+ },
+ },
+ {
+ env: {
+ browser: false,
+ worker: true,
+ },
+ files: [
+ // Most files should use the `.worker.` format to be consistent with
+ // other items like `.sys.mjs`, but we allow simply calling the file
+ // "worker" as well.
+ "**/?(*.)worker.?(m)js",
+ ],
+ },
+ ],
+
+ parserOptions: {
+ ecmaVersion: "latest",
+ },
+
+ // When adding items to this file please check for effects on sub-directories.
+ plugins: ["fetch-options", "html", "json", "no-unsanitized"],
+
+ // When adding items to this file please check for effects on all of toolkit
+ // and browser
+ rules: {
+ // This may conflict with prettier, so we turn it off.
+ "arrow-body-style": "off",
+
+ // Warn about cyclomatic complexity in functions.
+ // XXX Get this down to 20?
+ complexity: ["error", 34],
+
+ // Functions must always return something or nothing
+ "consistent-return": "error",
+
+ // XXX This rule line should be removed to enable it. See bug 1487642.
+ // Require super() calls in constructors
+ "constructor-super": "off",
+
+ // Require braces around blocks that start a new line
+ curly: ["error", "all"],
+
+ // Encourage the use of dot notation whenever possible.
+ "dot-notation": "error",
+
+ // XXX This rule should be enabled, see Bug 1557040
+ // No credentials submitted with fetch calls
+ "fetch-options/no-fetch-credentials": "off",
+
+ // XXX This rule line should be removed to enable it. See bug 1487642.
+ // Enforce return statements in getters
+ "getter-return": "off",
+
+ // Don't enforce the maximum depth that blocks can be nested. The complexity
+ // rule is a better rule to check this.
+ "max-depth": "off",
+
+ // Maximum depth callbacks can be nested.
+ "max-nested-callbacks": ["error", 10],
+
+ "mozilla/avoid-removeChild": "error",
+ "mozilla/consistent-if-bracing": "error",
+ "mozilla/import-browser-window-globals": "error",
+ "mozilla/import-globals": "error",
+ "mozilla/no-compare-against-boolean-literals": "error",
+ "mozilla/no-cu-reportError": "error",
+ "mozilla/no-define-cc-etc": "error",
+ "mozilla/no-throw-cr-literal": "error",
+ "mozilla/no-useless-parameters": "error",
+ "mozilla/no-useless-removeEventListener": "error",
+ "mozilla/prefer-boolean-length-check": "error",
+ "mozilla/prefer-formatValues": "error",
+ "mozilla/reject-addtask-only": "error",
+ "mozilla/reject-chromeutils-import-params": "error",
+ "mozilla/reject-importGlobalProperties": ["error", "allownonwebidl"],
+ "mozilla/reject-multiple-getters-calls": "error",
+ "mozilla/reject-scriptableunicodeconverter": "warn",
+ "mozilla/rejects-requires-await": "error",
+ "mozilla/use-cc-etc": "error",
+ "mozilla/use-chromeutils-definelazygetter": "error",
+ "mozilla/use-chromeutils-generateqi": "error",
+ "mozilla/use-chromeutils-import": "error",
+ "mozilla/use-console-createInstance": "error",
+ "mozilla/use-default-preference-values": "error",
+ "mozilla/use-includes-instead-of-indexOf": "error",
+ "mozilla/use-isInstance": "error",
+ "mozilla/use-ownerGlobal": "error",
+ "mozilla/use-returnValue": "error",
+ "mozilla/use-services": "error",
+ "mozilla/valid-lazy": "error",
+ "mozilla/valid-services": "error",
+
+ // Use [] instead of Array()
+ "no-array-constructor": "error",
+
+ // Disallow use of arguments.caller or arguments.callee.
+ "no-caller": "error",
+
+ // XXX Bug 1487642 - decide if we want to enable this or not.
+ // Disallow lexical declarations in case clauses
+ "no-case-declarations": "off",
+
+ // XXX Bug 1487642 - decide if we want to enable this or not.
+ // Disallow the use of console
+ "no-console": "off",
+
+ // Disallows expressions where the operation doesn't affect the value.
+ // TODO: This is enabled by default in ESLint's v9 recommended configuration.
+ "no-constant-binary-expression": "error",
+
+ // XXX Bug 1487642 - decide if we want to enable this or not.
+ // Disallow constant expressions in conditions
+ "no-constant-condition": "off",
+
+ // If an if block ends with a return no need for an else block
+ "no-else-return": "error",
+
+ // No empty statements
+ "no-empty": ["error", { allowEmptyCatch: true }],
+
+ // Disallow eval and setInteral/setTimeout with strings
+ "no-eval": "error",
+
+ // Disallow unnecessary calls to .bind()
+ "no-extra-bind": "error",
+
+ // Disallow fallthrough of case statements
+ "no-fallthrough": [
+ "error",
+ {
+ // The eslint rule doesn't allow for case-insensitive regex option.
+ // The following pattern allows for a dash between "fall through" as
+ // well as alternate spelling of "fall thru". The pattern also allows
+ // for an optional "s" at the end of "fall" ("falls through").
+ commentPattern:
+ "[Ff][Aa][Ll][Ll][Ss]?[\\s-]?([Tt][Hh][Rr][Oo][Uu][Gg][Hh]|[Tt][Hh][Rr][Uu])",
+ },
+ ],
+
+ // Disallow eval and setInteral/setTimeout with strings
+ "no-implied-eval": "error",
+
+ // This has been superseded since we're using ES6.
+ // Disallow variable or function declarations in nested blocks
+ "no-inner-declarations": "off",
+
+ // Disallow the use of the __iterator__ property
+ "no-iterator": "error",
+
+ // No labels
+ "no-labels": "error",
+
+ // Disallow unnecessary nested blocks
+ "no-lone-blocks": "error",
+
+ // No single if block inside an else block
+ "no-lonely-if": "error",
+
+ // Nested ternary statements are confusing
+ "no-nested-ternary": "error",
+
+ // Disallow use of new wrappers
+ "no-new-wrappers": "error",
+
+ // Use {} instead of new Object(), unless arguments are passed.
+ "no-object-constructor": "error",
+
+ // We don't want this, see bug 1551829
+ "no-prototype-builtins": "off",
+
+ // Disable builtinGlobals for no-redeclare as this conflicts with our
+ // globals declarations especially for browser window.
+ "no-redeclare": ["error", { builtinGlobals: false }],
+
+ // Disallow use of event global.
+ "no-restricted-globals": ["error", "event"],
+
+ // No unnecessary comparisons
+ "no-self-compare": "error",
+
+ // No comma sequenced statements
+ "no-sequences": "error",
+
+ // No declaring variables from an outer scope
+ // "no-shadow": "error",
+
+ // Disallow throwing literals (eg. throw "error" instead of
+ // throw new Error("error")).
+ "no-throw-literal": "error",
+
+ // Disallow the use of Boolean literals in conditional expressions.
+ "no-unneeded-ternary": "error",
+
+ // No unsanitized use of innerHTML=, document.write() etc.
+ // cf. https://github.com/mozilla/eslint-plugin-no-unsanitized#rule-details
+ "no-unsanitized/method": "error",
+ "no-unsanitized/property": "error",
+
+ // No declaring variables that are never used
+ "no-unused-vars": [
+ "error",
+ {
+ args: "none",
+ vars: "local",
+ },
+ ],
+
+ // No using variables before defined
+ // "no-use-before-define": ["error", "nofunc"],
+
+ // Disallow unnecessary .call() and .apply()
+ "no-useless-call": "error",
+
+ // Don't concatenate string literals together (unless they span multiple
+ // lines)
+ "no-useless-concat": "error",
+
+ // XXX Bug 1487642 - decide if we want to enable this or not.
+ // Disallow unnecessary escape characters
+ "no-useless-escape": "off",
+
+ // Disallow redundant return statements
+ "no-useless-return": "error",
+
+ // Require object-literal shorthand with ES6 method syntax
+ "object-shorthand": ["error", "always", { avoidQuotes: true }],
+
+ // This may conflict with prettier, so turn it off.
+ "prefer-arrow-callback": "off",
+
+ // XXX Bug 1487642 - decide if we want to enable this or not.
+ // Require generator functions to contain yield
+ "require-yield": "off",
+ },
+};
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/require-jsdoc.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/require-jsdoc.js
new file mode 100644
index 0000000000..086fc8b1d3
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/require-jsdoc.js
@@ -0,0 +1,41 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+module.exports = {
+ plugins: ["jsdoc"],
+
+ rules: {
+ "jsdoc/require-jsdoc": [
+ "error",
+ {
+ require: {
+ ClassDeclaration: true,
+ FunctionDeclaration: false,
+ },
+ },
+ ],
+ "jsdoc/require-param": "error",
+ "jsdoc/require-param-description": "error",
+ "jsdoc/require-param-name": "error",
+ "jsdoc/require-property": "error",
+ "jsdoc/require-property-description": "error",
+ "jsdoc/require-property-name": "error",
+ "jsdoc/require-property-type": "error",
+ "jsdoc/require-returns": "error",
+ "jsdoc/require-returns-check": "error",
+ "jsdoc/require-yields": "error",
+ "jsdoc/require-yields-check": "error",
+ },
+ settings: {
+ jsdoc: {
+ // This changes what's allowed in JSDocs, enabling more type-inference
+ // friendly types. This is the default in eslint-plugin-jsdoc versions
+ // since May 2023, but we're still on 39.9 and need opt-in for now.
+ // https://github.com/gajus/eslint-plugin-jsdoc/issues/834
+ mode: "typescript",
+ },
+ },
+};
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/valid-jsdoc.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/valid-jsdoc.js
new file mode 100644
index 0000000000..65fb760fe0
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/valid-jsdoc.js
@@ -0,0 +1,34 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+module.exports = {
+ plugins: ["jsdoc"],
+
+ rules: {
+ "jsdoc/check-access": "error",
+ // Handled by prettier
+ // "jsdoc/check-alignment": "error",
+ "jsdoc/check-param-names": "error",
+ "jsdoc/check-property-names": "error",
+ "jsdoc/check-tag-names": "error",
+ "jsdoc/check-types": "error",
+ "jsdoc/empty-tags": "error",
+ "jsdoc/newline-after-description": "error",
+ "jsdoc/no-multi-asterisks": "error",
+ "jsdoc/require-param-type": "error",
+ "jsdoc/require-returns-type": "error",
+ "jsdoc/valid-types": "error",
+ },
+ settings: {
+ jsdoc: {
+ // This changes what's allowed in JSDocs, enabling more type-inference
+ // friendly types. This is the default in eslint-plugin-jsdoc versions
+ // since May 2023, but we're still on 39.9 and need opt-in for now.
+ // https://github.com/gajus/eslint-plugin-jsdoc/issues/834
+ mode: "typescript",
+ },
+ },
+};
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/xpcshell-test.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/xpcshell-test.js
new file mode 100644
index 0000000000..6a4d572911
--- /dev/null
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/xpcshell-test.js
@@ -0,0 +1,54 @@
+// Parent config file for all xpcshell files.
+"use strict";
+
+module.exports = {
+ env: {
+ browser: false,
+ "mozilla/privileged": true,
+ "mozilla/xpcshell": true,
+ },
+
+ overrides: [
+ {
+ // If it is a head file, we turn off global unused variable checks, as it
+ // would require searching the other test files to know if they are used or not.
+ // This would be expensive and slow, and it isn't worth it for head files.
+ // We could get developers to declare as exported, but that doesn't seem worth it.
+ files: "head*.js",
+ rules: {
+ "no-unused-vars": [
+ "error",
+ {
+ args: "none",
+ vars: "local",
+ },
+ ],
+ },
+ },
+ {
+ // No declaring variables that are never used
+ files: "test*.js",
+ rules: {
+ "no-unused-vars": [
+ "error",
+ {
+ args: "none",
+ vars: "all",
+ },
+ ],
+ },
+ },
+ ],
+
+ rules: {
+ "mozilla/import-headjs-globals": "error",
+ "mozilla/mark-test-function-used": "error",
+ "mozilla/no-arbitrary-setTimeout": "error",
+ "mozilla/no-useless-run-test": "error",
+ "no-shadow": "error",
+ // Turn off no-unsanitized for tests, as we do want to be able to use
+ // these for testing.
+ "no-unsanitized/method": "off",
+ "no-unsanitized/property": "off",
+ },
+};