From af69393a1c72f58606e01875d69f0bad85d646e7 Mon Sep 17 00:00:00 2001 From: DonIsaac <22823424+DonIsaac@users.noreply.github.com> Date: Fri, 6 Sep 2024 19:03:16 +0000 Subject: [PATCH] test(linter/no-useless-spread): ensure spreads on identifiers pass (#5561) Closes #5405 --- crates/oxc_linter/src/rules/unicorn/no_useless_spread/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/oxc_linter/src/rules/unicorn/no_useless_spread/mod.rs b/crates/oxc_linter/src/rules/unicorn/no_useless_spread/mod.rs index 79a68fd40434f..2cfbc57101d11 100644 --- a/crates/oxc_linter/src/rules/unicorn/no_useless_spread/mod.rs +++ b/crates/oxc_linter/src/rules/unicorn/no_useless_spread/mod.rs @@ -553,6 +553,7 @@ fn test() { r"[...not.array]", r"[...not.array()]", r"[...array.unknown()]", + r"const arr = [1, 2, 3]; const unique = [...arr];", // valid method to shallow-clone an array r"[...Object.notReturningArray(foo)]", r"[...NotObject.keys(foo)]", // NOTE (@DonIsaac) these are pathological, should really not be done, @@ -562,6 +563,7 @@ fn test() { // r"[...Int8Array.of()]", // r"[...new Int8Array(3)]", r"[...new Set(iter)]", + r"const set = new Set([1, 2, 3]); const unique = [...set];", r"[...Promise.all(foo)]", r"[...Promise.allSettled(foo)]", r"[...await Promise.all(foo, extraArgument)]", @@ -722,7 +724,6 @@ fn test() { ("[...foo.map(x => !!x)]", "foo.map(x => !!x)"), ("[...new Array()]", "new Array()"), ("[...new Array(1, 2, 3)]", "new Array(1, 2, 3)"), - // usel // useless clones - complex (r"[...await Promise.all(foo)]", r"await Promise.all(foo)"), (r"[...Array.from(iterable)]", r"Array.from(iterable)"),