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
1. Write `parser` option into your `.eslintrc.*` file.
23
-
2. Use glob patterns or `--ext .vue` CLI option.
22
+
Write `parser` option into your `eslint.config.*` file.
24
23
25
-
```json
26
-
{
27
-
"extends": "eslint:recommended",
28
-
"parser": "vue-eslint-parser"
29
-
}
30
-
```
31
-
32
-
```console
33
-
$ eslint "src/**/*.{js,vue}"
34
-
# or
35
-
$ eslint src --ext .vue
24
+
```js
25
+
importvueParserfrom"vue-eslint-parser"
26
+
exportdefault [
27
+
js.configs.recommended,
28
+
{
29
+
files: ["*.vue", "**/*.vue"],
30
+
languageOptions: {
31
+
parser: vueParser,
32
+
},
33
+
}
34
+
]
36
35
```
37
36
38
37
## 🔧 Options
39
38
40
39
`parserOptions` has the same properties as what [espree](https://github.com/eslint/espree#usage), the default parser of ESLint, is supporting.
41
40
For example:
42
41
43
-
```json
44
-
{
45
-
"parser": "vue-eslint-parser",
46
-
"parserOptions": {
47
-
"sourceType": "module",
48
-
"ecmaVersion": "latest",
49
-
"ecmaFeatures": {
50
-
"globalReturn": false,
51
-
"impliedStrict": false,
52
-
"jsx": false
53
-
}
42
+
```js
43
+
importvueParserfrom"vue-eslint-parser"
44
+
exportdefault [
45
+
{
46
+
files: ["*.vue", "**/*.vue"],
47
+
languageOptions: {
48
+
parser: vueParser,
49
+
sourceType:"module",
50
+
ecmaVersion:"latest",
51
+
parserOptions: {
52
+
ecmaFeatures: {
53
+
globalReturn:false,
54
+
impliedStrict:false,
55
+
jsx:false
56
+
}
57
+
}
58
+
},
54
59
}
55
-
}
60
+
]
56
61
```
57
62
58
63
### parserOptions.parser
@@ -61,66 +66,65 @@ You can use `parserOptions.parser` property to specify a custom parser to parse
61
66
Other properties than parser would be given to the specified parser.
62
67
For example:
63
68
64
-
```json
65
-
{
66
-
"parser": "vue-eslint-parser",
67
-
"parserOptions": {
68
-
"parser": "@babel/eslint-parser",
69
-
"sourceType": "module"
69
+
```js
70
+
importvueParserfrom"vue-eslint-parser"
71
+
importbabelParserfrom"@babel/eslint-parser"
72
+
exportdefault [
73
+
{
74
+
files: ["*.vue", "**/*.vue"],
75
+
languageOptions: {
76
+
parser: vueParser,
77
+
parserOptions: {
78
+
parser: babelParser,
79
+
}
80
+
},
70
81
}
71
-
}
82
+
]
72
83
```
73
84
74
-
```json
75
-
{
76
-
"parser": "vue-eslint-parser",
77
-
"parserOptions": {
78
-
"parser": "@typescript-eslint/parser",
79
-
"sourceType": "module"
85
+
```js
86
+
importvueParserfrom"vue-eslint-parser"
87
+
importtsParserfrom"@typescript-eslint/parser"
88
+
exportdefault [
89
+
{
90
+
files: ["*.vue", "**/*.vue"],
91
+
languageOptions: {
92
+
parser: vueParser,
93
+
parserOptions: {
94
+
parser: tsParser,
95
+
}
96
+
},
80
97
}
81
-
}
98
+
]
82
99
```
83
100
84
101
You can also specify an object and change the parser separately for `<script lang="...">`.
85
102
86
-
```jsonc
87
-
{
88
-
"parser":"vue-eslint-parser",
89
-
"parserOptions": {
90
-
"parser": {
91
-
// Script parser for `<script>`
92
-
"js":"espree",
93
-
94
-
// Script parser for `<script lang="ts">`
95
-
"ts":"@typescript-eslint/parser",
96
-
97
-
// Script parser for vue directives (e.g. `v-if=` or `:attribute=`)
98
-
// and vue interpolations (e.g. `{{variable}}`).
99
-
// If not specified, the parser determined by `<script lang ="...">` is used.
100
-
"<template>":"espree",
101
-
}
102
-
}
103
-
}
104
-
```
105
-
106
-
When using JavaScript configuration (`.eslintrc.js`), you can also give the parser object directly.
0 commit comments