Bug 1783406 - Provide a separate environment for the globals in recommended ESLint config r=Standard8

Differential Revision: https://phabricator.services.mozilla.com/D157665
This commit is contained in:
Jonathan Sudiaman 2022-09-22 15:11:38 +00:00
Родитель db4c1e8525
Коммит 9c0af7af23
4 изменённых файлов: 34 добавлений и 36 удалений

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

@ -22,6 +22,7 @@ module.exports = {
// "tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js".
es2021: false,
"mozilla/privileged": false,
"mozilla/specific": false,
// Enable SpiderMonkey's self-hosted environment.
"spidermonkey-js/environment": true,
@ -136,22 +137,6 @@ module.exports = {
Record: "off",
Temporal: "off",
Tuple: "off",
// Undefine globals from Mozilla recommended file
// "tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js".
Cc: "off",
ChromeUtils: "off",
Ci: "off",
Components: "off",
Cr: "off",
Cu: "off",
Debugger: "off",
InstallTrigger: "off",
InternalError: "off",
Services: "off",
dump: "off",
openDialog: "off",
uneval: "off",
},
},
],

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

@ -16,30 +16,11 @@ module.exports = {
browser: true,
es2021: true,
"mozilla/privileged": true,
"mozilla/specific": true,
},
extends: ["eslint:recommended", "plugin:prettier/recommended"],
globals: {
// These are all specific to Firefox unless otherwise stated.
Cc: false,
ChromeUtils: false,
Ci: false,
Components: false,
Cr: false,
Cu: false,
Debugger: false,
InstallTrigger: false,
// https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/InternalError
InternalError: true,
Services: false,
// https://developer.mozilla.org/docs/Web/API/Window/dump
dump: true,
openDialog: false,
// https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/uneval
uneval: false,
},
overrides: [
{
// System mjs files and jsm files are not loaded in the browser scope,

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

@ -0,0 +1,31 @@
/**
* @fileoverview Defines the environment for the Firefox browser. Allows global
* variables which are non-standard and specific to Firefox.
*
* 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 = {
globals: {
Cc: false,
ChromeUtils: false,
Ci: false,
Components: false,
Cr: false,
Cu: false,
Debugger: false,
InstallTrigger: false,
// https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/InternalError
InternalError: true,
Services: false,
// https://developer.mozilla.org/docs/Web/API/Window/dump
dump: true,
openDialog: false,
// https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/uneval
uneval: false,
},
};

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

@ -30,6 +30,7 @@ module.exports = {
simpletest: require("../lib/environments/simpletest.js"),
sjs: require("../lib/environments/sjs.js"),
"special-powers-sandbox": require("../lib/environments/special-powers-sandbox.js"),
specific: require("../lib/environments/specific"),
privileged: require("../lib/environments/privileged.js"),
xpcshell: require("../lib/environments/xpcshell.js"),
},