Skip to content

fix(linter/unicorn): stop three autofixes changing behaviour - #3

Merged
maxholman[bot] merged 4 commits into
mainfrom
fix/unicorn-behaviour-fixes
Oct 18, 2026
Merged

maxholman[bot] merged 4 commits into
mainfrom
fix/unicorn-behaviour-fixes

Conversation

@maxholman

@maxholman maxholman Bot commented Oct 18, 2026

Copy link
Copy Markdown

Three unicorn/ autofixes changed what the code does, and --fix applies them without review:

  • prefer-dom-node-append rewrote x = parent.appendChild(node); append() returns undefined. It now fixes only a call whose result is discarded.
  • prefer-query-selector rewrote getElementById(id) to querySelector(`#${id}`) with no CSS.escape(). It now fixes only a literal that is a plain selector, and no longer trims it. null and empty arguments are reported without a fix.
  • catch-error-name renamed { cause } to { err }, a different key. It now writes { cause: err }, for destructuring targets too.

Every case is still reported. The READMEs list the changes. cargo test -p oxc_linter --lib rules::unicorn (150) and clippy pass; codegen is unchanged.

maxholman and others added 4 commits October 18, 2026 18:11
…result

`append()` returns `undefined`, so rewriting `x = parent.appendChild(node)`
loses the node. The fix now applies only where the call is a statement on
its own. Every other call is still reported, without a fix.

Co-Authored-By: LLM <noreply@block65.dev>
…t is a plain selector

`getElementById(id)` became ``querySelector(`#${id}`)``, which needs
`CSS.escape()`: an id such as `address.line1` selects a class instead,
and one starting with a digit throws. A literal id, class or tag name is
now rewritten only when it is ASCII letters, digits, `_` and `-` without a
leading digit, and a name only when it holds no quotes. The literal is no
longer trimmed, since `getElementById(" foo ")` does not match `#foo`.
`null` and empty arguments, which a selector would match differently or
throw on, are reported without a fix.

Co-Authored-By: LLM <noreply@block65.dev>
…perty

Renaming the binding renamed every reference, so `{ cause }` became
`{ err }`, a different key, which a loosely typed options object accepts
silently. A shorthand property or destructuring target is now expanded to
`{ cause: err }`.

Co-Authored-By: LLM <noreply@block65.dev>
…name fixes

Co-Authored-By: LLM <noreply@block65.dev>
@maxholman
maxholman Bot merged commit edb623a into main Oct 18, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant