mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-22 09:45:41 +00:00
Bug 1464548: Part 2 - Add ESLint support for defineLazyGlobalGetters. r=standard8
MozReview-Commit-ID: 38hk1MquFrg --HG-- extra : rebase_source : 8b418883093e15ed2ae7d052d7f191fc07e93636
This commit is contained in:
parent
a4973ad0d6
commit
4eacff920e
@ -37,6 +37,7 @@ const callExpressionDefinitions = [
|
||||
];
|
||||
|
||||
const callExpressionMultiDefinitions = [
|
||||
"XPCOMUtils.defineLazyGlobalGetters(this,",
|
||||
"XPCOMUtils.defineLazyModuleGetters(this,",
|
||||
"XPCOMUtils.defineLazyServiceGetters(this,"
|
||||
];
|
||||
@ -308,11 +309,18 @@ module.exports = {
|
||||
}
|
||||
|
||||
if (callExpressionMultiDefinitions.some(expr => source.startsWith(expr)) &&
|
||||
node.expression.arguments[1] &&
|
||||
node.expression.arguments[1].type === "ObjectExpression") {
|
||||
return node.expression.arguments[1].properties
|
||||
.map(p => ({ name: p.type === "Property" && p.key.name, writable: true, explicit: true }))
|
||||
.filter(g => g.name);
|
||||
node.expression.arguments[1]) {
|
||||
let arg = node.expression.arguments[1];
|
||||
if (arg.type === "ObjectExpression") {
|
||||
return arg.properties
|
||||
.map(p => ({ name: p.type === "Property" && p.key.name, writable: true, explicit: true }))
|
||||
.filter(g => g.name);
|
||||
}
|
||||
if (arg.type === "ArrayExpression") {
|
||||
return arg.elements
|
||||
.map(p => ({ name: p.type === "Literal" && p.value, writable: true, explicit: true }))
|
||||
.filter(g => typeof g.name == "string");
|
||||
}
|
||||
}
|
||||
|
||||
if (node.expression.callee.type == "MemberExpression" &&
|
||||
|
Loading…
Reference in New Issue
Block a user