Skip to content

Commit 83ca621

Browse files
author
vvo
committed
feat(prettier): prepare prettier migration
1 parent 61ed32b commit 83ca621

File tree

10 files changed

+4382
-296
lines changed

10 files changed

+4382
-296
lines changed

.eslintrc.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
extends: './index.js',
3+
};

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
language: node_js
22
node_js: "6"
33
cache:
4+
yarn: true
45
directories:
56
- node_modules

README.md

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
This is [Algolia](https://www.algolia.com/)'s [ESLint](http://eslint.org/) configuration.
66

7-
87
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
98
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
109
**Table of Contents**
@@ -17,10 +16,13 @@ This is [Algolia](https://www.algolia.com/)'s [ESLint](http://eslint.org/) confi
1716

1817
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
1918

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.
2123

2224
```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
2426
```
2527

2628
create an `.eslintrc.js` file:
@@ -30,24 +32,40 @@ module.exports = {
3032
};
3133
```
3234

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.
3437

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)
3639

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
4244
```
4345

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+
```
4561

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.
4763

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
4967

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.
5169

5270
## Ignoring files
5371

@@ -64,7 +82,7 @@ yarn test
6482
## Release
6583

6684
```sh
67-
yarn release
85+
npm run release
6886
```
6987

7088
[version-svg]: https://img.shields.io/npm/v/eslint-config-algolia.svg?style=flat-square

0 commit comments

Comments
 (0)