Skip to content

Commit

Permalink
fix(linter): false positive in unicorn/no-useless-spread
Browse files Browse the repository at this point in the history
  • Loading branch information
shulaoda committed Dec 16, 2024
1 parent 9b3a2be commit 7dd4ab3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl ConstEval for Argument<'_> {

impl ConstEval for NewExpression<'_> {
fn const_eval(&self) -> ValueHint {
if is_new_array(self) || is_new_typed_array(self) {
if is_new_array(self) {
ValueHint::NewArray
} else if is_new_map_or_set(self) {
ValueHint::NewIterable
Expand Down
3 changes: 3 additions & 0 deletions crates/oxc_linter/src/rules/unicorn/no_useless_spread/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,9 @@ fn test() {
"[...arr.reduce((set, b) => set.add(b), new Set(iter))]",
// NOTE: we may want to consider this a violation in the future
"[...(foo ? new Set() : [])]",
// Issue: <https://github.com/oxc-project/oxc/issues/7936>
"[ ...Uint8Array([ 1, 2, 3 ]) ].map(byte => byte.toString())",
"[ ...new Uint8Array([ 1, 2, 3 ]) ].map(byte => byte.toString())",
];

let fail = vec![
Expand Down

0 comments on commit 7dd4ab3

Please sign in to comment.