Skip to content
This repository was archived by the owner on Jan 19, 2019. It is now read-only.

Breaking: typescript-estree v5 #538

Merged
merged 5 commits into from
Nov 7, 2018
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ npm install --save-dev typescript-eslint-parser
In your ESLint configuration file, set the `parser` property:

```json
"parser": "typescript-eslint-parser"
{
"parser": "typescript-eslint-parser"
}
```

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.
Expand All @@ -30,15 +32,23 @@ Instead, you also need to make use of one more plugins which will add or extend

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).

## Options
## Configuration

The following additional configuration options are available by specifying them in [`parserOptions`](https://eslint.org/docs/user-guide/configuring#specifying-parser-options) in your ESLint configuration file.

**`jsx`** - default `false`. Enable parsing JSX when `true`. More details can be found [here](https://www.typescriptlang.org/docs/handbook/jsx.html).
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are technically other options (range, loc, comment, etc.), but these aren't particularly useful for the end user, since ESLint supplies them. I think we should document the API (parse(), parseForESLint(), etc.) and document those options there.


The full list of options can be found in the [typescript-estree README](https://github.com/JamesHenry/typescript-estree#parsecode-options). Use them like this in your eslintrc:
**`useJSXTextNode`** - default `false`. The JSX AST changed the node type for string literals inside a JSX Element from `Literal` to `JSXText`. When value is `true`, these nodes will be parsed as type `JSXText`. When value is `false`, these nodes will be parsed as type `Literal`.

```js
parserOptions: {
ecmaFeatures: {
jsx: true,
}
### .eslintrc.json

```json
{
"parser": "typescript-eslint-parser",
"parserOptions": {
"jsx": true,
"useJSXTextNode": true
}
}
```

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"dependencies": {
"eslint": "4.19.1",
"eslint-visitor-keys": "^1.0.0",
"typescript-estree": "2.1.0"
"typescript-estree": "5.0.0"
},
"peerDependencies": {
"typescript": "*"
Expand Down
9 changes: 9 additions & 0 deletions tests/lib/__snapshots__/basics.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ Object {
"type": "ExpressionStatement",
},
],
"comments": Array [],
"loc": Object {
"end": Object {
"column": 0,
Expand Down Expand Up @@ -499,6 +500,7 @@ Object {
"type": "DoWhileStatement",
},
],
"comments": Array [],
"loc": Object {
"end": Object {
"column": 0,
Expand Down Expand Up @@ -1177,6 +1179,7 @@ Object {
"type": "FunctionDeclaration",
},
],
"comments": Array [],
"loc": Object {
"end": Object {
"column": 0,
Expand Down Expand Up @@ -1544,6 +1547,7 @@ Object {
"type": "ExpressionStatement",
},
],
"comments": Array [],
"loc": Object {
"end": Object {
"column": 17,
Expand Down Expand Up @@ -1712,6 +1716,7 @@ Object {
"type": "ExpressionStatement",
},
],
"comments": Array [],
"loc": Object {
"end": Object {
"column": 0,
Expand Down Expand Up @@ -1973,6 +1978,7 @@ Object {
"type": "ExpressionStatement",
},
],
"comments": Array [],
"loc": Object {
"end": Object {
"column": 6,
Expand Down Expand Up @@ -2215,6 +2221,7 @@ Object {
"type": "ExpressionStatement",
},
],
"comments": Array [],
"loc": Object {
"end": Object {
"column": 0,
Expand Down Expand Up @@ -2515,6 +2522,7 @@ Object {
"type": "ExpressionStatement",
},
],
"comments": Array [],
"loc": Object {
"end": Object {
"column": 4,
Expand Down Expand Up @@ -2974,6 +2982,7 @@ Object {
"type": "ExpressionStatement",
},
],
"comments": Array [],
"loc": Object {
"end": Object {
"column": 0,
Expand Down
Loading