Skip to content

Commit e33db0b

Browse files
committed
refactor!: rename defineConfig to defineConfigWithVueTs; configs to vueTsConfigs
1 parent de86921 commit e33db0b

File tree

17 files changed

+75
-66
lines changed

17 files changed

+75
-66
lines changed

README.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ Because of the complexity of this config, it is exported as a factory function t
2929

3030
This package exports:
3131

32-
- `defineConfig`, a utility function whose type signature is the same as the [`config` function from `typescript-eslint`](https://typescript-eslint.io/packages/typescript-eslint#config).
33-
- `configs`, contains all the [shared configruations from `typescript-eslint`](https://typescript-eslint.io/users/configs) (in camelCase, e.g. `configs.recommendedTypeChecked`).
32+
- `defineConfigWithVueTs`, a utility function whose type signature is the same as the [`config` function from `typescript-eslint`](https://typescript-eslint.io/packages/typescript-eslint#config), but will modify the given config to work with Vue.js + TypeScript.
33+
- `vueTsConfigs`, contains all the [shared configruations from `typescript-eslint`](https://typescript-eslint.io/users/configs) (in camelCase, e.g. `configs.recommendedTypeChecked`).
3434
- a Vue-specific config factory: `configureVueProject({ scriptLangs, rootDir })`. More info below.
3535

3636
### Minimal Setup
@@ -39,13 +39,13 @@ This package exports:
3939
// eslint.config.mjs
4040
import pluginVue from 'eslint-plugin-vue'
4141
import {
42-
defineConfig,
43-
configs,
42+
defineConfigWithVueTs,
43+
vueTsConfigs,
4444
} from '@vue/eslint-config-typescript'
4545

46-
export default defineConfig(
46+
export default defineConfigWithVueTs(
4747
pluginVue.configs['flat/essential'],
48-
configs.recommended,
48+
vueTsConfigs.recommended,
4949
)
5050
```
5151

@@ -59,9 +59,9 @@ All the `<script>` blocks in `.vue` files *MUST* be written in TypeScript (shoul
5959
// eslint.config.mjs
6060
import pluginVue from 'eslint-plugin-vue'
6161
import {
62-
defineConfig,
62+
defineConfigWithVueTs,
63+
vueTsConfigs,
6364
configureVueProject,
64-
configs,
6565
} from '@vue/eslint-config-typescript'
6666

6767
configureVueProject({
@@ -97,13 +97,13 @@ configureVueProject({
9797
rootDir: import.meta.dirname,
9898
})
9999

100-
export default defineConfig(
100+
export default defineConfigWithVueTs(
101101
pluginVue.configs["flat/essential"],
102102

103103
// We STRONGLY RECOMMEND you to start with `recommended` or `recommendedTypeChecked`.
104104
// But if you are determined to configure all rules by yourself,
105105
// you can start with `base`, and then turn on/off the rules you need.
106-
configs.base,
106+
vueTsConfigs.base,
107107
)
108108
```
109109

@@ -120,13 +120,13 @@ Instead, you can start by extending from the `recommendedTypeChecked` configurat
120120
// eslint.config.mjs
121121
import pluginVue from 'eslint-plugin-vue'
122122
import {
123-
defineConfig,
124-
configs,
123+
defineConfigWithVueTs,
124+
vueTsConfigs,
125125
} from '@vue/eslint-config-typescript'
126126

127-
export default defineConfig(
127+
export default defineConfigWithVueTs(
128128
pluginVue.configs['flat/essential'],
129-
configs.recommendedTypeChecked
129+
vueTsConfigs.recommendedTypeChecked
130130
)
131131
```
132132

examples/allow-js/eslint.config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import pluginVue from 'eslint-plugin-vue'
22
import {
3-
defineConfig,
3+
defineConfigWithVueTs,
4+
vueTsConfigs,
45
configureVueProject,
5-
configs,
66
} from '@vue/eslint-config-typescript'
77

88
configureVueProject({ scriptLangs: ['js', 'ts'] })
99

10-
export default defineConfig(
10+
export default defineConfigWithVueTs(
1111
{
1212
name: 'app/files-to-lint',
1313
files: ['**/*.js', '**/*.mjs', '**/*.ts', '**/*.mts', '**/*.vue'],
@@ -19,5 +19,5 @@ export default defineConfig(
1919
},
2020

2121
pluginVue.configs['flat/essential'],
22-
configs.recommended,
22+
vueTsConfigs.recommended,
2323
)

examples/minimal/eslint.config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import pluginVue from 'eslint-plugin-vue'
2-
import { defineConfig, configs } from '@vue/eslint-config-typescript'
2+
import { defineConfigWithVueTs, vueTsConfigs } from '@vue/eslint-config-typescript'
33

4-
export default defineConfig(
4+
export default defineConfigWithVueTs(
55
{
66
name: 'app/files-to-lint',
77
files: ['**/*.ts', '**/*.mts', '**/*.vue'],
@@ -12,6 +12,6 @@ export default defineConfig(
1212
ignores: ['**/dist/**', '**/dist-ssr/**', '**/coverage/**'],
1313
},
1414

15-
...pluginVue.configs['flat/essential'],
16-
configs.recommended,
15+
pluginVue.configs['flat/essential'],
16+
vueTsConfigs.recommended,
1717
)

examples/type-checked/eslint.config.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import pluginVue from 'eslint-plugin-vue'
2-
import { defineConfig, configs } from '@vue/eslint-config-typescript'
2+
import { defineConfigWithVueTs, vueTsConfigs } from '@vue/eslint-config-typescript'
33
import pluginVitest from '@vitest/eslint-plugin'
44
import pluginCypress from 'eslint-plugin-cypress/flat'
55
import skipFormatting from '@vue/eslint-config-prettier/skip-formatting'
66

7-
export default defineConfig(
7+
export default defineConfigWithVueTs(
88
{
99
name: 'app/files-to-lint',
1010
files: ['**/*.{ts,mts,tsx,vue}'],
@@ -16,7 +16,7 @@ export default defineConfig(
1616
},
1717

1818
pluginVue.configs['flat/essential'],
19-
configs.recommendedTypeChecked,
19+
vueTsConfigs.recommendedTypeChecked,
2020

2121
{
2222
...pluginVitest.configs.recommended,

examples/with-cypress/eslint.config.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import pluginVue from 'eslint-plugin-vue'
22
import pluginCypress from 'eslint-plugin-cypress/flat'
3-
import { defineConfig, configs } from '@vue/eslint-config-typescript'
3+
import { defineConfigWithVueTs, vueTsConfigs } from '@vue/eslint-config-typescript'
44

5-
export default defineConfig(
5+
export default defineConfigWithVueTs(
66
{
77
name: 'app/files-to-lint',
88
files: ['**/*.ts', '**/*.mts', '**/*.vue'],
@@ -14,7 +14,7 @@ export default defineConfig(
1414
},
1515

1616
pluginVue.configs['flat/essential'],
17-
configs.recommended,
17+
vueTsConfigs.recommended,
1818

1919
{
2020
...pluginCypress.configs.recommended,

examples/with-jsx-in-vue/eslint.config.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import pluginVue from 'eslint-plugin-vue'
22
import {
3-
defineConfig,
3+
defineConfigWithVueTs,
4+
vueTsConfigs,
45
configureVueProject,
5-
configs,
66
} from '@vue/eslint-config-typescript'
77

88
configureVueProject({ scriptLangs: ['js', 'jsx', 'ts', 'tsx'] })
99

10-
export default defineConfig(
10+
export default defineConfigWithVueTs(
1111
{
1212
name: 'app/files-to-lint',
1313
files: [
@@ -26,6 +26,6 @@ export default defineConfig(
2626
ignores: ['**/dist/**', '**/dist-ssr/**', '**/coverage/**'],
2727
},
2828

29-
...pluginVue.configs['flat/essential'],
30-
configs.recommended,
29+
pluginVue.configs['flat/essential'],
30+
vueTsConfigs.recommended,
3131
)

examples/with-jsx/eslint.config.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import pluginVue from 'eslint-plugin-vue'
2-
import { defineConfig, configs } from '@vue/eslint-config-typescript'
2+
import { defineConfigWithVueTs, vueTsConfigs } from '@vue/eslint-config-typescript'
33

4-
export default defineConfig(
4+
export default defineConfigWithVueTs(
55
{
66
name: 'app/files-to-lint',
77
files: ['**/*.js', '**/*.mjs', '**/*.jsx', '**/*.ts', '**/*.mts', '**/*.tsx', '**/*.vue'],
@@ -13,5 +13,5 @@ export default defineConfig(
1313
},
1414

1515
pluginVue.configs['flat/essential'],
16-
configs.recommended,
16+
vueTsConfigs.recommended,
1717
)

examples/with-nightwatch/eslint.config.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import pluginVue from 'eslint-plugin-vue'
2-
import { defineConfig, configs } from '@vue/eslint-config-typescript'
2+
import { defineConfigWithVueTs, vueTsConfigs } from '@vue/eslint-config-typescript'
33

4-
export default defineConfig(
4+
export default defineConfigWithVueTs(
55
{
66
name: 'app/files-to-lint',
77
files: ['**/*.ts', '**/*.mts', '**/*.vue'],
@@ -13,7 +13,7 @@ export default defineConfig(
1313
},
1414

1515
pluginVue.configs['flat/essential'],
16-
configs.recommended,
16+
vueTsConfigs.recommended,
1717

1818
{
1919
// nightwatch specs

examples/with-playwright/eslint.config.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import pluginVue from 'eslint-plugin-vue'
22
import pluginPlaywright from 'eslint-plugin-playwright'
3-
import { defineConfig, configs } from '@vue/eslint-config-typescript'
3+
import { defineConfigWithVueTs, vueTsConfigs } from '@vue/eslint-config-typescript'
44

5-
export default defineConfig(
5+
export default defineConfigWithVueTs(
66
{
77
name: 'app/files-to-lint',
88
files: ['**/*.ts', '**/*.mts', '**/*.vue'],
@@ -14,7 +14,7 @@ export default defineConfig(
1414
},
1515

1616
pluginVue.configs['flat/essential'],
17-
configs.recommended,
17+
vueTsConfigs.recommended,
1818

1919
{
2020
...pluginPlaywright.configs['flat/recommended'],

examples/with-prettier/eslint.config.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import pluginVue from 'eslint-plugin-vue'
2-
import { defineConfig, configs } from '@vue/eslint-config-typescript'
2+
import { defineConfigWithVueTs, vueTsConfigs } from '@vue/eslint-config-typescript'
33
import skipFormatting from '@vue/eslint-config-prettier/skip-formatting'
44

5-
export default defineConfig(
5+
export default defineConfigWithVueTs(
66
{
77
name: 'app/files-to-lint',
88
files: ['**/*.ts', '**/*.mts', '**/*.vue'],
@@ -14,7 +14,7 @@ export default defineConfig(
1414
},
1515

1616
pluginVue.configs['flat/essential'],
17-
configs.recommended,
17+
vueTsConfigs.recommended,
1818

1919
skipFormatting
2020
)
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import pluginVue from 'eslint-plugin-vue'
22
import {
3-
defineConfig,
3+
defineConfigWithVueTs,
4+
vueTsConfigs,
45
configureVueProject,
5-
configs,
66
} from '@vue/eslint-config-typescript'
77

88
configureVueProject({ scriptLangs: ['ts', 'tsx'] })
99

10-
export default defineConfig(
10+
export default defineConfigWithVueTs(
1111
{
1212
name: 'app/files-to-lint',
1313
files: ['**/*.ts', '**/*.mts', '**/*.tsx', '**/*.vue'],
@@ -18,6 +18,6 @@ export default defineConfig(
1818
ignores: ['**/dist/**', '**/dist-ssr/**', '**/coverage/**'],
1919
},
2020

21-
...pluginVue.configs['flat/essential'],
22-
configs.recommended,
21+
pluginVue.configs['flat/essential'],
22+
vueTsConfigs.recommended,
2323
)

examples/with-tsx/eslint.config.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import pluginVue from 'eslint-plugin-vue'
2-
import { defineConfig, configs } from '@vue/eslint-config-typescript'
2+
import { defineConfigWithVueTs, vueTsConfigs } from '@vue/eslint-config-typescript'
33

4-
export default defineConfig(
4+
export default defineConfigWithVueTs(
55
{
66
name: 'app/files-to-lint',
77
files: ['**/*.ts', '**/*.mts', '**/*.tsx', '**/*.vue'],
@@ -13,5 +13,5 @@ export default defineConfig(
1313
},
1414

1515
pluginVue.configs['flat/essential'],
16-
configs.recommended,
16+
vueTsConfigs.recommended,
1717
)

examples/with-vitest/eslint.config.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import pluginVue from 'eslint-plugin-vue'
22
import pluginVitest from '@vitest/eslint-plugin'
3-
import { defineConfig, configs } from '@vue/eslint-config-typescript'
3+
import { defineConfigWithVueTs, vueTsConfigs } from '@vue/eslint-config-typescript'
44

5-
export default defineConfig(
5+
export default defineConfigWithVueTs(
66
{
77
name: 'app/files-to-lint',
88
files: ['**/*.ts', '**/*.mts', '**/*.vue'],
@@ -14,7 +14,7 @@ export default defineConfig(
1414
},
1515

1616
pluginVue.configs['flat/essential'],
17-
configs.recommended,
17+
vueTsConfigs.recommended,
1818

1919
{
2020
...pluginVitest.configs['recommended'],

src/configs.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import tseslint from 'typescript-eslint'
33
import type { FlatConfig } from '@typescript-eslint/utils/ts-eslint'
44

55
const PlaceholderPrefix =
6-
'PLACEHOLDER_THAT_MUST_BE_WRAPPED_INSIDE_defineConfig_'
6+
'PLACEHOLDER_THAT_MUST_BE_WRAPPED_INSIDE_defineConfigWithVueTs_'
77

88
// Manually declare all the available configs as enums to make the auto-completion more user-friendly.
99
// It's also a good way to avoid the placeholder strings to appear in the auto-completion.
@@ -26,7 +26,7 @@ export enum VueTsPreset {
2626
// `enum`s are just objects with reverse mapping during runtime.
2727
// We redefine the type here only to make the auto-completion more user-friendly.
2828
export type ExtendableConfigName = keyof typeof VueTsPreset
29-
export const configs = VueTsPreset as {
29+
export const vueTsConfigs = VueTsPreset as {
3030
[key in ExtendableConfigName]: VueTsPreset
3131
}
3232

src/createConfig.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,20 @@ import type { FlatConfig } from '@typescript-eslint/utils/ts-eslint'
66

77
import {
88
configureVueProject,
9-
defineConfig,
9+
defineConfigWithVueTs,
1010
type ProjectOptions,
1111
} from './utilities'
12-
import { configs, type ExtendableConfigName } from './configs'
12+
import { vueTsConfigs, type ExtendableConfigName } from './configs'
1313
import type { ScriptLang } from './internals'
1414

1515
type ConfigOptions = ProjectOptions & {
1616
extends?: Array<ExtendableConfigName>
1717
supportedScriptLangs?: Record<ScriptLang, boolean>
1818
}
1919

20+
/**
21+
* @deprecated Use `defineConfigWithVueTs` + `vueTsConfigs` instead.
22+
*/
2023
export default function createConfig({
2124
extends: configNamesToExtend = ['recommended'],
2225
supportedScriptLangs = { ts: true, tsx: false, js: false, jsx: false },
@@ -47,7 +50,7 @@ export default function createConfig({
4750
) as ScriptLang[],
4851
rootDir,
4952
})
50-
return defineConfig(
51-
...configNamesToExtend.map(name => configs[name as ExtendableConfigName]),
53+
return defineConfigWithVueTs(
54+
...configNamesToExtend.map(name => vueTsConfigs[name as ExtendableConfigName]),
5255
)
5356
}

src/index.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
export {
2-
defineConfig,
2+
defineConfigWithVueTs,
33
configureVueProject,
44
} from './utilities'
5-
export { configs } from './configs'
5+
export { vueTsConfigs } from './configs'
66

77
// Compatibility layer for the `createConfig` function in <= 14.2.0
88
export { default as createConfig } from './createConfig'
99
export { default } from './createConfig'
10+
11+
import { defineConfigWithVueTs } from './utilities'
12+
/**
13+
* @deprecated `defineConfig` is renamed to `defineConfigWithVueTs` in 14.3.0
14+
*/
15+
export const defineConfig = defineConfigWithVueTs

0 commit comments

Comments
 (0)