Skip to content

Commit

Permalink
docs: fix type-aware linting example
Browse files Browse the repository at this point in the history
I know it's not an ideal solution. I may need to add additional options
to the factory function later.
  • Loading branch information
haoqunjiang committed Oct 15, 2024
1 parent 3bca91e commit 21142b1
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,22 +111,29 @@ It is not always easy to set up the type-checking environment for ESLint without
So we don't recommend you to configure individual type-aware rules and the corresponding language options all by yourself.
Instead, you can start by extending from the `recommendedTypeChecked` configuration and then turn on/off the rules you need.

As of now, all the rules you need to turn on must appear *before* calling `...vueTsEslintConfig({ extends: ['recommendedTypeChecked'] })`, and all the rules you need to turn off must appear *after* calling it.

```js
// eslint.config.mjs
import pluginVue from "eslint-plugin-vue";
import vueTsEslintConfig from "@vue/eslint-config-typescript";

export default [
...pluginVue.configs["flat/essential"],

{
files: ['**/*.ts', '**/*.tsx', '**/*.mts', '**/*.vue'],
rules: {
// Turn on other rules that you need.
'@typescript-eslint/require-array-sort-compare': 'error'
}
},
...vueTsEslintConfig({ extends: ['recommendedTypeChecked'] }),
{
files: ['**/*.ts', '**/*.tsx', '**/*.mts', '**/*.vue'],
rules: {
// Turn off the recommended rules that you don't need.
'@typescript-eslint/no-redundant-type-constituents': 'off',

// Turn on other rules that you need.
'@typescript-eslint/require-array-sort-compare': 'error'
}
]
```
Expand Down

0 comments on commit 21142b1

Please sign in to comment.