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