Skip to content

Commit c5df221

Browse files
committed
refactor: only use regex
1 parent 2336de0 commit c5df221

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

lib/rules/syntaxes/slot-attribute.js

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,11 @@ module.exports = {
1616
/** @type {{ ignore: string[] }} */
1717
const options = context.options[0] || {}
1818
const { ignore = [] } = options
19-
/** @type {Set<string>} */
20-
const ignoreStrings = new Set()
2119
/** @type {RegExp[]} */
2220
const ignorePatterns = []
2321

2422
for (const str of ignore) {
25-
if (regexp.isRegExp(str)) {
26-
ignorePatterns.push(regexp.toRegExp(str))
27-
} else {
28-
ignoreStrings.add(str)
29-
}
23+
ignorePatterns.push(regexp.toRegExp(str))
3024
}
3125

3226
const sourceCode = context.getSourceCode()
@@ -136,15 +130,16 @@ module.exports = {
136130
function reportSlot(slotAttr) {
137131
const componentName = slotAttr.parent.parent.rawName
138132
if (
139-
ignoreStrings.has(componentName) ||
140-
ignoreStrings.has(casing.pascalCase(componentName)) ||
141-
ignoreStrings.has(casing.kebabCase(componentName))
133+
ignorePatterns.some((pattern) => pattern.test(componentName)) ||
134+
ignorePatterns.some((pattern) =>
135+
pattern.test(casing.pascalCase(componentName))
136+
) ||
137+
ignorePatterns.some((pattern) =>
138+
pattern.test(casing.kebabCase(componentName))
139+
)
142140
) {
143141
return
144142
}
145-
if (ignorePatterns.some((pattern) => pattern.test(componentName))) {
146-
return
147-
}
148143

149144
context.report({
150145
node: slotAttr.key,

0 commit comments

Comments
 (0)