Skip to main content
PRONeed enterprise-grade codemods tailored to your codebase?

Assess, plan, evolve.

Reusable compiler-aware skills that help coding agents understand, plan, and safely evolve your codebase.

3 packages

Sort by
biome/migrate-rules

This codemod replaces configuration files for ESLint with corresponding biome.json for all the found rules. It also replaces Prettier configuration. ## Note: This codemod accepts manual user input, which is required to migrate away from eslint. In order to run it properly, run the following command: ```bash npx eslint --print-config <path-to-a-file-that-eslint-checks> | codemod eslint/biome/migrate-rules ``` It's important that you pass these rules to the codemod, because our codemods are limited in access for security purposes and have no access to most node features that could maliciously affect your system. This codemod requires internet connection. ## Example ### `package.json` ### Before ```json { "name": "package-name", "dependencies": { "prettier": "^3.1.0", "prettier-plugin-tailwindcss": "^0.5.4", "@tanstack/eslint-plugin-query": "^4.29.25", "@someorg/prettier-config": "^1.1.1" }, "devDependencies": { "eslint-plugin-airbnb": "^10.2.0", "eslint": "^10.2.0", "eslint-plugin-prettier": "^10.2.0", "eslint-config-prettier": "^10.2.0" }, "main": "./dist/index.cjs", "scripts": { "start": "pnpm run build:cjs && node ./dist/index.cjs", "lint:eslint": "eslint . --fix", "lint:prettier": "prettier --write ." }, "eslintIgnore": ["ignore-key"], "files": [ "prettier-test-no-replace", "README.md", ".codemodrc.json", "./dist/index.cjs" ], "lint-staged": { "*.js": "eslint --fix", "*.ts": "eslint --fix" }, "type": "module" } ``` ### After ```json { "name": "package-name", "dependencies": {}, "devDependencies": { "@biomejs/biome": "1.5.3" }, "main": "./dist/index.cjs", "scripts": { "start": "pnpm run build:cjs && node ./dist/index.cjs", "lint:eslint": "pnpm dlx @biomejs/biome lint . --apply", "lint:prettier": "pnpm dlx @biomejs/biome format --write .", "NOTE": "You can apply both linter, formatter and import ordering by using https://biomejs.dev/reference/cli/#biome-check", "NOTE2": "There is an ongoing work to release prettier-tailwind-plugin alternative: https://biomejs.dev/linter/rules/use-sorted-classes/, https://github.com/biomejs/biome/issues/1274" }, "files": [ "prettier-test-no-replace", "README.md", ".codemodrc.json", "./dist/index.cjs" ], "lint-staged": { "*.js": "pnpm dlx @biomejs/biome lint --apply", "*.ts": "pnpm dlx @biomejs/biome lint --apply" }, "type": "module" } ``` ### `.eslintrc.json` ### Before ```json { "rules": [...] } ``` ### After `Removed and replaced with corresponding rules in biome.json` ### `.prettierrc` ### Before ```json { "printWidth": 80 } ``` ### After `Removed and replaced with corresponding values in biome.json` ### `biome.json` ```json { "linter": { "ignore": [ "ignore-key", "dist", "build", "pnpm-lock.yaml", "node_modules" ], "rules": { "suspicious": { "noDoubleEquals": "warn", "noAssignInExpressions": "warn" }, "correctness": { "noUnusedVariables": "off" } } }, "formatter": { "ignore": [], "indentStyle": "tab" } } ```

  • migration
  • eslint
CCodemod
v1.0.2
647
a year ago
@nodejs/correct-ts-specifiers

# Correct TypeScript Specifiers This package transforms import specifiers from the old `tsc` (TypeScript's compiler) requirement of using `.js` file extensions in source-code to import files that are actually typescript; the corrected specifiers enable source-code to be runnable by standards-compliant software like Node.js. This is a one-and-done process, and the updated source-code should be committed to your version control (eg git); thereafter, source-code import statements should be authored compliant with the ECMAScript (JavaScript) standard. > [!TIP] > Those using `tsc` to compile will need to enable [`rewriteRelativeImportExtensions`](https://www.typescriptlang.org/tsconfig/#rewriteRelativeImportExtensions); using `tsc` for only type-checking (ex via a lint/test step like `npm run test:types`) needs [`allowImportingTsExtensions`](https://www.typescriptlang.org/tsconfig/#allowImportingTsExtensions) (and some additional compile options—see the cited documentation); This package does not just blindly find & replace file extensions within specifiers: It confirms that the replacement specifier actually exists; in ambiguous cases (such as two files with the same basename in the same location but different relevant file extensions like `/tmp/foo.js` and `/tmp/foo.ts`), it logs an error, skips that specifier, and continues processing. > [!CAUTION] > This package does not confirm that imported modules contain the desired export(s). This _shouldn't_ actually ever result in a problem because ambiguous cases are skipped (so if there is a problem, it existed before the migration started). Merely running your source-code after the mirgration completes will confirm all is well (if there are problems, node will error, citing the problems). > [!TIP] > Node.js requires the `type` keyword be present on type imports. For own code, this package usually handles that. However, in some cases and for node modules, it does not. Robust tooling already exists that will automatically fix this, such as > > * [`use-import-type` via biome](https://biomejs.dev/linter/rules/use-import-type/) > * [`typescript/no-import-type-side-effects` via oxlint](https://oxc.rs/docs/guide/usage/linter/rules/typescript/no-import-type-side-effects) > * [`consistent-type-imports` via typescript-lint](https://typescript-eslint.io/rules/consistent-type-imports) > > If your source code needs that, first run this codemod and then one of those fixers. ## Running > [!CAUTION] > This will change your source-code. Commit any unsaved changes before running this package. > [!IMPORTANT] > [`--experimental-import-meta-resolve`](https://nodejs.org/api/cli.html#--experimental-import-meta-resolve) MUST be enabled; the feature is not really experimental—it's nonstandard because it's not relevant for browsers. ```console $ NODE_OPTIONS="--experimental-import-meta-resolve" \ npx codemod@latest correct-ts-specifiers ``` ### Monorepos For best results, run this _within_ each workspace of the monorepo. ```text project-root/ ├ workspaces/ ├ foo/ ←--------- RUN HERE ├ … ├ package.json └ tsconfig.json └ bar/ ←--------- RUN HERE ├ … ├ package.json └ tsconfig.json └ utils/ ←--------- RUN HERE ├ qux.js └ zed.js ``` ## Supported cases * no file extension → `.cts`, `.mts`, `.js`, `.ts`, `.d.cts`, `.d.mts`, or `.d.ts` * `.cjs` → `.cts`, `.mjs` → `.mts`, `.js` → `.ts` * `.js` → `.d.cts`, `.d.mts`, or `.d.ts` * [Package.json subpath imports](https://nodejs.org/api/packages.html#subpath-imports) * [tsconfig paths](https://www.typescriptlang.org/tsconfig/#paths) (via [`@nodejs-loaders/alias`](https://github.com/JakobJingleheimer/nodejs-loaders/blob/main/packages/alias?tab=readme-ov-file)) * In order to subsequently run code via node, you will need to add this (or another) loader to your own project. Or, switch to [subimports](https://nodejs.org/api/packages.html#subpath-imports). * Commonjs-like directory specifiers Before: ```ts import { URL } from 'node:url'; import { bar } from '@dep/bar'; import { foo } from 'foo'; import { Bird } from './Bird'; // a directory import { Cat } from './Cat.ts'; import { Dog } from '…/Dog/index.mjs'; // tsconfig paths import { baseUrl } from '#config.js'; // package.json imports export { Zed } from './zed'; export const makeLink = (path: URL) => (new URL(path, baseUrl)).href; const nil = await import('./nil.js'); const bird = new Bird('Tweety'); const cat = new Cat('Milo'); const dog = new Dog('Otis'); ``` After: ```ts import { URL } from 'node:url'; import { bar } from '@dep/bar'; import { foo } from 'foo'; import { Bird } from './Bird/index.ts'; import { Cat } from './Cat.ts'; import { Dog } from '…/Dog/index.mts'; // tsconfig paths import { baseUrl } from '#config.js'; // package.json imports export type { Zed } from './zed.d.ts'; export const makeLink = (path: URL) => (new URL(path, baseUrl)).href; const nil = await import('./nil.ts'); const bird = new Bird('Tweety'); const cat = new Cat('Milo'); const dog = new Dog('Otis'); ```

  • esm
  • import
  • +2
Nnodejs
v1.0.0
50
a year ago
correct-ts-specifiers

# Correct TypeScript Specifiers This package transforms import specifiers from the old `tsc` (TypeScript's compiler) requirement of using `.js` file extensions in source-code to import files that are actually typescript; the corrected specifiers enable source-code to be runnable by standards-compliant software like Node.js. This is a one-and-done process, and the updated source-code should be committed to your version control (eg git); thereafter, source-code import statements should be authored compliant with the ECMAScript (JavaScript) standard. > [!TIP] > Those using `tsc` to compile will need to enable [`rewriteRelativeImportExtensions`](https://www.typescriptlang.org/tsconfig/#rewriteRelativeImportExtensions); using `tsc` for only type-checking (ex via a lint/test step like `npm run test:types`) needs [`allowImportingTsExtensions`](https://www.typescriptlang.org/tsconfig/#allowImportingTsExtensions) (and some additional compile options—see the cited documentation); This package does not just blindly find & replace file extensions within specifiers: It confirms that the replacement specifier actually exists; in ambiguous cases (such as two files with the same basename in the same location but different relevant file extensions like `/tmp/foo.js` and `/tmp/foo.ts`), it logs an error, skips that specifier, and continues processing. > [!CAUTION] > This package does not confirm that imported modules contain the desired export(s). This _shouldn't_ actually ever result in a problem because ambiguous cases are skipped (so if there is a problem, it existed before the migration started). Merely running your source-code after the mirgration completes will confirm all is well (if there are problems, node will error, citing the problems). > [!TIP] > Node.js requires the `type` keyword be present on type imports. For own code, this package usually handles that. However, in some cases and for node modules, it does not. Robust tooling already exists that will automatically fix this, such as [`consistent-type-imports` via typescript-lint](https://typescript-eslint.io/rules/consistent-type-imports) and [`use-import-type` via biome](https://biomejs.dev/linter/rules/use-import-type/). If your source code needs that, first run this codemod and then one of those fixers. ## Running > [!CAUTION] > This will change your source-code. Commit any unsaved changes before running this package. ```sh NODE_OPTIONS="--experimental-import-meta-resolve" \ npx codemod@latest correct-ts-specifiers ``` ### Monorepos For best results, run this _within_ each workspace of the monorepo. ```text project-root/ ├ workspaces/ ├ foo/ ←--------- RUN HERE ├ … ├ package.json └ tsconfig.json └ bar/ ←--------- RUN HERE ├ … ├ package.json └ tsconfig.json └ utils/ ←--------- RUN HERE ├ qux.js └ zed.js ``` ## Supported cases * no file extension → `.cts`, `.mts`, `.js`, `.ts`, `.d.cts`, `.d.mts`, or `.d.ts` * `.cjs` → `.cts`, `.mjs` → `.mts`, `.js` → `.ts` * `.js` → `.d.cts`, `.d.mts`, or `.d.ts` * [Package.json subimports](https://nodejs.org/api/packages.html#subpath-imports) * [tsconfig paths](https://www.typescriptlang.org/tsconfig/#paths) (via [`@nodejs-loaders/alias`](https://github.com/JakobJingleheimer/nodejs-loaders/blob/main/packages/alias?tab=readme-ov-file)) * In order to subsequently run code via node, you will need to add this (or another) loader to your own project. Or, switch to [subimports](https://nodejs.org/api/packages.html#subpath-imports). * Commonjs-like directory specifiers Before: ```ts import { URL } from 'node:url'; import { bar } from '@dep/bar'; import { foo } from 'foo'; import { Bird } from './Bird'; // a directory import { Cat } from './Cat.ts'; import { Dog } from '…/Dog/index.mjs'; // tsconfig paths import { baseUrl } from '#config.js'; // package.json imports export { Zed } from './zed'; export const makeLink = (path: URL) => (new URL(path, baseUrl)).href; const nil = await import('./nil.js'); const bird = new Bird('Tweety'); const cat = new Cat('Milo'); const dog = new Dog('Otis'); ``` After: ```ts import { URL } from 'node:url'; import { bar } from '@dep/bar'; import { foo } from 'foo'; import { Bird } from './Bird/index.ts'; import { Cat } from './Cat.ts'; import { Dog } from '…/Dog/index.mts'; // tsconfig paths import { baseUrl } from '#config.js'; // package.json imports export type { Zed } from './zed.d.ts'; export const makeLink = (path: URL) => (new URL(path, baseUrl)).href; const nil = await import('./nil.ts'); const bird = new Bird('Tweety'); const cat = new Cat('Milo'); const dog = new Dog('Otis'); ```

  • esm
  • import
  • +2
Jjakobjingleheimer
v1.0.12
1
a year ago

Build your own codemod!

Describe the migration you need and Codemod Agent will create a codemod for you.

Ready to evolve your codebase?

Build tailored, compiler-aware skills to assess, plan, and automate complex codebase changes.