You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 19, 2019. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+13-25
Original file line number
Diff line number
Diff line change
@@ -1,18 +1,21 @@
1
1
# TypeScript ESLint Parser
2
2
3
-
A parser that converts TypeScript source code into an [ESTree](https://github.com/estree/estree)-compatible form.
3
+
An ESLint custom parser which leverages [TypeScript ESTree](https://github.com/JamesHenry/typescript-estree) to allow for ESLint to lint TypeScript source code.
4
4
5
-
## Usage
6
5
7
-
This parser is actually somewhat generic and robust - it could be used to power any use-case which requires taking TypeScript source code and producing an ESTree-compatiable AST.
6
+
## Installation:
8
7
9
-
In fact, that is exactly what it is used for in the popular open-source code formatter, [Prettier](https://prettier.io), to power its TypeScript support.
8
+
```sh
9
+
npm install --save-dev typescript-eslint-parser
10
+
```
10
11
11
-
Nevertheless, the parser does have a special appreciation for ESLint-specific use-cases built in, and can even produce a slightly different AST for ESLint if needed (using the special `parseForESLint()` method).
12
+
## Usage
12
13
13
-
The majority of users of this parser use it to enable them to use ESLint on their TypeScript source files, so they will not actually be interacting with the parser directly. Instead they will configure ESLint to use it instead of its default parser, [espree](https://github.com/eslint/espree), which does not understand TypeScript.
14
+
In your ESLint configuration file, set the `parser` property:
14
15
15
-
## Usage with ESLint
16
+
```json
17
+
"parser": "typescript-eslint-parser"
18
+
```
16
19
17
20
There is sometimes an incorrect assumption that the parser itself is what does everything necessary to facilitate the use of ESLint with TypeScript. In actuality, it is the combination of the parser _and_ one or more plugins which allow you to maximize your usage of ESLint with TypeScript.
18
21
@@ -24,18 +27,6 @@ Instead, you also need to make use of one more plugins which will add or extend
24
27
25
28
By far the most common case will be installing the [eslint-plugin-typescript](https://github.com/nzakas/eslint-plugin-typescript) plugin, but there are also other relevant options available such a [eslint-plugin-tslint](https://github.com/JamesHenry/eslint-plugin-tslint).
26
29
27
-
Install:
28
-
29
-
```sh
30
-
npm install --save-dev typescript-eslint-parser
31
-
```
32
-
33
-
And in your ESLint configuration file:
34
-
35
-
```json
36
-
"parser": "typescript-eslint-parser"
37
-
```
38
-
39
30
## Supported TypeScript Version
40
31
41
32
We will always endeavor to support the latest stable version of TypeScript.
@@ -52,9 +43,7 @@ If you're familiar with TypeScript and ESLint, and you'd like to see this projec
52
43
53
44
## Reporting Issues
54
45
55
-
The vast majority of issues which are submitted here are not actually parsing bugs at all. They are integration issues with the ESLint ecosystem.
56
-
57
-
This is not ideal, but users need a place to be able to report those things, so it has become accepted that that will also be done in this repo.
46
+
Please **do not report parsing/AST issues in this repo**, report them directly to [TypeScript ESTree](https://github.com/JamesHenry/typescript-estree).
58
47
59
48
Please check the current list of open and known issues and ensure the issue has not been reported before. When creating a new issue provide as much information about your environment as possible. This includes:
60
49
@@ -69,9 +58,9 @@ We have a very flexible way of running integration tests which connects all of t
69
58
70
59
We run each test within its own docker container, and so each one has complete autonomy over what dependencies/plugins are installed and what versions are used. This also has the benefit of not bloating the `package.json` and `node_modules` of the parser project itself.
71
60
72
-
> If you are going to submit an issue related to the usage of this parser with ESLint, please consider creating a failing integration which clearly demonstrates the behavior. It's honestly super quick!
61
+
> If you are going to submit an issue related to the usage of this parser with ESLint, please consider creating a failing integration test which clearly demonstrates the behavior. It's honestly super quick!
73
62
74
-
You just need to duplicate on of the existing test sub-directories found in `tests/integration/`, tweak the dependencies and ESLint config to match what you need, and add a new entry to the docker-compose.yml file which matches the format of the existing ones.
63
+
You just need to duplicate one of the existing test sub-directories found in `tests/integration/`, tweak the dependencies and ESLint config to match what you need, and add a new entry to the docker-compose.yml file which matches the format of the existing ones.
75
64
76
65
Then run:
77
66
@@ -93,7 +82,6 @@ Issues and pull requests will be triaged and responded to as quickly as possible
93
82
94
83
-`npm test` - run all linting and tests
95
84
-`npm run lint` - run all linting
96
-
-`npm run ast-alignment-tests` - run only Babylon AST alignment tests
97
85
-`npm run integration-tests` - run only integration tests
0 commit comments