Skip to content

Commit f782034

Browse files
author
Ray Schamp
committed
docs(setup): Add installation and usage instructions
1 parent 8f97688 commit f782034

File tree

2 files changed

+57
-3
lines changed

2 files changed

+57
-3
lines changed

README.md

+56-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,59 @@
11
# Scratch ESLint config
22
#### eslint-config-scratch defines the eslint rules used for Scratch Javascript projects
33

4+
## Installation
5+
Install the config along with its peer dependencies, eslint and babel-eslint.
6+
```bash
7+
npm install -D eslint-config-scratch eslint@3 babel-eslint@7
8+
```
9+
10+
If you're using the React config, also install the dependency for that
11+
```bash
12+
npm install -D eslint-plugin-react@6
13+
```
14+
15+
## Usage
16+
The configuration is split up into several modules:
17+
* `scratch`: The base configuration. Always extend this.
18+
* `scratch/node`: Rules for node, e.g., server-side code, tests, and scripts
19+
* `scratch/es6`: Rules for ES6, for use when you're transpiling with webpack
20+
* `scratch/react`: Rules for React projects
21+
22+
Usually web projects have a mix of node and web environment files. To lint both
23+
with the appropriate rules, set up a base `.eslintrc.js` with the rules for node
24+
and then override the node configuration in `src` (where web code usually lives).
25+
E.g., with a file structure like this:
26+
```
27+
scratch-project
28+
- .eslintrc.js
29+
- package.json
30+
- src
31+
- .eslintrc.js
32+
- index.js
33+
```
34+
Your config files should be set up like
35+
```javascript
36+
// scratch-project/.eslintrc.js
37+
module.exports = {
38+
extends: ['scratch', 'scratch/node'],
39+
env: {
40+
node: true
41+
}
42+
};
43+
44+
// scratch-project/src/.eslintrc.js
45+
module.exports = {
46+
root: true,
47+
extends: ['scratch', 'scratch/es6', 'scratch/react'],
48+
env: {
49+
browser: true
50+
}
51+
};
52+
```
53+
This will set up all the files in the project for linting as Node.js by default,
54+
except for those in `src/`, which will be linted as ES6 and React files.
55+
56+
457
## Committing
558
This project uses [semantic release](https://github.com/semantic-release/semantic-release)
659
to ensure version bumps follow semver so that projects using the config don't
@@ -23,5 +76,6 @@ Now you're ready to make commits using `git cz`.
2376
## Breaking changes
2477
If you're committing a change that makes the linter more strict, or will
2578
otherwise require changes to existing code, ensure your commit specifies a
26-
breaking change. This will cause a major version bump so downstream projects
27-
must choose to upgrade the config and will not break the build unexpectedly.
79+
breaking change. In your commit body, prefix the changes with "BREAKING CHANGE: "
80+
This will cause a major version bump so downstream projects must choose to upgrade
81+
the config and will not break the build unexpectedly.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"scratch"
2727
],
2828
"optionalDependencies": {
29-
"eslint-plugin-react": "^6.4.1"
29+
"eslint-plugin-react": "6.x"
3030
},
3131
"peerDependencies": {
3232
"babel-eslint": "7.x",

0 commit comments

Comments
 (0)