Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(linter): false positive in unicorn/no-useless-spread #7940

Merged
merged 1 commit into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading