Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
eventGenerator = new CommentEventGenerator(eventGenerator, sourceCode);
/*
* Each node has a type property. Whenever a particular type of node is found,
* an event is fired. This allows any listeners to automatically be informed
* that this type of node has been found and react accordingly.
*/
controller.traverse(ast, {
enter: function(node, parent) {
node.parent = parent;
eventGenerator.enterNode(node);
},
leave: function(node) {
eventGenerator.leaveNode(node);
},
keys: espree.VisitorKeys
});
}
// sort by line and column
messages.sort(function(a, b) {
var lineDiff = a.line - b.line;
if (lineDiff === 0) {
return a.column - b.column;
} else {
return lineDiff;
}
});
return messages;
};
// save config so rules can access as necessary
currentConfig = config;
controller = new estraverse.Controller();
ecmaFeatures = currentConfig.parserOptions.ecmaFeatures || {};
ecmaVersion = currentConfig.parserOptions.ecmaVersion || 5;
// gather data that may be needed by the rules
scopeManager = escope.analyze(ast, {
ignoreEval: true,
nodejsScope: ecmaFeatures.globalReturn,
impliedStrict: ecmaFeatures.impliedStrict,
ecmaVersion: ecmaVersion,
sourceType: currentConfig.parserOptions.sourceType || "script",
childVisitorKeys: espree.VisitorKeys,
fallback: "none"
});
currentScopes = scopeManager.scopes;
/*
* Index the scopes by the start range of their block for efficient
* lookup in getScope.
*/
scopeMap = [];
currentScopes.forEach(function(scope, index) {
var range = scope.block.range[0];
// Sometimes two scopes are returned for a given node. This is
// handled later in a known way, so just don't overwrite here.
if (!scopeMap[range]) {
scopeMap[range] = index;