Bug 1776837 - Part 2: Reject defining lazy getter for module that is already loaded eagerly at top-level. r=mossop

Depends on D150935

Differential Revision: https://phabricator.services.mozilla.com/D150936
This commit is contained in:
Tooru Fujisawa
2022-07-05 01:01:35 +00:00
parent 1862091f08
commit e1538f8276
6 changed files with 302 additions and 0 deletions

View File

@@ -53,6 +53,7 @@ The plugin implements the following rules:
eslint-plugin-mozilla/reject-global-this
eslint-plugin-mozilla/reject-globalThis-modification
eslint-plugin-mozilla/reject-importGlobalProperties
eslint-plugin-mozilla/reject-mixing-eager-and-lazy
eslint-plugin-mozilla/reject-osfile
eslint-plugin-mozilla/reject-relative-requires
eslint-plugin-mozilla/reject-requires-await

View File

@@ -0,0 +1,22 @@
reject-mixing-eager-and-lazy
==================================
Rejects defining a lazy getter for a module that's eagerly imported at
top-level script unconditionally.
Examples of incorrect code for this rule:
-----------------------------------------
.. code-block:: js
const { SomeProp } = ChromeUtils.import("resource://gre/modules/Foo.jsm");
XPCOMUtils.defineLazyModuleGetter(lazy, {
OtherProp: "resource://gre/modules/Foo.jsm",
});
Examples of correct code for this rule:
---------------------------------------
.. code-block:: js
const { SomeProp, OtherProp } = ChromeUtils.import("resource://gre/modules/Foo.jsm");