diff options
Diffstat (limited to 'tools/eslint/lib/rules/no-sync.js')
-rw-r--r-- | tools/eslint/lib/rules/no-sync.js | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/tools/eslint/lib/rules/no-sync.js b/tools/eslint/lib/rules/no-sync.js index 885b1eb628..06305969a1 100644 --- a/tools/eslint/lib/rules/no-sync.js +++ b/tools/eslint/lib/rules/no-sync.js @@ -19,14 +19,26 @@ module.exports = { recommended: false }, - schema: [] + schema: [ + { + type: "object", + properties: { + allowAtRootLevel: { + type: "boolean" + } + }, + additionalProperties: false + } + ] }, create(context) { + const selector = context.options[0] && context.options[0].allowAtRootLevel + ? ":function MemberExpression[property.name=/.*Sync$/]" + : "MemberExpression[property.name=/.*Sync$/]"; return { - - "MemberExpression[property.name=/.*Sync$/]"(node) { + [selector](node) { context.report({ node, message: "Unexpected sync method: '{{propertyName}}'.", |