{"_id":"@brightnightpower/ts-codemod","_rev":"2-eb7c5db0e1491e930e5d3c49cc8a9c0a","name":"@brightnightpower/ts-codemod","dist-tags":{"latest":"1.4.1"},"versions":{"1.4.0":{"name":"@brightnightpower/ts-codemod","version":"1.4.0","keywords":["codemod","typescript","ecma","react-query-v5","migrate"],"author":"","license":"ISC","_id":"@brightnightpower/ts-codemod@1.4.0","maintainers":[{"name":"admin-bn","email":"administration@brightnightpower.com"}],"bin":{"ts-codemod":"dist/src/index.js"},"dist":{"shasum":"b11516a398fb868f7c6bb8681b66253ddad56afc","tarball":"https://registry.npmjs.org/@brightnightpower/ts-codemod/-/ts-codemod-1.4.0.tgz","fileCount":30,"integrity":"sha512-NB+MZBW1NpaDtNJW0RmGyDfkTXYvqcOyeZeCOklt0hF7jcxRgxpNkysobJTI+2MstS2aqJHft/C82T2kyR3UWA==","signatures":[{"sig":"MEYCIQCBNannJBT3xabttxOxUaonJgeEkSjaGwe2eoadxFLfLAIhAP/6aW4tQydRiiGKb8I0uyLbIwgu8M0be9VMuyoRzZ+d","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":49399},"main":"src/index.js","type":"module","gitHead":"0a3f318063eeff2b72515e4da46c4528ee517951","scripts":{"lint":"biome lint --write src/ && tsc --noEmit -p .","test":"vitest","build":"tsc","check":"biome check --write src/","format":"biome format --write src/","check-no-fix":"biome check src/ && tsc --noEmit -p .","prepublishOnly":"npm run build"},"_npmUser":{"name":"admin-bn","email":"administration@brightnightpower.com"},"_npmVersion":"10.9.2","description":"A codemod tool to transform imports in Typescript","directories":{},"_nodeVersion":"20.12.0","dependencies":{"ts-morph":"^25.0.1","commander":"^13.1.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^3.0.9","typescript":"^5.8.2","@types/node":"^22.13.10","@biomejs/biome":"^1.9.4","semantic-release":"^24.2.3","@semantic-release/git":"^10.0.1","@semantic-release/npm":"^12.0.1","@semantic-release/changelog":"^6.0.3","conventional-changelog-conventionalcommits":"^8.0.0"},"_npmOperationalInternal":{"tmp":"tmp/ts-codemod_1.4.0_1746717109675_0.8282714219754606","host":"s3://npm-registry-packages-npm-production"}},"1.4.1":{"name":"@brightnightpower/ts-codemod","version":"1.4.1","publishConfig":{"access":"public"},"description":"A codemod tool to transform imports in Typescript","keywords":["codemod","typescript","ecma","react-query-v5","migrate"],"license":"ISC","author":"","type":"module","main":"src/index.js","bin":{"ts-codemod":"dist/src/index.js"},"dependencies":{"commander":"^13.1.0","ts-morph":"^25.0.1"},"devDependencies":{"@biomejs/biome":"^1.9.4","@semantic-release/changelog":"^6.0.3","@semantic-release/git":"^10.0.1","@semantic-release/npm":"^12.0.1","@types/node":"^22.13.10","conventional-changelog-conventionalcommits":"^8.0.0","semantic-release":"^24.2.3","typescript":"^5.8.2","vitest":"^3.0.9"},"scripts":{"build":"tsc","lint":"biome lint --write src/ && tsc --noEmit -p .","format":"biome format --write src/","check":"biome check --write src/","check-no-fix":"biome check src/ && tsc --noEmit -p .","test":"vitest","prepublishOnly":"npm run build"},"_id":"@brightnightpower/ts-codemod@1.4.1","gitHead":"deb37b55295f386ad91e888858705582943a3a35","_nodeVersion":"20.12.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-kIKSllM8brhd5SwY5r2QeyNEGIJGjcONidf8XKMSkcjH0+qPqgGRQOpu6YF9B27a6jAm7K0C6OztalZi6wPBMw==","shasum":"a08378796f74d929ae2b5cf9cbc3346f27b6a908","tarball":"https://registry.npmjs.org/@brightnightpower/ts-codemod/-/ts-codemod-1.4.1.tgz","fileCount":30,"unpackedSize":55496,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQD9ig+Ticui473T7xQrtuz9W5H0Y3/yNaDNroCpdycb8AIhAK1Qg99gGAnKnuJ8qlCQEU9smDDmkDxqdbghPPGAIxg8"}]},"_npmUser":{"name":"admin-bn","email":"administration@brightnightpower.com"},"directories":{},"maintainers":[{"name":"admin-bn","email":"administration@brightnightpower.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/ts-codemod_1.4.1_1746737979647_0.018648146410291"},"_hasShrinkwrap":false}},"time":{"created":"2025-05-08T15:11:49.598Z","modified":"2025-05-08T20:59:40.118Z","1.4.0":"2025-05-08T15:11:49.848Z","1.4.1":"2025-05-08T20:59:39.918Z"},"license":"ISC","keywords":["codemod","typescript","ecma","react-query-v5","migrate"],"description":"A codemod tool to transform imports in Typescript","maintainers":[{"name":"admin-bn","email":"administration@brightnightpower.com"}],"readme":"# Typescript Codemod\n\n[![semantic-release: angular](https://img.shields.io/badge/semantic--release-angular-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release)\n![GitHub CI](https://github.com/BrightNight-Energy/ts-codemod/actions/workflows/cicd.yml/badge.svg)\n[![npm version](https://badge.fury.io/js/%40brightnightpower%2Fts-codemod.svg)](https://www.npmjs.com/package/%40brightnightpower%2Fts-codemod)\n\nA collection of mostly random codemods you (might) find helpful.\n\n\n## Installation\n\n```shell\nnpm install -g @brightnightpower/ts-codemod\n````\n\n## Usage\n\n```\nts-codemod [options] <directory>\n\nArguments:\n  directory            Source directory\n\nOptions:\n  -V, --version        output the version number\n  -c, --config <path>  Path to tsconfig.json (default: \"tsconfig.json\")\n  -t, --type <type>    Type of codemod, default .js (default: \".js\")\n  -h, --help           display help for command\n```\n\n## Codemods\n\n### Update imports to .js\n\nCodmod to turn all Typescript imports to '.js', as customary for ECMA modules.\n\n```shell\nts-codemod src/ -t convert-to-.js-imports\n```\n\nFor example, will turn:\n```typescript\nimport myModule from \"./myModule\";\nimport { type Type, Class } from \"./myMixedModule\";\nimport myJson from \"./myJson.json\";\n```\n\ninto\n\n```typescript\nimport myModule from \"./myModule.js\";\nimport { type Type, Class } from \"./myMixedModule.js\";\nimport myJson from \"./myJson.json\" with { type: 'json' };\n```\n\n### Update Material UI Icon imports\n\n```shell\nts-codemod src/ -t merge-mui-icons\n```\n\nFor example, will turn:\n```typescript\nimport myIcon from \"@mui/material-icons/Icon\";\n```\n\ninto\n\n```typescript\nimport { Icon as myIcon } from \"@mui/material-icons\";\n```\n\n### Remove .js imports\n\n```shell\nts-codemod src/ -t remove-.js-imports\n```\n\nFor example, will turn:\n```typescript\nimport myModule from \"./myModule.js\";\n```\n\ninto\n\n```typescript\nimport myModule from \"./myModule\";\n```\n\n### Merge imports\n\n```shell\nts-codemod src/ -t merge-duplicate-imports\n```\n\nWill turn\n```typescript\nimport myModule from \"./myModule.js\";\nimport { Project } from \"ts-morph\";\nimport { type Stuff } from \"ts-morph\";\nimport { type Type, Class } from \"./myModule.js\";\nimport * as yup from \"yup\";\nimport type { AnySchema } from \"yup\";\n```\n\ninto\n```typescript\nimport myModule, { type Type, Class } from \"./myModule.js\";\nimport { Project, type Stuff } from \"ts-morph\";\nimport * as yup from \"yup\";\nimport { AnySchema } from \"yup\"; // note: import type was dropped\nimport { Data } from \"plotly.js\";\n```\n\n> [!NOTE]\n> As noted in the comment above, the 'Type' modifier in the import statement may be dropped.\n> A linter like [biome](https://biomejs.dev/) will add these back in.\n\n### Tanstack's React Query v4 to v5\n\n```shell\nts-codemod src/ -t react-query-v5-migrate\n```\n\nWill turn\n```typescript jsx\nuseQuery('todos', fetchTodos, { enabled: false });\nuseMutation(createTodo, { onSuccess });\n```\n\ninto\n```typescript jsx\nuseQuery({ queryKey: 'todos', queryFn: fetchTodos, enabled: false });\nuseMutation({ mutationFn: createTodo, onSuccess });\n```\n\n## Contributing\n\nAll contributions welcome! Make sure to install precommit hooks for complete functionality:\n```shell\npre-commit install --install-hooks\npre-commit install --hook-type commit-msg\n```\n","readmeFilename":"readme.md"}