You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+32-29Lines changed: 32 additions & 29 deletions
Original file line number
Diff line number
Diff line change
@@ -74,13 +74,13 @@ Having a good guideline for creating commits and sticking to it makes working wi
74
74
* Limit the subject line to 50 characters
75
75
* Capitalize the subject line
76
76
* Do not end the subject line with a period
77
-
* Use the imperative mood in the subject line
77
+
* Use imperative mood in the subject line
78
78
* Wrap the body at 72 characters
79
-
* Use the body to explain what and why vs. how
79
+
* Use the body to explain **what** and **why** as opposed to **how**
80
80
81
81
## 2. Documentation <a name="documentation"></a>
82
82
* Use this [template](./README.sample.md) for `README.md`, Feel free to add uncovered sections.
83
-
* For project with more than one repository, provide links to between them in their `README.md` files.
83
+
* For projects with more than one repository, provide links to them in their respective `README.md` files.
84
84
* Keep `README.md` updated as project evolves.
85
85
* Comment your code. Try to make it as clear as possible what you are intending with each major section.
86
86
* Comment small sections of code if you think it's not self explanatory.
@@ -90,56 +90,59 @@ Having a good guideline for creating commits and sticking to it makes working wi
90
90
* Depending on project size, define separate `development`, `test` and `production` environments.
91
91
* Load your deployment specific configurations from environment variables and never add them to the codebase as constants, [look at this sample](./config.sample.js).
92
92
* Your config should be correctly separated from the app internals as if the codebase could be made public at any moment. Use `.env` files to store your variables and add them to `.gitignore` to be excluded from your code base because of course, you want the environment to provide them. Instead commit a `.env.example` which serves as a guide for developers to know which environment variables the project needs. It is important to remember that this setup should only be used for development. For production you should still set your environment variables in the standard way.
93
-
* It’s recommended to validate environment variables before your app starts , [look at this sample](./configWithTest.sample.js) using `joi` to validate provided values:
93
+
* It’s recommended to validate environment variables before your app starts. [Look at this sample](./configWithTest.sample.js) using `joi` to validate provided values.
94
94
95
95
### 3.1 Consistent dev environments:
96
96
* Set `engines` in `package.json` to specify the version of node your project works on.
97
-
* Additionally, Use `nvm` and create a `.nvmrc` in your project root. Don't forget to mention in documentation
97
+
* Additionally, use `nvm` and create a `.nvmrc` in your project root. Don't forget to mention it in the documentation
98
98
* You can also use a `preinstall` script that checks node and npm versions
99
-
* Or if it doesn't make things complicated use a docker images
100
-
* Use local modules instead of requiring global installation
99
+
* Use Docker images provided it doesn't make things more complicated
100
+
* Use local modules instead of using globally installed modules
101
101
102
102
## 4. Dependencies <a name="dependencies"></a>
103
-
Before using a package check its Github open issues, daily downloads and number of contributors as well as the date package last updated.
103
+
Before using a package, check its GitHub. Look for the number of open issues, daily downloads and number of contributors as well as the date the package was last updated.
104
104
105
-
* If less known dependency is needed, discuss it with the team before using it.
105
+
* If less known dependency is needed, discuss it with the team before using it.
106
106
* Keep track of your currently available packages: e.g., `npm ls --depth=0` ([documentation](https://docs.npmjs.com/cli/ls)).
107
107
* See if any of your packages have become unused or irrelevant: `depcheck` ([documentation](https://www.npmjs.com/package/depcheck)).
108
108
* Check download statistics to see if the dependency is heavily used by the community: `npm-stat` ([documentation](https://npm-stat.com/)).
109
109
* Check to see if the dependency has a good, mature version release frequency with a large number of maintainers: e.g., `npm view async` ([documentation](https://docs.npmjs.com/cli/view)).
110
110
* Always make sure your app works with the latest versions of dependencies without breaking: `npm outdated` ([documentation](https://docs.npmjs.com/cli/outdated)).
111
-
* Check to see package has known security vulnerabilities with, e.g., [Snyk](https://snyk.io/test?utm_source=risingstack_blog).
111
+
* Check to see if the package has known security vulnerabilities with, e.g., [Snyk](https://snyk.io/test?utm_source=risingstack_blog).
112
112
113
113
### 4.1 Consistent dependencies:
114
-
* Use `package-lock.json` on npm 5 or higher
115
-
* For older versions of npm Use `—save --save-exact` when installing a new dependency and create `npm-shrinkwrap.json` before publishing.
114
+
* Use `package-lock.json` on `npm@5` or higher
115
+
* For older versions of `npm`, use `—save --save-exact` when installing a new dependency and create `npm-shrinkwrap.json` before publishing.
116
116
* Alternatively you can use `Yarn` and make sure to mention it in `README.md`. Your lock file and `package.json` should have the same versions after each dependency update.
117
117
* Read more here: [package-locks | npm Documentation](https://docs.npmjs.com/files/package-locks)
118
118
119
119
## 5. Testing <a name="testing"></a>
120
120
* Have a test mode environment if needed.
121
121
* Place your test files next to the tested modules using `*.test.js` or `*.spec.js` naming convention, like `module_name.spec.js`
122
122
* Put your additional test files into a separate test folder to avoid confusion.
123
-
* write testable code, avoid side effect, extract side effects, write pure functions
124
-
* Don’t write too many tests to check types, instead use a Static type checker
125
-
* Run tests locally before any pull request to `develop`.
123
+
* Write testable code, avoid side effects, extract side effects, write pure functions
124
+
* Don’t write too many tests to check types, instead use a static type checker
125
+
* Run tests locally before making any pull requests to `develop`.
126
126
* Document your tests, with instructions.
127
127
128
128
## 6. Structure and Naming <a name="structure-and-naming"></a>
129
-
* Organize your files around product features / pages / components, not Roles:
130
-
```
131
-
// BAD
129
+
* Organize your files around product features / pages / components, not roles
130
+
131
+
**Bad**
132
+
133
+
```
132
134
.
133
135
├── controllers
134
136
| ├── product.js
135
137
| └── user.js
136
138
├── models
137
139
| ├── product.js
138
140
| └── user.js
139
-
```
141
+
```
140
142
141
-
```
142
-
// GOOD
143
+
**Good**
144
+
145
+
```
143
146
.
144
147
├── product
145
148
| ├── index.js
@@ -149,15 +152,15 @@ Before using a package check its Github open issues, daily downloads and number
149
152
| ├── index.js
150
153
| ├── user.js
151
154
| └── user.test.js
152
-
```
153
-
* Place your test files next to the implementation.
155
+
```
156
+
* Place your test files next to their implementation.
154
157
* Put your additional test files to a separate test folder to avoid confusion.
155
-
* Use a `./config` folder. Values to be used in config files are provided by environmental variables.
156
-
* Put your scripts in a `./scripts` folder. This includes bash and node scripts for database synchronisation, build and bundling and so on.
158
+
* Use a `./config` folder. Values to be used in config files are provided by environment variables.
159
+
* Put your scripts in a `./scripts` folder. This includes `bash` and `node` scripts for database synchronisation, build and bundling and so on.
157
160
* Place your build output in a `./build` folder. Add `build/` to `.gitignore`.
158
-
* Use `PascalCase' 'camelCase` for filenames and directory names too. Use `PascalCase` only for Components.
161
+
* Use `PascalCase' 'camelCase` for filenames and directory names. Use `PascalCase` only for Components.
159
162
* `CheckBox/index.js` should have the `CheckBox` component, as could `CheckBox.js`, but **not** `CheckBox/CheckBox.js` or `checkbox/CheckBox.js` which are redundant.
160
-
* Ideally the directory name would match the name of the default export of `index.js`.
163
+
* Ideally the directory name should match the name of the default export of `index.js`.
161
164
162
165
## 7. Code style <a name="code-style"></a>
163
166
* Use stage-1 and higher JavaScript (modern) syntax for new projects. For old project stay consistent with existing syntax unless you intend to modernise the project.
@@ -167,7 +170,7 @@ Before using a package check its Github open issues, daily downloads and number
167
170
* Use [Flow type style check rules for ESLint.](https://github.com/gajus/eslint-plugin-flowtype) for [FlowType](https://flow.org/).
168
171
* Use `.eslintignore` to exclude file or folders from code style check.
169
172
* Remove any of your `eslint` disable comments before making a Pull Request.
170
-
* Always use `//todo:` comments to remind yourself and others about an unfinished job.
173
+
* Always use `//TODO:` comments to remind yourself and others about an unfinished job.
171
174
* Always comment and keep them relevant as code changes.
172
175
* Remove commented block of code when possible.
173
176
* Avoid js alerts in production.
@@ -177,7 +180,7 @@ Before using a package check its Github open issues, daily downloads and number
177
180
* Organize your functions in a file according to the step-down rule. Higher level functions should be on top and lower levels below. It makes it more natural to read the source code.
178
181
179
182
## 8. Logging <a name="logging"></a>
180
-
* Avoid clientside console logs in production
183
+
* Avoid client-side console logs in production
181
184
* Produce readable production logging. Ideally use logging libraries to be used in production mode (such as [winston](https://github.com/winstonjs/winston) or
0 commit comments