Skip to content

Commit

Permalink
Use Set instead of array
Browse files Browse the repository at this point in the history
  • Loading branch information
alexzherdev committed Sep 25, 2018
1 parent 45019af commit 301a489
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/rules/jsx-fragments.js
Expand Up @@ -116,7 +116,7 @@ module.exports = {
}

const jsxElements = [];
const fragmentNames = [`${reactPragma}.${fragmentPragma}`];
const fragmentNames = new Set([`${reactPragma}.${fragmentPragma}`]);

// --------------------------------------------------------------------------
// Public
Expand Down Expand Up @@ -146,7 +146,7 @@ module.exports = {
node.specifiers.forEach(spec => {
if (spec.imported && spec.imported.name === fragmentPragma) {
if (spec.local) {
fragmentNames.push(spec.local.name);
fragmentNames.add(spec.local.name);
}
}
});
Expand All @@ -158,7 +158,7 @@ module.exports = {
const openingEl = node.openingElement;
const elName = elementType(openingEl);

if (fragmentNames.indexOf(elName) !== -1 || refersToReactFragment(elName)) {
if (fragmentNames.has(elName) || refersToReactFragment(elName)) {
if (reportOnReactVersion(node)) {
return;
}
Expand Down

0 comments on commit 301a489

Please sign in to comment.