fix(linter/unicorn/prefer-array-flat): skip plain concat normalization - #26604
Open
im10furry wants to merge 1 commit into
Open
fix(linter/unicorn/prefer-array-flat): skip plain concat normalization#26604im10furry wants to merge 1 commit into
concat normalization#26604im10furry wants to merge 1 commit into
Conversation
im10furry
force-pushed
the
fix/prefer-array-flat-concat-spread
branch
from
September 13, 2026 18:15
c129d61 to
e025e73
Compare
im10furry
force-pushed
the
fix/prefer-array-flat-concat-spread
branch
from
September 13, 2026 18:38
e025e73 to
570da6d
Compare
[].concat(value) normalizationconcat normalization
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
unicorn/prefer-array-flatreports plain concat normalization — patterns that do not consume an array of concat arguments. Upstream deliberately does not report them, and points atprefer-spreadinstead:Two families are affected, both currently reported by Oxlint:
Same root cause: the port reports the shape without checking whether the single argument is spread, which is what actually makes the call flatten.
Repro (all upstream-valid, i.e. should NOT be reported)
Expected
Only the forms that actually flatten are reported:
Fix
check_array_concat_case— require the single argument to be aSpreadElement:check_array_prototype_concat_case—callonly flattens with a spread second argument, whileapplypasses the array as-is, so a spread there is not flattening (this mirrors upstream'sarrayPrototypeConcat):The rule's doc examples no longer list
[].concat(maybeArray)/Array.prototype.concat.call([], maybeArray)as incorrect (upstream's docs do not either), and the upstream-valid normalization cases (16) were moved into the rule's pass list so the false positives cannot regress.Tests
cargo test -p oxc_linter --all-features --lib→ 1261 passed, 0 failed, 1 ignoredcargo test -p oxc_linter --lib rules::unicorn→ 147 passedcargo fmt -p oxc_linter -- --checkclean,cargo clippy -p oxc_linter --all-targetsno new warnings (only the pre-existing pedanticfrom_iter_instead_of_collectwarnings inlib.rs)cargo lintgen,pnpm --filter oxlint-app generate-config-typesandcargo lint-timingsproduce no diff (rule node types and call counts are unchanged)typosclean;cargo check --all-features --all-targets --lockedon the workspace passescargo insta acceptand reviewed: only the false-positive blocks are removed; the spread forms still report as beforeCloses #26593
Prepared with AI assistance.