Skip to content

Commit 6f41d92

Browse files
authored
fix(linter): false positive in unicorn/no-useless-spread (#7940)
closes #7936
1 parent 6f8bb1c commit 6f41d92

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

crates/oxc_linter/src/rules/unicorn/no_useless_spread/const_eval.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ impl ConstEval for Argument<'_> {
8989

9090
impl ConstEval for NewExpression<'_> {
9191
fn const_eval(&self) -> ValueHint {
92-
if is_new_array(self) || is_new_typed_array(self) {
92+
if is_new_array(self) {
9393
ValueHint::NewArray
9494
} else if is_new_map_or_set(self) {
9595
ValueHint::NewIterable

crates/oxc_linter/src/rules/unicorn/no_useless_spread/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,9 @@ fn test() {
594594
"[...arr.reduce((set, b) => set.add(b), new Set(iter))]",
595595
// NOTE: we may want to consider this a violation in the future
596596
"[...(foo ? new Set() : [])]",
597+
// Issue: <https://github.com/oxc-project/oxc/issues/7936>
598+
"[ ...Uint8Array([ 1, 2, 3 ]) ].map(byte => byte.toString())",
599+
"[ ...new Uint8Array([ 1, 2, 3 ]) ].map(byte => byte.toString())",
597600
];
598601

599602
let fail = vec![

0 commit comments

Comments
 (0)