зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1884623 - Cleanup jsm references in ESLint files. r=mossop,devtools-reviewers,omc-reviewers,ochameau,aminomancer
Differential Revision: https://phabricator.services.mozilla.com/D204180
This commit is contained in:
Родитель
544296f729
Коммит
43d2964f1b
|
@ -580,7 +580,6 @@ module.exports = {
|
|||
"toolkit/components/lz4/lz4.js",
|
||||
"toolkit/components/messaging-system/**",
|
||||
"toolkit/components/mozintl/mozIntl.sys.mjs",
|
||||
"toolkit/components/narrate/Narrator.jsm",
|
||||
"toolkit/components/nimbus/**",
|
||||
"toolkit/components/normandy/**",
|
||||
"toolkit/components/passwordmgr/**",
|
||||
|
@ -1267,7 +1266,6 @@ module.exports = {
|
|||
"browser/components/urlbar/tests/browser/browser_view_resultDisplay.js",
|
||||
"browser/components/urlbar/tests/browser/browser_view_resultTypes_display.js",
|
||||
"browser/components/urlbar/tests/ext/browser/browser_ext_urlbar_clearInput.js",
|
||||
"browser/components/urlbar/tests/quicksuggest/QuickSuggestTestUtils.jsm ",
|
||||
"browser/components/urlbar/tests/quicksuggest/browser/browser_quicksuggest.js",
|
||||
"browser/components/urlbar/tests/quicksuggest/browser/browser_quicksuggest_block.js",
|
||||
"browser/components/urlbar/tests/quicksuggest/browser/browser_quicksuggest_configuration.js",
|
||||
|
@ -1828,7 +1826,6 @@ module.exports = {
|
|||
"dom/u2f/tests/frame_appid_facet_insecure.html",
|
||||
"dom/u2f/tests/frame_appid_facet_subdomain.html",
|
||||
"dom/url/tests/browser_download_after_revoke.js",
|
||||
"dom/url/tests/file_url.jsm ",
|
||||
"dom/url/tests/protocol_worker.js",
|
||||
"dom/url/tests/test_unknown_url_origin.html",
|
||||
"dom/url/tests/test_url.html",
|
||||
|
@ -1873,7 +1870,6 @@ module.exports = {
|
|||
"image/test/browser/head.js",
|
||||
"image/test/mochitest/test_animated_gif.html",
|
||||
"image/test/mochitest/test_bug671906.html",
|
||||
"intl/locale/tests/LangPackMatcherTestUtils.jsm ",
|
||||
"layout/base/tests/browser_disableDialogs_onbeforeunload.js",
|
||||
"layout/base/tests/browser_lazyload_page_load_telemetry_iframe.js",
|
||||
"layout/base/tests/browser_lazyload_telemetry.js",
|
||||
|
@ -1905,8 +1901,6 @@ module.exports = {
|
|||
"netwerk/test/browser/browser_103_preload.js",
|
||||
"netwerk/test/browser/browser_cookie_filtering_subdomain.js",
|
||||
"netwerk/test/browser/browser_test_favicon.js",
|
||||
"netwerk/test/browser/cookie_filtering_helper.jsm",
|
||||
"netwerk/test/browser/early_hint_preload_test_helper.jsm ",
|
||||
"netwerk/test/httpserver/httpd.js",
|
||||
"netwerk/test/mochitests/file_loadinfo_redirectchain.sjs",
|
||||
"netwerk/test/mochitests/file_testloadflags_chromescript.js",
|
||||
|
@ -2016,11 +2010,9 @@ module.exports = {
|
|||
"toolkit/components/httpsonlyerror/tests/browser/browser_errorpage_www_suggestion.js",
|
||||
"toolkit/components/httpsonlyerror/tests/browser/browser_exception.js",
|
||||
"toolkit/components/narrate/test/head.js",
|
||||
"toolkit/components/normandy/test/NormandyTestUtils.jsm ",
|
||||
"toolkit/components/normandy/test/browser/browser_RecipeRunner.js",
|
||||
"toolkit/components/normandy/test/browser/browser_actions_ShowHeartbeatAction.js",
|
||||
"toolkit/components/normandy/test/browser/head.js",
|
||||
"toolkit/components/passwordmgr/test/LoginTestUtils.jsm ",
|
||||
"toolkit/components/passwordmgr/test/browser/browser_autofill_http.js",
|
||||
"toolkit/components/passwordmgr/test/browser/browser_context_menu.js",
|
||||
"toolkit/components/passwordmgr/test/browser/browser_context_menu_iframe.js",
|
||||
|
|
|
@ -46,7 +46,7 @@ module.exports = {
|
|||
{
|
||||
// Use a configuration that's appropriate for modules, workers and
|
||||
// non-production files.
|
||||
files: ["modules/*.jsm", "tests/**"],
|
||||
files: ["tests/**"],
|
||||
rules: {
|
||||
"no-implicit-globals": "off",
|
||||
},
|
||||
|
|
|
@ -58,7 +58,7 @@ module.exports = {
|
|||
{
|
||||
// Use a configuration that's appropriate for modules, workers and
|
||||
// non-production files.
|
||||
files: ["*.jsm", "lib/cache.worker.js", "test/**"],
|
||||
files: ["lib/cache.worker.js", "test/**"],
|
||||
rules: {
|
||||
"no-implicit-globals": "off",
|
||||
},
|
||||
|
|
|
@ -82,30 +82,6 @@ module.exports = {
|
|||
"**/test*/**/*",
|
||||
],
|
||||
},
|
||||
{
|
||||
// Cu, Cc etc... are not available in most devtools modules loaded by require.
|
||||
files: ["**"],
|
||||
excludedFiles: [
|
||||
// Enable the rule on JSM, test head files and some specific files.
|
||||
"**/*.jsm",
|
||||
"**/*.sjs",
|
||||
"**/test/**/head.js",
|
||||
"**/test/**/shared-head.js",
|
||||
"client/debugger/test/mochitest/code_frame-script.js",
|
||||
"client/responsive.html/browser/content.js",
|
||||
"server/startup/content-process.js",
|
||||
"server/startup/frame.js",
|
||||
"shared/loader/base-loader.sys.mjs",
|
||||
"shared/loader/browser-loader.js",
|
||||
"shared/loader/worker-loader.js",
|
||||
"startup/aboutdebugging-registration.js",
|
||||
"startup/aboutdevtoolstoolbox-registration.js",
|
||||
"startup/devtools-startup.js",
|
||||
],
|
||||
rules: {
|
||||
"mozilla/no-define-cc-etc": "off",
|
||||
},
|
||||
},
|
||||
{
|
||||
// All DevTools files should avoid relative paths.
|
||||
files: ["**"],
|
||||
|
|
|
@ -153,5 +153,4 @@ This should help you write eslint-clean code:
|
|||
* When cleaning an entire file or folder from ESLint errors, do not forget to remove the corresponding entry from the `.eslintignore` file.
|
||||
* When writing new code, from scratch, please make it ESLint compliant from the start. This is a lot easier than having to revisit it later.
|
||||
* ESLint also runs on `<script>` tags in HTML files, so if you create new HTML test files for mochitests for example, make sure that JavaScript code in those files is free of ESLint errors.
|
||||
* Depending on how a dependency is loaded into a file, the symbols this dependency exports might not be considered as defined by ESLint. For instance, using `Cu.import("some.jsm")` doesn't explicitly say which symbols are now available in the scope of the file, and so using those symbols will be consider by ESLint as using undefined variables. When this happens, please avoid using the `/* globals ... */` ESLint comment (which tells it that these variables are defined). Instead, please use `/* import-globals-from relative/path/to/file.js */`. This way, you won't have a list of variables to maintain manually, the globals are going to be imported dynamically instead.
|
||||
* In test files (xpcshell and mochitest), all globals from the corresponding `head.js` file are imported automatically, so you don't need to define them using a `/* globals ... */` comment or a `/* import-globals-from head.js */` comment.
|
||||
|
|
|
@ -19,7 +19,6 @@ If path does not exist because it is generated e.g.
|
|||
|
||||
The following patterns are supported:
|
||||
|
||||
- ``Cu.import("resource://devtools/client/shared/widgets/ViewHelpers.jsm");``
|
||||
- ``loader.lazyRequireGetter(this, "name2"``
|
||||
- ``loader.lazyServiceGetter(this, "name3"``
|
||||
- ``loader.lazyGetter(this, "toolboxStrings"``
|
||||
|
|
|
@ -9,9 +9,10 @@ Examples of incorrect code for this rule:
|
|||
|
||||
.. code-block:: js
|
||||
|
||||
const { SomeProp } = ChromeUtils.import("resource://gre/modules/Foo.jsm");
|
||||
ChromeUtils.defineLazyModuleGetters(lazy, {
|
||||
OtherProp: "resource://gre/modules/Foo.jsm",
|
||||
const { SomeProp } =
|
||||
ChromeUtils.importESModule("resource://gre/modules/Foo.sys.mjs");
|
||||
ChromeUtils.defineESModuleGetters(lazy, {
|
||||
OtherProp: "resource://gre/modules/Foo.sys.mjs",
|
||||
});
|
||||
|
||||
Examples of correct code for this rule:
|
||||
|
@ -19,4 +20,6 @@ Examples of correct code for this rule:
|
|||
|
||||
.. code-block:: js
|
||||
|
||||
const { SomeProp, OtherProp } = ChromeUtils.import("resource://gre/modules/Foo.jsm");
|
||||
const { SomeProp, OtherProp } = ChromeUtils.importESModule(
|
||||
"resource://gre/modules/Foo.sys.mjs"
|
||||
);
|
||||
|
|
|
@ -18,5 +18,5 @@ Examples of correct code for this rule:
|
|||
.. code-block:: js
|
||||
|
||||
require("devtools/absolute/path")
|
||||
require("resource://gre/modules/SomeModule.jsm")
|
||||
require("resource://gre/modules/SomeModule.sys.mjs")
|
||||
loader.lazyRequireGetter(this, "path", "devtools/absolute/path", true)
|
||||
|
|
|
@ -19,10 +19,10 @@ Examples of incorrect code for this rule:
|
|||
.. code-block:: js
|
||||
|
||||
const lazy = {};
|
||||
ChromeUtils.defineLazyGetter(lazy, "foo", "foo.jsm");
|
||||
ChromeUtils.defineESModuleGetters(lazy, { foo: "foo.sys.mjs"});
|
||||
|
||||
// Duplicate symbol foo being added to lazy.
|
||||
ChromeUtils.defineLazyGetter(lazy, "foo", "foo1.jsm");
|
||||
ChromeUtils.defineLazyGetter(lazy, "foo", () => {});
|
||||
if (x) {
|
||||
lazy.foo3.bar();
|
||||
}
|
||||
|
@ -31,12 +31,12 @@ Examples of incorrect code for this rule:
|
|||
|
||||
const lazy = {};
|
||||
// Unused lazy property foo
|
||||
ChromeUtils.defineLazyGetter(lazy, "foo", "foo.jsm");
|
||||
ChromeUtils.defineESModuleGetters(lazy, { foo: "foo.sys.mjs"});
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
const lazy = {};
|
||||
ChromeUtils.defineLazyGetter(lazy, "foo", "foo.jsm");
|
||||
ChromeUtils.defineESModuleGetters(lazy, { foo: "foo.sys.mjs"});
|
||||
// Used at top-level unconditionally.
|
||||
lazy.foo.bar();
|
||||
|
||||
|
@ -47,7 +47,7 @@ Examples of correct code for this rule:
|
|||
|
||||
const lazy = {};
|
||||
ChromeUtils.defineLazyGetter(lazy, "foo1", () => {});
|
||||
XPCOMUtils.defineLazyModuleGetters(lazy, { foo2: "foo2.jsm" });
|
||||
ChromeUtils.defineESModuleGetters(lazy, { foo2: "foo2.sys.mjs"});
|
||||
|
||||
if (x) {
|
||||
lazy.foo1.bar();
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
module.exports = {
|
||||
globals: {
|
||||
// Injected into tests via tps.jsm
|
||||
// Injected into tests via tps.sys.mjs
|
||||
Addons: false,
|
||||
Addresses: false,
|
||||
Bookmarks: false,
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
module.exports = {
|
||||
globals: {
|
||||
// These are defined in the WebExtension script scopes by ExtensionCommon.jsm
|
||||
// These are defined in the WebExtension script scopes by ExtensionCommon.sys.mjs
|
||||
Cc: true,
|
||||
Ci: true,
|
||||
Cr: true,
|
||||
|
|
|
@ -50,7 +50,7 @@ module.exports = {
|
|||
// environment for them.
|
||||
env: {
|
||||
browser: false,
|
||||
"mozilla/jsm": true,
|
||||
"mozilla/sysmjs": true,
|
||||
},
|
||||
files: ["**/*.sys.mjs", "**/*.jsm"],
|
||||
rules: {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* @fileoverview Defines the environment for jsm files.
|
||||
* @fileoverview Defines the environment for sys module files.
|
||||
*
|
||||
* 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
|
||||
|
@ -10,7 +10,7 @@
|
|||
|
||||
module.exports = {
|
||||
globals: {
|
||||
// These globals are hard-coded and available in .jsm scopes.
|
||||
// These globals are hard-coded and available in .sys.mjs scopes.
|
||||
// https://searchfox.org/mozilla-central/rev/dcb0cfb66e4ed3b9c7fbef1e80572426ff5f3c3a/js/xpconnect/loader/mozJSModuleLoader.cpp#222-223
|
||||
// Although `debug` is allowed for jsm files, this is non-standard and something
|
||||
// we don't want to allow in mjs files. Hence it is not included here.
|
||||
|
@ -18,8 +18,8 @@ module.exports = {
|
|||
btoa: false,
|
||||
dump: false,
|
||||
// The WebAssembly global is available in most (if not all) contexts where
|
||||
// JS can run. It's definitely available in JSMs. So even if this is not
|
||||
// the perfect place to add it, it's not wrong, and we can move it later.
|
||||
// JS can run. It's definitely available in system modules. So even if this
|
||||
// is not the perfect place to add it, it's not wrong, and we can move it later.
|
||||
WebAssembly: false,
|
||||
},
|
||||
};
|
|
@ -27,7 +27,7 @@ module.exports = {
|
|||
"chrome-script": require("../lib/environments/chrome-script.js"),
|
||||
"chrome-worker": require("../lib/environments/chrome-worker.js"),
|
||||
"frame-script": require("../lib/environments/frame-script.js"),
|
||||
jsm: require("../lib/environments/jsm.js"),
|
||||
sysmjs: require("../lib/environments/sysmjs.js"),
|
||||
privileged: require("../lib/environments/privileged.js"),
|
||||
"process-script": require("../lib/environments/process-script.js"),
|
||||
"remote-page": require("../lib/environments/remote-page.js"),
|
||||
|
|
Загрузка…
Ссылка в новой задаче