1 | # eslint-plugin-babel
|
2 |
|
3 | An `eslint` plugin companion to `babel-eslint`. `babel-eslint` does a great job at adapting `eslint`
|
4 | for use with Babel, but it can't change the built in rules to support experimental features.
|
5 | `eslint-plugin-babel` re-implements problematic rules so they do not give false positives or negatives.
|
6 |
|
7 | > Requires Node 4 or greater
|
8 |
|
9 | ### Install
|
10 |
|
11 | ```sh
|
12 | npm install eslint-plugin-babel --save-dev
|
13 | ```
|
14 |
|
15 | Load the plugin in your `.eslintrc` file:
|
16 |
|
17 | ```json
|
18 | {
|
19 | "plugins": [
|
20 | "babel"
|
21 | ]
|
22 | }
|
23 | ```
|
24 |
|
25 | Finally enable all the rules you would like to use (remember to disable the
|
26 | original ones as well!).
|
27 |
|
28 | ```json
|
29 | {
|
30 | "rules": {
|
31 | "babel/new-cap": 1,
|
32 | "babel/object-curly-spacing": 1,
|
33 | "babel/no-await-in-loop": 1,
|
34 | "babel/flow-object-type": 1,
|
35 | "babel/no-invalid-this": 1
|
36 | }
|
37 | }
|
38 | ```
|
39 | ### Rules
|
40 |
|
41 | Each rule corresponds to a core `eslint` rule, and has the same options.
|
42 |
|
43 | 🛠: means it's autofixable with `--fix`.
|
44 |
|
45 | - `babel/new-cap`: Ignores capitalized decorators (`@Decorator`)
|
46 | - `babel/object-curly-spacing`: doesn't complain about `export x from "mod";` or `export * as x from "mod";` (🛠)
|
47 | - `babel/no-invalid-this`: doesn't fail when inside class properties (`class A { a = this.b; }`)
|
48 |
|
49 | The following rules are not in `eslint`, but are relevant only to syntax that is not specified by
|
50 | the current JavaScript standard or supported by `eslint`.
|
51 |
|
52 | - `babel/no-await-in-loop`: guard against awaiting async functions inside of a loop
|
53 |
|
54 | #### Deprecated
|
55 |
|
56 | - `babel/generator-star-spacing`: Use [`generator-star-spacing`](http://eslint.org/docs/rules/generator-star-spacing).
|
57 | - `babel/object-shorthand`: Use [`object-shorthand`](http://eslint.org/docs/rules/object-shorthand).
|
58 | - `babel/arrow-parens`: Use [`arrow-parens`](http://eslint.org/docs/rules/arrow-parens).
|
59 | - `babel/func-params-comma-dangle`: Use [`comma-dangle`](http://eslint.org/docs/rules/comma-dangle).
|
60 | - `babel/array-bracket-spacing`: Use [`array-bracket-spacing`](http://eslint.org/docs/rules/array-bracket-spacing).
|
61 | - `babel/flow-object-type`: Use [`flowtype/object-type-delimiter`](https://github.com/gajus/eslint-plugin-flowtype#eslint-plugin-flowtype-rules-object-type-delimiter).
|