{"id":13532195,"url":"https://github.com/yangshun/js-codemods","last_synced_at":"2025-05-05T22:00:19.159Z","repository":{"id":65977206,"uuid":"88253238","full_name":"yangshun/js-codemods","owner":"yangshun","description":"Some codemod scripts to transform code for good styling","archived":false,"fork":false,"pushed_at":"2017-04-21T15:12:28.000Z","size":8,"stargazers_count":6,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-01T20:31:48.942Z","etag":null,"topics":["codemod","es6","javascript","jscodeshift"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/yangshun.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}},"created_at":"2017-04-14T09:18:45.000Z","updated_at":"2024-07-07T21:36:56.000Z","dependencies_parsed_at":"2023-02-19T18:30:44.668Z","dependency_job_id":null,"html_url":"https://github.com/yangshun/js-codemods","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yangshun%2Fjs-codemods","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yangshun%2Fjs-codemods/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yangshun%2Fjs-codemods/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yangshun%2Fjs-codemods/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yangshun","download_url":"https://codeload.github.com/yangshun/js-codemods/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252584326,"owners_count":21771944,"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","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":["codemod","es6","javascript","jscodeshift"],"created_at":"2024-08-01T07:01:08.983Z","updated_at":"2025-05-05T22:00:19.131Z","avatar_url":"https://github.com/yangshun.png","language":"JavaScript","funding_links":[],"categories":["javascript","JavaScript"],"sub_categories":[],"readme":"## js-codemods\n\nThis repository contains a collection of codemod scripts for use with\n[JSCodeshift](https://github.com/facebook/jscodeshift).\n\n### Setup \u0026 Run\n\n```sh\nnpm install -g jscodeshift\ngit clone https://github.com/yangshun/js-codemods.git\njscodeshift -t path/to/codemod-script.js \u003cfile\u003e\n```\n\nUse the `-d` option for a dry-run and use `-p` to print the output for\ncomparison.\n\n### Included Scripts\n\n#### `jsx-conditional-rendering-operator`\n\nTransforms JSX inline If-Else with conditional operator rendering into inline if with logical `\u0026\u0026` operator rendering.\n\n```sh\njscodeshift -t js-codemods/transforms/jsx-conditional-rendering-operator.js \u003cfile\u003e\n```\n\n**Before**:\n\n```jsx\n\u003cdiv\u003e\n  {this.state.showAlert ? \u003cAlert /\u003e : null}\n  {this.state.hideAlert ? null : \u003cAlert /\u003e}\n\u003c/div\u003e\n```\n\n**After**:\n\n```jsx\n\u003cdiv\u003e\n  {this.state.showAlert \u0026\u0026 \u003cAlert /\u003e}\n  {!this.state.hideAlert \u0026\u0026 \u003cAlert /\u003e}\n\u003c/div\u003e\n```\n\n#### `jsxattribute-expression-to-literal`\n\nTransforms JSX attribute values which are string literals wrapped within `JSXExpressionContainers` to just the string literal itself.\n\n```sh\njscodeshift -t js-codemods/transforms/jsxattribute-expression-to-literal.js \u003cfile\u003e\n```\n\n**Before**:\n\n```jsx\n\u003cFoo header={\"Lorem Ipsum\"} message={'dolor sit amet'} /\u003e\n```\n\n**After**:\n\n```jsx\n\u003cFoo header=\"Lorem Ipsum\" message=\"dolor sit amet\" /\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyangshun%2Fjs-codemods","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyangshun%2Fjs-codemods","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyangshun%2Fjs-codemods/lists"}