summaryrefslogtreecommitdiffstats
path: root/docs/code-quality/lint/linters/eslint-plugin-mozilla/rules/reject-global-this.rst
blob: b3d94321f5b78e44984cbe295a003fb05018a961 (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
reject-global-this
======================

Rejects global ``this`` usage in JSM files.  The global ``this`` is not
available in ESM, and this is a preparation for the migration.

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

.. code-block:: js

    this.EXPORTED_SYMBOLS = ["foo"];

    XPCOMUtils.defineLazyModuleGetters(this, {
      AddonManager: "resource://gre/modules/AddonManager.jsm",
    });


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

.. code-block:: js

    const EXPORTED_SYMBOLS = ["foo"];

    const lazy = {};
    XPCOMUtils.defineLazyModuleGetters(lazy, {
      AddonManager: "resource://gre/modules/AddonManager.jsm",
    });