eslint-transforms

raw JSON →
3.0.0 verified Sat Apr 25 auth: no javascript

A collection of jscodeshift-based codemods for automating ESLint rule upgrades across major versions. Current stable version is 3.0.0, released June 2024. Active development with recent transforms for ESLint v9 migration. Key differentiator: provides automated transforms for rule format changes (new-rule-format, v9-rule-migration) that would otherwise require manual refactoring. Requires Node >=20 and jscodeshift as a peer dependency. Alternative to manual upgrading or using ESLint's built-in migration tools.

error Error: Cannot find module 'eslint-transforms'
cause Package not installed or incorrect import path.
fix
Run npm install eslint-transforms --save-dev. If using ESM, ensure package.json has type: module or use .mjs extension.
error Error [ERR_REQUIRE_ESM]: require() of ES Module ... from ... not supported.
cause Using CommonJS require() with ESM-only package (v3+).
fix
Switch to ESM imports: import eslintTransforms from 'eslint-transforms' or convert your script to ESM.
error TypeError: eslintTransforms is not a function
cause Incorrect usage: attempting to call the package as a function instead of using CLI or named exports.
fix
Use CLI: npx eslint-transforms v9-rule-migration <path>. Or import named transform functions.
error Error: Node.js version 14 is not supported.
cause Running on Node <20 with v3.0.0.
fix
Upgrade Node to v20 or higher. If unable, use v2.x with Node 12+ by pinning version: npm install eslint-transforms@2.
breaking Node.js >=20 required. Older versions unsupported.
fix Upgrade Node.js to v20 or higher.
breaking ESM-only from v3.0.0. CommonJS require() will fail.
fix Use ESM imports or ensure compatibility with ESM modules.
gotcha The new-rule-format transform does not work for rules using ES6 module syntax.
fix Convert ES6 modules to CommonJS before running the transform, or manually update the rule.
gotcha Transforms modify files in-place. No undo mechanism provided.
fix Commit changes or use version control before running transforms. Use --dry flag if available (check docs).
breaking Drop support for Node <12 in v2.0.0.
fix Upgrade to Node >=12 to use v2+, or stay on v1.x if stuck on older Node.
npm install eslint-transforms
yarn add eslint-transforms
pnpm add eslint-transforms

Install the package as a dev dependency and run the v9-rule-migration transform on a rules directory, then new-rule-format on legacy rules.

npm install eslint-transforms --save-dev
npx eslint-transforms v9-rule-migration ./lib/rules
npx eslint-transforms new-rule-format ./legacy-rules