Skip to content

Commit 0c63608

Browse files
committed
chore: update deps and fix eslint rules
1 parent 106120d commit 0c63608

38 files changed

+1960
-3329
lines changed

.prettierrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"semi": false,
1313
"singleQuote": true,
1414
"tabWidth": 2,
15-
"trailingComma": "none",
15+
"trailingComma": "all",
1616
"useTabs": false,
1717
"endOfLine": "lf"
1818
}

.vscode/extensions.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
11
{
2-
"recommendations": [
3-
"Vue.volar",
4-
"tauri-apps.tauri-vscode",
5-
"rust-lang.rust-analyzer"
6-
]
2+
"recommendations": ["Vue.volar", "tauri-apps.tauri-vscode", "rust-lang.rust-analyzer"]
73
}

.vscode/mcp.json

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

.vscode/settings.json

Lines changed: 53 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,71 @@
11
{
2+
"eslint.run": "onSave",
3+
"eslint.codeActionsOnSave.mode": "all",
4+
"eslint.format.enable": true,
5+
"[typescript]": {
6+
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
7+
"editor.codeActionsOnSave": {
8+
"source.fixAll.eslint": "always"
9+
},
10+
"editor.formatOnSave": false
11+
},
212
"[rust]": {
313
"editor.defaultFormatter": "rust-lang.rust-analyzer",
414
"editor.formatOnSave": true
515
},
616
"[javascript]": {
7-
"editor.defaultFormatter": "esbenp.prettier-vscode",
8-
"editor.formatOnSave": true
17+
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
18+
"editor.codeActionsOnSave": {
19+
"source.fixAll.eslint": "always"
20+
},
21+
"editor.formatOnSave": false
922
},
1023
"[vue]": {
11-
"editor.defaultFormatter": "esbenp.prettier-vscode",
12-
"editor.formatOnSave": true
13-
},
14-
"[json]": {
15-
"editor.defaultFormatter": "esbenp.prettier-vscode",
16-
"editor.formatOnSave": true
17-
},
18-
"[html]": {
19-
"editor.defaultFormatter": "esbenp.prettier-vscode",
20-
"editor.formatOnSave": true
24+
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
25+
"editor.codeActionsOnSave": {
26+
"source.fixAll.eslint": "always"
27+
},
28+
"editor.formatOnSave": false
2129
},
22-
"[css]": {
23-
"editor.defaultFormatter": "esbenp.prettier-vscode",
24-
"editor.formatOnSave": true
30+
"[typescriptreact]": {
31+
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
32+
"editor.codeActionsOnSave": {
33+
"source.fixAll.eslint": "always"
34+
},
35+
"editor.formatOnSave": false
2536
},
26-
"[typescript]": {
27-
"editor.defaultFormatter": "esbenp.prettier-vscode",
28-
"editor.formatOnSave": true
37+
"[javascriptreact]": {
38+
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
39+
"editor.codeActionsOnSave": {
40+
"source.fixAll.eslint": "always"
41+
},
42+
"editor.formatOnSave": false
2943
},
3044
"editor.codeActionsOnSave": {
3145
"source.fixAll.eslint": "explicit"
3246
},
33-
"typescript.tsdk": "node_modules\\typescript\\lib",
34-
"i18n-ally.localesPaths": [
35-
"src/i18n",
36-
"src/i18n/locales"
37-
],
47+
"[css]": {
48+
"editor.defaultFormatter": "stylelint.vscode-stylelint",
49+
"editor.codeActionsOnSave": {
50+
"source.fixAll.stylelint": "always"
51+
},
52+
"editor.formatOnSave": false
53+
},
54+
"eslint.validate": ["javascript", "javascriptreact", "vue", "typescript", "typescriptreact", "json", "jsonc"],
55+
"githubPullRequests.ignoredPullRequestBranches": ["dev"],
56+
"i18n-ally.localesPaths": ["src\\i18n\\locales"],
3857
"i18n-ally.keystyle": "nested",
58+
"i18n-ally.sortKeys": true,
59+
"i18n-ally.namespace": true,
60+
"i18n-ally.enabledParsers": ["json", "yaml"],
61+
"i18n-ally.sourceLanguage": "en",
62+
"i18n-ally.displayLanguage": "zh",
63+
"i18n-ally.enabledFrameworks": ["vue"],
64+
"i18n-ally.editor.preferEditor": true,
65+
"typescript.tsdk": "node_modules\\typescript\\lib",
66+
"css.validate": false,
67+
"scss.validate": false,
68+
"less.validate": false
3969
// "rust-analyzer.cargo.target": "x86_64-unknown-linux-gnu"
4070
//"rust-analyzer.cargo.target": "x86_64-pc-windows-msvc"
4171
// "rust-analyzer.cargo.target": "x86_64-apple-darwin",

eslint.config.js

Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
import js from '@eslint/js'
2+
import { defineConfig } from 'eslint/config'
3+
import configPrettier from 'eslint-config-prettier'
4+
import jsonc from 'eslint-plugin-jsonc'
5+
import pluginPrettier from 'eslint-plugin-prettier/recommended'
6+
import simpleImportSort from 'eslint-plugin-simple-import-sort'
7+
import pluginUnicorn from 'eslint-plugin-unicorn'
8+
import pluginVue from 'eslint-plugin-vue'
9+
import globals from 'globals'
10+
import jsoncParser from 'jsonc-eslint-parser'
11+
import tseslint from 'typescript-eslint'
12+
import vueParser from 'vue-eslint-parser'
13+
14+
export default defineConfig(
15+
{
16+
ignores: [
17+
'**/node_modules/**',
18+
'**/dist/**',
19+
'vitest.workspace.mjs',
20+
'cases/**',
21+
'test/**',
22+
'benchmark/**',
23+
'webpack.config.js',
24+
'bin/*',
25+
'vite.config.ts',
26+
],
27+
},
28+
js.configs.recommended,
29+
...pluginVue.configs['flat/recommended'],
30+
...tseslint.configs.recommended,
31+
...tseslint.configs.stylistic,
32+
{
33+
files: ['**/*.ts', '**/*.d.ts'],
34+
languageOptions: {
35+
parser: tseslint.parser,
36+
sourceType: 'module',
37+
ecmaVersion: 'latest',
38+
globals: {
39+
...globals.browser,
40+
...globals.node,
41+
},
42+
},
43+
},
44+
{
45+
files: ['**/*.vue'],
46+
languageOptions: {
47+
parser: vueParser,
48+
parserOptions: {
49+
parser: tseslint.parser,
50+
extraFileExtensions: ['.vue'],
51+
sourceType: 'module',
52+
ecmaVersion: 'latest',
53+
},
54+
globals: {
55+
...globals.browser,
56+
...globals.node,
57+
},
58+
},
59+
},
60+
{
61+
files: ['**/*.ts', '**/*.d.ts', '**/*.vue', 'eslint.config.mjs'],
62+
plugins: {
63+
'simple-import-sort': simpleImportSort,
64+
unicorn: pluginUnicorn,
65+
},
66+
rules: {
67+
'unicorn/prefer-node-protocol': 'error',
68+
'unicorn/prefer-module': 'error',
69+
'simple-import-sort/imports': 'error',
70+
'simple-import-sort/exports': 'error',
71+
eqeqeq: 'error',
72+
'no-caller': 'error',
73+
'no-constant-condition': ['error', { checkLoops: false }],
74+
'no-eval': 'error',
75+
'no-extra-bind': 'error',
76+
'no-new-func': 'error',
77+
'no-new-wrappers': 'error',
78+
'no-throw-literal': 'error',
79+
'no-undef-init': 'error',
80+
'no-var': 'error',
81+
'object-shorthand': 'error',
82+
'prefer-const': 'error',
83+
'prefer-object-spread': 'error',
84+
'unicode-bom': ['error', 'never'],
85+
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
86+
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
87+
'no-unused-vars': 'off',
88+
'no-extra-boolean-cast': 'off',
89+
'no-case-declarations': 'off',
90+
'no-cond-assign': 'off',
91+
'no-control-regex': 'off',
92+
'no-inner-declarations': 'off',
93+
'no-empty': 'off',
94+
// @typescript-eslint/eslint-plugin
95+
'@typescript-eslint/no-unused-expressions': 'off',
96+
'@typescript-eslint/ban-ts-comment': 'off',
97+
'@typescript-eslint/no-empty-function': 'off',
98+
'@typescript-eslint/no-namespace': 'off',
99+
'@typescript-eslint/no-non-null-asserted-optional-chain': 'off',
100+
'@typescript-eslint/no-var-requires': 'off',
101+
'@typescript-eslint/no-empty-interface': 'off',
102+
'@typescript-eslint/no-explicit-any': 'off',
103+
'@typescript-eslint/no-empty-object-type': 'off', // {} is a totally useful and valid type.
104+
'@typescript-eslint/no-require-imports': 'off',
105+
'@typescript-eslint/no-inferrable-types': 'off',
106+
'@typescript-eslint/no-this-alias': 'off',
107+
// Pending https://github.com/typescript-eslint/typescript-eslint/issues/4820
108+
'@typescript-eslint/prefer-optional-chain': 'off',
109+
'@typescript-eslint/no-unused-vars': [
110+
'error',
111+
{
112+
args: 'all',
113+
argsIgnorePattern: '^_',
114+
caughtErrors: 'all',
115+
caughtErrorsIgnorePattern: '^_',
116+
},
117+
],
118+
'vue/no-v-html': 'off',
119+
'vue/multi-word-component-names': 'off',
120+
'no-undef': 'off', // TypeScript handles this
121+
'no-async-promise-executor': 'off',
122+
},
123+
},
124+
...jsonc.configs['flat/recommended-with-jsonc'],
125+
{
126+
files: ['**/*.json', '**/*.jsonc', '**/*.json5'],
127+
languageOptions: {
128+
parser: jsoncParser,
129+
},
130+
rules: {
131+
'jsonc/array-bracket-spacing': ['error', 'never'],
132+
'jsonc/comma-dangle': ['error', 'never'],
133+
'jsonc/indent': ['error', 2],
134+
'jsonc/no-comments': 'off',
135+
'jsonc/quotes': ['error', 'double'],
136+
},
137+
},
138+
{
139+
files: ['src/i18n/**/*.json'],
140+
rules: {
141+
'jsonc/sort-keys': [
142+
'error',
143+
'asc', // 升序排列
144+
{
145+
caseSensitive: false,
146+
natural: true,
147+
},
148+
],
149+
},
150+
},
151+
{
152+
files: ['**/*.mjs', '**/*.mts'],
153+
rules: {
154+
// These globals don't exist outside of CJS files.
155+
'no-restricted-globals': [
156+
'error',
157+
{ name: '__filename' },
158+
{ name: '__dirname' },
159+
{ name: 'require' },
160+
{ name: 'module' },
161+
{ name: 'exports' },
162+
],
163+
},
164+
},
165+
{
166+
files: ['*.config.js', 'scripts/*.{js,mjs,cjs}'],
167+
languageOptions: {
168+
globals: {
169+
...globals.node,
170+
},
171+
},
172+
rules: {
173+
// 在脚本文件中,通常允许使用 console 和 require
174+
'no-console': 'off',
175+
'@typescript-eslint/no-require-imports': 'off',
176+
'@typescript-eslint/no-var-requires': 'off',
177+
},
178+
},
179+
configPrettier,
180+
pluginPrettier,
181+
)

0 commit comments

Comments
 (0)