diff options
Diffstat (limited to 'tools/node_modules/eslint/lib/rules/no-sync.js')
-rw-r--r-- | tools/node_modules/eslint/lib/rules/no-sync.js | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/tools/node_modules/eslint/lib/rules/no-sync.js b/tools/node_modules/eslint/lib/rules/no-sync.js new file mode 100644 index 0000000000..06305969a1 --- /dev/null +++ b/tools/node_modules/eslint/lib/rules/no-sync.js @@ -0,0 +1,53 @@ +/** + * @fileoverview Rule to check for properties whose identifier ends with the string Sync + * @author Matt DuVall<http://mattduvall.com/> + */ + +/* jshint node:true */ + +"use strict"; + +//------------------------------------------------------------------------------ +// Rule Definition +//------------------------------------------------------------------------------ + +module.exports = { + meta: { + docs: { + description: "disallow synchronous methods", + category: "Node.js and CommonJS", + recommended: false + }, + + 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 { + [selector](node) { + context.report({ + node, + message: "Unexpected sync method: '{{propertyName}}'.", + data: { + propertyName: node.property.name + } + }); + } + }; + + } +}; |