{"id":24823414,"url":"https://github.com/markalfred/react-generate-props","last_synced_at":"2025-10-09T16:40:47.615Z","repository":{"id":47309762,"uuid":"63176778","full_name":"markalfred/react-generate-props","owner":"markalfred","description":"Generate default props based on your React component's PropTypes","archived":false,"fork":false,"pushed_at":"2023-03-03T04:30:45.000Z","size":561,"stargazers_count":22,"open_issues_count":8,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-23T04:34:28.429Z","etag":null,"topics":["enzyme","jest","props","proptypes","react","test"],"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/markalfred.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2016-07-12T17:02:12.000Z","updated_at":"2025-07-22T13:33:47.000Z","dependencies_parsed_at":"2024-06-18T20:08:51.000Z","dependency_job_id":"8ab82a78-32b0-4252-bdc9-40688bac6a83","html_url":"https://github.com/markalfred/react-generate-props","commit_stats":{"total_commits":134,"total_committers":5,"mean_commits":26.8,"dds":0.5895522388059702,"last_synced_commit":"ee25615cf6611e84f41a6aed95b118d3740f1195"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/markalfred/react-generate-props","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markalfred%2Freact-generate-props","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markalfred%2Freact-generate-props/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markalfred%2Freact-generate-props/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markalfred%2Freact-generate-props/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/markalfred","download_url":"https://codeload.github.com/markalfred/react-generate-props/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markalfred%2Freact-generate-props/sbom","scorecard":{"id":619652,"data":{"date":"2025-08-11","repo":{"name":"github.com/markalfred/react-generate-props","commit":"ee25615cf6611e84f41a6aed95b118d3740f1195"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":-1,"reason":"Found no human activity in the last 16 changesets","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 30 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"23 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw","Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c","Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq","Warn: Project is vulnerable to: GHSA-2j2x-2gpw-g8fm","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-4q6p-r6v2-jvc5","Warn: Project is vulnerable to: GHSA-896r-f27r-55mw","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-g6ww-v8xp-vmwg","Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp","Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36","Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-21T04:54:29.656Z","repository_id":47309762,"created_at":"2025-08-21T04:54:29.656Z","updated_at":"2025-08-21T04:54:29.656Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279001779,"owners_count":26083173,"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-10-09T02:00:07.460Z","response_time":59,"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":["enzyme","jest","props","proptypes","react","test"],"created_at":"2025-01-30T19:58:38.769Z","updated_at":"2025-10-09T16:40:47.582Z","avatar_url":"https://github.com/markalfred.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-generate-props\nGenerate default props based on your React component's PropTypes\n\n[![Build Status](https://travis-ci.org/markalfred/react-generate-props.svg?branch=master)](https://travis-ci.org/markalfred/react-generate-props)\n[![Coverage Status](https://coveralls.io/repos/github/markalfred/react-generate-props/badge.svg?branch=master)](https://coveralls.io/github/markalfred/react-generate-props?branch=master)\n\n```js\ngenerateProps({ name: PropTypes.string, number: PropTypes.number })\n// =\u003e { name: 'name', number: 1 }\n```\n\n## Installation\n```bash\n$ npm install --save-dev react-generate-props\n```\n\n## Usage\n\n**Important:**\nInitialize the library *before* importing any components into your test suite.\n\n```js\n// test-helper.js\n\nimport { init } from 'react-generate-props'\ninit()\n```\n\nDefine your component's propTypes.\n\n```jsx\nconst Counter = ({ count }) =\u003e \u003cdiv\u003e{count}\u003c/div\u003e\nCounter.propTypes = { count: PropTypes.number.isRequired }\nexport default Counter\n```\n\nPass the component to this library. It will generate reasonable props based on the defined types.\n\n```js\nimport generateProps from 'react-generate-props'\nimport Counter from './counter'\ngenerateProps(Counter)\n// =\u003e { count: 1 }\n```\n\nUse these default props to reduce boilerplate and prop type validation errors in your tests! :tada:\n\n## Example\n\nA more in-depth example.\n\n```jsx\n// component.jsx\n\nclass Component extends React.Component {\n  static propTypes = {\n    title: PropTypes.string.isRequired,\n    followers: PropTypes.number.isRequired,\n    user: PropTypes.shape({\n      loggedIn: PropTypes.bool.isRequired,\n      name: PropTypes.string.isRequired\n    }).isRequired\n  }\n\n  render() {\n    \u003cdiv\u003e\n      \u003ch1\u003e{this.props.title}\u003c/h1\u003e\n      \u003csmall\u003e{this.props.followers}\u003c/small\u003e\n      {this.props.user.loggedIn \u0026\u0026 \u003cp\u003eHello, {this.props.user.name}.\u003c/p\u003e}\n    \u003c/div\u003e\n  }\n}\n\nexport default Component\n```\n\n```jsx\n// component-test.js\n\nimport generateProps from 'react-generate-props'\nimport Component from './component.jsx'\n\nconst props = generateProps(Component)\n// =\u003e { title: 'title', followers: 1, user: { loggedIn: true, name: 'name' } }\n\nrender(\u003cComponent {...props} /\u003e)\n/* =\u003e\n\u003cdiv\u003e\n  \u003ch1\u003etitle\u003c/h1\u003e\n  \u003csmall\u003e1\u003c/small\u003e\n  \u003cp\u003eHello, name.\u003c/p\u003e\n\u003c/div\u003e\n*/\n\n```\n\n## API\n\nThe library takes two arguments.\n\n```js\ngenerateProps(schema, opts)\n```\n\n#### `schema`: An Object, Function, or Class containing a PropTypes definition, or a single PropType. All of the following are valid:\n\nPlain Object\n```js\nconst Counter = { count: PropTypes.number.isRequired }\n```\n\nPlain Object with a `propTypes` key\n```js\nconst Counter = { propTypes: { count: PropTypes.number.isRequired } }\n```\n\nFunctional Component\n```js\nconst Counter = ({ counter }) =\u003e {/* ... */}\nCounter.propTypes = { count: PropTypes.number.isRequired }\n```\n\n`React.Component` Class\n```js\nclass Counter extends React.Component {\n  static propTypes = { count: PropTypes.number.isRequired }\n}\n```\n\nSingle PropType\n```js\nconst Counter = PropTypes.shape({ count: PropTypes.number.isRequired }).isRequired\n```\n\nIn each of these cases, the effect would be the same\n```js\ngenerateProps(Counter)\n// =\u003e { count: 1 }\n```\n\n#### `opts`: An Object which may contain the following:\n\n```js\n{\n  required: true,\n  // default: true. When true, props marked as .isRequired will be generated.\n\n  optional: false,\n  // default: false. When true, props *not* marked as .isRequired will be generated.\n\n  generators: {\n    // Can be used to override this lib's default generators.\n    // Each key is a prop type, each value is a function.\n    // Each function receives the propName as its first argument,\n    // followed by that prop type's argument, if it takes one.\n\n    bool: (propName) =\u003e false,\n    function: (propName) =\u003e spy(),\n    number: (propName) =\u003e propName.length,\n    instanceOf: (propName, klass) =\u003e new klass(),\n    oneOf: (propName, values) =\u003e values[values.length - 1]\n  }\n}\n```\n\n## One More Example\n\n```js\nconst propTypes = {\n  name: PropTypes.string.isRequired,\n  loggedIn: PropTypes.bool,\n  userType: PropTypes.oneOf(['admin', 'user']).isRequired\n}\n\ngenerateProps(propTypes)\n// =\u003e { name: 'string', userType: 'admin' }\n\ngenerateProps(propTypes, { optional: true })\n// =\u003e { name: 'string', loggedIn: true, userType: 'admin' }\n\ngenerateProps(propTypes, {\n  optional: true,\n  generators: {\n    string: (propName) =\u003e 'Alice',\n    bool: (propName) =\u003e propName === 'loggedIn',\n    oneOf: (propName, values) =\u003e values[values.length - 1]\n  }\n})\n// =\u003e { name: 'Alice', loggedIn: true, userType: 'user' }\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkalfred%2Freact-generate-props","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarkalfred%2Freact-generate-props","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkalfred%2Freact-generate-props/lists"}