next.js
e9a8ee50 - Update codemod ESLint template to Flat config (#84919)

Commit
124 days ago
Update codemod ESLint template to Flat config (#84919) Stacked on https://github.com/vercel/next.js/pull/84874 ### Why? As `eslint-config-next` supports Flat config since PR https://github.com/vercel/next.js/pull/84874, Release [v16.0.0-canary.6](https://github.com/vercel/next.js/releases/tag/v16.0.0-canary.6), update codemod to use Flat config. Since `eslint-config-next` version and this codemod's version will match, no need to gate the version, as by the time this change is released, the same `eslint-config-next` version will support Flat config. ### How? Updated to handle the three cases: - Legacy config - Flat config with FlatCompat (Which we used to recommend for v15) - Flat config with no FlatCompat (Which means the app does not use `eslint-config-next`) For the Legacy config, ESLint provides a [Migration tool](https://eslint.org/docs/latest/use/configure/migration-guide), so use that to convert to Flat config. It will include FlatCompat, so the rest of the process is the same as Flat config with FlatCompat. For the Flat config with FlatCompat, the codemod will remove FlatCompat and map the `eslint-config-next` imports directly to the export. For the Flat config with no FlatCompat, the codemod will import `eslint-config-next` and map the imports directly to the export. Tested on [shadcn/ui](https://github.com/shadcn-ui/ui/blob/cb769b7059b50b5dca033a6eb57bb8ecde69fc87/.eslintrc.json) and other large legacy ESLint configs.
Author
Parents
Loading