Skip to content

Commit

Permalink
docs: add an example on how to use custom parser with flat config (#2490
Browse files Browse the repository at this point in the history
)

Co-authored-by: Yosuke Ota <otameshiyo23@gmail.com>
  • Loading branch information
Lehoczky and ota-meshi authored Jul 1, 2024
1 parent d7169e1 commit 4f52734
Showing 1 changed file with 44 additions and 4 deletions.
48 changes: 44 additions & 4 deletions docs/user-guide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,48 @@ If you want to use custom parsers such as [@babel/eslint-parser](https://www.npm
}
```

Full example:

::: code-group

```json [.eslintrc]
{
"root": true,
"plugins": ["@typescript-eslint"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:vue/vue3-recommended"
],
"parser": "vue-eslint-parser",
"parserOptions": {
"parser": "@typescript-eslint/parser"
}
}
```

```js [eslint.config.js]
import js from '@eslint/js'
import eslintPluginVue from 'eslint-plugin-vue'
import ts from 'typescript-eslint'

export default ts.config(
js.configs.recommended,
...ts.configs.recommended,
...eslintPluginVue.configs['flat/recommended'],
{
files: ['*.vue', '**/*.vue'],
languageOptions: {
parserOptions: {
parser: '@typescript-eslint/parser'
}
}
}
)
```

:::

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.

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

::: code-group

```json [Legacy Config]
// .eslintrc
```json [.eslintrc]
{
"globals": {
"ref": "readonly",
Expand All @@ -454,8 +495,7 @@ In [Nuxt 3](https://nuxt.com/) or with [`unplugin-auto-import`](https://github.c
}
```

```js [Flat Config]
// eslint.config.js
```js [eslint.config.js]
export default [
{
languageOptions: {
Expand Down

0 comments on commit 4f52734

Please sign in to comment.