mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1854948 - Remove support for Cu.import and XPCOMUtils.defineLazyModuleGetter from most of ESLint. r=arai
Differential Revision: https://phabricator.services.mozilla.com/D189132
This commit is contained in:
parent
66ae587f22
commit
c2782050e8
@ -22,7 +22,6 @@ The following patterns are supported:
|
|||||||
- ``Cu.import("resource://devtools/client/shared/widgets/ViewHelpers.jsm");``
|
- ``Cu.import("resource://devtools/client/shared/widgets/ViewHelpers.jsm");``
|
||||||
- ``loader.lazyRequireGetter(this, "name2"``
|
- ``loader.lazyRequireGetter(this, "name2"``
|
||||||
- ``loader.lazyServiceGetter(this, "name3"``
|
- ``loader.lazyServiceGetter(this, "name3"``
|
||||||
- ``XPCOMUtils.defineLazyModuleGetter(this, "setNamedTimeout", ...)``
|
|
||||||
- ``loader.lazyGetter(this, "toolboxStrings"``
|
- ``loader.lazyGetter(this, "toolboxStrings"``
|
||||||
- ``XPCOMUtils.defineLazyGetter(this, "clipboardHelper"``
|
- ``XPCOMUtils.defineLazyGetter(this, "clipboardHelper"``
|
||||||
- ``ChromeUtils.defineLazyGetter(this, "clipboardHelper"``
|
- ``ChromeUtils.defineLazyGetter(this, "clipboardHelper"``
|
||||||
|
@ -9,14 +9,10 @@ Examples of incorrect code for this rule:
|
|||||||
|
|
||||||
.. code-block:: js
|
.. code-block:: js
|
||||||
|
|
||||||
Components.utils.import("resource://gre/modules/AppConstants.jsm");
|
|
||||||
Cu.import("resource://gre/modules/AppConstants.jsm");
|
|
||||||
ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
|
ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
|
||||||
|
|
||||||
ChromeUtils.defineModuleGetter(
|
ChromeUtils.defineModuleGetter(
|
||||||
obj, "AppConstants", "resource://gre/modules/AppConstants.jsm");
|
obj, "AppConstants", "resource://gre/modules/AppConstants.jsm");
|
||||||
XPCOMUtils.defineLazyModuleGetter(
|
|
||||||
obj, "AppConstants", "resource://gre/modules/AppConstants.jsm");
|
|
||||||
XPCOMUtils.defineLazyModuleGetters(
|
XPCOMUtils.defineLazyModuleGetters(
|
||||||
obj, { AppConstants: "resource://gre/modules/AppConstants.jsm" });
|
obj, { AppConstants: "resource://gre/modules/AppConstants.jsm" });
|
||||||
|
|
||||||
|
@ -15,11 +15,6 @@ Examples of incorrect code for this rule:
|
|||||||
XPCOMUtils.defineLazyModuleGetters(lazy, {
|
XPCOMUtils.defineLazyModuleGetters(lazy, {
|
||||||
XPCOMUtils: "resource://gre/modules/XPCOMUtils.jsm",
|
XPCOMUtils: "resource://gre/modules/XPCOMUtils.jsm",
|
||||||
});
|
});
|
||||||
XPCOMUtils.defineLazyModuleGetter(
|
|
||||||
lazy,
|
|
||||||
"AppConstants",
|
|
||||||
"resource://gre/modules/AppConstants.jsm",
|
|
||||||
});
|
|
||||||
|
|
||||||
Examples of correct code for this rule:
|
Examples of correct code for this rule:
|
||||||
---------------------------------------
|
---------------------------------------
|
||||||
|
@ -19,8 +19,8 @@ Examples of incorrect code for this rule:
|
|||||||
|
|
||||||
.. code-block:: js
|
.. code-block:: js
|
||||||
|
|
||||||
XPCOMUtils.defineLazyModuleGetter(globalThis, "foo", "foo.jsm");
|
ChromeUtils.defineESModuleGetters(globalThis, { foo: "foo.sys.mjs" });
|
||||||
XPCOMUtils.defineLazyModuleGetter(window, "foo", "foo.jsm");
|
ChromeUtils.defineESModuleGetters(window, { "foo": "foo.sys.mjs" });
|
||||||
XPCOMUtils.defineLazyGetter(globalThis, "foo", () => {});
|
XPCOMUtils.defineLazyGetter(globalThis, "foo", () => {});
|
||||||
XPCOMUtils.defineLazyGetter(window, "foo", () => {});
|
XPCOMUtils.defineLazyGetter(window, "foo", () => {});
|
||||||
ChromeUtils.defineLazyGetter(globalThis, "foo", () => {});
|
ChromeUtils.defineLazyGetter(globalThis, "foo", () => {});
|
||||||
|
@ -10,7 +10,7 @@ Examples of incorrect code for this rule:
|
|||||||
.. code-block:: js
|
.. code-block:: js
|
||||||
|
|
||||||
const { SomeProp } = ChromeUtils.import("resource://gre/modules/Foo.jsm");
|
const { SomeProp } = ChromeUtils.import("resource://gre/modules/Foo.jsm");
|
||||||
XPCOMUtils.defineLazyModuleGetter(lazy, {
|
ChromeUtils.defineLazyModuleGetters(lazy, {
|
||||||
OtherProp: "resource://gre/modules/Foo.jsm",
|
OtherProp: "resource://gre/modules/Foo.jsm",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -18,14 +18,12 @@ const callExpressionDefinitions = [
|
|||||||
/^loader\.lazyServiceGetter\((?:globalThis|this), "(\w+)"/,
|
/^loader\.lazyServiceGetter\((?:globalThis|this), "(\w+)"/,
|
||||||
/^loader\.lazyRequireGetter\((?:globalThis|this), "(\w+)"/,
|
/^loader\.lazyRequireGetter\((?:globalThis|this), "(\w+)"/,
|
||||||
/^XPCOMUtils\.defineLazyGetter\((?:globalThis|this), "(\w+)"/,
|
/^XPCOMUtils\.defineLazyGetter\((?:globalThis|this), "(\w+)"/,
|
||||||
/^XPCOMUtils\.defineLazyModuleGetter\((?:globalThis|this), "(\w+)"/,
|
|
||||||
/^ChromeUtils\.defineLazyGetter\((?:globalThis|this), "(\w+)"/,
|
/^ChromeUtils\.defineLazyGetter\((?:globalThis|this), "(\w+)"/,
|
||||||
/^ChromeUtils\.defineModuleGetter\((?:globalThis|this), "(\w+)"/,
|
/^ChromeUtils\.defineModuleGetter\((?:globalThis|this), "(\w+)"/,
|
||||||
/^XPCOMUtils\.defineLazyPreferenceGetter\((?:globalThis|this), "(\w+)"/,
|
/^XPCOMUtils\.defineLazyPreferenceGetter\((?:globalThis|this), "(\w+)"/,
|
||||||
/^XPCOMUtils\.defineLazyScriptGetter\((?:globalThis|this), "(\w+)"/,
|
/^XPCOMUtils\.defineLazyScriptGetter\((?:globalThis|this), "(\w+)"/,
|
||||||
/^XPCOMUtils\.defineLazyServiceGetter\((?:globalThis|this), "(\w+)"/,
|
/^XPCOMUtils\.defineLazyServiceGetter\((?:globalThis|this), "(\w+)"/,
|
||||||
/^XPCOMUtils\.defineConstant\((?:globalThis|this), "(\w+)"/,
|
/^XPCOMUtils\.defineConstant\((?:globalThis|this), "(\w+)"/,
|
||||||
/^DevToolsUtils\.defineLazyModuleGetter\((?:globalThis|this), "(\w+)"/,
|
|
||||||
/^DevToolsUtils\.defineLazyGetter\((?:globalThis|this), "(\w+)"/,
|
/^DevToolsUtils\.defineLazyGetter\((?:globalThis|this), "(\w+)"/,
|
||||||
/^Object\.defineProperty\((?:globalThis|this), "(\w+)"/,
|
/^Object\.defineProperty\((?:globalThis|this), "(\w+)"/,
|
||||||
/^Reflect\.defineProperty\((?:globalThis|this), "(\w+)"/,
|
/^Reflect\.defineProperty\((?:globalThis|this), "(\w+)"/,
|
||||||
|
@ -49,10 +49,7 @@ module.exports = {
|
|||||||
let { callee } = node;
|
let { callee } = node;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
(isMemberExpression(callee.object, "Components", "utils") ||
|
(isIdentifier(callee.object, "ChromeUtils") ||
|
||||||
isIdentifier(callee.object, "Cu") ||
|
|
||||||
isMemberExpression(callee.object, "SpecialPowers", "Cu") ||
|
|
||||||
isIdentifier(callee.object, "ChromeUtils") ||
|
|
||||||
isMemberExpression(
|
isMemberExpression(
|
||||||
callee.object,
|
callee.object,
|
||||||
"SpecialPowers",
|
"SpecialPowers",
|
||||||
@ -70,7 +67,6 @@ module.exports = {
|
|||||||
(isMemberExpression(callee.object, "SpecialPowers", "ChromeUtils") &&
|
(isMemberExpression(callee.object, "SpecialPowers", "ChromeUtils") &&
|
||||||
isIdentifier(callee.property, "defineModuleGetter")) ||
|
isIdentifier(callee.property, "defineModuleGetter")) ||
|
||||||
isMemberExpression(callee, "ChromeUtils", "defineModuleGetter") ||
|
isMemberExpression(callee, "ChromeUtils", "defineModuleGetter") ||
|
||||||
isMemberExpression(callee, "XPCOMUtils", "defineLazyModuleGetter") ||
|
|
||||||
isMemberExpression(callee, "XPCOMUtils", "defineLazyModuleGetters")
|
isMemberExpression(callee, "XPCOMUtils", "defineLazyModuleGetters")
|
||||||
) {
|
) {
|
||||||
context.report({
|
context.report({
|
||||||
|
@ -59,10 +59,7 @@ module.exports = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (callerSource === "ChromeUtils.defineModuleGetter") {
|
||||||
callerSource === "XPCOMUtils.defineLazyModuleGetter" ||
|
|
||||||
callerSource === "ChromeUtils.defineModuleGetter"
|
|
||||||
) {
|
|
||||||
if (node.arguments.length < 3) {
|
if (node.arguments.length < 3) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -13,14 +13,12 @@ const callExpressionDefinitions = [
|
|||||||
/^loader\.lazyServiceGetter\((?:globalThis|window), "(\w+)"/,
|
/^loader\.lazyServiceGetter\((?:globalThis|window), "(\w+)"/,
|
||||||
/^loader\.lazyRequireGetter\((?:globalThis|window), "(\w+)"/,
|
/^loader\.lazyRequireGetter\((?:globalThis|window), "(\w+)"/,
|
||||||
/^XPCOMUtils\.defineLazyGetter\((?:globalThis|window), "(\w+)"/,
|
/^XPCOMUtils\.defineLazyGetter\((?:globalThis|window), "(\w+)"/,
|
||||||
/^XPCOMUtils\.defineLazyModuleGetter\((?:globalThis|window), "(\w+)"/,
|
|
||||||
/^ChromeUtils\.defineLazyGetter\((?:globalThis|window), "(\w+)"/,
|
/^ChromeUtils\.defineLazyGetter\((?:globalThis|window), "(\w+)"/,
|
||||||
/^ChromeUtils\.defineModuleGetter\((?:globalThis|window), "(\w+)"/,
|
/^ChromeUtils\.defineModuleGetter\((?:globalThis|window), "(\w+)"/,
|
||||||
/^XPCOMUtils\.defineLazyPreferenceGetter\((?:globalThis|window), "(\w+)"/,
|
/^XPCOMUtils\.defineLazyPreferenceGetter\((?:globalThis|window), "(\w+)"/,
|
||||||
/^XPCOMUtils\.defineLazyScriptGetter\((?:globalThis|window), "(\w+)"/,
|
/^XPCOMUtils\.defineLazyScriptGetter\((?:globalThis|window), "(\w+)"/,
|
||||||
/^XPCOMUtils\.defineLazyServiceGetter\((?:globalThis|window), "(\w+)"/,
|
/^XPCOMUtils\.defineLazyServiceGetter\((?:globalThis|window), "(\w+)"/,
|
||||||
/^XPCOMUtils\.defineConstant\((?:globalThis|window), "(\w+)"/,
|
/^XPCOMUtils\.defineConstant\((?:globalThis|window), "(\w+)"/,
|
||||||
/^DevToolsUtils\.defineLazyModuleGetter\((?:globalThis|window), "(\w+)"/,
|
|
||||||
/^DevToolsUtils\.defineLazyGetter\((?:globalThis|window), "(\w+)"/,
|
/^DevToolsUtils\.defineLazyGetter\((?:globalThis|window), "(\w+)"/,
|
||||||
/^Object\.defineProperty\((?:globalThis|window), "(\w+)"/,
|
/^Object\.defineProperty\((?:globalThis|window), "(\w+)"/,
|
||||||
/^Reflect\.defineProperty\((?:globalThis|window), "(\w+)"/,
|
/^Reflect\.defineProperty\((?:globalThis|window), "(\w+)"/,
|
||||||
|
@ -90,10 +90,7 @@ module.exports = {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (callerSource === "ChromeUtils.defineModuleGetter") {
|
||||||
callerSource === "XPCOMUtils.defineLazyModuleGetter" ||
|
|
||||||
callerSource === "ChromeUtils.defineModuleGetter"
|
|
||||||
) {
|
|
||||||
if (node.arguments.length < 3) {
|
if (node.arguments.length < 3) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -26,14 +26,12 @@ const callExpressionDefinitions = [
|
|||||||
/^loader\.lazyRequireGetter\(lazy, "(\w+)"/,
|
/^loader\.lazyRequireGetter\(lazy, "(\w+)"/,
|
||||||
/^XPCOMUtils\.defineLazyGetter\(lazy, "(\w+)"/,
|
/^XPCOMUtils\.defineLazyGetter\(lazy, "(\w+)"/,
|
||||||
/^Integration\.downloads\.defineESModuleGetter\(lazy, "(\w+)"/,
|
/^Integration\.downloads\.defineESModuleGetter\(lazy, "(\w+)"/,
|
||||||
/^XPCOMUtils\.defineLazyModuleGetter\(lazy, "(\w+)"/,
|
|
||||||
/^ChromeUtils\.defineLazyGetter\(lazy, "(\w+)"/,
|
/^ChromeUtils\.defineLazyGetter\(lazy, "(\w+)"/,
|
||||||
/^ChromeUtils\.defineModuleGetter\(lazy, "(\w+)"/,
|
/^ChromeUtils\.defineModuleGetter\(lazy, "(\w+)"/,
|
||||||
/^XPCOMUtils\.defineLazyPreferenceGetter\(lazy, "(\w+)"/,
|
/^XPCOMUtils\.defineLazyPreferenceGetter\(lazy, "(\w+)"/,
|
||||||
/^XPCOMUtils\.defineLazyScriptGetter\(lazy, "(\w+)"/,
|
/^XPCOMUtils\.defineLazyScriptGetter\(lazy, "(\w+)"/,
|
||||||
/^XPCOMUtils\.defineLazyServiceGetter\(lazy, "(\w+)"/,
|
/^XPCOMUtils\.defineLazyServiceGetter\(lazy, "(\w+)"/,
|
||||||
/^XPCOMUtils\.defineConstant\(lazy, "(\w+)"/,
|
/^XPCOMUtils\.defineConstant\(lazy, "(\w+)"/,
|
||||||
/^DevToolsUtils\.defineLazyModuleGetter\(lazy, "(\w+)"/,
|
|
||||||
/^DevToolsUtils\.defineLazyGetter\(lazy, "(\w+)"/,
|
/^DevToolsUtils\.defineLazyGetter\(lazy, "(\w+)"/,
|
||||||
/^Object\.defineProperty\(lazy, "(\w+)"/,
|
/^Object\.defineProperty\(lazy, "(\w+)"/,
|
||||||
/^Reflect\.defineProperty\(lazy, "(\w+)"/,
|
/^Reflect\.defineProperty\(lazy, "(\w+)"/,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "eslint-plugin-mozilla",
|
"name": "eslint-plugin-mozilla",
|
||||||
"version": "3.2.0",
|
"version": "3.3.0",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "eslint-plugin-mozilla",
|
"name": "eslint-plugin-mozilla",
|
||||||
"version": "3.2.0",
|
"version": "3.3.0",
|
||||||
"description": "A collection of rules that help enforce JavaScript coding standard in the Mozilla project.",
|
"description": "A collection of rules that help enforce JavaScript coding standard in the Mozilla project.",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"eslint",
|
"eslint",
|
||||||
|
@ -36,22 +36,10 @@ ruleTester.run("reject-chromeutils-import", rule, {
|
|||||||
'ChromeUtils.defineESModuleGetters(obj, { My: "resource://some/path/to/My.sys.mjs" })',
|
'ChromeUtils.defineESModuleGetters(obj, { My: "resource://some/path/to/My.sys.mjs" })',
|
||||||
],
|
],
|
||||||
invalid: [
|
invalid: [
|
||||||
{
|
|
||||||
code: 'Components.utils.import("resource://some/path/to/My.jsm")',
|
|
||||||
errors: invalidError,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
code: 'Cu.import("resource://some/path/to/My.jsm")',
|
|
||||||
errors: invalidError,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
code: 'ChromeUtils.import("resource://some/path/to/My.jsm")',
|
code: 'ChromeUtils.import("resource://some/path/to/My.jsm")',
|
||||||
errors: invalidError,
|
errors: invalidError,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
code: 'SpecialPowers.Cu.import("resource://some/path/to/My.jsm")',
|
|
||||||
errors: invalidError,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
code: 'SpecialPowers.ChromeUtils.import("resource://some/path/to/My.jsm")',
|
code: 'SpecialPowers.ChromeUtils.import("resource://some/path/to/My.jsm")',
|
||||||
errors: invalidError,
|
errors: invalidError,
|
||||||
@ -64,10 +52,6 @@ ruleTester.run("reject-chromeutils-import", rule, {
|
|||||||
code: 'SpecialPowers.ChromeUtils.defineModuleGetter(obj, "My", "resource://some/path/to/My.jsm")',
|
code: 'SpecialPowers.ChromeUtils.defineModuleGetter(obj, "My", "resource://some/path/to/My.jsm")',
|
||||||
errors: invalidErrorLazy,
|
errors: invalidErrorLazy,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
code: 'XPCOMUtils.defineLazyModuleGetter(obj, "My", "resource://some/path/to/My.jsm")',
|
|
||||||
errors: invalidErrorLazy,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
code: 'XPCOMUtils.defineLazyModuleGetters(obj, { My: "resource://some/path/to/My.jsm" })',
|
code: 'XPCOMUtils.defineLazyModuleGetters(obj, { My: "resource://some/path/to/My.jsm" })',
|
||||||
errors: invalidErrorLazy,
|
errors: invalidErrorLazy,
|
||||||
|
@ -22,11 +22,6 @@ function invalidCode(code, uri) {
|
|||||||
|
|
||||||
ruleTester.run("reject-eager-module-in-lazy-getter", rule, {
|
ruleTester.run("reject-eager-module-in-lazy-getter", rule, {
|
||||||
valid: [
|
valid: [
|
||||||
`
|
|
||||||
XPCOMUtils.defineLazyModuleGetter(
|
|
||||||
lazy, "Integration", "resource://gre/modules/Integration.jsm"
|
|
||||||
);
|
|
||||||
`,
|
|
||||||
`
|
`
|
||||||
ChromeUtils.defineModuleGetter(
|
ChromeUtils.defineModuleGetter(
|
||||||
lazy, "Integration", "resource://gre/modules/Integration.jsm"
|
lazy, "Integration", "resource://gre/modules/Integration.jsm"
|
||||||
@ -44,14 +39,6 @@ ruleTester.run("reject-eager-module-in-lazy-getter", rule, {
|
|||||||
`,
|
`,
|
||||||
],
|
],
|
||||||
invalid: [
|
invalid: [
|
||||||
invalidCode(
|
|
||||||
`
|
|
||||||
XPCOMUtils.defineLazyModuleGetter(
|
|
||||||
lazy, "AppConstants", "resource://gre/modules/AppConstants.jsm"
|
|
||||||
);
|
|
||||||
`,
|
|
||||||
"resource://gre/modules/AppConstants.jsm"
|
|
||||||
),
|
|
||||||
invalidCode(
|
invalidCode(
|
||||||
`
|
`
|
||||||
ChromeUtils.defineModuleGetter(
|
ChromeUtils.defineModuleGetter(
|
||||||
|
@ -70,11 +70,6 @@ ruleTester.run("reject-globalThis-modification", rule, {
|
|||||||
ChromeUtils.defineESMGetters(globalThis, {
|
ChromeUtils.defineESMGetters(globalThis, {
|
||||||
AppConstants: "resource://gre/modules/AppConstants.sys.mjs",
|
AppConstants: "resource://gre/modules/AppConstants.sys.mjs",
|
||||||
});
|
});
|
||||||
`),
|
|
||||||
invalidCall(`
|
|
||||||
XPCOMUtils.defineLazyModuleGetter(
|
|
||||||
globalThis, "AppConstants", "resource://gre/modules/AppConstants.jsm"
|
|
||||||
);
|
|
||||||
`),
|
`),
|
||||||
invalidCall(`
|
invalidCall(`
|
||||||
XPCOMUtils.defineLazyModuleGetters(globalThis, {
|
XPCOMUtils.defineLazyModuleGetters(globalThis, {
|
||||||
|
@ -38,10 +38,6 @@ ruleTester.run("reject-lazy-imports-into-globals", rule, {
|
|||||||
invalidCode(`XPCOMUtils.defineLazyGetter(window, "foo", () => {});`),
|
invalidCode(`XPCOMUtils.defineLazyGetter(window, "foo", () => {});`),
|
||||||
invalidCode(`ChromeUtils.defineLazyGetter(globalThis, "foo", () => {});`),
|
invalidCode(`ChromeUtils.defineLazyGetter(globalThis, "foo", () => {});`),
|
||||||
invalidCode(`ChromeUtils.defineLazyGetter(window, "foo", () => {});`),
|
invalidCode(`ChromeUtils.defineLazyGetter(window, "foo", () => {});`),
|
||||||
invalidCode(
|
|
||||||
`XPCOMUtils.defineLazyModuleGetter(globalThis, "foo", "foo.jsm");`
|
|
||||||
),
|
|
||||||
invalidCode(`XPCOMUtils.defineLazyModuleGetter(window, "foo", "foo.jsm");`),
|
|
||||||
invalidCode(
|
invalidCode(
|
||||||
`XPCOMUtils.defineLazyPreferenceGetter(globalThis, "foo", "foo.bar");`
|
`XPCOMUtils.defineLazyPreferenceGetter(globalThis, "foo", "foo.bar");`
|
||||||
),
|
),
|
||||||
|
@ -32,11 +32,6 @@ ruleTester.run("reject-mixing-eager-and-lazy", rule, {
|
|||||||
`,
|
`,
|
||||||
`
|
`
|
||||||
import{ AppConstants } from "resource://gre/modules/AppConstants.sys.mjs";
|
import{ AppConstants } from "resource://gre/modules/AppConstants.sys.mjs";
|
||||||
`,
|
|
||||||
`
|
|
||||||
XPCOMUtils.defineLazyModuleGetter(
|
|
||||||
lazy, "AppConstants", "resource://gre/modules/AppConstants.jsm"
|
|
||||||
);
|
|
||||||
`,
|
`,
|
||||||
`
|
`
|
||||||
ChromeUtils.defineModuleGetter(
|
ChromeUtils.defineModuleGetter(
|
||||||
@ -57,15 +52,9 @@ ruleTester.run("reject-mixing-eager-and-lazy", rule, {
|
|||||||
if (some_condition) {
|
if (some_condition) {
|
||||||
ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
|
ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
|
||||||
}
|
}
|
||||||
XPCOMUtils.defineLazyModuleGetter(
|
XPCOMUtils.defineLazyModuleGetters(lazy, {
|
||||||
lazy, "AppConstants", "resource://gre/modules/AppConstants.jsm"
|
AppConstants: "resource://gre/modules/AppConstants.jsm"
|
||||||
);
|
});
|
||||||
`,
|
|
||||||
`
|
|
||||||
ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
|
|
||||||
XPCOMUtils.defineLazyModuleGetter(
|
|
||||||
sandbox, "AppConstants", "resource://gre/modules/AppConstants.jsm"
|
|
||||||
);
|
|
||||||
`,
|
`,
|
||||||
`
|
`
|
||||||
ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
|
ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
|
||||||
@ -75,15 +64,6 @@ ruleTester.run("reject-mixing-eager-and-lazy", rule, {
|
|||||||
`,
|
`,
|
||||||
],
|
],
|
||||||
invalid: [
|
invalid: [
|
||||||
invalidCode(
|
|
||||||
`
|
|
||||||
ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
|
|
||||||
XPCOMUtils.defineLazyModuleGetter(
|
|
||||||
lazy, "AppConstants", "resource://gre/modules/AppConstants.jsm"
|
|
||||||
);
|
|
||||||
`,
|
|
||||||
"resource://gre/modules/AppConstants.jsm"
|
|
||||||
),
|
|
||||||
invalidCode(
|
invalidCode(
|
||||||
`
|
`
|
||||||
ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
|
ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
|
||||||
|
@ -34,13 +34,6 @@ ruleTester.run("valid-lazy", rule, {
|
|||||||
ChromeUtils.defineLazyGetter(lazy, "foo", () => {});
|
ChromeUtils.defineLazyGetter(lazy, "foo", () => {});
|
||||||
if (x) { lazy.foo.bar(); }
|
if (x) { lazy.foo.bar(); }
|
||||||
`,
|
`,
|
||||||
`
|
|
||||||
const lazy = {};
|
|
||||||
XPCOMUtils.defineLazyModuleGetters(lazy, {
|
|
||||||
foo: "foo.jsm",
|
|
||||||
});
|
|
||||||
if (x) { lazy.foo.bar(); }
|
|
||||||
`,
|
|
||||||
`
|
`
|
||||||
const lazy = {};
|
const lazy = {};
|
||||||
ChromeUtils.defineESModuleGetters(lazy, {
|
ChromeUtils.defineESModuleGetters(lazy, {
|
||||||
|
Loading…
Reference in New Issue
Block a user