We recently migrated to ESLint v9 with Flat Config (somewhat...

@karlhorky
Karl Horky@karlhorky
20 views Jul 03, 2024 ~1 min read
Advertisement
1
We recently migrated to ESLint v9 with Flat Config (somewhat painful migration)

some things that we found out that may be helpful for you πŸ‘‡
Media image
2
1) eslint-plugin-import is not only incompatible with ESLint v9, but also has multiple other issues and missing features

Instead of fixing it, we migrated to eslint-plugin-import-x, a fork which has ESLint v9 support, extra features and fixes

gist.github.com/karlhorky/b78f…
3
2) some ESLint plugins are not compatible yet, like eslint-plugin-react and eslint-plugin-deprecation

Use ESLint Compatibility Utilities (@eslint/compat) for this

github.com/jsx-eslint/esl…
4
3a) plugins with old transitive / peer dependencies (eg. dependencies on `eslint` or on `typescript-eslint` packages) can cause failures

eg. the "you have used a rule which requires parserServices to be generated" with eslint-plugin-jsx-expressions

github.com/hluisson/eslin…
5
3b) if you're not publishing a shared config, you can probably get away with pnpm Overrides (or npm Overrides / Yarn Resolutions)

pnpm.io/package_json#p…
6
3c) if you are publishing a shared config, you can vendor the plugin (copy the necessary files from node_modules to a vendor/ directory and delete the package.json)

github.com/hluisson/eslin…
7
4) some packages may require a combination of multiple of these techniques - eg. pnpm Overrides along with ESLint Compatibility Utilities

github.com/typescript-esl…
8
5) it is easier to migrate to Flat Config using ESLint v8 (fewer breaking changes than migrating in ESLint v9)

and reviewing examples of migrations which have been performed already can help

github.com/upleveled/esli…
9
Here's the PR with the commits fixing the problems migrating to ESLint v9

(Flat Config migration is separate, in previous tweet)

github.com/upleveled/esli…
10
By the way, since my original post may have come across as a bit of a downer, I think the new @geteslint Flat Config is great! πŸ’―

Addresses many issues in a years-long carefully-planned design and rollout strategy
Actions
What You Can Do
  • Export as PDF or Markdown
  • Batch Export to Notion
  • Bookmark & Highlight
  • Screenshot Tweet
Create Free Account

Includes 7-day Premium trial

Advertisement