{"id":13533715,"url":"https://github.com/styled-components/styled-components-codemods","last_synced_at":"2025-07-28T12:07:32.266Z","repository":{"id":57138129,"uuid":"151055172","full_name":"styled-components/styled-components-codemods","owner":"styled-components","description":"Automatic codemods to upgrade your styled-components code to newer versions.","archived":false,"fork":false,"pushed_at":"2018-10-10T18:05:19.000Z","size":100,"stargazers_count":52,"open_issues_count":7,"forks_count":5,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-01-25T12:33:26.796Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/styled-components.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":"2018-10-01T08:06:15.000Z","updated_at":"2023-09-18T02:14:02.000Z","dependencies_parsed_at":"2022-08-25T10:10:18.349Z","dependency_job_id":null,"html_url":"https://github.com/styled-components/styled-components-codemods","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/styled-components%2Fstyled-components-codemods","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/styled-components%2Fstyled-components-codemods/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/styled-components%2Fstyled-components-codemods/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/styled-components%2Fstyled-components-codemods/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/styled-components","download_url":"https://codeload.github.com/styled-components/styled-components-codemods/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237116489,"owners_count":19258262,"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":[],"created_at":"2024-08-01T07:01:22.416Z","updated_at":"2025-02-04T12:31:13.740Z","avatar_url":"https://github.com/styled-components.png","language":"JavaScript","readme":"# styled-components-codemods\n\nAutomatic codemods to upgrade your styled-components code to newer versions.\n\n## Installation\n\nThanks to `npx` no installation is needed, just run the command below!\n\n## Usage\n\n```sh\nUsage: npx styled-components-codemods [options] [command]\n\nOptions:\n\n  -V, --version                                  output the version number\n  -h, --help                                     output usage information\n\nCommands:\n\n  v4 [...files]                                  Run all v4 codemods\n  v4-extendToStyled [...files]                   Run just the extendToStyled codemod\n  v4-injectGlobalToCreateGlobalStyle [...files]  Run just the injectGlobalToCreateGlobalStyle codemod\n\nExamples:\n\n  $ styled-components-codemods v4-extendToStyled src/components/Box.js src/components/Button.js\n  $ styled-components-codemods v4 src/**/*.js (this will only work if your terminal expands globs)\n```\n\n### Codemods\n\n#### v4\n\nIn version 4 of `styled-components` the `Component.extends` API will be removed in favor of only using `styled(Component)`. This codemod replaces all `.extends` calls to equivalent `styled()` calls instead. Furthermore, the injectGlobal API has been upgraded to slot into React's lifecycle more naturally. It refactors all `injectGlobal` calls, and warns you where they are, so you can export them and include them when rendering.\n\n##### Limitations\n\nThere is no way to distinguish whether `.extend` identifier is related to `styled-components` or any other library/prototype etc. If you know that there is another `.extend` function in your project that is not related to `styled-components` be aware and revert these instances manually.\n\n\u003e Be aware that `.extend` used in combination with `.withComponent` can give you a different result than `styled(WithComponentedComponent)`. Refer to this [issue](https://github.com/styled-components/styled-components/issues/1956) to understand the difference.\n\n##### Example\n\n\u003cdetails\u003e\n\n  \u003csummary\u003eCode Before\u003c/summary\u003e\n\n```javascript\nStyledComponent.extend``;\n\nStyledComponent.extend`\n  color: red;\n`;\n\nStyledComponent.extend({ color: \"red\" });\n\nStyledComponent.extend;\n\nStyledComponent.extend``.extend;\n\nStyledComponent.extend({ color: red }).extend;\n\nstyled.div``.extend``;\n\nstyled.div`\n  color: red;\n`.extend`color: blue;`;\n\nstyled.div({ color: \"red\" }).extend({ color: \"blue\" });\n\nStyledComponent.withComponent(\"div\").extend``;\n\nStyledComponent.withComponent(\"div\").extend`color: red;`;\n\nStyledComponent.withComponent(\"div\").extend();\n\nStyledComponent.withComponent(\"div\").extend({ color: red });\n\nStyledComponent.extend()\n  .extend()\n  .extend().extend``;\n\nStyledComponent.extend``.extend().extend``.extend``;\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\n  \u003csummary\u003eCode after\u003c/summary\u003e\n\n```javascript\nimport styled, { css } from \"styled-components\";\n\nstyled(StyledComponent)``;\n\nstyled(StyledComponent)`\n  color: red;\n`;\n\nstyled(StyledComponent)({ color: \"red\" });\n\nstyled(StyledComponent);\n\nstyled(styled(StyledComponent)``);\n\nstyled(styled(StyledComponent)({ color: red }));\n\nstyled(styled.div``)``;\n\nstyled(\n  styled.div`\n    color: red;\n  `\n)`\n  color: blue;\n`;\n\nstyled(styled.div({ color: \"red\" }))({ color: \"blue\" });\n\nstyled(StyledComponent.withComponent(\"div\"))``;\n\nstyled(StyledComponent.withComponent(\"div\"))`\n  color: red;\n`;\n\nstyled(StyledComponent.withComponent(\"div\"))();\n\nstyled(StyledComponent.withComponent(\"div\"))({ color: red });\n\nstyled(styled(styled(styled(StyledComponent)())())())``;\n\nstyled(styled(styled(styled(StyledComponent)``)())``)``;\n```\n\n\u003c/details\u003e\n","funding_links":[],"categories":["Libraries"],"sub_categories":["Styled Components"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstyled-components%2Fstyled-components-codemods","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstyled-components%2Fstyled-components-codemods","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstyled-components%2Fstyled-components-codemods/lists"}