diff --git a/lib/rules/template-no-implicit-this.js b/lib/rules/template-no-implicit-this.js index 00f08aab03..74ab5e2ca2 100644 --- a/lib/rules/template-no-implicit-this.js +++ b/lib/rules/template-no-implicit-this.js @@ -108,8 +108,8 @@ module.exports = { properties: { allow: { type: 'array', - items: { type: 'string' }, - uniqueItems: true, + items: { anyOf: [{ type: 'string' }, { instanceof: 'RegExp' }] }, + uniqueItems: false, }, }, additionalProperties: false, @@ -145,8 +145,8 @@ module.exports = { return; } - // Skip paths matching the allow list (exact match only) - if (allowList.includes(path)) { + // Skip paths matching the allow list (exact string or regex) + if (allowList.some((item) => (item instanceof RegExp ? item.test(path) : item === path))) { return; } diff --git a/tests/lib/rules/template-no-implicit-this.js b/tests/lib/rules/template-no-implicit-this.js index 0871f76cdc..f69482b838 100644 --- a/tests/lib/rules/template-no-implicit-this.js +++ b/tests/lib/rules/template-no-implicit-this.js @@ -204,6 +204,11 @@ hbsRuleTester.run('template-no-implicit-this', rule, { code: '{{book-details}}', options: [{ allow: ['book-details'] }], }, + // Allow config option — regex pattern + { + code: '{{data-test-foo}}', + options: [{ allow: [/^data-test-.+/] }], + }, ], invalid: [ {