oxc-project
oxc
BlogDocsChangelog

fix(linter/no-accumulating-spread): false positive in nested callbacks within reduce

#14898Merged
Comparing
c/10-22-fix_linter_no-accumulating-spread_false_positive_in_nested_callbacks_within_reduce
(
dc5a71b
) with
main
(
90add74
)
CodSpeed Performance Gauge
0%
Untouched
4
Skipped
33

Benchmarks

Skipped (33)

Passed

linter[RadixUIAdoptionSection.jsx]
tasks/benchmark/benches/linter.rs::linter::bench_linter
CodSpeed Performance Gauge
0%
744.2 µs743.4 µs
linter[binder.ts]
tasks/benchmark/benches/linter.rs::linter::bench_linter
CodSpeed Performance Gauge
0%
49.8 ms49.8 ms
linter[cal.com.tsx]
tasks/benchmark/benches/linter.rs::linter::bench_linter
CodSpeed Performance Gauge
0%
481.6 ms481.6 ms
linter[react.development.js]
tasks/benchmark/benches/linter.rs::linter::bench_linter
CodSpeed Performance Gauge
0%
19.4 ms19.4 ms

Commits

Click on a commit to change the comparison range
Base
main
90add74
0%
fix(linter/no-accumulating-spread): false positive in nested callbacks within reduce (#14898) fixes #14894 Example: ```js // Original code (works correctly) function original() { const list = [ { subList: [{ subList: [1, 2] }, { subList: [3, 4] }] }, { subList: [{ subList: [5, 6] }] } ]; return list.reduce((acc, each) => { return each.subList.flatMap((subEach) => { return [...acc, subEach.subList]; }); }, []); } // "Fixed" code following oxlint suggestion (broken) function broken() { const list = [ { subList: [{ subList: [1, 2] }, { subList: [3, 4] }] }, { subList: [{ subList: [5, 6] }] } ]; return list.reduce((acc, each) => { return each.subList.flatMap((subEach) => { acc.push(subEach.subList); return acc; }); }, []); } console.log("Original output:", JSON.stringify(original())); console.log("Broken output:", JSON.stringify(broken())); ``` ``` $ node test_case.js Original output: [[1,2],[3,4],[5,6]] Broken output: [[1,2],[1,2],[3,4],[5,6]] ```
dc5a71b
20 days ago
by camc314
© 2025 CodSpeed Technology
Home Terms Privacy Docs