Skip to content

Commit 27caf5f

Browse files
committed
docs: initial idea of a more intuitive config
1 parent d135b1f commit 27caf5f

File tree

1 file changed

+13
-41
lines changed

1 file changed

+13
-41
lines changed

README.md

+13-41
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@ Please also make sure that you have `typescript` and `eslint` installed.
2727

2828
Because of the complexity of this config, it is exported as a factory function that takes an options object and returns an ESLint configuration object.
2929

30-
This package exports 2 utility functions:
30+
This package exports:
3131

32-
- `defineConfig`, as a re-export of the [`config` function from `typescript-eslint`](https://typescript-eslint.io/packages/typescript-eslint#config).
33-
- `createConfig`, used for creating an ESLint configuration array that extends from the [`typescript-eslint` shared configs](https://typescript-eslint.io/users/configs).
32+
- a utility function: `defineConfig`, as a re-export of the [`config` function from `typescript-eslint`](https://typescript-eslint.io/packages/typescript-eslint#config).
33+
- all the [shared configruations from `typescript-eslint`](https://typescript-eslint.io/users/configs), available as named exports (in camelCase, e.g. `recommendedTypeChecked`).
34+
- a Vue-specific config factory: `configureVueProject({ supportedScriptLangs, rootDir })`. More info below.
3435

3536
### Minimal Setup
3637

@@ -39,12 +40,12 @@ This package exports 2 utility functions:
3940
import pluginVue from 'eslint-plugin-vue'
4041
import {
4142
defineConfig,
42-
createConfig as vueTsEslintConfig,
43+
recommended,
4344
} from '@vue/eslint-config-typescript'
4445

4546
export default defineConfig(
4647
pluginVue.configs['flat/essential'],
47-
vueTsEslintConfig(),
48+
recommended,
4849
)
4950
```
5051

@@ -59,26 +60,14 @@ All the `<script>` blocks in `.vue` files _MUST_ be written in TypeScript (shoul
5960
import pluginVue from 'eslint-plugin-vue'
6061
import {
6162
defineConfig,
62-
createConfig as vueTsEslintConfig,
63+
configureVueProject,
64+
recommended,
6365
} from '@vue/eslint-config-typescript'
6466

6567
export default defineConfig(
6668
pluginVue.configs['flat/essential'],
6769

68-
vueTsEslintConfig({
69-
// Optional: extend additional configurations from `typescript-eslint`.
70-
// Supports all the configurations in
71-
// https://typescript-eslint.io/users/configs#recommended-configurations
72-
extends: [
73-
// By default, only the recommended rules are enabled.
74-
'recommended',
75-
// You can also manually enable the stylistic rules.
76-
// "stylistic",
77-
78-
// Other utility configurations, such as `eslintRecommended`, (note that it's in camelCase)
79-
// are also extendable here. But we don't recommend using them directly.
80-
],
81-
70+
configureVueProject({
8271
// Optional: specify the script langs in `.vue` files
8372
// Defaults to `{ ts: true, js: false, tsx: false, jsx: false }`
8473
supportedScriptLangs: {
@@ -110,6 +99,8 @@ export default defineConfig(
11099
// and only apply the loosened rules to the files that do need them.
111100
rootDir: import.meta.dirname,
112101
}),
102+
103+
recommended,
113104
)
114105
```
115106

@@ -122,36 +113,17 @@ It is not always easy to set up the type-checking environment for ESLint without
122113
So we don't recommend you to configure individual type-aware rules and the corresponding language options all by yourself.
123114
Instead, you can start by extending from the `recommendedTypeChecked` configuration and then turn on/off the rules you need.
124115

125-
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.
126-
127116
```js
128117
// eslint.config.mjs
129118
import pluginVue from 'eslint-plugin-vue'
130119
import {
131120
defineConfig,
132-
createConfig as vueTsEslintConfig,
121+
recommendedTypeChecked,
133122
} from '@vue/eslint-config-typescript'
134123

135124
export default defineConfig(
136125
pluginVue.configs['flat/essential'],
137-
138-
{
139-
files: ['**/*.ts', '**/*.tsx', '**/*.mts', '**/*.vue'],
140-
rules: {
141-
// Turn on other rules that you need.
142-
'@typescript-eslint/require-array-sort-compare': 'error',
143-
},
144-
},
145-
146-
vueTsEslintConfig({ extends: ['recommendedTypeChecked'] }),
147-
148-
{
149-
files: ['**/*.ts', '**/*.tsx', '**/*.mts', '**/*.vue'],
150-
rules: {
151-
// Turn off the recommended rules that you don't need.
152-
'@typescript-eslint/no-redundant-type-constituents': 'off',
153-
},
154-
},
126+
recommendedTypeChecked
155127
)
156128
```
157129

0 commit comments

Comments
 (0)