infra: migrate from eslint to oxlint#3773
Draft
Shinigami92 wants to merge 1 commit into
Draft
Conversation
✅ Deploy Preview for fakerjs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## next #3773 +/- ##
=======================================
Coverage 98.84% 98.84%
=======================================
Files 923 923
Lines 3216 3216
Branches 583 566 -17
=======================================
Hits 3179 3179
Misses 33 33
Partials 4 4
🚀 New features to boost your workflow:
|
265aa50 to
0923eac
Compare
f813931 to
3c5f3b6
Compare
3c5f3b6 to
5b9084e
Compare
5b9084e to
901fb90
Compare
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.
Summary
This PR replaces ESLint with oxlint - a much faster linter written in Rust by the oxc project.
What changed:
oxlint+oxlint-tsgolint(for type-aware linting)oxlint.config.tseslint-disablecomments tooxlint-disablewhere the rule exists, removed them where it doesn't.gitignorepnpm prettier), a follow-up PR will look into oxfmtoxlint-tsgolint, so rules likeconsistent-type-exports,restrict-plus-operands,switch-exhaustiveness-checketc. all work with full type informationPerformance: The lint step in CI went from 52s (
nextbranch) to ~1s - a ~50x speedup - even with type-aware linting enabled.Rules regained since the original migration
Thanks to the
oxlint/oxlint-tsgolintupdates, the following rules - listed as "lost" in the first version of this PR - are enforced again with full parity to the original ESLint config:logical-assignment-operatorstypescript/no-mixed-enumstypescript/no-unsafe-argumenttypescript/require-await(TS, type-aware)The intentional violations these rules guard (a placeholder
asynchelper in the apidocs generator, the mixed-enum test fixtures, and the dynamicBROKEN_LOCALE_METHODSaccess) are suppressed inline withoxlint-disable-next-line, exactly as they were under ESLint.Rules that are still not enforced
Not all ESLint rules have an oxlint equivalent yet. Below is what we're still temporarily losing, grouped by how far away support is.
Rules not yet implemented (no type info needed)
jsdoc/require-jsdocsrc/**/*.ts) - this is a big one for us since it guards our public API docsjsdoc/sort-tags@template,@internal,@remark,@param,@returns, ...)jsdoc/tag-linesoff, but noting for completeness)unicorn rules not yet implemented by oxlint
Rebasing onto the latest
next(which bumpedeslint-plugin-unicorn) pulled in code suppressing these unicorn rules. oxlint does not flag them, so theeslint-disabledirectives were removed and these checks are currently not enforced:unicorn/no-unreadable-array-destructuringsrc/modules/helpers/module.ts)unicorn/no-declarations-before-early-exitsrc/modules/commerce/module.ts)unicorn/no-top-level-assignment-in-functionscripts/shared/markdown.ts)unicorn/prefer-iterator-to-arraymatchAllspread, needs Node 22+ (test/scripts/apidocs/verify-jsdoc-tags.spec.ts)unicorn/no-nonstandard-builtin-propertiesError.prototype.stackaccess (test/support/seeded-runs.ts)unicorn/no-top-level-side-effectsconsole.login vitest configs (vitest.config.ts,vitest.it-config.ts)Rules not yet implemented (need type-aware linting via tsgolint)
typescript/naming-conventionT-prefix for type params conventionRules disabled to preserve parity with the original ESLint config
oxlint1.71.0 categorizes some additional rules ascorrectness/suspicious, so they started erroring after the bump. These were not part of our original ESLint config (or, in one case, oxlint's implementation is stricter thaneslint-plugin-unicorn's), so they are turned off to avoid introducing new violations. They can be evaluated and enabled separately:no-underscore-dangletypescript/consistent-returnvitest/require-to-throw-messageunicorn/consistent-function-scopingeslint-plugin-unicorn's recommended set, but oxlint 1.71.0's implementation flags non-capturing local/arrow functions that ESLint did not, which would introduce new violationsIntentionally dropped (not needed with oxlint)
@stylistic/padding-line-between-statements@stylisticplugin. Closed as "not planned" (oxc#11435). Will be covered by oxfmt in the future.eslint-plugin-file-progresseslint-plugin-prettierpnpm prettier --check .in CI. This was just the bridge between ESLint and Prettier. Will be replaced by oxfmt in a future PR.Other notes
test/require.spec.ctsis ignored by oxlint due to a parser limitation with top-levelawaitin.cts(CommonJS) filesdocs/.vitepress/components/api-docs/method.vueadded to ignore list - oxlint's.vuesupport is limitedcypress/added to ignore list - separate tsconfig causes a parser errorno-unsafe-type-assertion,require-array-sort-compare) are explicitly turned off since they weren't in our original ESLint config - we can evaluate enabling them separately.gitignore, so no need to duplicate those patterns inignorePatternsTest plan
pnpm run lintpasses with 0 errors (type-aware enabled). One intentionalvitest/warn-todowarning remains on the Windows-flakyit.todoinfinance.spec.ts; CI runsoxlintwithout--deny-warnings, so it is non-fatalpnpm run ts-checkpassespnpm prettier --check .passespnpm run testpassesnext