]> git.proxmox.com Git - pve-eslint.git/blame - eslint/docs/src/developer-guide/contributing/pull-requests.md
build: add missing dh-nodejs to build-dependencies
[pve-eslint.git] / eslint / docs / src / developer-guide / contributing / pull-requests.md
CommitLineData
8f9d1d4d
DC
1---
2title: Pull Requests
3layout: doc
4
5---
eb39fafa
DC
6
7If you want to contribute to an ESLint repo, please use a GitHub pull request. This is the fastest way for us to evaluate your code and to merge it into the code base. Please don't file an issue with snippets of code. Doing so means that we need to manually merge the changes in and update any appropriate tests. That decreases the likelihood that your code is going to get included in a timely manner. Please use pull requests.
8
9## Getting Started
10
11If you'd like to work on a pull request and you've never submitted code before, follow these steps:
12
8f9d1d4d
DC
131. Set up a [development environment](../development-environment).
141. If you want to implement a breaking change or a change to the core, ensure there's an issue that describes what you're doing and the issue has been accepted. You can create a new issue or just indicate you're [working on an existing issue](working-on-issues). Bug fixes, documentation changes, and other pull requests do not require an issue.
eb39fafa
DC
15
16After that, you're ready to start working on code.
17
18## Working with Code
19
20The process of submitting a pull request is fairly straightforward and generally follows the same pattern each time:
21
221. [Create a new branch](#step1)
232. [Make your changes](#step2)
243. [Rebase onto upstream](#step3)
254. [Run the tests](#step4)
265. [Double check your submission](#step5)
276. [Push your changes](#step6)
287. [Submit the pull request](#step7)
29
30Details about each step are found below.
31
32### Step 1: Create a new branch<a name="step1"></a>
33
34The first step to sending a pull request is to create a new branch in your ESLint fork. Give the branch a descriptive name that describes what it is you're fixing, such as:
35
8f9d1d4d
DC
36```shell
37git checkout -b issue1234
eb39fafa
DC
38```
39
40You should do all of your development for the issue in this branch.
41
42**Note:** Do not combine fixes for multiple issues into one branch. Use a separate branch for each issue you're working on.
43
44### Step 2: Make your changes<a name="step2"></a>
45
8f9d1d4d 46Make the changes to the code and tests, following the [code conventions](../code-conventions) as you go. Once you have finished, commit the changes to your branch:
eb39fafa 47
8f9d1d4d
DC
48```shell
49git add -A
50git commit
eb39fafa
DC
51```
52
609c276f 53All ESLint projects follow [Conventional Commits](https://www.conventionalcommits.org/) for our commit messages. Here's an example commit message:
eb39fafa 54
8f9d1d4d 55```txt
609c276f 56tag: Short description of what you did
eb39fafa
DC
57
58Longer description here if necessary
609c276f
TL
59
60Fixes #1234
eb39fafa
DC
61```
62
63The first line of the commit message (the summary) must have a specific format. This format is checked by our build tools.
64
609c276f 65The `tag` is one of the following:
eb39fafa 66
609c276f
TL
67* `fix` - for a bug fix.
68* `feat` - either for a backwards-compatible enhancement or for a rule change that adds reported problems.
69* `fix!` - for a backwards-incompatible bug fix.
70* `feat!` - for a backwards-incompatible enhancement or feature.
71* `docs` - changes to documentation only.
72* `chore` - for changes that aren't user-facing.
73* `build` - changes to build process only.
74* `refactor` - a change that doesn't affect APIs or user experience.
75* `test` - just changes to test files.
76* `ci` - changes to our CI configuration files and scripts.
77* `perf` - a code change that improves performance.
eb39fafa 78
8f9d1d4d 79Use the [labels of the issue you are working on](working-on-issues#issue-labels) to determine the best tag.
eb39fafa 80
609c276f 81The message summary should be a one-sentence description of the change, and it must be 72 characters in length or shorter. If the pull request addresses an issue, then the issue number should be mentioned in the body of the commit message in the format `Fixes #1234`. If the commit doesn't completely fix the issue, then use `Refs #1234` instead of `Fixes #1234`.
eb39fafa
DC
82
83Here are some good commit message summary examples:
84
8f9d1d4d 85```txt
609c276f
TL
86build: Update Travis to only test Node 0.10
87fix: Semi rule incorrectly flagging extra semicolon
88chore: Upgrade Esprima to 1.2, switch to using comment attachment
eb39fafa
DC
89```
90
91The commit message format is important because these messages are used to create a changelog for each release. The tag and issue number help to create more consistent and useful changelogs.
92
93### Step 3: Rebase onto upstream<a name="step3"></a>
94
95Before you send the pull request, be sure to rebase onto the upstream source. This ensures your code is running on the latest available code.
96
8f9d1d4d 97```shell
eb39fafa 98git fetch upstream
609c276f 99git rebase upstream/main
eb39fafa
DC
100```
101
102### Step 4: Run the tests<a name="step4"></a>
103
104After rebasing, be sure to run all of the tests once again to make sure nothing broke:
105
8f9d1d4d 106```shell
eb39fafa
DC
107npm test
108```
109
110If there are any failing tests, update your code until all tests pass.
111
112### Step 5: Double check your submission<a name="step5"></a>
113
114With your code ready to go, this is a good time to double-check your submission to make sure it follows our conventions. Here are the things to check:
115
116* Make sure your commit is formatted correctly.
117* The pull request must have a description. The description should explain what you did and how its effects can be seen.
118* The commit message is properly formatted.
119* The change introduces no functional regression. Be sure to run `npm test` to verify your changes before submitting a pull request.
120* Make separate pull requests for unrelated changes. Large pull requests with multiple unrelated changes may be closed without merging.
121* All changes must be accompanied by tests, even if the feature you're working on previously had no tests.
122* All user-facing changes must be accompanied by appropriate documentation.
8f9d1d4d 123* Follow the [Code Conventions](../code-conventions).
eb39fafa
DC
124
125### Step 6: Push your changes<a name="step6"></a>
126
127Next, push your changes to your clone:
128
8f9d1d4d 129```shell
eb39fafa
DC
130git push origin issue1234
131```
132
133If you are unable to push because some references are old, do a forced push instead:
134
8f9d1d4d 135```shell
eb39fafa
DC
136git push -f origin issue1234
137```
138
139### Step 7: Send the pull request<a name="step7"></a>
140
141Now you're ready to send the pull request. Go to your ESLint fork and then follow the [GitHub documentation](https://help.github.com/articles/creating-a-pull-request) on how to send a pull request.
142
8f9d1d4d
DC
143In order to submit code or documentation to an ESLint project, you’ll be asked to sign our CLA when you send your first pull request. (Read more about the Open JS Foundation CLA process at <https://cla.openjsf.org/>.)
144
eb39fafa
DC
145## Following Up
146
147Once your pull request is sent, it's time for the team to review it. As such, please make sure to:
148
1491. Monitor the status of the Travis CI build for your pull request. If it fails, please investigate why. We cannot merge pull requests that fail Travis for any reason.
1501. Respond to comments left on the pull request from team members. Remember, we want to help you land your code, so please be receptive to our feedback.
1511. We may ask you to make changes, rebase, or squash your commits.
152
153### Updating the Commit Message
154
155If your commit message is in the incorrect format, you'll be asked to update it. You can do so via:
156
8f9d1d4d
DC
157```shell
158git commit --amend
eb39fafa
DC
159```
160
161This will open up your editor so you can make changes. After that, you'll need to do a forced push to your branch:
162
8f9d1d4d
DC
163```shell
164git push origin issue1234 -f
eb39fafa
DC
165```
166
167### Updating the Code
168
169If we ask you to make code changes, there's no need to close the pull request and create a new one. Just go back to the branch on your fork and make your changes. Then, when you're ready, you can add your changes into the branch:
170
8f9d1d4d
DC
171```shell
172git add -A
173git commit
174git push origin issue1234
eb39fafa
DC
175```
176
609c276f
TL
177When updating the code, it's usually better to add additional commits to your branch rather than amending the original commit, because reviewers can easily tell which changes were made in response to a particular review. When we merge pull requests, we will squash all the commits from your branch into a single commit on the `main` branch.
178
179The commit messages in subsequent commits do not need to be in any specific format because these commits do not show up in the changelog.
eb39fafa
DC
180
181### Rebasing
182
8f9d1d4d 183If your code is out-of-date, we might ask you to rebase. That means we want you to apply your changes on top of the latest upstream code. Make sure you have set up a [development environment](../development-environment) and then you can rebase using these commands:
eb39fafa 184
8f9d1d4d
DC
185```shell
186git fetch upstream
187git rebase upstream/main
eb39fafa
DC
188```
189
190You might find that there are merge conflicts when you attempt to rebase. Please [resolve the conflicts](https://help.github.com/articles/resolving-merge-conflicts-after-a-git-rebase/) and then do a forced push to your branch:
191
8f9d1d4d
DC
192```shell
193git push origin issue1234 -f
eb39fafa 194```