{"id":28334155,"url":"https://github.com/knightedcodemonkey/display-name","last_synced_at":"2026-02-28T17:32:09.672Z","repository":{"id":291883985,"uuid":"979107302","full_name":"knightedcodemonkey/display-name","owner":"knightedcodemonkey","description":"Codemod to add a React displayName to function components.","archived":false,"fork":false,"pushed_at":"2025-05-11T23:12:04.000Z","size":157,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-30T06:44:48.590Z","etag":null,"topics":["codemod","displayname","function-component","react"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/knightedcodemonkey.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":"2025-05-07T02:25:21.000Z","updated_at":"2025-05-11T23:11:05.000Z","dependencies_parsed_at":"2025-05-07T03:35:16.180Z","dependency_job_id":null,"html_url":"https://github.com/knightedcodemonkey/display-name","commit_stats":null,"previous_names":["knightedcodemonkey/display-name"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/knightedcodemonkey/display-name","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knightedcodemonkey%2Fdisplay-name","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knightedcodemonkey%2Fdisplay-name/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knightedcodemonkey%2Fdisplay-name/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knightedcodemonkey%2Fdisplay-name/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/knightedcodemonkey","download_url":"https://codeload.github.com/knightedcodemonkey/display-name/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knightedcodemonkey%2Fdisplay-name/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29944766,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-28T13:49:17.081Z","status":"ssl_error","status_checked_at":"2026-02-28T13:48:50.396Z","response_time":90,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["codemod","displayname","function-component","react"],"created_at":"2025-05-26T20:59:34.434Z","updated_at":"2026-02-28T17:32:09.664Z","avatar_url":"https://github.com/knightedcodemonkey.png","language":"TypeScript","readme":"# [`@knighted/display-name`](https://www.npmjs.com/package/@knighted/display-name)\n\n![CI](https://github.com/knightedcodemonkey/display-name/actions/workflows/ci.yml/badge.svg)\n[![codecov](https://codecov.io/gh/knightedcodemonkey/display-name/graph/badge.svg?token=R2GF8WJmXE)](https://codecov.io/gh/knightedcodemonkey/display-name)\n[![NPM version](https://img.shields.io/npm/v/@knighted/display-name.svg)](https://www.npmjs.com/package/@knighted/display-name)\n\nA codemod to add `displayName` to React function components.\n\n- Works with TypeScript or JavaScript source code.\n- Quickly fix [`react/display-name`](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/display-name.md) lint errors.\n- Use `displayName` or a named function expression.\n- Pass a path to a file, or a string.\n\n## Example\n\nGiven\n\n```tsx\nimport React, { memo } from 'react'\n\nconst Foo = memo(({ a }) =\u003e {\n  return \u003c\u003e{a}\u003c/\u003e\n})\nconst Bar = React.forwardRef((props, ref) =\u003e \u003cp ref={ref}\u003ebar\u003c/p\u003e)\nconst Baz = memo(\n  React.forwardRef((props, ref) =\u003e {\n    return \u003cp ref={ref}\u003ebaz\u003c/p\u003e\n  }),\n)\n```\n\nThen running `modify` on the source code (or `modifyFile` on the file path) results in\n\n```tsx\nimport React, { memo } from 'react'\n\nconst Foo = memo(({ a }) =\u003e {\n  return \u003c\u003e{a}\u003c/\u003e\n})\nFoo.displayName = 'Foo'\nconst Bar = React.forwardRef((props, ref) =\u003e \u003cp ref={ref}\u003ebar\u003c/p\u003e)\nBar.displayName = 'Bar'\nconst Baz = memo(\n  React.forwardRef((props, ref) =\u003e {\n    return \u003cp ref={ref}\u003ebaz\u003c/p\u003e\n  }),\n)\n```\n\nIf running the codemod against a codebase that has recently added `eslint-plugin-react` you can write a script.\n\n```js\nimport { globSync } from 'node:fs'\nimport { writeFile } from 'node:fs/promises'\nimport { modifyFile } from '@knighted/display-name'\n\nconst doCodeMod = async () =\u003e {\n  for (const file of globSync('**/*.tsx', {\n    exclude: ['**/node_modules/**', '**/dist/**', '**/build/**'],\n  })) {\n    await writeFile(file, await modifyFile(file))\n  }\n}\n\nawait doCodeMod()\n```\n\nThen optionally run the results through a formatter like `prettier`.\n\n## Options\n\nThere are some options, none are required. Most notably you can choose a `style` for adding the display name. The default is `displayName` which adds a displayName property to the function component, or you can choose `namedFuncExpr` to use a named function expression instead.\n\n```ts\ntype Options = {\n  requirePascal?: boolean\n  insertSemicolon?: boolean\n  modifyNestedForwardRef?: boolean\n  style?: 'displayName' | 'namedFuncExpr'\n}\n```\n\nFor example, using `namedFuncExpr`\n\n```tsx\nconst Foo = memo(() =\u003e \u003c\u003efoo\u003c/\u003e)\n```\n\nbecomes\n\n```tsx\nconst Foo = memo(function Foo() {\n  return \u003c\u003efoo\u003c/\u003e\n})\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fknightedcodemonkey%2Fdisplay-name","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fknightedcodemonkey%2Fdisplay-name","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fknightedcodemonkey%2Fdisplay-name/lists"}