Sha256: 35c22bc1cdf7cac9c76c0b29256f500383c20f0723c3290e2ec8a9ea3092cc77
Contents?: true
Size: 1.66 KB
Versions: 2
Compression:
Stored size: 1.66 KB
Contents
/** * @fileoverview Disallow shadowing of NaN, undefined, and Infinity (ES5 section 15.1.1) * @author Michael Ficarra * @copyright 2013 Michael Ficarra. All rights reserved. */ "use strict"; //------------------------------------------------------------------------------ // Rule Definition //------------------------------------------------------------------------------ module.exports = function(context) { var RESTRICTED = ["undefined", "NaN", "Infinity", "arguments", "eval"]; /** * Check if the node name is present inside the restricted list * @param {ASTNode} id id to evaluate * @returns {void} * @private */ function checkForViolation(id) { if (RESTRICTED.indexOf(id.name) > -1) { context.report(id, "Shadowing of global property \"" + id.name + "\"."); } } return { "VariableDeclarator": function(node) { checkForViolation(node.id); }, "ArrowFunctionExpression": function(node) { if (node.id) { checkForViolation(node.id); } [].map.call(node.params, checkForViolation); }, "FunctionExpression": function(node) { if (node.id) { checkForViolation(node.id); } [].map.call(node.params, checkForViolation); }, "FunctionDeclaration": function(node) { if (node.id) { checkForViolation(node.id); [].map.call(node.params, checkForViolation); } }, "CatchClause": function(node) { checkForViolation(node.param); } }; }; module.exports.schema = [];
Version data entries
2 entries across 2 versions & 1 rubygems