Skip to content

Commit c23f0ad

Browse files
committed
feat: add strict option to rule
1 parent 1d7d501 commit c23f0ad

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

lib/rules/no-undef-components.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ module.exports = {
120120
properties: {
121121
ignorePatterns: {
122122
type: 'array'
123+
},
124+
strict: {
125+
type: 'boolean'
123126
}
124127
},
125128
additionalProperties: false
@@ -155,10 +158,15 @@ module.exports = {
155158
return false
156159
}
157160
const pascalCaseName = casing.pascalCase(rawName)
161+
158162
// Check ignored patterns
159163
if (
160164
ignorePatterns.some((pattern) => {
161-
const regExp = new RegExp(pattern)
165+
const regExp = new RegExp(
166+
options.strict === true || options.strict === undefined
167+
? `^${pattern}$`
168+
: pattern
169+
)
162170
return (
163171
regExp.test(rawName) ||
164172
regExp.test(kebabCaseName) ||

tests/lib/rules/no-undef-components.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,7 @@ tester.run('no-undef-components', rule, {
853853
<FooBar />
854854
</template>
855855
`,
856-
options: [{ ignorePatterns: ['Foo'] }],
856+
options: [{ ignorePatterns: ['Foo'], strict: true }],
857857
errors: [
858858
{
859859
message: "The '<FooBar>' component has been used, but not defined.",
@@ -862,17 +862,18 @@ tester.run('no-undef-components', rule, {
862862
]
863863
},
864864

865+
// Default to strict
865866
{
866867
filename: 'test.vue',
867868
code: `
868869
<template>
869-
<Foo />
870+
<FooBar />
870871
</template>
871872
`,
872873
options: [{ ignorePatterns: ['Foo'] }],
873874
errors: [
874875
{
875-
message: "The '<Foo>' component has been used, but not defined.",
876+
message: "The '<FooBar>' component has been used, but not defined.",
876877
line: 3
877878
}
878879
]

0 commit comments

Comments
 (0)