-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.js
More file actions
74 lines (73 loc) · 2.42 KB
/
eslint.config.js
File metadata and controls
74 lines (73 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import js from "@eslint/js";
import stylistic from "@stylistic/eslint-plugin";
import { defineConfig, globalIgnores } from "eslint/config";
import reactHooks from "eslint-plugin-react-hooks";
import reactRefresh from "eslint-plugin-react-refresh";
import globals from "globals";
import tseslint from "typescript-eslint";
import prettier from "eslint-plugin-prettier";
import prettierConfig from "eslint-config-prettier";
import reactX from 'eslint-plugin-react-x'
import reactDom from 'eslint-plugin-react-dom'
export default defineConfig([
globalIgnores(["dist", "sharkey-js", "locales-source"]),
{
files: ["**/*.{ts,tsx}"],
ignores: ["src/components/ui/*.tsx", "dev-script/**/*"],
plugins: {
prettier, // 加入 Prettier 插件
},
extends: [
js.configs.recommended,
// Remove tseslint.configs.recommended and replace with this
tseslint.configs.recommendedTypeChecked,
// Alternatively, use this for stricter rules
tseslint.configs.strictTypeChecked,
// Optionally, add this for stylistic rules
tseslint.configs.stylisticTypeChecked,
reactHooks.configs.flat.recommended,
reactRefresh.configs.vite,
// Enable lint rules for React
reactX.configs['recommended-typescript'],
// Enable lint rules for React DOM
reactDom.configs.recommended,
stylistic.configs.recommended,
prettierConfig, // 禁用冲突规则
{
rules: {
// 启用 prettier 检查
"prettier/prettier": ["error", {
plugins: ["prettier-plugin-tailwindcss"],
endOfLine: "lf",
singleQuote: true,
semi: true,
trailingComma: "all",
printWidth: 120,
tabWidth: 2,
}],
"@stylistic/jsx-self-closing-comp": "error",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-misused-promises": "off",
"@typescript-eslint/restrict-template-expressions": "off",
"@typescript-eslint/prefer-nullish-coalescing": ["error", {
"ignoreConditionalTests": true,
"ignoreMixedLogicalExpressions": true,
}],
"@typescript-eslint/ban-ts-comment": ["error", {
'ts-check': false,
'ts-expect-error': 'allow-with-description',
'ts-ignore': 'allow-with-description',
}],
},
},
],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: import.meta.dirname,
},
},
},
]);