- shadcn/ui 标准化:废弃纸感令牌,统一 bg-background/text-foreground 等 - Tailwind v4 + @theme inline,移除 tailwind.config.js - React 19 use() + Suspense 流式渲染,首屏骨架秒出 - 三级错误边界:Route → Section → Widget 层层兜底 - 错误上报:useErrorReport → sendBeacon → /api/log mock 端点 - 三层安全边界:L1 角色门禁 / L2 权限点门禁 / L3 数据范围 - 权限位图 base36 压缩:67 权限点 → ~14 字符,JWT 体积减少 ≥ 99% - notify 统一 Toast 封装,禁止业务直接 import sonner - PluginBoundary 替代 PluginLoader(错误边界 + Suspense + Skeleton 三件套) 验证:typecheck 0 错误 / lint 0 错误 / build 6 路由生成成功
94 lines
2.2 KiB
JavaScript
94 lines
2.2 KiB
JavaScript
/**
|
||
* portal-shell ESLint flat config (ESM)
|
||
*
|
||
* 包含设计令牌强制规则(project_rules §3.10):
|
||
* - 禁止 #hex 颜色字面量
|
||
* - 禁止 'Inter'/'Fraunces'/'JetBrains Mono' 字体名字面量
|
||
*
|
||
* 关联:project_rules §3.10、portal-shell spec §7
|
||
*/
|
||
import js from "@eslint/js";
|
||
import tseslint from "typescript-eslint";
|
||
import prettierConfig from "eslint-config-prettier";
|
||
|
||
export default tseslint.config(
|
||
{
|
||
ignores: [
|
||
"**/dist/**",
|
||
"**/node_modules/**",
|
||
"**/.next/**",
|
||
"**/coverage/**",
|
||
"**/*.config.js",
|
||
"**/*.config.mjs",
|
||
],
|
||
},
|
||
|
||
js.configs.recommended,
|
||
...tseslint.configs.recommended,
|
||
|
||
{
|
||
languageOptions: {
|
||
ecmaVersion: 2024,
|
||
sourceType: "module",
|
||
},
|
||
rules: {
|
||
"@typescript-eslint/no-explicit-any": "warn",
|
||
"@typescript-eslint/no-unused-vars": [
|
||
"error",
|
||
{
|
||
argsIgnorePattern: "^_",
|
||
varsIgnorePattern: "^_",
|
||
},
|
||
],
|
||
"no-console": "off",
|
||
},
|
||
},
|
||
|
||
// 设计令牌强制规则(project_rules §3.10)
|
||
{
|
||
files: ["**/*.{ts,tsx,js,jsx}"],
|
||
rules: {
|
||
"no-restricted-syntax": [
|
||
"error",
|
||
{
|
||
// 禁止 #hex 颜色字面量(如 "#fff"、"#000000")
|
||
selector: "Literal[value=/^#[0-9a-fA-F]{3,8}$/]",
|
||
message:
|
||
"禁止硬编码颜色 #hex,使用 var(--*) 或 Tailwind bg-* 类(project_rules §3.10)",
|
||
},
|
||
{
|
||
// 禁止字体名字面量(next/font 的 import 标识符不受影响)
|
||
selector: "Literal[value=/^(Inter|Fraunces|JetBrains Mono)$/]",
|
||
message:
|
||
"禁止硬编码字体名字面量,使用 var(--font-family-sans/serif/mono)(project_rules §3.10)",
|
||
},
|
||
],
|
||
},
|
||
},
|
||
|
||
// 白名单:令牌原始定义、PWA manifest
|
||
{
|
||
files: ["**/primitive.css", "**/manifest.ts"],
|
||
rules: {
|
||
"no-restricted-syntax": "off",
|
||
},
|
||
},
|
||
|
||
// 测试文件放宽规则
|
||
{
|
||
files: [
|
||
"**/*.test.ts",
|
||
"**/*.test.tsx",
|
||
"**/*.spec.ts",
|
||
"**/*.spec.tsx",
|
||
"**/__tests__/**",
|
||
],
|
||
rules: {
|
||
"@typescript-eslint/no-explicit-any": "off",
|
||
"@typescript-eslint/no-non-null-assertion": "off",
|
||
},
|
||
},
|
||
|
||
prettierConfig,
|
||
);
|