Bug 1905959 - Move jsm rule handling out of eslint-plugin-mozilla to the top-level config. r=frontend-codestyle-reviewers,Gijs

This helps to simplify the combinations in eslint-plugin-mozilla ahead of supporting the ESLint flat config.

Differential Revision: https://phabricator.services.mozilla.com/D215541
This commit is contained in:
Mark Banner 2024-07-03 11:41:30 +00:00
Родитель 21fda4f9d2
Коммит 1d0ca7396f
4 изменённых файлов: 43 добавлений и 12 удалений

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

@ -272,6 +272,43 @@ module.exports = {
"@microsoft/sdl/no-insecure-url": "off",
},
},
// JSM Handling. This handles the obsolete JSM files whilst we await the
// removal of JSM. These reflect some of the rules in recommended.js but
// are moved here to simplify reworking the configuration for flat config.
{
// 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/sysmjs": true,
},
files: ["**/*.jsm"],
rules: {
"mozilla/lazy-getter-object-name": "error",
"mozilla/mark-exported-symbols-as-used": "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 }],
// 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",
{
argsIgnorePattern: "^_",
vars: "all",
},
],
},
},
...rollouts,
],
};

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

@ -45,14 +45,14 @@ module.exports = {
overrides: [
{
// System mjs files and jsm files are not loaded in the browser scope,
// System mjs files 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/sysmjs": true,
},
files: ["**/*.sys.mjs", "**/*.jsm"],
files: ["**/*.sys.mjs"],
rules: {
"mozilla/lazy-getter-object-name": "error",
"mozilla/reject-eager-module-in-lazy-getter": "error",
@ -64,12 +64,12 @@ module.exports = {
"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.
// We can enable builtinGlobals for mjs files due to their scopes.
"no-redeclare": ["error", { builtinGlobals: false }],
},
},
{
files: ["**/*.mjs", "**/*.jsx", "**/*.jsm", "**/?(*.)worker.?(m)js"],
files: ["**/*.mjs", "**/*.jsx", "**/?(*.)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.
@ -103,12 +103,6 @@ module.exports = {
strict: "error",
},
},
{
files: ["**/*.jsm"],
rules: {
"mozilla/mark-exported-symbols-as-used": "error",
},
},
{
env: {
browser: false,

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

@ -1,6 +1,6 @@
{
"name": "eslint-plugin-mozilla",
"version": "3.7.4",
"version": "3.7.5",
"lockfileVersion": 3,
"requires": true,
"packages": {

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

@ -1,6 +1,6 @@
{
"name": "eslint-plugin-mozilla",
"version": "3.7.4",
"version": "3.7.5",
"description": "A collection of rules that help enforce JavaScript coding standard in the Mozilla project.",
"keywords": [
"eslint",