linter: bunch of small auto-fix missing
What version of Oxlint are you using?
0.16.5
What command did you run?
oxlint --fix --fix-suggestions --quiet
What happened?
Missing lot of quick auto-fixes:
- [ ] eslint-plugin-unicorn(prefer-number-properties): Use
Number.parseFloatinstead of the globalparseFloat=> Same for parseInt, isNaN- Should add
Number.beforeparseFloat
- Should add
- [ ] eslint(radix): Missing radix parameter
- Should add
, 10in the code asNumber.parseInt(str, 10)
- Should add
- [ ] eslint-plugin-unicorn(prefer-spread): Prefer the spread operator (
...) over Array.from()- Should replace
Array.from(store.getItems())with[...store.getItems()] - Should replace
store.getItems()?.concat(anotherItem) ?? [anotherItem]with[...store.getItems() ?? [], anotherItem]// More complex
- Should replace
- [ ] eslint-plugin-react(jsx-curly-brace-presence): Curly braces are unnecessary here
- Should replace
<div id={'my-div'} />with<div id="my-div" />
- Should replace
- [x] eslint(require-await): Async function has no 'await' expression
- Should strip out
async// Maybe a dangerous fix
- Should strip out
- [x] eslint-plugin-react(self-closing-comp): Unnecessary closing tag
- Should replace to self closing tag
- [ ] eslint-plugin-react(jsx-no-useless-fragment): Fragments should contain more than one child.
- Should replace to
<></>withnull<>{something}</>withsomething
- Should replace to
- [x] eslint(eqeqeq): Expected === and instead saw ==
- Should replace
==to===
- Should replace
Thank you for such a useful issue to help us improve!
Just a heads up (since you mentioned youre using --fix and --fix-suggestions flags), eqeqeq should be a dangerous fix since just blindly changing == to === can change the logic.
Just a heads up (since you mentioned youre using
--fix and --fix-suggestionsflags),eqeqeqshould be a dangerous fix since just blindly changing==to===can change the logic.
I think this is fair to have it as dangerous fix. Something is weird tho, I went to the rules doc and it is tagged as auto-fixable (safe) and I checked the rule source it seem to have a fix implemented but with oxlint --fix --fix-suggestions --fix-dangerously --quiet it doesnt auto fix it. Do you also confirm in your try?
@Hideman42 I'll take a look at this. I think it is only safely auto fixable in some cases. But we could provide it as a dangerous fix in all cases.
I added another usefull small auto-fix to the list, the eslint-plugin-react(exhaustive-deps) to add needed dependencies to the array.
I'd like to pick up implementation of eslint-plugin-react(exhaustive-deps) fix. Need it to migrate projects from eslint to oxlint. Is it ok?
I'd like to pick up implementation of
eslint-plugin-react(exhaustive-deps)fix. Need it to migrate projects from eslint to oxlint. Is it ok?
yeah this is great, thank you
I just added to the list some missing auto-fix that are very annoying and would be great time saver when migrating old projects up to quality.
- eslint-plugin-import(no-named-as-default): Module "@testing-library/user-event" has named export "userEvent"
- eslint-plugin-import(consistent-type-specifier-style): Prefer using a top-level type-only import instead of inline type specifiers.
- eslint-plugin-react(jsx-curly-brace-presence): Curly braces are unnecessary here
- eslint(arrow-body-style): Unexpected block statement surrounding arrow body; move the returned value immediately after the =>.
eslint-plugin-import(no-named-as-default): Should we transform import userEvent, {event} to import { userEvent, event } or should we leave them as non-fixable?
eslint-plugin-import(no-named-as-default): Should we transform
import userEvent, {event}toimport { userEvent, event }or should we leave them as non-fixable?
Left a comment on you're PR - it's too hard to fix correctly, so let's leave as non-fixable.
eslint-plugin-react(exhaustive-deps): React Hook useMyHook has a missing dependency myDep
looks like there's only one left!
eslint-plugin-react(exhaustive-deps): React Hook useMyHook has a missing dependency myDep
looks like there's only one left!
we actually do support a fixer for this case