Skip to content

Commit 1b4bfa3

Browse files
authored
improvements to CONTRIBUTING.md docs (#2861)
1 parent 85a0a06 commit 1b4bfa3

File tree

1 file changed

+49
-17
lines changed

1 file changed

+49
-17
lines changed

CONTRIBUTING.md

Lines changed: 49 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414

1515
- [Testing](#testing)
1616

17+
- [Unit tests](#unit-tests)
18+
- [REPL](#repl)
19+
- [Test build](#test-build)
20+
21+
1722
- [Code Style Guide](#code-style-guide)
1823

1924
- [Lint the Code](#lint-the-code)
@@ -29,16 +34,16 @@ Help is always welcome. There are areas where you can help:
2934
- The core functionality (performance improvements, bug fixes,
3035
new features, etc.).
3136

32-
- Documentation ([markdown documents](https://github.com/date-fns/date-fns/search?l=markdown),
33-
inline JSDoc comments).
37+
- Documentation ([markdown documents](https://github.com/date-fns/date-fns/tree/master/docs),
38+
[JSDoc annotations in source code](https://github.com/date-fns/date-fns/blob/master/src/toDate/index.ts)).
3439

3540
- Test suite & development environment improvements.
3641

3742
- The [website](https://github.com/date-fns/date-fns.org).
3843

3944
If you see a gap, but don't have time, experience, or you just need help
4045
with the library, don't hesitate to [start a discussion](https://github.com/date-fns/date-fns/discussions/new) or
41-
[shoot an issue](https://github.com/date-fns/date-fns/issues/new).
46+
[open a new issue](https://github.com/date-fns/date-fns/issues/new).
4247

4348
The date-fns functionality is comprehensive and covers most of the use cases,
4449
however it doesn't have an extended time zone support. Please leave a comment
@@ -61,8 +66,6 @@ Please follow the main contributing rules, to maintain date-fns' top quality:
6166

6267
- [Lint the code](#lint-the-code).
6368

64-
- [Use EditorConfig](#use-editorconfig).
65-
6669
- Write tests.
6770

6871
- [Write documentation](#documentation).
@@ -73,42 +76,71 @@ Please follow the main contributing rules, to maintain date-fns' top quality:
7376

7477
## Getting Started
7578

76-
1. Install [Node.js](https://nodejs.org/en/download) and [Yarn](https://yarnpkg.com/en/docs/install).
79+
1. Install [Node.js 14 or greater (LTS recommended)](https://nodejs.org/en/download/)
7780

78-
2. Fork the project and clone the fork repo.
81+
2. Install or upgrade to the latest [Yarn classic (v1)](https://classic.yarnpkg.com/en/docs/install) by running `npm install -g yarn@latest`
7982

80-
3. Run `yarn` to install the application dependencies.
83+
3. Fork the project, and clone your fork of the repo
84+
85+
4. Run `yarn` to install the dev dependencies
8186

8287
## Testing
8388

84-
Run all tests:
89+
### Unit tests
90+
91+
Karma + Mocha (Chrome):
8592

8693
```sh
94+
# all tests in watch mode
8795
yarn test
96+
97+
# all tests once
98+
yarn test --single-run
8899
```
89100

90-
Run tests once:
101+
Jest (Node.js):
91102

92103
```sh
93-
yarn test --single-run
104+
# all tests in watch mode
105+
yarn jest --watch
106+
107+
# all tests once
108+
yarn jest
94109
```
95110

96-
To test a function in REPL, use `babel-node` located in `./node_modules/.bin` (mind the `-x` flag to support also TypeScript files):
111+
### REPL
112+
113+
To test functions in a REPL, use `babel-node` located in `./node_modules/.bin` (mind the `-x` flag to also support TypeScript files):
97114

98115
```sh
99-
./node_modules/.bin/babel-node -x ".js",".ts"
116+
yarn babel-node -x .ts,.js
117+
```
100118

119+
and then require invididual functions:
120+
```sh
101121
> const toDate = require('./src/toDate')
102122
undefined
103123
> toDate(1392098430000).toString()
104124
'Tue Feb 11 2014 01:00:30 GMT-0500 (Eastern Standard Time)'
105125
>
106126
```
107127

108-
Build date-fns to test in in your project:
128+
or all functions (slower):
129+
```sh
130+
> const fns = require('./src')
131+
undefined
132+
> fns.toDate(1392098430000).toString()
133+
'Tue Feb 11 2014 01:00:30 GMT-0500 (Eastern Standard Time)'
134+
>
135+
```
136+
137+
### Test build
138+
139+
Build date-fns from source to test in your project. The ouput is equivalent to what gets published on npm with each release.
109140

110141
```sh
111-
env PACKAGE_OUTPUT_PATH="$(pwd)/../PATH-TO-YOUR-MODULE/node_modules/date-fns" ./scripts/build/package.sh
142+
# replace {YOUR-PROJECT-PATH} with an absolute or relative path to your project root
143+
env PACKAGE_OUTPUT_PATH="{YOUR-PROJECT-PATH}/node_modules/date-fns" ./scripts/build/package.sh
112144
```
113145

114146
## Code Style Guide
@@ -129,9 +161,9 @@ yarn lint
129161

130162
### JSDoc
131163

132-
[JSDoc](http://usejsdoc.org) is used for the code documentation. Along with the
164+
- [JSDoc](https://jsdoc.app/) is used for the code documentation. Along with the
133165
standard JSDoc tags, date-fns uses `@category` tag that allows
134166
to group functions.
135167

136-
[jsdoc-parse](https://github.com/jsdoc2md/jsdoc-parse) is used to parse
168+
- [jsdoc-to-markdown](https://github.com/jsdoc2md/jsdoc-to-markdown/) is used to parse
137169
JSDoc annotations.

0 commit comments

Comments
 (0)