Skip to content

Commit f8f21d6

Browse files
Belco90thomaslombarttimdeschryver
authored
docs: add contributing guidelines (#107)
* docs: adding contributing guidelines * docs: fix contributing file links * docs: update adding new rules section in contributing * docs: PR feedback Co-Authored-By: Thomas Lombart <t.lombart97@gmail.com> * docs: fix wrong PR suggestions * docs: More PR feedback Co-Authored-By: Tim Deschryver <28659384+timdeschryver@users.noreply.github.com> Co-authored-by: Thomas Lombart <t.lombart97@gmail.com> Co-authored-by: Tim Deschryver <28659384+timdeschryver@users.noreply.github.com>
1 parent 100ada0 commit f8f21d6

File tree

2 files changed

+88
-0
lines changed

2 files changed

+88
-0
lines changed

CONTRIBUTING.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Contributing
2+
3+
Thanks for being willing to contribute!
4+
5+
Working on your first Pull Request? You can learn how from this free series
6+
[How to Contribute to an Open Source Project on GitHub](https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github).
7+
8+
## Project setup
9+
10+
1. Fork this repository
11+
2. Clone your forked repository
12+
3. Run `npm install` to install corresponding dependencies
13+
4. Create a branch for your PR named like `pr/your-branch-name` (you can do this through git CLI with `git checkout -b pr/your-branch-name`)
14+
15+
> Tip: Keep your `master` branch pointing at the original repository and make
16+
> pull requests from branches on your fork. To do this, run:
17+
>
18+
> ```
19+
> git remote add upstream https://github.com/testing-library/eslint-plugin-testing-library.git
20+
> git fetch upstream
21+
> git branch --set-upstream-to=upstream/master master
22+
> ```
23+
>
24+
> This will add the original repository as a "remote" called "upstream," Then
25+
> fetch the git information from that remote, then set your local `master`
26+
> branch to use the upstream master branch whenever you run `git pull`. Then you
27+
> can make all of your pull request branches based on this `master` branch.
28+
> Whenever you want to update your version of `master`, do a regular `git pull`.
29+
30+
## Committing and Pushing changes
31+
32+
Git hooks are configured on this project when you install dependencies.
33+
The following will be run on every commit:
34+
35+
- Lint and format files automatically
36+
- Check all tests are passing
37+
- Check commit message is following [Conventional Commit specification](https://www.conventionalcommits.org/en/v1.0.0/)
38+
39+
If you ever need to update a snapshot, you can run `npm run test:update`
40+
41+
## Rule naming conventions
42+
43+
Based on [ESLint's Rule Naming Conventions](https://eslint.org/docs/developer-guide/working-with-rules#rule-naming-conventions), you must follow these rules:
44+
45+
- If your rule is disallowing something, prefix it with `no-` such as `no-debug`
46+
for disallowing `debug()`.
47+
- If your rule is suggesting to prefer a way of doing something, among other ways, you can **optionally** prefix it with
48+
`prefer-`. For example, `prefer-screen-queries` suggests to use `screen.getByText()` from imported `screen` rather
49+
than `getByText()` from `render`'s result though both are technically fine.
50+
- If your rule is enforcing the inclusion of something, use a short name without a special prefix. As an example,
51+
`await-async-utils` enforce to wait for proper async utils.
52+
- Use dashes between words.
53+
- Try to keep the name simple and clear.
54+
55+
## Adding new rules
56+
57+
In the [same way as ESLint](https://eslint.org/docs/developer-guide/working-with-rules),
58+
each rule has three files named with its identifier (e.g. `no-debug`):
59+
60+
- in the `lib/rules` directory: a source file (e.g. `no-debug.js`)
61+
- in the `tests/lib/rules` directory: a test file (e.g. `no-debug.js`)
62+
- in the `docs/rules` directory: a Markdown documentation file (e.g. `no-debug.md`)
63+
64+
Additionally, you need to do a couple of extra things:
65+
66+
- Import the new rule in `lib/index.js` and include it
67+
in `rules` constant (there is a test which will make sure you did
68+
this). Remember to include your rule under corresponding `config` if necessary
69+
(a snapshot test will check this too, but you can update it just running
70+
`npm run test:update`).
71+
- Include your rule in the "Supported Rules" table within the [README.md](./README.md).
72+
Don't forget to include the proper badges if needed and to sort alphabetically the rules for readability.
73+
74+
## Modifying rules
75+
76+
A couple of things you need to remember when editing already existing rules:
77+
78+
- If renaming a rule, make sure to update all points mentioned in
79+
"Adding new rules" section.
80+
- Try to add tests to cover the changes introduced, no matter if that's
81+
a bug fix or a new feature.
82+
83+
## Help needed
84+
85+
Please check the [the open issues](https://github.com/testing-library/eslint-plugin-testing-library/issues)
86+
87+
Also, please watch the repo and respond to questions/bug reports/feature requests! Thanks!

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"format": "prettier --write README.md {lib,docs,tests}/**/*.{js,md}",
3131
"test:local": "jest",
3232
"test:ci": "jest --coverage",
33+
"test:update": "npm run test:local -- --u",
3334
"test:watch": "npm run test:local -- --watch",
3435
"test": "is-ci test:ci test:local",
3536
"semantic-release": "semantic-release"

0 commit comments

Comments
 (0)