From 6bdd7280ce4c90a8b99482bfaade5117f86626f6 Mon Sep 17 00:00:00 2001 From: Dayo Olutayo Date: Sat, 12 Oct 2024 19:54:19 +0100 Subject: [PATCH 1/2] Fixed #2078: Allow let to be used in the test flies. This allows referencing let variables in the files in the tests directory without causing linting errors. --- lib/rules/template-no-let-reference.js | 5 +++++ 1 file changed, 5 insertions(+) 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; From 6431a7d15f3322f21ea6b3ba69af10dc3724c9ed Mon Sep 17 00:00:00 2001 From: Dayo Olutayo Date: Sun, 13 Oct 2024 18:40:37 +0100 Subject: [PATCH 2/2] Add test for 'no-let' rule for tests directory The test cases ensure that 'let' or 'var' can be used in the files in tests directory. --- tests/lib/rules/template-no-let-reference.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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: [