UNPKG

1.54 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### Install
8
9```sh
10npm install eslint-plugin-babel -D
11```
12
13Load the plugin in your `.eslintrc` file:
14
15```json
16{
17 "plugins": [
18 "babel"
19 ]
20}
21```
22
23Finally enable all the rules you would like to use (remember to disable the
24original ones as well!).
25
26```json
27{
28 "rules": {
29 "babel/generator-star-spacing": 1,
30 "babel/new-cap": 1,
31 "babel/array-bracket-spacing": 1,
32 "babel/object-curly-spacing": 1,
33 "babel/object-shorthand": 1,
34 "babel/arrow-parens": 1,
35 "babel/no-await-in-loop": 1
36 }
37}
38```
39### Rules
40
41Each rule corresponds to a core `eslint` rule, and has the same options.
42
43- `babel/generator-star-spacing`: Handles async/await functions correctly
44- `babel/new-cap`: Ignores capitalized decorators (`@Decorator`)
45- `babel/array-bracket-spacing`: Handles destructuring arrays with flow type in function parameters
46- `babel/object-curly-spacing`: doesn't complain about `export x from "mod";` or `export * as x from "mod";`
47- `babel/object-shorthand`: doesn't fail when using object spread (`...obj`)
48- `babel/arrow-parens`: Handles async functions correctly
49- `babel/no-await-in-loop`: guard against awaiting async functions inside of a loop