From 40a355a42d4a9444dc753c04c6608dade2f06a23 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:13:27 +0200 Subject: Adding upstream version 125.0.1. Signed-off-by: Daniel Baumann --- .../rules/import-headjs-globals.rst | 1 - .../eslint-plugin-mozilla/rules/no-more-globals.rst | 20 ++++++++++++++++++++ .../rules/reject-mixing-eager-and-lazy.rst | 11 +++++++---- .../rules/reject-relative-requires.rst | 2 +- .../eslint-plugin-mozilla/rules/valid-lazy.rst | 10 +++++----- 5 files changed, 33 insertions(+), 11 deletions(-) create mode 100644 docs/code-quality/lint/linters/eslint-plugin-mozilla/rules/no-more-globals.rst (limited to 'docs/code-quality/lint/linters/eslint-plugin-mozilla') diff --git a/docs/code-quality/lint/linters/eslint-plugin-mozilla/rules/import-headjs-globals.rst b/docs/code-quality/lint/linters/eslint-plugin-mozilla/rules/import-headjs-globals.rst index df8ef81300..51ec8eeb62 100644 --- a/docs/code-quality/lint/linters/eslint-plugin-mozilla/rules/import-headjs-globals.rst +++ b/docs/code-quality/lint/linters/eslint-plugin-mozilla/rules/import-headjs-globals.rst @@ -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"`` diff --git a/docs/code-quality/lint/linters/eslint-plugin-mozilla/rules/no-more-globals.rst b/docs/code-quality/lint/linters/eslint-plugin-mozilla/rules/no-more-globals.rst new file mode 100644 index 0000000000..2cbe7e82ab --- /dev/null +++ b/docs/code-quality/lint/linters/eslint-plugin-mozilla/rules/no-more-globals.rst @@ -0,0 +1,20 @@ +no-more-globals +=============== + +This rule is used to discourage people from adding ever more global variables to +files where the rule is run. + +For any file ``example.js`` where the rule is applied, the rule will read +an allowlist of globals from a sibling ``example.js.globals`` file. The rule +will warn for any globals defined in ``example.js`` that are not listed in the +``globals`` file, and will also warn for any items on the allowlist in +the ``globals`` file that are no longer present in ``example.js``, encouraging +people to remove them from the ``globals`` list. + +If you see errors from this rule about new globals, **do not just add items to +the allowlist**. Instead, work to find a way to run your code so that it does +not add to the list of globals. + +If you see errors when removing globals, simply remove them from the allowlist +to make sure it is up-to-date and things do not inadvertently end up getting +put back in. diff --git a/docs/code-quality/lint/linters/eslint-plugin-mozilla/rules/reject-mixing-eager-and-lazy.rst b/docs/code-quality/lint/linters/eslint-plugin-mozilla/rules/reject-mixing-eager-and-lazy.rst index 51524f4e14..1b7c165036 100644 --- a/docs/code-quality/lint/linters/eslint-plugin-mozilla/rules/reject-mixing-eager-and-lazy.rst +++ b/docs/code-quality/lint/linters/eslint-plugin-mozilla/rules/reject-mixing-eager-and-lazy.rst @@ -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" + ); diff --git a/docs/code-quality/lint/linters/eslint-plugin-mozilla/rules/reject-relative-requires.rst b/docs/code-quality/lint/linters/eslint-plugin-mozilla/rules/reject-relative-requires.rst index 4387041b26..c3ec0cfed8 100644 --- a/docs/code-quality/lint/linters/eslint-plugin-mozilla/rules/reject-relative-requires.rst +++ b/docs/code-quality/lint/linters/eslint-plugin-mozilla/rules/reject-relative-requires.rst @@ -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) diff --git a/docs/code-quality/lint/linters/eslint-plugin-mozilla/rules/valid-lazy.rst b/docs/code-quality/lint/linters/eslint-plugin-mozilla/rules/valid-lazy.rst index a7edeeb5fc..e7f6706d5b 100644 --- a/docs/code-quality/lint/linters/eslint-plugin-mozilla/rules/valid-lazy.rst +++ b/docs/code-quality/lint/linters/eslint-plugin-mozilla/rules/valid-lazy.rst @@ -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(); -- cgit v1.2.3