@eslint/v8-to-v9
Automatically migrate your ESLint configuration from v8 to v9 flat config format.
Overview
This codemod provides a comprehensive migration solution for ESLint v8 to v9:
- Config Migration: Converts
.eslintrc.*files to the new flat config format - Breaking Changes: Handles all v9 breaking changes in rules and options
- JSDoc Migration: Migrates deprecated JSDoc rules to
eslint-plugin-jsdoc - Comment Cleanup: Fixes malformed comments and removes deprecated syntax
What This Codemod Does
This codemod performs a comprehensive migration from ESLint v8 to v9. It handles the following breaking changes from the official ESLint v9 migration guide:
- ✅ New default config format (
eslint.config.js) - ✅ Removed
require-jsdocandvalid-jsdocrules - migrates toeslint-plugin-jsdoc - ✅ Multiple
/* eslint */comments for the same rule are now disallowed - removes duplicates - ✅ Stricter
/* exported */parsing - fixes malformed comments - ✅
no-constructor-returnandno-sequencesrule schemas are stricter - updates to new format - ✅
no-restricted-importsnow accepts multiple config entries with the samename- deduplicates paths - ✅
"eslint:recommended"and"eslint:all"no longer accepted in flat config - converts tojs.configs.* - ✅
no-unused-varsnow defaultscaughtErrorsto"all"- adds backward-compatible default - ✅
no-useless-computed-keyflags unnecessary computed member names in classes by default - addsenforceForClassMembers: false - ✅
camelcaseallow option only accepts an array of strings - validates and migrates options - ✅
Linternow expects flat config format - generates flat config files
Detailed Transformations:
1. Configuration File Migration
- Converts
.eslintrc.js,.eslintrc.json,.eslintrc.yaml, and.eslintrc.ymlto the new flat config format (eslint.config.cjs) - Transforms
extendsconfigurations (e.g.,"eslint:recommended"→js.configs.recommended) - Migrates
envsettings to the newlanguageOptions.globalsformat - Updates
globalsandparserOptionsto the flat config structure - Preserves
overridesby converting them to separate configuration objects - Adds necessary imports (
@eslint/js,globals, etc.)
2. Rule Transformations
Automatically updates several ESLint rules with breaking changes:
no-unused-vars: Adds defaultcaughtErrors: 'none'optionno-useless-computed-key: AddsenforceForClassMembers: falseoptionno-sequences: Properly migratesallowInParenthesesoptionno-constructor-return: Ensures proper array formatcamelcase: Migrates options while handling complexallowpatternsno-restricted-imports: Restructures paths configuration
3. JSDoc Migration
- Detects
require-jsdocandvalid-jsdocrules (removed in ESLint v9) - Migrates to
eslint-plugin-jsdocwith appropriate configuration - Removes deprecated JSDoc-related eslint comments
4. Comment Cleanup
- Removes unnecessary eslint comments from files
- Fixes malformed
/* exported */comments to proper format
Usage
Simply run the codemod in your project directory. It will automatically find and migrate all .eslintrc.* files:
bash
Manual Steps Required
After running this codemod, you may need to:
- Install new dependencies:
bash
-
Update JSDoc settings manually if needed (marked with
// TODO: Migrate settings manually) -
Test your ESLint configuration:
bash
What Gets Transformed
Before (.eslintrc.json)
json
After (eslint.config.cjs)
javascript