Skip to content

Commit

Permalink
Chore: removes unnecessary assignment in loop
Browse files Browse the repository at this point in the history
also reduces cyclomatic complexity with a slight reconfiguring of some conditions
  • Loading branch information
dimitropoulos committed May 29, 2019
1 parent d662b17 commit 978fcc5
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lib/linter/node-event-generator.js
Expand Up @@ -221,17 +221,23 @@ class NodeEventGenerator {
const selector = parseSelector(rawSelector);

if (selector.listenerTypes) {
selector.listenerTypes.forEach(nodeType => {
const typeMap = selector.isExit ? this.exitSelectorsByNodeType : this.enterSelectorsByNodeType;
const typeMap = selector.isExit ? this.exitSelectorsByNodeType : this.enterSelectorsByNodeType;

selector.listenerTypes.forEach(nodeType => {
if (!typeMap.has(nodeType)) {
typeMap.set(nodeType, []);
}
typeMap.get(nodeType).push(selector);
});
} else {
(selector.isExit ? this.anyTypeExitSelectors : this.anyTypeEnterSelectors).push(selector);
return;
}

if (selector.isExit) {
this.anyTypeExitSelectors.push(selector);
return;
}

this.anyTypeEnterSelectors.push(selector);
});

this.anyTypeEnterSelectors.sort(compareSpecificity);
Expand Down

0 comments on commit 978fcc5

Please sign in to comment.