summaryrefslogtreecommitdiffstats
path: root/docs/code-quality/lint/linters/eslint-plugin-mozilla/reject-globalThis-modification.rst
blob: dd4fc4b2afd3d025cd1c4df35e48e72240db3449 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
reject-globalThis-modification
==============================

Reject any modification to ``globalThis`` inside the system modules.

``globalThis`` is the shared global inside the system modules, and modification
on it is visible from all modules, and it shouldn't be done unless it's really
necessary.

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

.. code-block:: js

    globalThis.foo = 10;
    Object.defineProperty(globalThis, "bar", { value: 20});
    ChromeUtils.defineESModuleGetters(globalThis, {
      AppConstants: "resource://gre/modules/AppConstants.sys.mjs",
    });