-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrade ESLint to v9 #65648
base: trunk
Are you sure you want to change the base?
Upgrade ESLint to v9 #65648
Conversation
Awesome work @shvlv starting this PR. Thank you so much. The number of breaking changes is overwhelming. It won't be an easy upgrade for the folks using |
Are there automated migration tools that can help with migration? Were they used in this PR? It would be helpful for folks dealing with this breaking change to document how they can migrate and what tooling is available. |
Yes, tools exist. @eslint/migrate-configTo migrate config, https://eslint.org/docs/latest/use/configure/migration-guide#migrate-your-config-file could be used. However, as the documentation says, it's appropriate chiefly for static configuration files ( In projects I participated in, we often used the following approach: const defaultConfig = require( '@wordpress/scripts/config/.eslintrc.js' );
module.exports = {
...defaultConfig,
settings: {
'import/resolver': {
typescript: {},
},
},
}; But yes, it will not work now for several reasons, and I'm not sure the migration tool could help either. In general, migration to v9 is pretty complicated for several reasons:
But it's complex for the Gutenberg giant monorepo and should be easier for consuming projects. eslint-transformsIt can be used to migrate custom rules to the new API (https://www.npmjs.com/package/eslint-transforms and https://eslint.org/blog/2023/09/preparing-custom-rules-eslint-v9/). I tried it for @eslint/config-inspectorIt's the new tool to make debugging easier (https://eslint.org/docs/latest/use/configure/debug#use-the-config-inspector and https://github.com/eslint/config-inspector). It doesn't work if you have config errors. But now it works like the following: We can consider adding the
Yes, we should mention these tools in the documentation (or a blog post). However, I think documentation with examples of how-to is even more important. |
Last update:
Regarding the last one, ESLint v9 doesn't support multiple configurations as it used to. I.e., it stops after finding the parent configuration. I see the pros and cons of this decision. Pros: we have everything in a single place; it's transparent; we can merge duplicated rules. Cons: we already have 700+ lines in the config file. We can keep it as is and consider refactoring in the future. Refactoring can be done in the two directions:
Current status:
|
Hi, maybe I understand things incorrectly, but it seems to me that it's still possible to have multiple config files, you just have a different mechanism for using them - importing. So each package can have its own config, which imports some shared general config much like you import and use configs from third-party plugins. |
This is gonna be a very painful change for the ecosystem. Is there any way we could reduce the burden for users of these packages? For example by simultaneously supporting v8 and v9 or so? |
@marekdedic, I think we are talking about different things. We have the following structure:
When we run ESLint V8 from the root directory, and ESLint starts to lint files inside
But it does not work in this way now - https://eslint.org/docs/latest/use/configure/configuration-files#configuration-file-resolution:
That means if you run |
@swissspidy, the problem is Other issues are resolvable:
|
@shvlv You are right, we are misunderstanding each other. :) |
Last updates:
|
Hi @shvlv - check out eslint 9.12, I think they may have added exactly what we were talking about last week - see eslint/eslint#18742 |
Last updates:
We are almost there:
@marekdedic I didn't test the last ESLint release, but from the description, I see it's exactly what we talked about. But when I'm thinking about root |
The version 2.30.0 of `eslint-plugin-import` triggers "parserPath or languageOptions.parser is required!" error (see import-js/eslint-plugin-import#3051)
…/shared-tests.js` file
It decreases number of errors because we have `tseslint.configs.eslintRecommended` having the deal with suppressing not relevant ESLint core errors
…ments/` rule prefix
See microsoft/TypeScript#11859. Essentially JSDoc should not be used for Typescript
Hi @gziolo, technically, we are close to finishing. We have to additionally test the The main question is whether we are going to introduce this breaking change. You can check my consideration here: #65648 (comment). I think the |
What?
Upgrade ESLint to v9.
Why?
Fixes: #64782
ESLint was moving to the new flat config and new API — https://eslint.org/docs/latest/use/migrate-to-9.0.0. The community made great progress supporting v9 — eslint/eslint#18391.
How?
The following parts were updated:
eslint-plugin
to support the flat formatlint-js
command to support the v9 CLIpackage.json
to upgrade ESLint pluginsSeveral plugins are incompatible with ESLint v9 and were fixed with
eslint/compat
helper:Was released with v2.31.0eslint-plugin-import
. The issue and PR exist. We expect it to be released soon. Note that the forked plugin https://github.com/un-ts/eslint-plugin-import-x supports v9.eslint-plugin-react-hooks
supports v9 only in [RC version ] (eslint-plugin-react-hooks & "Flat Config" (ESLint 9) facebook/react#28313). We hope it will be released soon.eslint-plugin-testing-library
supports flat config but not support updated API.eslint-plugin-storybook
supports v9 in canary version. But it might be problems with a glob expression. The overall issue - Suport ESLint v9 storybookjs/eslint-plugin-storybook#157.eslint-plugin-ssr-friendly
doesn't support flat config and new API. The plugin looks unmaintained; we can consider moving these rules to@wordpress/eslint-plugin.
The issue - [Breaking Changes] Support ESLint 9 kopiro/eslint-plugin-ssr-friendly#30.eslint-plugin-eslint-comments
was replaced by@eslint-community/eslint-plugin-eslint-comments
- https://github.com/eslint-community/eslint-plugin-eslint-comments (see mysticatea/eslint-plugin-eslint-comments#79 (comment)).Testing Instructions
Run
npm run lint:js
.Current status
With upgrading plugins, new rules were introduced that have to be handled on the root config. Also, maybe the new configuration still does not completely reflect the previous one (while I strived for that goal). Some issues are repeated many times, so they can be easily addressed (like
@typescript-eslint/no-explicit-any
orno-undef
inreact-navite-editor
).Also, documentation for
eslint-plugin,
script
, and inside/docs
should be double-checked.