diff --git a/lib/rules/template-no-let-reference.js b/lib/rules/template-no-let-reference.js index b264da6dcb..107027f8e9 100644 --- a/lib/rules/template-no-let-reference.js +++ b/lib/rules/template-no-let-reference.js @@ -18,8 +18,13 @@ module.exports = { create: (context) => { const sourceCode = context.sourceCode; + const pathname = context.physicalFilename; function checkIfWritableReferences(node, scope) { + // Return if the pathname starts with '/start/' + if (pathname.startsWith('/tests/')) { + return; + } const ref = scope.references.find((v) => v.identifier === node); if (!ref) { return; diff --git a/tests/lib/rules/template-no-let-reference.js b/tests/lib/rules/template-no-let-reference.js index c9399aaf4c..23fd3a80f6 100644 --- a/tests/lib/rules/template-no-let-reference.js +++ b/tests/lib/rules/template-no-let-reference.js @@ -43,6 +43,25 @@ ruleTester.run('template-no-let-reference', rule, { `, + // Test cases for '/tests/' path, to allow let or var in tests directory + { + filename: '/tests/integration/components/simulate-test.js', + code: ` + let a = ''; + + `, + }, + { + filename: '/tests/integration/components/simulate-test.js', + code: ` + var a = ''; + + `, + }, ], invalid: [