4
4
5
5
This is [ Algolia] ( https://www.algolia.com/ ) 's [ ESLint] ( http://eslint.org/ ) configuration.
6
6
7
-
8
7
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
9
8
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
10
9
** Table of Contents**
@@ -17,10 +16,13 @@ This is [Algolia](https://www.algolia.com/)'s [ESLint](http://eslint.org/) confi
17
16
18
17
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
19
18
20
- ## Usage
19
+ ## Linting (ESLint)
20
+
21
+ We use linting as a way to ease our development mostly, getting info on a variable being global in your editor
22
+ is better than discovering it in production.
21
23
22
24
``` sh
23
- yarn add eslint-config-algolia babel-eslint eslint eslint-import-resolver-webpack eslint-plugin-import eslint-plugin-jasmine eslint-plugin-react --dev
25
+ yarn add eslint-config-algolia babel-eslint eslint eslint-plugin-import eslint-plugin-jest eslint-config-prettier prettier [ eslint-plugin-react eslint-import-resolver-webpack] --dev
24
26
```
25
27
26
28
create an ` .eslintrc.js ` file:
@@ -30,24 +32,40 @@ module.exports = {
30
32
};
31
33
```
32
34
33
- ### Jasmine
35
+ Then add [ an editor plugin] ( http://eslint.org/docs/user-guide/integrations.html#editors ) that will show you linting errors, do not activate
36
+ auto formatting fix, we use prettier for this.
34
37
35
- We have a specific set of rules if you are using [ Jasmine ] ( https://jasmine.github.io/ ) (or [ Jest ] ( https://facebook.github.io/jest/ ) ).
38
+ ## Formatting (Prettier)
36
39
37
- create an ` .eslintrc.js ` file:
38
- ``` js
39
- module .exports = {
40
- " extends" : [" algolia" , " algolia/jasmine" ]
41
- };
40
+ Please add [ Prettier] ( https://github.com/prettier/prettier ) to your JavaScript project:
41
+
42
+ ``` sh
43
+ yarn add prettier lint-staged husky --dev
42
44
```
43
45
44
- ### Tips
46
+ Then add this to your package.json:
47
+
48
+ ```
49
+ {
50
+ "scripts": {
51
+ "precommit": "lint-staged"
52
+ },
53
+ "lint-staged": {
54
+ "*.js": [
55
+ "prettier --write --single-quote --trailing-comma es5",
56
+ "git add"
57
+ ]
58
+ }
59
+ }
60
+ ```
45
61
46
- If you are using [ any editors plugin ] ( http://eslint.org/docs/user-guide/integrations.html#editors ) for ESLint then it will show you warnings/errors .
62
+ This will automatically reformat staged files .
47
63
48
- Also activate fix errors on save in your editor. ESLint is able to fix many errors for you given your ESLint configuration.
64
+ Rules:
65
+ - single-quote YES
66
+ - trailing-comma YES
49
67
50
- Now you can create an npm ` lint ` [ script ] ( https://docs.npmjs. com/files/package.json#scripts ) that will run ` eslint . ` to lint all files .
68
+ Add [ an editor plugin ] ( https://github. com/prettier/prettier#atom ) , configure the rules, done .
51
69
52
70
## Ignoring files
53
71
@@ -64,7 +82,7 @@ yarn test
64
82
## Release
65
83
66
84
``` sh
67
- yarn release
85
+ npm run release
68
86
```
69
87
70
88
[ version-svg ] : https://img.shields.io/npm/v/eslint-config-algolia.svg?style=flat-square
0 commit comments