@eslint/v9-to-v10-custom-rules
Migrate custom ESLint rules from v9 to v10.
Overview
ESLint v10 removes context methods and SourceCode methods that were deprecated in v9. This codemod rewrites all removed API calls to their v10 equivalents.
What This Codemod Does
- ✅ Removed context methods — replaces
context.getFilename(),context.getPhysicalFilename(),context.getCwd(),context.getSourceCode()with their property equivalents - ✅
context.parserOptions— replaces withcontext.languageOptions.parserOptions - ✅
context.parserPath— inserts a/* TODO */block comment (no replacement exists) - ✅ v8→v9 fallback patterns — collapses
context.filename ?? context.getFilename()tocontext.filename - ✅ Removed SourceCode methods — replaces
getTokenOrCommentBefore,getTokenOrCommentAfter,isSpaceBetweenTokens; inserts/* TODO */block comment forgetJSDocComment - ✅ Optional
skipargument — correctly migratesgetTokenOrCommentBefore(node, skip)togetTokenBefore(node, { includeComments: true, skip })
Transformations
Context methods:
js
v8→v9 fallback cleanup:
js
SourceCode methods:
js
Usage
bash
Or run locally from source:
bash
Manual Steps Required
After running this codemod, search your files for TODO comments and address each one:
| TODO comment | Action required |
|---|---|
context.parserPath removed in ESLint v10, no replacement | Remove the usage. If you were checking the parser, use context.languageOptions.parser instead (the value is the parser object, not a path string) |
getJSDocComment removed in ESLint v10, no replacement | Remove the usage. If you need JSDoc information, use a third-party library or implement the logic manually using sourceCode.getCommentsBefore(node) |