-
Notifications
You must be signed in to change notification settings - Fork 150
docs: add contributing guidelines #107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
535992c
docs: adding contributing guidelines
Belco90 61bf75e
docs: fix contributing file links
Belco90 51a5fed
docs: update adding new rules section in contributing
Belco90 ca5e846
docs: PR feedback
Belco90 18e17e4
docs: fix wrong PR suggestions
Belco90 b7807c1
docs: More PR feedback
Belco90 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# Contributing | ||
|
||
Thanks for being willing to contribute! | ||
|
||
Working on your first Pull Request? You can learn how from this free series | ||
[How to Contribute to an Open Source Project on GitHub](https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github). | ||
|
||
## Project setup | ||
|
||
1. Fork this repository | ||
2. Clone your forked repository | ||
3. Run `npm install` to install corresponding dependencies | ||
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`) | ||
|
||
> Tip: Keep your `master` branch pointing at the original repository and make | ||
> pull requests from branches on your fork. To do this, run: | ||
> | ||
> ``` | ||
> git remote add upstream https://github.com/testing-library/eslint-plugin-testing-library.git | ||
> git fetch upstream | ||
> git branch --set-upstream-to=upstream/master master | ||
> ``` | ||
> | ||
> This will add the original repository as a "remote" called "upstream," Then | ||
> fetch the git information from that remote, then set your local `master` | ||
> branch to use the upstream master branch whenever you run `git pull`. Then you | ||
> can make all of your pull request branches based on this `master` branch. | ||
> Whenever you want to update your version of `master`, do a regular `git pull`. | ||
|
||
## Committing and Pushing changes | ||
|
||
There are git hooks config with this project that are automatically installed | ||
and set up when you install dependencies. This will be run on every commit: | ||
Belco90 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
- check all tests are passing, code validation is fine and format files automatically | ||
Belco90 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- check commit message is following [Conventional Commit specification](https://www.conventionalcommits.org/en/v1.0.0/) | ||
Belco90 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
You can run `npm run test:update` which will update any snapshots that need updating. | ||
Belco90 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Rule naming conventions | ||
|
||
Based on [ESLint's Rule Naming Conventions](https://eslint.org/docs/developer-guide/working-with-rules#rule-naming-conventions), this is the simple convention you must follow: | ||
Belco90 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
- If your rule is disallowing something, prefix it with `no-` such as `no-debug` | ||
for disallowing `debug()`. | ||
- If your rule is suggesting to use a specific way for something that can be | ||
done in several ways, you could **optionally** prefix it with `prefer-` such as | ||
`prefer-screen-queries` for suggesting to use `screen.getByText()` from | ||
imported `screen` rather than`getByText()` from `render`'s result, | ||
even though both are technically fine. | ||
Belco90 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- If your rule is enforcing the inclusion of something, use a short name without a special prefix such as `await-async-utils` for enforcing to await proper async utils. | ||
Belco90 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- Use dashes between words. | ||
- Try to keep the name simple. | ||
Belco90 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Adding new rules | ||
|
||
In the [same way as ESLint](https://eslint.org/docs/developer-guide/working-with-rules), | ||
each rule has three files named with its identifier (e.g. `no-debug`): | ||
|
||
- in the `lib/rules` directory: a source file (e.g. `no-debug.js`) | ||
- in the `tests/lib/rules` directory: a test file (e.g. `no-debug.js`) | ||
- in the `docs/rules` directory: a Markdown documentation file (e.g. `no-debug.md`) | ||
|
||
Additionally, you need to do couple of extra things: | ||
Belco90 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
- Import the new rule in `lib/index.js` and include it | ||
in `rules` constant (there is a test which will make sure you did | ||
this). Remember to include your rule under corresponding `config` if necessary | ||
Belco90 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
(a snapshot test will check this too, but you can update it just running | ||
`npm run test:update`). | ||
- Include your rule in "Supported Rules" table within `README.md`. | ||
Belco90 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Don't forget to include proper badges if needed. | ||
Belco90 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Modifying rules | ||
|
||
Just couple of things you need to remember when editing already existing rules: | ||
Belco90 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
- If renaming a rule, make sure to update all points mentioned in | ||
"Adding new rules" section. | ||
- Try to add tests to cover the changes introduced, no matter if that's | ||
a bug fix or a new feature. | ||
|
||
## Help needed | ||
|
||
Please checkout the [the open issues](https://github.com/testing-library/eslint-plugin-testing-library/issues) | ||
Belco90 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Also, please watch the repo and respond to questions/bug reports/feature requests! Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.