Skip to content

Commit 301a489

Browse files
committed
Use Set instead of array
1 parent 45019af commit 301a489

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/rules/jsx-fragments.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ module.exports = {
116116
}
117117

118118
const jsxElements = [];
119-
const fragmentNames = [`${reactPragma}.${fragmentPragma}`];
119+
const fragmentNames = new Set([`${reactPragma}.${fragmentPragma}`]);
120120

121121
// --------------------------------------------------------------------------
122122
// Public
@@ -146,7 +146,7 @@ module.exports = {
146146
node.specifiers.forEach(spec => {
147147
if (spec.imported && spec.imported.name === fragmentPragma) {
148148
if (spec.local) {
149-
fragmentNames.push(spec.local.name);
149+
fragmentNames.add(spec.local.name);
150150
}
151151
}
152152
});
@@ -158,7 +158,7 @@ module.exports = {
158158
const openingEl = node.openingElement;
159159
const elName = elementType(openingEl);
160160

161-
if (fragmentNames.indexOf(elName) !== -1 || refersToReactFragment(elName)) {
161+
if (fragmentNames.has(elName) || refersToReactFragment(elName)) {
162162
if (reportOnReactVersion(node)) {
163163
return;
164164
}

0 commit comments

Comments
 (0)