Skip to content

Commit 8ef29aa

Browse files
committed
docs: add an example on how to use custom parser with flat config
1 parent ca7daff commit 8ef29aa

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

docs/user-guide/index.md

Lines changed: 42 additions & 0 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 [Legacy Config]
154+
// .eslintrc
155+
{
156+
"root": true,
157+
"plugins": ["@typescript-eslint"],
158+
"extends": [
159+
"eslint:recommended",
160+
"plugin:@typescript-eslint/recommended",
161+
"plugin:vue/vue3-recommended"
162+
],
163+
"parser": "vue-eslint-parser",
164+
"parserOptions": {
165+
"parser": "@typescript-eslint/parser"
166+
}
167+
}
168+
```
169+
170+
```js [Flat Config]
171+
// eslint.config.js
172+
import js from '@eslint/js'
173+
import eslintPluginVue from 'eslint-plugin-vue'
174+
import ts from 'typescript-eslint'
175+
176+
export default ts.config(
177+
js.configs.recommended,
178+
...ts.configs.recommended,
179+
...eslintPluginVue.configs['flat/recommended'],
180+
{
181+
files: ['*.vue', '**/*.vue'],
182+
languageOptions: {
183+
parserOptions: {
184+
parser: '@typescript-eslint/parser'
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?

0 commit comments

Comments
 (0)