Skip to content

Commit 041bcfc

Browse files
Merge pull request #2707 from johanrd/fix/template-no-implicit-this-regex-allow
Post-merge-review: template-no-implicit-this support regex patterns in allow option
2 parents 8d8490b + 659f485 commit 041bcfc

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

lib/rules/template-no-implicit-this.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ module.exports = {
108108
properties: {
109109
allow: {
110110
type: 'array',
111-
items: { type: 'string' },
112-
uniqueItems: true,
111+
items: { anyOf: [{ type: 'string' }, { instanceof: 'RegExp' }] },
112+
uniqueItems: false,
113113
},
114114
},
115115
additionalProperties: false,
@@ -145,8 +145,8 @@ module.exports = {
145145
return;
146146
}
147147

148-
// Skip paths matching the allow list (exact match only)
149-
if (allowList.includes(path)) {
148+
// Skip paths matching the allow list (exact string or regex)
149+
if (allowList.some((item) => (item instanceof RegExp ? item.test(path) : item === path))) {
150150
return;
151151
}
152152

tests/lib/rules/template-no-implicit-this.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,11 @@ hbsRuleTester.run('template-no-implicit-this', rule, {
204204
code: '{{book-details}}',
205205
options: [{ allow: ['book-details'] }],
206206
},
207+
// Allow config option — regex pattern
208+
{
209+
code: '{{data-test-foo}}',
210+
options: [{ allow: [/^data-test-.+/] }],
211+
},
207212
],
208213
invalid: [
209214
{

0 commit comments

Comments
 (0)