UNPKG

764 BJavaScriptView Raw
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"use strict";
7
8//------------------------------------------------------------------------------
9// Rule Definition
10//------------------------------------------------------------------------------
11
12module.exports = function(context) {
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};
27
28module.exports.schema = [];