{"id":30305317,"url":"https://github.com/codemod-com/userland-migrations","last_synced_at":"2025-08-17T08:08:43.238Z","repository":{"id":310264161,"uuid":"866189412","full_name":"codemod-com/userland-migrations","owner":"codemod-com","description":"node.js codemod scripts","archived":false,"fork":false,"pushed_at":"2024-10-01T23:42:13.000Z","size":9,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-16T22:21:54.571Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codemod-com.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-10-01T19:54:04.000Z","updated_at":"2024-11-08T14:08:40.000Z","dependencies_parsed_at":"2025-08-16T22:21:56.377Z","dependency_job_id":"6504a90c-4770-43e0-b15e-39162d6326da","html_url":"https://github.com/codemod-com/userland-migrations","commit_stats":null,"previous_names":["codemod-com/userland-migrations"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/codemod-com/userland-migrations","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemod-com%2Fuserland-migrations","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemod-com%2Fuserland-migrations/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemod-com%2Fuserland-migrations/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemod-com%2Fuserland-migrations/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codemod-com","download_url":"https://codeload.github.com/codemod-com/userland-migrations/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemod-com%2Fuserland-migrations/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270820793,"owners_count":24651534,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-17T02:00:09.016Z","response_time":129,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-08-17T08:08:42.316Z","updated_at":"2025-08-17T08:08:43.220Z","avatar_url":"https://github.com/codemod-com.png","language":null,"readme":"# Node.js codemods\nThis repository contains a collection of free and open-source codemods/transform scripts to help update Node.js projects.\n\n## Usage\n\nTo run the transform scripts use [`codemod`](https://go.codemod.com/github) command below:\n\n`npx codemod \u003ctransform\u003e --target \u003cpath\u003e [...options]`\n\n* `transform` - name of transform. see available transforms below.\n* `path` - directory to transform. defaults to the current directory.\n\n⚠️ Caution: The scripts will change your source code. Commit or stash any unsaved changes before running them.\n\nCheck out this [doc](https://go.codemod.com/cli-docs) for the full list of available commands.\n\n## Available codemods\n\nAll Node.js codemods are also available in the [Codemod Registry](https://codemod.com/registry).\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003e Correct TypeScript specifiers \u003c/strong\u003e\u003c/summary\u003e\u003cbr\u003e\n  \n```sh\nnpx codemod node/correct-ts-specifiers\n```\n  \nThis script transforms import specifiers in source code from the broken state TypeScript's compiler (`tsc`) requires into proper ones. 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 to be compliant with the ECMAScript (JavaScript) standard.\n\nThis is useful when source code is processed by standards-compliant software like Node.js.\n\nThis script does not just blindly find \u0026 replace file extensions within specifiers: It confirms that the targeted file of replacement specifier actually exists; in cases where there is ambiguity (such as two files with the same basename in the same location but different relevant file extensions), it logs an error, skips that specifier, and continues processing.\n\nThis script does not confirm that the targetted module in the replacement contains the exports cited in the import statement. This should not 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 good (if there are problems, node will error, citing exactly where the problems are).\n\n**💡 Note**\n\n1. If you're using `tsconfig`'s `paths`, you will need a loader like [`nodejs-loaders/dev/alias`](https://github.com/JakobJingleheimer/nodejs-loaders?tab=readme-ov-file#alias)\n\n```sh\nnpm i nodejs-loaders\n\nNODE_OPTIONS=\"--loader=nodejs-loaders/dev/alias\" \\\nnpx codemod node/correct-ts-specifiers\n```\n\n2. If you want your source code to still be processessable with `tsc` (for instance, to run type-checking as a lint or test step), you'll need to set [`allowImportingTsExtensions`](https://www.typescriptlang.org/tsconfig/#allowImportingTsExtensions). You will need to use a different transpiler to convert your source code to JavaScript (you probably should be doing that anyway).\n\n### Supported cases\n\n* no file extension → `.cts`, `.mts`, `.js`, `.ts`, `.d.cts`, `.d.mts`, or `.d.ts`\n* `.cjs` → `.cts`, `.mjs` → `.mts`, `.js` → `.ts`\n* `.js` → `.d.cts`, `.d.mts`, or `.d.ts`\n* Package.json subimports\n* tsconfig paths (requires a loader)\n\nBefore:\n\n```ts\nimport { URL } from 'node:url';\n\nimport { bar } from '@dep/bar';\nimport { foo } from 'foo';\n\nimport { Cat } from './Cat.ts';\nimport { Dog } from '…/Dog/index.mjs'; // tsconfig paths\nimport { baseUrl } from '#config.js';  // package.json imports\n\nexport { Zed } from './zed';\n\n// should be unchanged\n\nexport const makeLink = (path: URL) =\u003e (new URL(path, baseUrl)).href;\n\nconst nil = await import('./nil.js');\n\nconst cat = new Cat('Milo');\nconst dog = new Dog('Otis');\n```\n\nAfter:\n\n```ts\nimport { URL } from 'node:url';\n\nimport { bar } from '@dep/bar';\nimport { foo } from 'foo';\n\nimport { Cat } from './Cat.ts';\nimport { Dog } from '…/Dog/index.mts'; // tsconfig paths\nimport { baseUrl } from '#config.js';  // package.json imports\n\nexport type { Zed } from './zed.d.ts';\n\n// should be unchanged\n\nexport const makeLink = (path: URL) =\u003e (new URL(path, baseUrl)).href;\n\nconst nil = await import('./nil.ts');\n\nconst cat = new Cat('Milo');\nconst dog = new Dog('Otis');\n```\n\n### Unsupported cases\n\n* Directory / commonjs-like specifiers¹\n\n```ts\nimport foo from '..'; // where '..' → '../index.ts' (or similar)\n```\n\n¹ Support may be added in a future release\n\n\n\u003c/details\u003e\n\n\n## Feedback\n\nTo provide feedback on existing codemods or request new ones open a GitHub issue in this repo. \n\n## Contribution\n\nFeel free to open a PR in this repo to contribute your codemods for Node.js migrations.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodemod-com%2Fuserland-migrations","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodemod-com%2Fuserland-migrations","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodemod-com%2Fuserland-migrations/lists"}