Bug 1917532 - Remove overrides sections from *-test configurations in eslint-plugin-mozilla. r=frontend-codestyle-reviewers,mossop

ESLint v9 doesn't support overrides/file specification in the configurations, so we don't want these
now.

The top-level configuration already strips out the overrides for these and handles them separately, so
there's nothing to add - simply remove the 'removeOverrides' function.

Differential Revision: https://phabricator.services.mozilla.com/D221447
This commit is contained in:
Mark Banner 2024-09-12 21:08:45 +00:00
Родитель 533bbce8a6
Коммит 2387ca3533
5 изменённых файлов: 4 добавлений и 97 удалений

Просмотреть файл

@ -14,21 +14,6 @@ const { rollouts } = require("./.eslintrc-rollouts.js");
const fs = require("fs"); const fs = require("fs");
const path = require("path"); const path = require("path");
/**
* Some configurations have overrides, which can't be specified within overrides,
* so we need to remove them.
*
* @param {object} config
* The configuration to remove overrides from.
* @returns {object}
* The new configuration.
*/
function removeOverrides(config) {
config = { ...config };
delete config.overrides;
return config;
}
function readFile(filePath) { function readFile(filePath) {
return fs return fs
.readFileSync(filePath, { encoding: "utf-8" }) .readFileSync(filePath, { encoding: "utf-8" })
@ -153,7 +138,7 @@ module.exports = {
extends: ["plugin:mozilla/general-test"], extends: ["plugin:mozilla/general-test"],
}, },
{ {
...removeOverrides(xpcshellTestConfig), ...xpcshellTestConfig,
files: testPaths.xpcshell.map(filePath => `${filePath}**`), files: testPaths.xpcshell.map(filePath => `${filePath}**`),
excludedFiles: ["**/*.jsm", "**/*.mjs", "**/*.sjs"], excludedFiles: ["**/*.jsm", "**/*.mjs", "**/*.sjs"],
}, },
@ -192,12 +177,12 @@ module.exports = {
}, },
}, },
{ {
...removeOverrides(browserTestConfig), ...browserTestConfig,
files: testPaths.browser.map(filePath => `${filePath}**`), files: testPaths.browser.map(filePath => `${filePath}**`),
excludedFiles: ["**/*.jsm", "**/*.mjs", "**/*.sjs"], excludedFiles: ["**/*.jsm", "**/*.mjs", "**/*.sjs"],
}, },
{ {
...removeOverrides(mochitestTestConfig), ...mochitestTestConfig,
files: testPaths.mochitest.map(filePath => `${filePath}**`), files: testPaths.mochitest.map(filePath => `${filePath}**`),
excludedFiles: [ excludedFiles: [
"**/*.jsm", "**/*.jsm",
@ -206,7 +191,7 @@ module.exports = {
], ],
}, },
{ {
...removeOverrides(chromeTestConfig), ...chromeTestConfig,
files: testPaths.chrome.map(filePath => `${filePath}**`), files: testPaths.chrome.map(filePath => `${filePath}**`),
excludedFiles: ["**/*.jsm", "**/*.mjs", "**/*.sjs"], excludedFiles: ["**/*.jsm", "**/*.mjs", "**/*.sjs"],
}, },

Просмотреть файл

@ -6,7 +6,6 @@ module.exports = {
browser: true, browser: true,
"mozilla/browser-window": true, "mozilla/browser-window": true,
"mozilla/simpletest": true, "mozilla/simpletest": true,
// "node": true
}, },
// All globals made available in the test environment. // All globals made available in the test environment.
@ -57,19 +56,6 @@ module.exports = {
waitForFocus: false, waitForFocus: false,
}, },
overrides: [
{
// Some directories have multiple kinds of tests, and some rules
// don't work well for plain mochitests, so disable those.
files: ["*.html", "*.xhtml"],
// plain/chrome mochitests don't automatically include Assert, so
// autofixing `ok()` to Assert.something is bad.
rules: {
"mozilla/no-comparison-or-assignment-inside-ok": "off",
},
},
],
plugins: ["mozilla"], plugins: ["mozilla"],
rules: { rules: {

Просмотреть файл

@ -18,18 +18,6 @@ module.exports = {
getRootDirectory: 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"], plugins: ["mozilla"],
rules: { rules: {

Просмотреть файл

@ -12,17 +12,6 @@ module.exports = {
SpecialPowers: false, 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"], plugins: ["mozilla"],
rules: { rules: {

Просмотреть файл

@ -8,47 +8,6 @@ module.exports = {
"mozilla/xpcshell": true, "mozilla/xpcshell": true,
}, },
overrides: [
{
// Some directories have multiple kinds of tests, and some rules
// don't work well for plain mochitests, so disable those.
files: ["*.html", "*.xhtml"],
// plain/chrome mochitests don't automatically include Assert, so
// autofixing `ok()` to Assert.something is bad.
rules: {
"mozilla/no-comparison-or-assignment-inside-ok": "off",
},
},
{
// 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",
{
argsIgnorePattern: "^_",
vars: "local",
},
],
},
},
{
// No declaring variables that are never used
files: "test*.js",
rules: {
"no-unused-vars": [
"error",
{
argsIgnorePattern: "^_",
vars: "all",
},
],
},
},
],
plugins: ["mozilla", "@microsoft/sdl"], plugins: ["mozilla", "@microsoft/sdl"],
rules: { rules: {