Debian Codegraph @

node/@patternfly/react-core/CONTRIBUTING.md

raw
1 ---
2 id: Contributing
3 section: root
4 hideTOC: true
5 ---
6
7 # Contributing to @patternfly/react-core
8
9 ## Adding a new component
10
11 1. Check for open issues that are not assigned to anyone, and assign yourself. If you do not see an issue for the component you want to contribute open an issue and assign yourself. Assigning yourself will ensure that others do not begin working on the component you currently have in progress.
12 2. Generate the component scaffolding by running `yarn generate`. This will generate a structure that resembles the following
13 ```text
14 packages/react-core/src/[type]/[ComponentName]/
15 index.js - Barrel File exporting public exports
16 ComponentName.js - Component Implementation
17 ComponentName.test.js - Component Tests
18 ComponentName.md - Component Docs
19 examples/ - dir for all examples
20 SimpleComponentName.js - Simple Example
21 ```
22 3. Write the component implementation in `[Component].js`.
23 4. Add jest tests to `[Component].test.js`. All new components must be tested.
24 5. Add any additional public exports to `index.js`
25 6. Update the generated `[ComponentName].md.` See how to create [component docs.](../react-core/README.md)
26 7. Add integration tests to the demo-app found [here](../react-integration)
27
28 ## Code contribution guidelines
29
30 Adhering to the following process is the best way to get your work included in the project:
31
32 1. [Fork](https://help.github.com/fork-a-repo/) the project, clone your fork, and configure the remotes:
33
34 ```bash
35 # Clone your fork of the repo into the current directory
36 git clone https://github.com/<your-username>/patternfly-react.git
37 # Navigate to the newly cloned directory
38 cd patternfly-react
39 # Assign the original repo to a remote called "upstream"
40 git remote add upstream https://github.com/patternfly/patternfly-react.git
41 ```
42
43 2. Create a branch:
44
45 ```text
46 $ git checkout -b my-branch -t upstream/main
47 ```
48
49 3. Generate your component
50
51 ```bash
52 # Run the tool to Generate the component scaffolding
53 yarn generate
54 ```
55
56 - When you select the option to generate a PatternFly component, a structure resembling the following is generated
57 ```text
58 packages/react-core/src/[type]/[ComponentName]/
59 index.js - Barrel File exporting public exports
60 ComponentName.js - Component Implementation
61 ComponentName.test.js - Component Tests
62 ComponentName.md - Component Docs
63 ```
64
65 4. Develop your component.
66
67 While developing, you can run the patternfly-react workspace to view the component docs with live examples.
68
69 ```bash
70 # Start up the workspace locally on port 8002
71 yarn install && yarn start
72 ```
73
74 5. After development is complete, ensure tests and lint standards pass.
75
76 ```text
77 $ yarn test
78 ```
79
80 Ensure no lint errors are introduced in `yarn-error.log` after running this command.
81
82 5. Add a commit using `git commit`:
83
84 This project uses [`lerna`](https://lerna.js.io/) to do automatic releases and generate a changelog based on the commit history. So we follow [a convention][3] for commit messages. Please follow [`this convention`](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#type) for your commit messages.
85
86 Once you are ready to commit the changes, please use the below commands:
87
88 ```text
89 $ git add <files to be committed>
90 $ git commit -m
91 ```
92
93 ... and follow the instruction of the interactive prompt.
94
95 6. Rebase
96
97 Use `git rebase` (not `git merge`) to sync your work from time to time. Ensure all commits related to a single issue have been [squashed](https://github.com/ginatrapani/todo.txt-android/wiki/Squash-All-Commits-Related-to-a-Single-Issue-into-a-Single-Commit).
98
99 ```text
100 $ git fetch upstream
101 $ git rebase upstream/main
102 ```
103
104 7. Push
105
106 ```text
107 $ git push origin my-branch
108 ```
109
110 8. Create a pull request
111
112 - A link to the PatternFly demo documentation will be automatically generated and posted as a comment after the pull request build is complete.
113
114 ## Additional information
115
116 See the PatternFly React Guide for full details on [Code Contribution Guidelines](https://github.com/patternfly/patternfly-react/blob/main/CONTRIBUTING.md#code-contribution-guidelines)