Eeslint

eslint/v9-to-v10-linter-api

Migrate removed Linter/ESLint constructor options and stricter rule config schema for ESLint v10

transformationmigrationeslintv9v10
Public
0 executions

Run locally

npx codemod @eslint/v9-to-v10-linter-api

@eslint/v9-to-v10-linter-api

Migrate removed Linter/ESLint constructor options and stricter rule config schema for ESLint v10.

Overview

ESLint v10 removes the configType option, the useFlatConfig option on loadESLint, several Linter instance methods, and tightens the schema for three built-in rules.

What This Codemod Does

Transform 1 — Remove configType from new Linter()

configType: 'flat' is the only supported mode in v10 and no longer needs to be specified. configType: 'eslintrc' is removed with no equivalent — a TODO comment is inserted.

diff

Transform 2 — Remove useFlatConfig from loadESLint()

diff

Transform 3 — Remove deprecated flag values from new ESLint({ flags: [...] })

diff

Transform 4 — Deprecated Linter instance methods → TODO

defineParser(), defineRule(), defineRules(), and getRules() are removed with no direct replacement. Register rules and parsers via the flat config instead.

diff

Transform 5 — func-names stricter schema (remove extra 4th element)

diff

Transform 6 — no-invalid-regexp deduplicate allowConstructorFlags

diff

Transform 7 — radix deprecated string options

The "always" and "as-needed" string options of the radix rule are deprecated in ESLint v10. The rule now always enforces providing a radix argument. "always" is stripped (it is now the sole behavior). "as-needed" is flagged with a TODO because removing it changes the rule's behavior.

diff

Transform 8 — Remove LintMessage.nodeType

LintMessage.nodeType was removed in ESLint v10. Two patterns are handled:

Object property pairsnodeType: <value> is removed from object literals (common in test assertions):

diff

Member expression accesses.nodeType in formatters and custom tooling is flagged with a TODO (the surrounding expression must be removed manually):

diff

Usage

bash

After running

Search for TODO comments added by this codemod:

TODO commentAction required
configType "eslintrc" is removedRewrite integration to use flat config (eslint.config.js)
defineParser() removed in ESLint v10Register parsers in eslint.config.js languageOptions.parser
defineRule() removed in ESLint v10Register rules in eslint.config.js plugins
defineRules() removed in ESLint v10Register rules in eslint.config.js plugins
getRules() removed in ESLint v10Use ESLint.getRulesMetaForResults() or Linter.getRules() was removed with no equivalent
LintMessage.nodeType was removedRemove the surrounding expression that reads message.nodeType

Limitations

  • message.nodeType member expression accesses are flagged with a TODO but the surrounding expression must be removed manually — the codemod cannot determine what to replace the access with.
  • Fixer non-string argument validation is not automatable — check manually if you call fixer.insertTextBefore(node, nonString).
  • loadESLint({ useFlatConfig: true/false, ...otherOptions }) is not transformed when extra options are present alongside useFlatConfig — remove useFlatConfig manually in those cases.
  • new Linter({ configType: 'eslintrc', ...otherOptions }) is not flagged with a TODO when additional options are present — add the TODO comment manually.
  • func-names options with nested objects (e.g. { generators: { mode: 'strict' } }) are not transformed — the regex only matches flat (non-nested) options objects.
  • radix rule with "always" is only stripped when it is the sole option in the array (e.g. ['error', 'always']); forms with additional elements are left untouched.

Resources

Ready to contribute?

Build your own codemod and share it with the community.