Loading docs/code-quality/lint/linters/eslint-plugin-mozilla.rst +1 −0 Original line number Diff line number Diff line Loading @@ -49,6 +49,7 @@ The plugin implements the following rules: eslint-plugin-mozilla/reject-addtask-only eslint-plugin-mozilla/reject-chromeutils-import-params eslint-plugin-mozilla/reject-global-this eslint-plugin-mozilla/reject-globalThis-modification eslint-plugin-mozilla/reject-importGlobalProperties eslint-plugin-mozilla/reject-osfile eslint-plugin-mozilla/reject-relative-requires Loading docs/code-quality/lint/linters/eslint-plugin-mozilla/reject-globalThis-modification.rst 0 → 100644 +19 −0 Original line number Diff line number Diff line 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}); XPCOMUtils.defineLazyModuleGetters(globalThis, { Services: "resource://gre/modules/Services.jsm", }); remote/cdp/domains/content/Runtime.jsm +1 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ XPCOMUtils.defineLazyGetter(lazy, "ConsoleAPIStorage", () => { }); // Import the `Debugger` constructor in the current scope // eslint-disable-next-line mozilla/reject-globalThis-modification addDebuggerToGlobal(globalThis); const CONSOLE_API_LEVEL_MAP = { Loading testing/modules/CoverageUtils.jsm +1 −0 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ var EXPORTED_SYMBOLS = ["CoverageCollector"]; const { addDebuggerToGlobal } = ChromeUtils.import( "resource://gre/modules/jsdebugger.jsm" ); // eslint-disable-next-line mozilla/reject-globalThis-modification addDebuggerToGlobal(globalThis); /** Loading toolkit/components/certviewer/content/certDecoder.jsm +2 −0 Original line number Diff line number Diff line Loading @@ -1297,6 +1297,8 @@ function certDecoderInitializer( return { parse, pemToDER }; } // This must be removed when all consumer is converted to ES module. // eslint-disable-next-line mozilla/reject-globalThis-modification globalThis.certDecoderInitializer = certDecoderInitializer; /* eslint-disable-next-line no-unused-vars */ var EXPORTED_SYMBOLS = ["certDecoderInitializer"]; Loading
docs/code-quality/lint/linters/eslint-plugin-mozilla.rst +1 −0 Original line number Diff line number Diff line Loading @@ -49,6 +49,7 @@ The plugin implements the following rules: eslint-plugin-mozilla/reject-addtask-only eslint-plugin-mozilla/reject-chromeutils-import-params eslint-plugin-mozilla/reject-global-this eslint-plugin-mozilla/reject-globalThis-modification eslint-plugin-mozilla/reject-importGlobalProperties eslint-plugin-mozilla/reject-osfile eslint-plugin-mozilla/reject-relative-requires Loading
docs/code-quality/lint/linters/eslint-plugin-mozilla/reject-globalThis-modification.rst 0 → 100644 +19 −0 Original line number Diff line number Diff line 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}); XPCOMUtils.defineLazyModuleGetters(globalThis, { Services: "resource://gre/modules/Services.jsm", });
remote/cdp/domains/content/Runtime.jsm +1 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ XPCOMUtils.defineLazyGetter(lazy, "ConsoleAPIStorage", () => { }); // Import the `Debugger` constructor in the current scope // eslint-disable-next-line mozilla/reject-globalThis-modification addDebuggerToGlobal(globalThis); const CONSOLE_API_LEVEL_MAP = { Loading
testing/modules/CoverageUtils.jsm +1 −0 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ var EXPORTED_SYMBOLS = ["CoverageCollector"]; const { addDebuggerToGlobal } = ChromeUtils.import( "resource://gre/modules/jsdebugger.jsm" ); // eslint-disable-next-line mozilla/reject-globalThis-modification addDebuggerToGlobal(globalThis); /** Loading
toolkit/components/certviewer/content/certDecoder.jsm +2 −0 Original line number Diff line number Diff line Loading @@ -1297,6 +1297,8 @@ function certDecoderInitializer( return { parse, pemToDER }; } // This must be removed when all consumer is converted to ES module. // eslint-disable-next-line mozilla/reject-globalThis-modification globalThis.certDecoderInitializer = certDecoderInitializer; /* eslint-disable-next-line no-unused-vars */ var EXPORTED_SYMBOLS = ["certDecoderInitializer"];