Skip to content

Commit 4f52734

Browse files
Lehoczkyota-meshi
andauthored
docs: add an example on how to use custom parser with flat config (#2490)
Co-authored-by: Yosuke Ota <otameshiyo23@gmail.com>
1 parent d7169e1 commit 4f52734

File tree

1 file changed

+44
-4
lines changed

1 file changed

+44
-4
lines changed

docs/user-guide/index.md

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,48 @@ If you want to use custom parsers such as [@babel/eslint-parser](https://www.npm
146146
}
147147
```
148148

149+
Full example:
150+
151+
::: code-group
152+
153+
```json [.eslintrc]
154+
{
155+
"root": true,
156+
"plugins": ["@typescript-eslint"],
157+
"extends": [
158+
"eslint:recommended",
159+
"plugin:@typescript-eslint/recommended",
160+
"plugin:vue/vue3-recommended"
161+
],
162+
"parser": "vue-eslint-parser",
163+
"parserOptions": {
164+
"parser": "@typescript-eslint/parser"
165+
}
166+
}
167+
```
168+
169+
```js [eslint.config.js]
170+
import js from '@eslint/js'
171+
import eslintPluginVue from 'eslint-plugin-vue'
172+
import ts from 'typescript-eslint'
173+
174+
export default ts.config(
175+
js.configs.recommended,
176+
...ts.configs.recommended,
177+
...eslintPluginVue.configs['flat/recommended'],
178+
{
179+
files: ['*.vue', '**/*.vue'],
180+
languageOptions: {
181+
parserOptions: {
182+
parser: '@typescript-eslint/parser'
183+
}
184+
}
185+
}
186+
)
187+
```
188+
189+
:::
190+
149191
The `parserOptions.parser` option can also specify an object to specify multiple parsers. See [vue-eslint-parser README](https://github.com/vuejs/vue-eslint-parser#readme) for more details.
150192

151193
### How does ESLint detect components?
@@ -441,8 +483,7 @@ In [Nuxt 3](https://nuxt.com/) or with [`unplugin-auto-import`](https://github.c
441483

442484
::: code-group
443485

444-
```json [Legacy Config]
445-
// .eslintrc
486+
```json [.eslintrc]
446487
{
447488
"globals": {
448489
"ref": "readonly",
@@ -454,8 +495,7 @@ In [Nuxt 3](https://nuxt.com/) or with [`unplugin-auto-import`](https://github.c
454495
}
455496
```
456497

457-
```js [Flat Config]
458-
// eslint.config.js
498+
```js [eslint.config.js]
459499
export default [
460500
{
461501
languageOptions: {

0 commit comments

Comments
 (0)