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

closes #7936
This commit is contained in:
dalaoshu 2024-12-16 22:20:58 +08:00 committed by GitHub
parent 6f8bb1cebf
commit 6f41d92972
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 1 deletions

View file

@ -89,7 +89,7 @@ impl ConstEval for Argument<'_> {
impl ConstEval for NewExpression<'_> { impl ConstEval for NewExpression<'_> {
fn const_eval(&self) -> ValueHint { fn const_eval(&self) -> ValueHint {
if is_new_array(self) || is_new_typed_array(self) { if is_new_array(self) {
ValueHint::NewArray ValueHint::NewArray
} else if is_new_map_or_set(self) { } else if is_new_map_or_set(self) {
ValueHint::NewIterable ValueHint::NewIterable

View file

@ -594,6 +594,9 @@ fn test() {
"[...arr.reduce((set, b) => set.add(b), new Set(iter))]", "[...arr.reduce((set, b) => set.add(b), new Set(iter))]",
// NOTE: we may want to consider this a violation in the future // NOTE: we may want to consider this a violation in the future
"[...(foo ? new Set() : [])]", "[...(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![ let fail = vec![