oxc icon indicating copy to clipboard operation
oxc copied to clipboard

linter: bunch of small auto-fix missing

Open Hideman42 opened this issue 8 months ago • 4 comments

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.parseFloat instead of the global parseFloat => Same for parseInt, isNaN
    • Should add Number. before parseFloat
  • [ ] eslint(radix): Missing radix parameter
    • Should add , 10 in the code as Number.parseInt(str, 10)
  • [ ] 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
  • [ ] eslint-plugin-react(jsx-curly-brace-presence): Curly braces are unnecessary here
    • Should replace <div id={'my-div'} /> with <div id="my-div" />
  • [x] eslint(require-await): Async function has no 'await' expression
    • Should strip out async // Maybe a dangerous fix
  • [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 <></> with null <>{something}</> with something
  • [x] eslint(eqeqeq): Expected === and instead saw ==
    • Should replace == to ===

Hideman42 avatar Apr 17 '25 15:04 Hideman42

Thank you for such a useful issue to help us improve!

Dunqing avatar Apr 18 '25 02:04 Dunqing

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.

Miodec avatar Apr 18 '25 11:04 Miodec

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.

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 avatar Apr 18 '25 11:04 Hideman42

@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.

camchenry avatar Apr 18 '25 15:04 camchenry

I added another usefull small auto-fix to the list, the eslint-plugin-react(exhaustive-deps) to add needed dependencies to the array.

Hideman42 avatar May 05 '25 11:05 Hideman42

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?

vladimir-kuba avatar Jul 11 '25 08:07 vladimir-kuba

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

camc314 avatar Jul 11 '25 09:07 camc314

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 =>.

Hideman42 avatar Jul 11 '25 11:07 Hideman42

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?

gaurav-rk9 avatar Dec 16 '25 06:12 gaurav-rk9

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?

Left a comment on you're PR - it's too hard to fix correctly, so let's leave as non-fixable.

camc314 avatar Dec 17 '25 13:12 camc314

eslint-plugin-react(exhaustive-deps): React Hook useMyHook has a missing dependency myDep

looks like there's only one left!

camc314 avatar Dec 17 '25 13:12 camc314

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

camc314 avatar Dec 20 '25 12:12 camc314