Skip to content

Commit c37f953

Browse files
authored
Remove jsx:true from shareable configs. (#1237)
* Remove jsx:true from shareable configs. * Fixed doc
1 parent fd205ad commit c37f953

File tree

3 files changed

+23
-10
lines changed

3 files changed

+23
-10
lines changed

Diff for: docs/user-guide/README.md

+21-2
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ eslint "src/**/*.{js,vue}"
6565
If you installed [@vue/cli-plugin-eslint](https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-eslint), you should have the `lint` script added to your `package.json`. That means you can just run `yarn lint` or `npm run lint`.
6666
:::
6767

68-
#### How to use a custom parser?
68+
### How to use a custom parser?
6969

7070
If you want to use custom parsers such as [babel-eslint](https://www.npmjs.com/package/babel-eslint) or [@typescript-eslint/parser](https://www.npmjs.com/package/@typescript-eslint/parser), you have to use the `parserOptions.parser` option instead of the `parser` option. Because this plugin requires [vue-eslint-parser](https://www.npmjs.com/package/vue-eslint-parser) to parse `.vue` files, this plugin doesn't work if you overwrite the `parser` option.
7171

@@ -197,7 +197,7 @@ If you already use another parser (e.g. `"parser": "babel-eslint"`), please move
197197
+ "parser": "vue-eslint-parser",
198198
"parserOptions": {
199199
+ "parser": "babel-eslint",
200-
"ecmaVersion": 2017,
200+
"ecmaVersion": 2020,
201201
"sourceType": "module"
202202
}
203203
```
@@ -264,3 +264,22 @@ module.exports = {
264264

265265
[prettier]: https://prettier.io/
266266
[eslint-config-prettier]: https://github.com/prettier/eslint-config-prettier
267+
268+
### Using JSX.
269+
270+
If you are using JSX, you need to enable JSX in your ESLint configuration.
271+
272+
```diff
273+
"parserOptions": {
274+
"ecmaVersion": 2020,
275+
"ecmaFeatures": {
276+
+ "jsx": true
277+
}
278+
}
279+
```
280+
281+
See also [ESLint - Specifying Parser Options](https://eslint.org/docs/user-guide/configuring#specifying-parser-options).
282+
283+
The same configuration is required when using JSX with TypeScript (TSX) in the `.vue` file.
284+
See also [here](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/parser/README.md#parseroptionsecmafeaturesjsx).
285+
Note that you cannot use angle-bracket type assertion style (`var x = <foo>bar;`) when using `jsx: true`.

Diff for: lib/configs/base.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@ module.exports = {
77
parser: require.resolve('vue-eslint-parser'),
88
parserOptions: {
99
ecmaVersion: 2018,
10-
sourceType: 'module',
11-
ecmaFeatures: {
12-
jsx: true
13-
}
10+
sourceType: 'module'
1411
},
1512
env: {
1613
browser: true,

Diff for: tools/update-lib-configs.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,7 @@ module.exports = {
5050
parser: require.resolve('vue-eslint-parser'),
5151
parserOptions: {
5252
ecmaVersion: 2018,
53-
sourceType: 'module',
54-
ecmaFeatures: {
55-
jsx: true,
56-
}
53+
sourceType: 'module'
5754
},
5855
env: {
5956
browser: true,

0 commit comments

Comments
 (0)