1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | "use strict";
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | module.exports = {
|
13 | meta: {
|
14 | type: "problem",
|
15 |
|
16 | docs: {
|
17 | description: "disallow calling global object properties as functions",
|
18 | category: "Possible Errors",
|
19 | recommended: true,
|
20 | url: "https://eslint.org/docs/rules/no-obj-calls"
|
21 | },
|
22 |
|
23 | schema: []
|
24 | },
|
25 |
|
26 | create(context) {
|
27 |
|
28 | return {
|
29 | CallExpression(node) {
|
30 |
|
31 | if (node.callee.type === "Identifier") {
|
32 | const name = node.callee.name;
|
33 |
|
34 | if (name === "Math" || name === "JSON" || name === "Reflect") {
|
35 | context.report({ node, message: "'{{name}}' is not a function.", data: { name } });
|
36 | }
|
37 | }
|
38 | }
|
39 | };
|
40 |
|
41 | }
|
42 | };
|