1 |
|
2 |
|
3 |
|
4 |
|
5 | "use strict";
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | module.exports = function(context) {
|
12 |
|
13 | var RESTRICTED = ["undefined", "NaN", "Infinity", "arguments", "eval"];
|
14 |
|
15 | function checkForViolation(id) {
|
16 | if(RESTRICTED.indexOf(id.name) > -1) {
|
17 | context.report(id, "Shadowing of global property \"" + id.name + "\".");
|
18 | }
|
19 | }
|
20 |
|
21 | return {
|
22 | "VariableDeclarator": function(node) {
|
23 | checkForViolation(node.id);
|
24 | },
|
25 | "FunctionExpression": function(node) {
|
26 | if(node.id) { checkForViolation(node.id); }
|
27 | [].map.call(node.params, checkForViolation);
|
28 | },
|
29 | "FunctionDeclaration": function(node) {
|
30 | checkForViolation(node.id);
|
31 | [].map.call(node.params, checkForViolation);
|
32 | },
|
33 | "CatchClause": function(node) {
|
34 | checkForViolation(node.param);
|
35 | }
|
36 | };
|
37 |
|
38 | };
|