feat: 前端统一 Logger 模块 — 接口、双流 Sink、ESLint 规则、测试

This commit is contained in:
2026-06-01 14:26:17 +08:00
parent 60843f7dbf
commit 4c72754739
11 changed files with 1003 additions and 2 deletions

View File

@@ -9,6 +9,9 @@ import tseslint from "typescript-eslint";
const noDirectConsoleMessage =
"后端运行时代码禁止直接使用 console.*;请通过注入的 Logger 实例输出日志,配置加载失败前使用 createConsoleFallback()。";
const noDirectConsoleFrontendMessage =
"前端代码禁止直接使用 console.*;请使用 useLogger() hook组件内或 createConsoleLogger()(非组件纯函数)。";
export default tseslint.config(
{
ignores: [
@@ -77,6 +80,7 @@ export default tseslint.config(
},
{
files: ["src/web/**/*.{ts,tsx}"],
ignores: ["src/web/**/logger.ts"],
plugins: {
"react-hooks": reactHooks,
"react-refresh": reactRefresh,
@@ -103,6 +107,13 @@ export default tseslint.config(
],
},
],
"no-restricted-syntax": [
"error",
{
message: noDirectConsoleFrontendMessage,
selector: "MemberExpression[object.name='console']",
},
],
"react-refresh/only-export-components": ["warn", { allowConstantExport: true }],
},
},