UNPKG

3.04 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/camelcase": 1,
33 "babel/no-invalid-this": 1,
34 "babel/object-curly-spacing": 1,
35 "babel/quotes": 1,
36 "babel/semi": 1,
37 "babel/no-unused-expressions": 1,
38 "babel/valid-typeof": 1
39 }
40}
41```
42### Rules
43
44Each rule corresponds to a core `eslint` rule, and has the same options.
45
46🛠: means it's autofixable with `--fix`.
47
48- `babel/new-cap`: Ignores capitalized decorators (`@Decorator`)
49- `babel/camelcase: doesn't complain about optional chaining (`var foo = bar?.a_b;`)
50- `babel/no-invalid-this`: doesn't fail when inside class properties (`class A { a = this.b; }`)
51- `babel/object-curly-spacing`: doesn't complain about `export x from "mod";` or `export * as x from "mod";` (🛠)
52- `babel/quotes`: doesn't complain about JSX fragment shorthand syntax (`<>foo</>;`)
53- `babel/semi`: doesn't fail when using `for await (let something of {})`. Includes class properties (🛠)
54- `babel/no-unused-expressions`: doesn't fail when using `do` expressions or [optional chaining](https://github.com/tc39/proposal-optional-chaining) (`a?.b()`).
55- `babel/valid-typeof`: doesn't complain when used with [BigInt](https://github.com/tc39/proposal-bigint) (`typeof BigInt(9007199254740991) === 'bigint'`).
56
57#### Deprecated
58
59| Rule | Notes |
60|:---------------------------------|:-----------------------------------|
61| `babel/generator-star-spacing` | Use [`generator-star-spacing`](http://eslint.org/docs/rules/generator-star-spacing) since eslint@3.6.0 |
62| `babel/object-shorthand` | Use [`object-shorthand`](http://eslint.org/docs/rules/object-shorthand) since eslint@0.20.0 |
63| `babel/arrow-parens` | Use [`arrow-parens`](http://eslint.org/docs/rules/arrow-parens) since eslint@3.10.0 |
64| `babel/func-params-comma-dangle` | Use [`comma-dangle`](http://eslint.org/docs/rules/comma-dangle) since eslint@3.8.0 |
65| `babel/array-bracket-spacing` | Use [`array-bracket-spacing`](http://eslint.org/docs/rules/array-bracket-spacing) since eslint@3.9.0 |
66| `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 |
67| `babel/no-await-in-loop` | Use [`no-await-in-loop`](http://eslint.org/docs/rules/no-await-in-loop) since eslint@3.12.0 |