feat: add a codemod to migrate from the deprecated "next lint" command (#82685)
## Add codemod to migrate from `next lint` to ESLint CLI
This PR introduces a new codemod `next-lint-to-eslint-cli` that helps
users migrate away from the deprecated `next lint` command to using
ESLint directly, in preparation for Next.js 16 where `next lint` will be
removed.
### What it does
The codemod automates the migration process by:
1. **Updating package.json scripts** - Replaces all `next lint` commands
with `eslint` equivalents
- Maps Next.js-specific flags (`--strict` → `--max-warnings 0`,
`--dir`/`--file` → paths)
- Preserves other ESLint-compatible flags
- Handles complex scripts with pipes, redirects, and multiple commands
2. **Managing ESLint configuration**
- Creates a new flat config (`eslint.config.mjs`) if none exists
- Updates existing flat configs to include Next.js rules
- Provides guidance for legacy configs that need manual migration
3. **Installing dependencies automatically**
- Adds required packages: `eslint`, `eslint-config-next`,
`@eslint/eslintrc`
- Detects and uses the project's package manager (npm/yarn/pnpm/bun)
- Falls back to manual instructions if installation fails
### Usage
```bash
npx @next/codemod@latest next-lint-to-eslint-cli .
```
### Example transformations
```json
// Before
{
"scripts": {
"lint": "next lint",
"lint:fix": "next lint --fix",
"lint:strict": "next lint --strict --dir src"
}
}
// After
{
"scripts": {
"lint": "eslint .",
"lint:fix": "eslint --fix .",
"lint:strict": "eslint --max-warnings 0 src"
}
}
```
### Why this change?
- `next lint` is being deprecated and will be removed in Next.js 16
- ESLint v9+ flat config is becoming the standard
- Direct ESLint usage provides more flexibility and better ecosystem
compatibility
- Reduces Next.js maintenance burden of wrapping ESLint functionality
The codemod ensures a smooth transition path for existing Next.js
projects while following ESLint best practices.