Skip to content

Commit fa3b66b

Browse files
committedMar 9, 2025··
feat!: drop vue 2 support, upgrade eslint-plugin-vue to v10
1 parent 7f54c15 commit fa3b66b

File tree

6 files changed

+313
-344
lines changed

6 files changed

+313
-344
lines changed
 

‎README.md

-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ and Prettier.
1414
- Reasonable defaults, best practices, only one-line of config
1515
- Reasonable strict, but with better code quality.
1616

17-
> [!TIP]
18-
> Support for Vue 2 is deprecated.
19-
2017
## Install
2118

2219
```bash

‎pnpm-lock.yaml

+262-249
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎pnpm-workspace.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ catalogs:
3939
eslint-plugin-jsdoc: ^50.6.3
4040
eslint-plugin-jsonc: ^2.19.1
4141
eslint-plugin-n: ^17.16.2
42-
eslint-plugin-perfectionist: ^4.9.0
42+
eslint-plugin-perfectionist: ^4.10.1
4343
eslint-plugin-pnpm: ^0.1.2
4444
eslint-plugin-prettier: ^5.2.3
4545
eslint-plugin-regexp: ^2.7.0
4646
eslint-plugin-sxzz: ^0.2.1
4747
eslint-plugin-unicorn: ^57.0.0
4848
eslint-plugin-unused-imports: ^4.1.4
49-
eslint-plugin-vue: ^9.32.0
49+
eslint-plugin-vue: ^10.0.0
5050
eslint-plugin-yml: ^1.17.0
5151
typescript-eslint: ^8.26.0

‎src/configs/prettier.ts

+4-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
import {
2-
configPrettier,
3-
pluginPrettier,
4-
pluginPrettierRecommended,
5-
} from '../plugins'
1+
import { pluginPrettier, pluginPrettierRecommended } from '../plugins'
62
import type { Config } from '../types'
73

8-
const prettierConflictRules = { ...configPrettier.rules }
9-
delete prettierConflictRules['vue/html-self-closing']
4+
const rules = { ...pluginPrettierRecommended.rules }
5+
delete rules['vue/html-self-closing']
106

117
export const prettier = (): Config[] => [
128
{
@@ -15,8 +11,7 @@ export const prettier = (): Config[] => [
1511
prettier: pluginPrettier,
1612
},
1713
rules: {
18-
...prettierConflictRules,
19-
...pluginPrettierRecommended.rules,
14+
...rules,
2015
'prettier/prettier': 'warn',
2116
},
2217
},

‎src/configs/vue.ts

+45-80
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,9 @@
1-
import process from 'node:process'
2-
import { getPackageInfoSync } from 'local-pkg'
31
import { GLOB_VUE } from '../globs'
42
import { parserVue, pluginVue, tseslint } from '../plugins'
5-
import type { Rules } from '../typegen'
63
import type { Config } from '../types'
74
import { typescriptCore } from './typescript'
85
import type { ESLint } from 'eslint'
96

10-
export function getVueVersion(): number {
11-
const pkg = getPackageInfoSync('vue', { paths: [process.cwd()] })
12-
if (
13-
pkg &&
14-
typeof pkg.version === 'string' &&
15-
!Number.isNaN(+pkg.version[0])
16-
) {
17-
return +pkg.version[0]
18-
}
19-
return 3
20-
}
21-
const isVue2 = getVueVersion() === 2
22-
if (isVue2) {
23-
console.warn('Support for Vue 2 is deprecated. Please upgrade to Vue 3.')
24-
}
25-
267
export const reactivityTransform = (): Config[] => [
278
{
289
languageOptions: {
@@ -46,64 +27,6 @@ export const reactivityTransform = (): Config[] => [
4627
},
4728
]
4829

49-
const vueCustomRules: Rules = {
50-
'vue/block-order': ['error', { order: ['script', 'template', 'style'] }],
51-
'vue/custom-event-name-casing': ['error', 'camelCase'],
52-
'vue/eqeqeq': ['error', 'smart'],
53-
'vue/html-self-closing': [
54-
'error',
55-
{
56-
html: {
57-
component: 'always',
58-
normal: 'always',
59-
void: 'any',
60-
},
61-
math: 'always',
62-
svg: 'always',
63-
},
64-
],
65-
'vue/max-attributes-per-line': 'off',
66-
67-
'vue/multi-word-component-names': 'off',
68-
'vue/no-constant-condition': 'warn',
69-
'vue/no-empty-pattern': 'error',
70-
'vue/no-loss-of-precision': 'error',
71-
'vue/no-unused-refs': 'error',
72-
'vue/no-useless-v-bind': 'error',
73-
74-
'vue/no-v-html': 'off',
75-
'vue/object-shorthand': [
76-
'error',
77-
'always',
78-
{
79-
avoidQuotes: true,
80-
ignoreConstructors: false,
81-
},
82-
],
83-
'vue/one-component-per-file': 'off',
84-
'vue/padding-line-between-blocks': ['error', 'always'],
85-
'vue/prefer-template': 'error',
86-
'vue/require-default-prop': 'off',
87-
'vue/require-prop-types': 'off',
88-
}
89-
90-
const vue3Rules: Rules = {
91-
...pluginVue.configs.base.rules,
92-
...pluginVue.configs['vue3-essential'].rules,
93-
...pluginVue.configs['vue3-strongly-recommended'].rules,
94-
...pluginVue.configs['vue3-recommended'].rules,
95-
}
96-
97-
const vue2Rules: Rules = {
98-
...pluginVue.configs.base.rules,
99-
...pluginVue.configs.essential.rules,
100-
...pluginVue.configs['strongly-recommended'].rules,
101-
...pluginVue.configs.recommended.rules,
102-
}
103-
104-
delete vue2Rules['vue/component-tags-order']
105-
delete vue3Rules['vue/component-tags-order']
106-
10730
const vueTs: Config[] = typescriptCore
10831
.filter((config) => config.name !== 'typescript-eslint/base')
10932
.map((config) => {
@@ -114,6 +37,10 @@ const vueTs: Config[] = typescriptCore
11437
}
11538
})
11639

40+
const recommendedRules = pluginVue.configs['flat/recommended']
41+
.map((c) => c.rules)
42+
.reduce((acc, c) => ({ ...acc, ...c }), {}) as any
43+
11744
export const vue = (): Config[] => [
11845
...vueTs,
11946
{
@@ -125,7 +52,7 @@ export const vue = (): Config[] => [
12552
jsx: true,
12653
},
12754
extraFileExtensions: ['.vue'],
128-
parser: '@typescript-eslint/parser',
55+
parser: tseslint.parser,
12956
sourceType: 'module',
13057
},
13158
},
@@ -136,8 +63,46 @@ export const vue = (): Config[] => [
13663
},
13764
processor: pluginVue.processors['.vue'],
13865
rules: {
139-
...(isVue2 ? vue2Rules : vue3Rules),
140-
...vueCustomRules,
66+
...recommendedRules,
67+
68+
'vue/block-order': ['error', { order: ['script', 'template', 'style'] }],
69+
'vue/custom-event-name-casing': ['error', 'camelCase'],
70+
'vue/eqeqeq': ['error', 'smart'],
71+
'vue/html-self-closing': [
72+
'error',
73+
{
74+
html: {
75+
component: 'always',
76+
normal: 'always',
77+
void: 'any',
78+
},
79+
math: 'always',
80+
svg: 'always',
81+
},
82+
],
83+
'vue/max-attributes-per-line': 'off',
84+
85+
'vue/multi-word-component-names': 'off',
86+
'vue/no-constant-condition': 'warn',
87+
'vue/no-empty-pattern': 'error',
88+
'vue/no-loss-of-precision': 'error',
89+
'vue/no-unused-refs': 'error',
90+
'vue/no-useless-v-bind': 'error',
91+
92+
'vue/no-v-html': 'off',
93+
'vue/object-shorthand': [
94+
'error',
95+
'always',
96+
{
97+
avoidQuotes: true,
98+
ignoreConstructors: false,
99+
},
100+
],
101+
'vue/one-component-per-file': 'off',
102+
'vue/padding-line-between-blocks': ['error', 'always'],
103+
'vue/prefer-template': 'error',
104+
'vue/require-default-prop': 'off',
105+
'vue/require-prop-types': 'off',
141106
},
142107
},
143108
...reactivityTransform(),

‎src/plugins.ts

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ export * as pluginYml from 'eslint-plugin-yml'
2222

2323
export { default as configJs } from '@eslint/js'
2424
export { default as configComments } from '@eslint-community/eslint-plugin-eslint-comments/configs'
25-
export { default as configPrettier } from 'eslint-config-prettier'
2625
export { default as configCommand } from 'eslint-plugin-command/config'
2726

2827
export * as parserVue from 'vue-eslint-parser'

0 commit comments

Comments
 (0)
Please sign in to comment.