Sha256: a107c910e01b77e4a9f5bb3436e648a899601741dc968f7e61215d7c8bdae2f8
Contents?: true
Size: 930 Bytes
Versions: 2
Compression:
Stored size: 930 Bytes
Contents
/** * @fileoverview Rule for disallowing require() outside of the top-level module context * @author Jamund Ferguson * @copyright 2015 Jamund Ferguson. All rights reserved. */ "use strict"; var ACCEPTABLE_PARENTS = [ "AssignmentExpression", "VariableDeclarator", "MemberExpression", "ExpressionStatement", "CallExpression", "ConditionalExpression", "Program", "VariableDeclaration" ]; module.exports = function(context) { return { "CallExpression": function(node) { if (node.callee.name === "require") { var isGoodRequire = context.getAncestors().every(function(parent) { return ACCEPTABLE_PARENTS.indexOf(parent.type) > -1; }); if (!isGoodRequire) { context.report(node, "Unexpected require()."); } } } }; }; module.exports.schema = [];
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
eslint_node_modules-1.6.0.1 | vendor/node_modules/eslint/lib/rules/global-require.js |
eslint_node_modules-1.6.0 | vendor/node_modules/eslint/lib/rules/global-require.js |