UNPKG

2.55 kBMarkdownView Raw
1# eslint-plugin-babel
2
3An `eslint` plugin companion to `babel-eslint`. `babel-eslint` does a great job at adapting `eslint`
4for 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
12npm install eslint-plugin-babel --save-dev
13```
14
15Load the plugin in your `.eslintrc` file:
16
17```json
18{
19 "plugins": [
20 "babel"
21 ]
22}
23```
24
25Finally enable all the rules you would like to use (remember to disable the
26original ones as well!).
27
28```json
29{
30 "rules": {
31 "babel/new-cap": 1,
32 "babel/no-invalid-this": 1,
33 "babel/object-curly-spacing": 1,
34 "babel/quotes": 1,
35 "babel/semi": 1
36 }
37}
38```
39### Rules
40
41Each 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/no-invalid-this`: doesn't fail when inside class properties (`class A { a = this.b; }`)
47- `babel/object-curly-spacing`: doesn't complain about `export x from "mod";` or `export * as x from "mod";` (🛠)
48- `babel/quotes`: doesn't complain about JSX fragment shorthand syntax (`<>foo</>;`)
49- `babel/semi`: doesn't fail when using `for await (let something of {})`. Includes class properties (🛠)
50
51#### Deprecated
52
53| Rule | Notes |
54|:---------------------------------|:-----------------------------------|
55| `babel/generator-star-spacing` | Use [`generator-star-spacing`](http://eslint.org/docs/rules/generator-star-spacing) since eslint@3.6.0 |
56| `babel/object-shorthand` | Use [`object-shorthand`](http://eslint.org/docs/rules/object-shorthand) since eslint@0.20.0 |
57| `babel/arrow-parens` | Use [`arrow-parens`](http://eslint.org/docs/rules/arrow-parens) since eslint@3.10.0 |
58| `babel/func-params-comma-dangle` | Use [`comma-dangle`](http://eslint.org/docs/rules/comma-dangle) since eslint@3.8.0 |
59| `babel/array-bracket-spacing` | Use [`array-bracket-spacing`](http://eslint.org/docs/rules/array-bracket-spacing) since eslint@3.9.0 |
60| `babel/flow-object-type` | Use [`flowtype/object-type-delimiter`](https://github.com/gajus/eslint-plugin-flowtype#eslint-plugin-flowtype-rules-object-type-delimiter) since eslint-plugin-flowtype@2.23.0 |
61| `babel/no-await-in-loop` | Use [`no-await-in-loop`](http://eslint.org/docs/rules/no-await-in-loop) since eslint@3.12.0 |