chore(frontend): eslint flat config + prettier baseline config

This commit is contained in:
2026-09-15 11:22:02 +08:00
parent 24c5d42531
commit 09a02fa0d7
5 changed files with 1597 additions and 32 deletions
+6
View File
@@ -0,0 +1,6 @@
dist
dist-stats
node_modules
package-lock.json
playwright-report
test-results
+7
View File
@@ -0,0 +1,7 @@
{
"printWidth": 120,
"tabWidth": 2,
"semi": true,
"singleQuote": false,
"trailingComma": "all"
}
+50
View File
@@ -0,0 +1,50 @@
import js from "@eslint/js";
import tseslint from "typescript-eslint";
import reactHooks from "eslint-plugin-react-hooks";
import jsxA11y from "eslint-plugin-jsx-a11y";
import prettier from "eslint-config-prettier";
export default tseslint.config(
{ ignores: ["dist/**", "dist-stats/**", "node_modules/**", "playwright-report/**", "test-results/**"] },
js.configs.recommended,
...tseslint.configs.recommended,
// react-hooks 插件的 flat 导出名随版本而异(recommended-latest / configs.flat.recommended),
// 以安装版本实际导出为准,用 npx eslint --print-config src/main.tsx 验证规则已生效
reactHooks.configs.flat["recommended-latest"],
jsxA11y.flatConfigs.recommended,
{
files: ["**/*.{ts,tsx}"],
rules: {
"@typescript-eslint/no-unused-vars": [
"error",
{ argsIgnorePattern: "^_", varsIgnorePattern: "^_", caughtErrorsIgnorePattern: "^_" },
],
},
},
{
// 旧阅读器 chrome 的点击区/交互元素将被 ② 阅读器改版迁入 radix 原语,
// 届时收严为 error;本期对存量文件降 warn(spec S1 决策)
files: [
"src/readers/**/*.tsx",
"src/components/Bookmarks.tsx",
"src/components/reader-nav.tsx",
"src/components/rd-slider.tsx",
"src/pages/Reader.tsx",
],
rules: {
"jsx-a11y/click-events-have-key-events": "warn",
"jsx-a11y/no-static-element-interactions": "warn",
"jsx-a11y/no-noninteractive-element-interactions": "warn",
},
},
{
files: ["e2e/**/*.ts"],
languageOptions: { globals: { process: "readonly", console: "readonly", URL: "readonly" } },
rules: { "@typescript-eslint/no-explicit-any": "off" },
},
{
files: ["**/*.test.{ts,tsx}", "test/**/*.ts"],
rules: { "@typescript-eslint/no-explicit-any": "off" },
},
prettier, // 必须最后:关闭所有与 prettier 冲突的格式规则
);
+1520 -30
View File
File diff suppressed because it is too large Load Diff
+14 -2
View File
@@ -8,7 +8,11 @@
"dev": "vite", "dev": "vite",
"build": "tsc --noEmit && vite build", "build": "tsc --noEmit && vite build",
"preview": "vite preview", "preview": "vite preview",
"check": "tsc --noEmit && vitest run && vite build" "check": "tsc --noEmit && vitest run && vite build",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"format": "prettier --write .",
"format:check": "prettier --check ."
}, },
"keywords": [], "keywords": [],
"author": "", "author": "",
@@ -32,12 +36,20 @@
"tw-animate-css": "^1.4.0" "tw-animate-css": "^1.4.0"
}, },
"devDependencies": { "devDependencies": {
"@eslint/js": "^10.0.1",
"@tailwindcss/vite": "^4.3.3", "@tailwindcss/vite": "^4.3.3",
"@types/react": "^19.2.18", "@types/react": "^19.2.18",
"@types/react-dom": "^19.2.7", "@types/react-dom": "^19.2.7",
"@typescript/native": "npm:typescript@^7.0.2",
"@vitejs/plugin-react": "^6.1.1", "@vitejs/plugin-react": "^6.1.1",
"eslint": "^10.10.0",
"eslint-config-prettier": "^10.1.8",
"eslint-plugin-jsx-a11y": "^6.10.2",
"eslint-plugin-react-hooks": "^7.1.1",
"prettier": "^3.9.6",
"tailwindcss": "^4.3.3", "tailwindcss": "^4.3.3",
"typescript": "^7.0.2", "typescript": "npm:@typescript/typescript6@^6.0.2",
"typescript-eslint": "^8.70.0",
"vite": "^8.2.2", "vite": "^8.2.2",
"vite-plugin-pwa": "^1.3.0", "vite-plugin-pwa": "^1.3.0",
"vitest": "^5.0.0" "vitest": "^5.0.0"