Bug 1591013 - Support lazyImporter in reject-some-requires r=Standard8,nchevobbe

Depends on D50466

reject-some-requires only supports require/lazyRequireGetter at the moment
We still have a few call sites for lazyImporter, even though they probably should be
migrated to lazyRequireGetter IMO.

Differential Revision: https://phabricator.services.mozilla.com/D50465

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Julian Descottes 2019-10-30 08:31:16 +00:00
Родитель 4f668cb36e
Коммит c87fb76740
4 изменённых файлов: 8 добавлений и 3 удалений

Просмотреть файл

@ -88,7 +88,7 @@ module.exports = {
"server/**",
],
"rules": {
"mozilla/reject-some-requires": ["error", "^devtools/client"],
"mozilla/reject-some-requires": ["error", "^(resource\://)?devtools/client"],
}
}, {
// Cu, Cc etc... are not available in most devtools modules loaded by require.

Просмотреть файл

@ -68,6 +68,9 @@ loader.lazyRequireGetter(
);
loader.lazyRequireGetter(this, "ObjectFront", "devtools/shared/fronts/object");
// This import to chrome code is forbidden according to the inspector specific
// eslintrc. TODO: Fix in Bug 1591091.
// eslint-disable-next-line mozilla/reject-some-requires
loader.lazyImporter(
this,
"DeferredTask",

Просмотреть файл

@ -8,6 +8,8 @@ const { Ci, Cu } = require("chrome");
// Note that this is only used in WebConsoleCommands, see $0, screenshot and pprint().
if (!isWorker) {
// TODO: Fix this server -> client import in Bug 1591055
// eslint-disable-next-line mozilla/reject-some-requires
loader.lazyImporter(
this,
"VariablesView",
@ -628,7 +630,6 @@ WebConsoleCommands._registerOriginal("pprint", function(owner, object) {
for (const name in obj) {
const desc = WebConsoleUtils.getPropertyDescriptor(obj, name) || {};
if (desc.get || desc.set) {
// TODO: Bug 842672 - toolkit/ imports modules from browser/.
const getGrip = VariablesView.getGrip(desc.get);
const setGrip = VariablesView.getGrip(desc.set);
const getString = VariablesView.getString(getGrip);

Просмотреть файл

@ -40,7 +40,8 @@ module.exports = function(context) {
} else if (
node.callee.type == "MemberExpression" &&
node.callee.property.type == "Identifier" &&
node.callee.property.name == "lazyRequireGetter" &&
(node.callee.property.name == "lazyRequireGetter" ||
node.callee.property.name == "lazyImporter") &&
node.arguments.length >= 3 &&
node.arguments[2].type == "Literal"
) {