UNPKG

763 BJavaScriptView Raw
1/**
2 * @fileoverview Rule to flag use of arguments.callee and arguments.caller.
3 * @author Nicholas C. Zakas
4 */
5
6//------------------------------------------------------------------------------
7// Rule Definition
8//------------------------------------------------------------------------------
9
10module.exports = function(context) {
11
12 "use strict";
13
14 return {
15
16 "MemberExpression": function(node) {
17 var objectName = node.object.name,
18 propertyName = node.property.name;
19
20 if (objectName === "arguments" && !node.computed && propertyName && propertyName.match(/^calle[er]$/)) {
21 context.report(node, "Avoid arguments.{{property}}.", { property: propertyName });
22 }
23
24 }
25 };
26
27};