提交 d96aed69 authored 作者: 王鹏飞's avatar 王鹏飞

fix: modernize learning lint toolchain

上级 01d63698
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
This repository is a pnpm workspace. Use Node >=22.13 and pnpm 11.13.1 from the repository root. This repository is a pnpm workspace. Use Node >=22.13 and pnpm 11.13.1 from the repository root.
- `apps/admin` is the legacy JavaScript/JSX administration app. It remains on React 18 and Ant Design 5 in Stage 0; Redux, Redux Toolkit, React Redux, and Redux Persist are allowed there. Do not make broad dependency upgrades unless a later task explicitly authorizes them. - `apps/admin` is the legacy JavaScript/JSX administration app. It remains on React 18 and Ant Design 5 in Stage 0; Redux, Redux Toolkit, React Redux, and Redux Persist are allowed there. Do not make broad dependency upgrades unless a later task explicitly authorizes them.
- `apps/learning` is the planned TypeScript learning app. It uses React/ReactDOM 19, TanStack React Query for server state, nuqs for URL-restorable page state, and Zustand only for transient cross-component client state. The Redux family is forbidden: `redux`, Redux Toolkit, React Redux, and Redux Persist. - `apps/learning` is the TypeScript learning app. It uses React/ReactDOM 19, TanStack React Query for server state, nuqs for URL-restorable page state, and Zustand only for transient cross-component client state. The Redux family is forbidden: `redux`, Redux Toolkit, React Redux, and Redux Persist.
- Apps own their routes, state, API clients, dependencies, and build outputs. Never import another app's `src` directory; extract a deliberate shared package only when a task calls for it. - Apps own their routes, state, API clients, dependencies, and build outputs. Never import another app's `src` directory; extract a deliberate shared package only when a task calls for it.
- Do not add Ant Design to the learning placeholder. If learning later adopts it, use the current stable v6 baseline (`^6.5.1` as of this plan), never admin's v5 dependency. - Do not add Ant Design to the learning placeholder. If learning later adopts it, use the current stable v6 baseline (`^6.5.1` as of this plan), never admin's v5 dependency.
......
module.exports = {
root: true,
env: { browser: true, es2022: true },
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'react-hooks', 'react-refresh'],
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'plugin:react-hooks/recommended'],
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
ignorePatterns: ['dist'],
}
import js from '@eslint/js'
import globals from 'globals'
import reactHooks from 'eslint-plugin-react-hooks'
import reactRefresh from 'eslint-plugin-react-refresh'
import tseslint from 'typescript-eslint'
export default tseslint.config(
{ ignores: ['dist'] },
{
files: ['**/*.{ts,tsx}'],
extends: [
js.configs.recommended,
tseslint.configs.recommended,
reactHooks.configs.flat.recommended,
reactRefresh.configs.vite,
],
languageOptions: {
ecmaVersion: 2022,
globals: globals.browser,
},
},
)
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
"build": "tsc -b && vite build", "build": "tsc -b && vite build",
"lint": "eslint . --ext ts,tsx --max-warnings 0", "lint": "eslint . --max-warnings 0",
"test": "vitest run --passWithNoTests", "test": "vitest run --passWithNoTests",
"test:watch": "vitest" "test:watch": "vitest"
}, },
...@@ -23,17 +23,18 @@ ...@@ -23,17 +23,18 @@
"@testing-library/jest-dom": "^6.6.3", "@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^16.3.0", "@testing-library/react": "^16.3.0",
"@testing-library/user-event": "^14.6.1", "@testing-library/user-event": "^14.6.1",
"@eslint/js": "^10.0.1",
"@types/node": "^22.13.9", "@types/node": "^22.13.9",
"@types/react": "^19.2.17", "@types/react": "^19.2.17",
"@types/react-dom": "^19.2.3", "@types/react-dom": "^19.2.3",
"@typescript-eslint/eslint-plugin": "^7.18.0",
"@typescript-eslint/parser": "^7.18.0",
"@vitejs/plugin-react": "^6.0.3", "@vitejs/plugin-react": "^6.0.3",
"eslint": "^8.57.0", "eslint": "^10.7.0",
"eslint-plugin-react-hooks": "^5.2.0", "eslint-plugin-react-hooks": "^7.1.1",
"eslint-plugin-react-refresh": "^0.4.19", "eslint-plugin-react-refresh": "^0.5.3",
"jsdom": "^26.1.0", "globals": "^17.7.0",
"jsdom": "^29.1.1",
"typescript": "^5.7.3", "typescript": "^5.7.3",
"typescript-eslint": "^8.64.0",
"vite": "^8.1.5", "vite": "^8.1.5",
"vite-plugin-mkcert": "^1.17.10", "vite-plugin-mkcert": "^1.17.10",
"vitest": "^4.1.10" "vitest": "^4.1.10"
......
...@@ -56,6 +56,7 @@ ...@@ -56,6 +56,7 @@
- `apps/learning/package.json`: learning-only runtime and test dependencies. - `apps/learning/package.json`: learning-only runtime and test dependencies.
- `apps/learning/tsconfig*.json`: strict TypeScript configuration. - `apps/learning/tsconfig*.json`: strict TypeScript configuration.
- `apps/learning/eslint.config.js`: ESLint 10 flat configuration for the TypeScript/React learning app.
- `apps/learning/vite.config.ts`: root base, port 5173, local `/admin` and API proxies, `dist/learning` output. - `apps/learning/vite.config.ts`: root base, port 5173, local `/admin` and API proxies, `dist/learning` output.
- `apps/learning/src/main.tsx`: QueryClient and Router providers. - `apps/learning/src/main.tsx`: QueryClient and Router providers.
- `apps/learning/src/router/RootLayout.tsx`: NuqsAdapter inside React Router context. - `apps/learning/src/router/RootLayout.tsx`: NuqsAdapter inside React Router context.
...@@ -472,7 +473,7 @@ Do not add generated `dist` contents. ...@@ -472,7 +473,7 @@ Do not add generated `dist` contents.
- Create: `apps/learning/tsconfig.json` - Create: `apps/learning/tsconfig.json`
- Create: `apps/learning/tsconfig.app.json` - Create: `apps/learning/tsconfig.app.json`
- Create: `apps/learning/tsconfig.node.json` - Create: `apps/learning/tsconfig.node.json`
- Create: `apps/learning/.eslintrc.cjs` - Create: `apps/learning/eslint.config.js`
- Create: `apps/learning/vite.config.ts` - Create: `apps/learning/vite.config.ts`
- Create: `apps/learning/src/vite-env.d.ts` - Create: `apps/learning/src/vite-env.d.ts`
- Create: `apps/learning/src/test/setup.ts` - Create: `apps/learning/src/test/setup.ts`
...@@ -502,7 +503,7 @@ Create `apps/learning/package.json`: ...@@ -502,7 +503,7 @@ Create `apps/learning/package.json`:
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
"build": "tsc -b && vite build", "build": "tsc -b && vite build",
"lint": "eslint . --ext ts,tsx --max-warnings 0", "lint": "eslint . --max-warnings 0",
"test": "vitest run --passWithNoTests", "test": "vitest run --passWithNoTests",
"test:watch": "vitest" "test:watch": "vitest"
}, },
...@@ -519,17 +520,18 @@ Create `apps/learning/package.json`: ...@@ -519,17 +520,18 @@ Create `apps/learning/package.json`:
"@testing-library/jest-dom": "^6.6.3", "@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^16.3.0", "@testing-library/react": "^16.3.0",
"@testing-library/user-event": "^14.6.1", "@testing-library/user-event": "^14.6.1",
"@eslint/js": "^10.0.1",
"@types/node": "^22.13.9", "@types/node": "^22.13.9",
"@types/react": "^19.2.17", "@types/react": "^19.2.17",
"@types/react-dom": "^19.2.3", "@types/react-dom": "^19.2.3",
"@typescript-eslint/eslint-plugin": "^7.18.0",
"@typescript-eslint/parser": "^7.18.0",
"@vitejs/plugin-react": "^6.0.3", "@vitejs/plugin-react": "^6.0.3",
"eslint": "^8.57.0", "eslint": "^10.7.0",
"eslint-plugin-react-hooks": "^5.2.0", "eslint-plugin-react-hooks": "^7.1.1",
"eslint-plugin-react-refresh": "^0.4.19", "eslint-plugin-react-refresh": "^0.5.3",
"jsdom": "^26.1.0", "globals": "^17.7.0",
"jsdom": "^29.1.1",
"typescript": "^5.7.3", "typescript": "^5.7.3",
"typescript-eslint": "^8.64.0",
"vite": "^8.1.5", "vite": "^8.1.5",
"vite-plugin-mkcert": "^1.17.10", "vite-plugin-mkcert": "^1.17.10",
"vitest": "^4.1.10" "vitest": "^4.1.10"
...@@ -627,18 +629,31 @@ Create `apps/learning/src/test/setup.ts`: ...@@ -627,18 +629,31 @@ Create `apps/learning/src/test/setup.ts`:
import '@testing-library/jest-dom/vitest' import '@testing-library/jest-dom/vitest'
``` ```
Create `apps/learning/.eslintrc.cjs`: Create `apps/learning/eslint.config.js`:
```js ```js
module.exports = { import js from '@eslint/js'
root: true, import globals from 'globals'
env: { browser: true, es2022: true }, import reactHooks from 'eslint-plugin-react-hooks'
parser: '@typescript-eslint/parser', import reactRefresh from 'eslint-plugin-react-refresh'
plugins: ['@typescript-eslint', 'react-hooks', 'react-refresh'], import tseslint from 'typescript-eslint'
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'plugin:react-hooks/recommended'],
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' }, export default tseslint.config(
ignorePatterns: ['dist'], { ignores: ['dist'] },
} {
files: ['**/*.{ts,tsx}'],
extends: [
js.configs.recommended,
tseslint.configs.recommended,
reactHooks.configs.flat.recommended,
reactRefresh.configs.vite,
],
languageOptions: {
ecmaVersion: 2022,
globals: globals.browser,
},
},
)
``` ```
Create `apps/learning/vite.config.ts`: Create `apps/learning/vite.config.ts`:
......
差异被折叠。
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论