|
10 | 10 |
|
11 | 11 | ## Installation |
12 | 12 |
|
13 | | -You'll first need to install [ESLint](http://eslint.org): |
14 | | - |
15 | | -```sh |
16 | | -npm i eslint --save-dev |
17 | | -``` |
18 | | - |
19 | | -Next, install `typescript` if you haven’t already: |
20 | | - |
21 | | -```sh |
22 | | -npm i typescript@~3.1.1 --save-dev |
23 | | -``` |
24 | | - |
25 | | -Last, install `@typescript-eslint/eslint-plugin`: |
| 13 | +Make sure you have TypeScript and @typescript-eslint/parser installed, then install the plugin: |
26 | 14 |
|
27 | 15 | ```sh |
28 | 16 | npm i @typescript-eslint/eslint-plugin --save-dev |
29 | 17 | ``` |
30 | 18 |
|
| 19 | +It is important that you use the same version number for `@typescript-eslint/parser` and `@typescript-eslint/eslint-plugin`. |
| 20 | + |
31 | 21 | **Note:** If you installed ESLint globally (using the `-g` flag) then you must also install `@typescript-eslint/eslint-plugin` globally. |
32 | 22 |
|
33 | 23 | ## Usage |
34 | 24 |
|
35 | | -Add `@typescript-eslint/eslint-plugin/parser` to the `parser` field and `typescript` to the plugins section of your `.eslintrc` configuration file: |
| 25 | +Add `@typescript-eslint/parser` to the `parser` field and `@typescript-eslint` to the plugins section of your `.eslintrc` configuration file: |
36 | 26 |
|
37 | 27 | ```json |
38 | 28 | { |
39 | | - "parser": "@typescript-eslint/eslint-plugin/parser", |
| 29 | + "parser": "@typescript-eslint/parser", |
40 | 30 | "plugins": ["@typescript-eslint"] |
41 | 31 | } |
42 | 32 | ``` |
43 | 33 |
|
44 | | -Note: The plugin provides its own version of the `@typescript-eslint/parser` via `@typescript-eslint/eslint-plugin/parser`. |
45 | | -This helps us guarantee 100% compatibility between the plugin and the parser. |
46 | | - |
47 | 34 | Then configure the rules you want to use under the rules section. |
48 | 35 |
|
49 | 36 | ```json |
50 | 37 | { |
51 | | - "parser": "@typescript-eslint/eslint-plugin/parser", |
| 38 | + "parser": "@typescript-eslint/parser", |
52 | 39 | "plugins": ["@typescript-eslint"], |
53 | 40 | "rules": { |
54 | 41 | "@typescript-eslint/rule-name": "error" |
55 | 42 | } |
56 | 43 | } |
57 | 44 | ``` |
58 | 45 |
|
59 | | -You can also enable all the recommended rules at once. Add `plugin:typescript/recommended` in extends: |
| 46 | +You can also enable all the recommended rules at once. Add `plugin:@typescript-eslint/recommended` in extends: |
60 | 47 |
|
61 | 48 | ```json |
62 | 49 | { |
|
0 commit comments