Skip to content

Commit

Permalink
Chore: removes unnecessary assignment in loop (#11780)
Browse files Browse the repository at this point in the history
* Chore: removes unnecessary assignment in loop

also reduces cyclomatic complexity with a slight reconfiguring of some conditions

* uses ternary based on review notes
  • Loading branch information
dimitropoulos authored and ilyavolodin committed Jun 8, 2019
1 parent 20908a3 commit e0fafc8
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/linter/node-event-generator.js
Expand Up @@ -221,17 +221,19 @@ 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;
}
const selectors = selector.isExit ? this.anyTypeExitSelectors : this.anyTypeEnterSelectors;

selectors.push(selector);
});

this.anyTypeEnterSelectors.sort(compareSpecificity);
Expand Down

0 comments on commit e0fafc8

Please sign in to comment.