1 | /**
|
2 | * @fileoverview Rule to flag use of an object property of the global object (Math and JSON) as a function
|
3 | * @author James Allardice
|
4 | */
|
5 |
|
6 | //------------------------------------------------------------------------------
|
7 | // Rule Definition
|
8 | //------------------------------------------------------------------------------
|
9 |
|
10 | module.exports = function(context) {
|
11 |
|
12 | ;
|
13 |
|
14 | return {
|
15 | "CallExpression": function(node) {
|
16 |
|
17 | if (node.callee.type === "Identifier") {
|
18 | var name = node.callee.name;
|
19 | if (name === "Math" || name === "JSON") {
|
20 | context.report(node, "'{{name}}' is not a function.", { name: name });
|
21 | }
|
22 | }
|
23 | }
|
24 | };
|
25 |
|
26 | };
|