summaryrefslogtreecommitdiffstats
path: root/docs/code-quality/lint/linters/eslint-plugin-mozilla/reject-eager-module-in-lazy-getter.rst
blob: fd81793690c27bd879578dd8c6e9f52c0a16c9b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
reject-eager-module-in-lazy-getter
==================================

Rejects defining a lazy getter for module that's known to be loaded early in the
startup process and it is not necessary to lazy load it.

Examples of incorrect code for this rule:
-----------------------------------------

.. code-block:: js

    ChromeUtils.defineESModuleGetters(lazy, {
      AppConstants: "resource://gre/modules/AppConstants.sys.mjs",
    });
    XPCOMUtils.defineLazyModuleGetters(lazy, {
      XPCOMUtils: "resource://gre/modules/XPCOMUtils.jsm",
    });
    XPCOMUtils.defineLazyModuleGetter(
      lazy,
      "AppConstants",
      "resource://gre/modules/AppConstants.jsm",
    });

Examples of correct code for this rule:
---------------------------------------

.. code-block:: js

    import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs";
    const { XPCOMUtils } = ChromeUtils.import(
      "resource://gre/modules/XPCOMUtils.jsm"
    );
    const { AppConstants } = ChromeUtils.import(
      "resource://gre/modules/AppConstants.jsm"
    );