Skip to content

Commit

Permalink
tools: enforce loading required modules first
Browse files Browse the repository at this point in the history
  • Loading branch information
Trott committed Jul 22, 2016
1 parent 6123075 commit bc591e9
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions tools/eslint-rules/required-modules.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**
* @fileoverview Require usage of specified node modules.
* @fileoverview Require usage of specified node modules before any other
* modules are loaded.
* @author Rich Trott
*/
'use strict';
Expand Down Expand Up @@ -63,11 +64,16 @@ module.exports = function(context) {

return {
'CallExpression': function(node) {
if (isRequireCall(node)) {
if (isRequireCall(node) && foundModules.length < requiredModules.length) {
var requiredModuleName = getRequiredModuleName(node);

if (requiredModuleName) {
foundModules.push(requiredModuleName);
} else {
context.report(
node,
'Module loaded before all required modules loaded.'
);
}
}
},
Expand All @@ -89,11 +95,3 @@ module.exports = function(context) {
}
};
};

module.exports.schema = {
'type': 'array',
'additionalItems': {
'type': 'string'
},
'uniqueItems': true
};

0 comments on commit bc591e9

Please sign in to comment.