]> git.proxmox.com Git - pve-eslint.git/blob - eslint/lib/rules/no-caller.js
import 8.3.0 source
[pve-eslint.git] / eslint / lib / rules / no-caller.js
1 /**
2 * @fileoverview Rule to flag use of arguments.callee and arguments.caller.
3 * @author Nicholas C. Zakas
4 */
5
6 "use strict";
7
8 //------------------------------------------------------------------------------
9 // Rule Definition
10 //------------------------------------------------------------------------------
11
12 module.exports = {
13 meta: {
14 type: "suggestion",
15
16 docs: {
17 description: "disallow the use of `arguments.caller` or `arguments.callee`",
18 recommended: false,
19 url: "https://eslint.org/docs/rules/no-caller"
20 },
21
22 schema: [],
23
24 messages: {
25 unexpected: "Avoid arguments.{{prop}}."
26 }
27 },
28
29 create(context) {
30
31 return {
32
33 MemberExpression(node) {
34 const objectName = node.object.name,
35 propertyName = node.property.name;
36
37 if (objectName === "arguments" && !node.computed && propertyName && propertyName.match(/^calle[er]$/u)) {
38 context.report({ node, messageId: "unexpected", data: { prop: propertyName } });
39 }
40
41 }
42 };
43
44 }
45 };