Skip to content

Commit b16ca24

Browse files
committed
docs: add a contributing guide
1 parent 155a401 commit b16ca24

File tree

1 file changed

+194
-0
lines changed

1 file changed

+194
-0
lines changed

contributing.md

Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
# Contributing Guide
2+
3+
Thanks for your interest in contributing to `rate-limit-memcached`! This guide
4+
will show you how to set up your environment and contribute to this library.
5+
6+
## Set Up
7+
8+
First, you need to install and be familiar the following:
9+
10+
- `git`: [Here](https://github.com/git-guides) is a great guide by GitHub on
11+
installing and getting started with Git.
12+
- `node` and `npm`:
13+
[This guide](https://nodejs.org/en/download/package-manager/) will help you
14+
install Node and npm. The recommended method is using the `n` version manager
15+
if you are on MacOS or Linux. Make sure you are using the
16+
[active LTS version](https://github.com/nodejs/Release#release-schedule) of
17+
Node.
18+
19+
Once you have installed the above, follow
20+
[these instructions](https://docs.github.com/en/get-started/quickstart/fork-a-repo)
21+
to
22+
[`fork`](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks)
23+
and [`clone`](https://github.com/git-guides/git-clone) the repository
24+
(`express-rate-limit/rate-limit-memcached`).
25+
26+
Once you have forked and cloned the repository, you can
27+
[pick out an issue](https://github.com/express-rate-limit/rate-limit-memcached/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc)
28+
you want to fix/implement!
29+
30+
## Making Changes
31+
32+
Once you have cloned the repository to your computer (say, in
33+
`~/Code/rate-limit-memcached`) and picked the issue you want to tackle, create a
34+
branch based off the `next` branch:
35+
36+
```sh
37+
> git switch next
38+
> git switch --create branch-name
39+
```
40+
41+
While naming your branch, make sure the name is short and self explanatory.
42+
43+
Once you have created a branch, you can start coding!
44+
45+
The library is written in
46+
[Typescript](https://github.com/microsoft/TypeScript#readme) and supports Node
47+
16, 18 and 20. The code is arranged as follows:
48+
49+
```sh
50+
.
51+
├── config
52+
│ └── husky
53+
│ └── pre-commit
54+
├── source
55+
│ ├── index.ts
56+
│ ├── memcached-store.ts
57+
│ └── types.ts
58+
├── test
59+
│ ├── options-test.ts
60+
│ ├── store-test.ts
61+
│ └── types.ts
62+
├── changelog.md
63+
├── contributing.md
64+
├── jest.config.json
65+
├── license.md
66+
├── package-lock.json
67+
├── package.json
68+
├── readme.md
69+
└── tsconfig.json
70+
```
71+
72+
> Most files have a little description of what they do at the top.
73+
74+
#### `./`
75+
76+
- `package.json`: Node package information.
77+
- `package-lock.json`: npm lock file, please do not modify manually.
78+
- `tsconfig.json`: The TSC configuration for this project.
79+
- `changelog.md`: A list of changes that have been made in each version.
80+
- `contributing.md`: This file, helps contributors get started.
81+
- `license.md`: Tells people how they can use this package.
82+
- `readme.md`: The file everyone should read before using the package. Contains
83+
installation and usage instructions and the API reference.
84+
85+
#### `source/`
86+
87+
- `source/index.ts`: Exports the `MemcachedStore` function as a named export
88+
from `source/memcached-store.ts`, and types from `source/types.ts`.
89+
- `source/memcached-store.ts`: The store itself.
90+
- `source/types.ts`: Typescript types for the library.
91+
92+
#### `test/`
93+
94+
- `test/options-test.ts`: Ensures the library can parse options correctly.
95+
- `test/store-test.ts`: Ensures the store works correctly with in various
96+
different situations.
97+
- `test/types.ts`: Declares types for the tests.
98+
99+
#### `config/`
100+
101+
- `config/husky/pre-commit`: The bash script to run just before someone runs
102+
`git commit`.
103+
104+
### Documentation and testing
105+
106+
When adding a new feature/fixing a bug, please add/update the readme and
107+
changelog as well as add tests for the same. Also make sure the codebase passes
108+
the linter and library tests by running `npm test`. Note that running
109+
`npm run format` will automatically resolve most style/lint issues.
110+
111+
Once you have made changes to the code, you will want to
112+
[`commit`](https://github.com/git-guides/git-commit) (basically, Git's version
113+
of save) the changes. To commit the changes you have made locally:
114+
115+
```sh
116+
> git add this/folder that-file.js
117+
> git commit --message 'commit-message'
118+
```
119+
120+
While writing the `commit-message`, try to follow the below guidelines:
121+
122+
1. Prefix the message with `type:`, where `type` is one of the following
123+
dependending on what the commit does:
124+
- `fix`: Introduces a bug fix.
125+
- `feat`: Adds a new feature.
126+
- `test`: Any change related to tests.
127+
- `perf`: Any performance related change.
128+
- `meta`: Any change related to the build process, workflows, issue
129+
templates, etc.
130+
- `refc`: Any refactoring work.
131+
- `docs`: Any documentation related changes.
132+
2. Keep the first line brief, and less than 60 characters.
133+
3. Try describing the change in detail in a new paragraph (double newline after
134+
the first line).
135+
136+
When you commit files, `husky` and `lint-staged` will automatically lint the
137+
code and fix most issues. In case an error is not automatically fixable, they
138+
will cancel the commit. Please fix the errors before committing the changes. If
139+
you still wish to commit the changes, prefix the `git commit` command with
140+
`HUSKY=0`, like so:
141+
142+
```sh
143+
> HUSKY=0 git commit --message 'commit-message'
144+
```
145+
146+
## Contributing Changes
147+
148+
Once you have committed your changes, you will want to
149+
[`push`](https://github.com/git-guides/git-push) (basically, publish your
150+
changes to GitHub) your commits. To push your changes to your fork:
151+
152+
```sh
153+
> git push origin branch-name
154+
```
155+
156+
If there are changes made to the `next` branch of the
157+
`express-rate-limit/rate-limit-memcached` repository, you may wish to merge
158+
those changes into your branch. To do so, you can run the following commands:
159+
160+
```
161+
> git fetch upstream next
162+
> git merge upstream/next
163+
```
164+
165+
This will automatically add the changes from `next` branch of the
166+
`express-rate-limit/rate-limit-memcached` repository to the current branch. If
167+
you encounter any merge conflicts, follow
168+
[this guide](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/addressing-merge-conflicts/resolving-a-merge-conflict-using-the-command-line)
169+
to resolve them.
170+
171+
Once you have pushed your changes to your fork, follow
172+
[these instructions](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork)
173+
to open a
174+
[`pull request`](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests):
175+
176+
Once you have submitted a pull request, the maintainers of the repository will
177+
review your pull requests. Whenever a maintainer reviews a pull request they may
178+
request changes. These may be small, such as fixing a typo, or may involve
179+
substantive changes. Such requests are intended to be helpful, but at times may
180+
come across as abrupt or unhelpful, especially if they do not include concrete
181+
suggestions on how to change them. Try not to be discouraged. If you feel that a
182+
review is unfair, say so or seek the input of another project contributor. Often
183+
such comments are the result of a reviewer having taken insufficient time to
184+
review and are not ill-intended. Such difficulties can often be resolved with a
185+
bit of patience. That said, reviewers should be expected to provide helpful
186+
feedback.
187+
188+
In order to land, a pull request needs to be reviewed and approved by at least
189+
one maintainer and pass CI. After that, if there are no objections from other
190+
contributors, the pull request can be merged.
191+
192+
#### Congratulations and thanks for your contribution!
193+
194+
<!-- This contributing guide was inspired by the Electron project's contributing guide. -->

0 commit comments

Comments
 (0)