1
1
# Scratch ESLint config
2
2
#### eslint-config-scratch defines the eslint rules used for Scratch Javascript projects
3
3
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
+
4
57
## Committing
5
58
This project uses [ semantic release] ( https://github.com/semantic-release/semantic-release )
6
59
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`.
23
76
## Breaking changes
24
77
If you're committing a change that makes the linter more strict, or will
25
78
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.
0 commit comments