Repository navigation
fix(linter/unicorn): stop three autofixes changing behaviour - #3
Merged
Merged
Conversation
…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>
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.
Three
unicorn/autofixes changed what the code does, and--fixapplies them without review:prefer-dom-node-appendrewrotex = parent.appendChild(node);append()returnsundefined. It now fixes only a call whose result is discarded.prefer-query-selectorrewrotegetElementById(id)toquerySelector(`#${id}`)with noCSS.escape(). It now fixes only a literal that is a plain selector, and no longer trims it.nulland empty arguments are reported without a fix.catch-error-namerenamed{ 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.