diff options
Diffstat (limited to 'tools/eslint/lib/rules/no-caller.js')
-rw-r--r-- | tools/eslint/lib/rules/no-caller.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tools/eslint/lib/rules/no-caller.js b/tools/eslint/lib/rules/no-caller.js new file mode 100644 index 0000000000..b489d79c54 --- /dev/null +++ b/tools/eslint/lib/rules/no-caller.js @@ -0,0 +1,27 @@ +/** + * @fileoverview Rule to flag use of arguments.callee and arguments.caller. + * @author Nicholas C. Zakas + */ + +"use strict"; + +//------------------------------------------------------------------------------ +// Rule Definition +//------------------------------------------------------------------------------ + +module.exports = function(context) { + + return { + + "MemberExpression": function(node) { + var objectName = node.object.name, + propertyName = node.property.name; + + if (objectName === "arguments" && !node.computed && propertyName && propertyName.match(/^calle[er]$/)) { + context.report(node, "Avoid arguments.{{property}}.", { property: propertyName }); + } + + } + }; + +}; |