From 6cd7aae7882a5f81792ee4a5984140a05c58dffa Mon Sep 17 00:00:00 2001 From: Matt Wilkinson Date: Fri, 14 Jul 2023 14:01:04 +0100 Subject: [PATCH] fix: Update no-loop-func to not overlap with no-undef --- tests/lib/rules/no-loop-func.js | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/tests/lib/rules/no-loop-func.js b/tests/lib/rules/no-loop-func.js index 4fffa55c6c36..0f0fc6a417d3 100644 --- a/tests/lib/rules/no-loop-func.js +++ b/tests/lib/rules/no-loop-func.js @@ -117,14 +117,8 @@ ruleTester.run("no-loop-func", rule, { * These loops _look_ like they might be unsafe, but because i is undeclared, they're fine * at least as far as this rule is concerned - the loop doesn't declare/generate the variable. */ - { - code: "while(i) { (function() { i; }) }", - errors: [{ messageId: "unsafeRefs", data: { varNames: "'i'" }, type: "FunctionExpression" }] - }, - { - code: "do { (function() { i; }) } while (i)", - errors: [{ messageId: "unsafeRefs", data: { varNames: "'i'" }, type: "FunctionExpression" }] - }, + "while(i) { (function() { i; }) }", + "do { (function() { i; }) } while (i)", /** * These loops _look_ like they might be unsafe, but because i is declared outside the loop, @@ -132,14 +126,8 @@ ruleTester.run("no-loop-func", rule, { * The variable that's captured is just the one variable shared by all the loops, but that's * explicitly expected in these cases. */ - { - code: "var i; while(i) { (function() { i; }) }", - errors: [{ messageId: "unsafeRefs", data: { varNames: "'i'" }, type: "FunctionExpression" }] - }, - { - code: "var i; do { (function() { i; }) } while (i)", - errors: [{ messageId: "unsafeRefs", data: { varNames: "'i'" }, type: "FunctionExpression" }] - }, + "var i; while(i) { (function() { i; }) }", + "var i; do { (function() { i; }) } while (i)", /** * These loops use an undeclared variable, and so shouldn't be flagged by this rule,