Skip to content

Commit 672c0fc

Browse files
refactor(ESLint): 迁移ESLint至v9 (#826)
* chore(deps): 拉高依赖版本 * feat(ESLint): migration to v9+ * feat: 为i18n重写类型 * feat(ESLint): 迁移并优化有关代码 * types: 修正多语言类型 * chore: 移除无用配置文件 * fix(deps): 修复因为锁文件过期导致的编译错误 * fix(deps): 修复因为环境问题导致的编译错误 * fix(deps): 修复因为依赖问题导致的编译错误 * fix(eslint): typescript unused var fix, disable vue/padding-line-between-blocks * chore: remove duplicate config * style: add blank * chore: 移除重复的配置 --------- Co-authored-by: ngyyuusora <jiliangsoft@live.com>
1 parent d53934b commit 672c0fc

84 files changed

Lines changed: 6270 additions & 6757 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintignore

Lines changed: 0 additions & 14 deletions
This file was deleted.

.eslintrc

Lines changed: 0 additions & 112 deletions
This file was deleted.

.vscode/settings.json

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"files.eol":"\n",
2+
"files.eol": "\n",
33
"editor.tabSize": 2,
44
"eslint.format.enable": true,
55
"eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact", "vue"],
@@ -23,14 +23,23 @@
2323
"editor.formatOnSave": true,
2424
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
2525
},
26-
"cSpell.words": [
27-
"tdesign",
28-
"tvision",
29-
"echarts",
30-
"nprogress",
31-
"commitlint",
32-
"stylelint",
33-
"pinia",
34-
"qrcode"
35-
],
26+
"cSpell.words": ["tdesign", "tvision", "echarts", "nprogress", "commitlint", "stylelint", "pinia", "qrcode"],
27+
"prettier.enable": false,
28+
"editor.formatOnSave": false,
29+
"editor.codeActionsOnSave": {
30+
"source.fixAll.eslint": "explicit",
31+
"source.organizeImports": "never"
32+
},
33+
"eslint.rules.customizations": [
34+
{ "rule": "style/*", "severity": "off", "fixable": true },
35+
{ "rule": "format/*", "severity": "off", "fixable": true },
36+
{ "rule": "*-indent", "severity": "off", "fixable": true },
37+
{ "rule": "*-spacing", "severity": "off", "fixable": true },
38+
{ "rule": "*-spaces", "severity": "off", "fixable": true },
39+
{ "rule": "*-order", "severity": "off", "fixable": true },
40+
{ "rule": "*-dangle", "severity": "off", "fixable": true },
41+
{ "rule": "*-newline", "severity": "off", "fixable": true },
42+
{ "rule": "*quotes", "severity": "off", "fixable": true },
43+
{ "rule": "*semi", "severity": "off", "fixable": true }
44+
]
3645
}

eslint.config.js

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
import antfu from '@antfu/eslint-config';
2+
import { globalIgnores } from 'eslint/config';
3+
import prettier from 'eslint-plugin-prettier/recommended';
4+
import simpleImportSort from 'eslint-plugin-simple-import-sort';
5+
import vueCss from 'eslint-plugin-vue-scoped-css';
6+
import globals from 'globals';
7+
import typescript from 'typescript-eslint';
8+
9+
export default antfu(
10+
{
11+
typescript: true,
12+
vue: true,
13+
jsonc: false,
14+
yaml: false,
15+
markdown: false,
16+
formatters: false,
17+
},
18+
[
19+
...vueCss.configs['flat/recommended'],
20+
prettier,
21+
{
22+
languageOptions: {
23+
globals: {
24+
...globals.browser,
25+
...globals.node,
26+
...globals.jest,
27+
defineProps: 'readonly',
28+
defineEmits: 'readonly',
29+
},
30+
ecmaVersion: 6,
31+
sourceType: 'module',
32+
33+
parserOptions: {
34+
parser: typescript.parser,
35+
allowImportExportEverywhere: true,
36+
37+
ecmaFeatures: {
38+
jsx: true,
39+
},
40+
},
41+
},
42+
43+
plugins: {
44+
'simple-import-sort': simpleImportSort,
45+
},
46+
47+
settings: {
48+
'import/extensions': ['.js', '.jsx', '.ts', '.tsx'],
49+
},
50+
51+
rules: {
52+
/* Closed due to template running
53+
* (Recommended to open!)
54+
*/
55+
'no-console': 'off',
56+
'ts/no-explicit-any': 'off',
57+
58+
/* Disallow person rules */
59+
'antfu/top-level-function': 'off',
60+
'antfu/if-newline': 'off',
61+
'n/prefer-global/process': 'off',
62+
63+
/* If you need control the imports sequence, must be off
64+
* https://github.com/vuejs/vue-eslint-parser/issues/58
65+
*/
66+
'import/first': 'off',
67+
68+
/* Allow start with _ */
69+
'@typescript-eslint/no-unused-vars': [
70+
'error',
71+
{
72+
argsIgnorePattern: '^_',
73+
varsIgnorePattern: '^_',
74+
},
75+
],
76+
'vue/no-unused-vars': [
77+
'error',
78+
{
79+
ignorePattern: '^_',
80+
},
81+
],
82+
// Using ts/no-unused-vars instead
83+
'no-unused-vars': 'off',
84+
85+
/* Some variables are initialized in the function */
86+
'@typescript-eslint/no-use-before-define': 'off',
87+
'no-use-before-define': 'off',
88+
89+
/* Disable antfu sort, use simple sort import */
90+
'perfectionist/sort-imports': 'off',
91+
'perfectionist/sort-named-imports': 'off',
92+
'simple-import-sort/imports': 'error',
93+
'simple-import-sort/exports': 'error',
94+
// Disable unused-imports rules in other presets
95+
'unused-imports/no-unused-imports': 'off',
96+
'unused-imports/no-unused-vars': 'off',
97+
},
98+
},
99+
{
100+
files: ['**/*.vue'],
101+
102+
rules: {
103+
'vue/component-name-in-template-casing': ['error', 'kebab-case'],
104+
'vue/custom-event-name-casing': ['error', 'kebab-case'],
105+
'vue/block-order': [
106+
'error',
107+
{
108+
order: ['template', 'script', 'style'],
109+
},
110+
],
111+
'vue/block-lang': [
112+
'error',
113+
{
114+
script: {
115+
lang: ['ts', 'tsx'],
116+
},
117+
},
118+
],
119+
'vue/multi-word-component-names': 'off',
120+
'vue/no-reserved-props': 'off',
121+
'vue/no-v-html': 'off',
122+
123+
'vue-scoped-css/no-parsing-error': 'off',
124+
'vue-scoped-css/no-unused-selector': 'off',
125+
'vue-scoped-css/enforce-style-type': [
126+
'error',
127+
{
128+
allows: ['scoped'],
129+
},
130+
],
131+
'vue/padding-line-between-blocks': ['error', 'never'],
132+
},
133+
},
134+
globalIgnores([
135+
'**/snapshot*',
136+
'**/dist',
137+
'**/lib',
138+
'**/es',
139+
'**/esm',
140+
'**/node_modules',
141+
'src/_common',
142+
'**/static',
143+
'**/cypress',
144+
'script/test/cypress',
145+
'**/_site',
146+
'**/temp*',
147+
'**/static/',
148+
'!**/.prettierrc.js',
149+
]),
150+
],
151+
);

mock/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Mock from 'mockjs';
2-
import { MockMethod } from 'vite-plugin-mock';
2+
import type { MockMethod } from 'vite-plugin-mock';
33

44
export default [
55
{
@@ -11,7 +11,7 @@ export default [
1111
...Mock.mock({
1212
'list|1-100': [
1313
{
14-
index: /S20201228115950[0-9][0-9][0-9]/,
14+
index: /S20201228115950\d\d\d/,
1515
pdName: 'Macbook',
1616
pdNum: 'p_tmp_60a637cd0d',
1717
'purchaseNum|1-100': 100,
@@ -20,7 +20,7 @@ export default [
2020
pdType: '电子产品',
2121
},
2222
{
23-
index: /S20201228115950[0-9][0-9][0-9]/,
23+
index: /S20201228115950\d\d\d/,
2424
pdName: 'Macbook',
2525
pdNum: 'p_tmp_60a637cd0d',
2626
'purchaseNum|1-100': 100,

0 commit comments

Comments
 (0)