Eeslint

eslint/v9-to-v10-custom-rules

Migrate custom ESLint rules from v9 to v10 format

transformationmigrationeslintv9v10
Public
0 executions

Run locally

npx codemod @eslint/v9-to-v10-custom-rules

@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 with context.languageOptions.parserOptions
  • context.parserPath — inserts a /* TODO */ block comment (no replacement exists)
  • v8→v9 fallback patterns — collapses context.filename ?? context.getFilename() to context.filename
  • Removed SourceCode methods — replaces getTokenOrCommentBefore, getTokenOrCommentAfter, isSpaceBetweenTokens; inserts /* TODO */ block comment for getJSDocComment
  • Optional skip argument — correctly migrates getTokenOrCommentBefore(node, skip) to getTokenBefore(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 commentAction required
context.parserPath removed in ESLint v10, no replacementRemove 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 replacementRemove the usage. If you need JSDoc information, use a third-party library or implement the logic manually using sourceCode.getCommentsBefore(node)

Resources

Ready to contribute?

Build your own codemod and share it with the community.