cursor-init/eslint.config.js
expressgy 2ee70e5d42 feat: 完成健康检查接口和Swagger文档完善
 健康检查功能:
- 实现完整的健康检查接口(/api/health, /api/health/detailed)
- 支持MySQL和Redis依赖状态检查
- 包含系统信息、性能指标监控
- 修复this上下文问题,确保服务方法正常调用
- 添加全面的健康检查测试用例

📝 Swagger文档优化:
- 创建全局响应Schema定义和错误码说明
- 完善API文档,包含详细的错误码表格
- 添加JWT认证说明和响应格式示例
- 增加全局组件、响应模板和示例
- 创建Swagger文档功能测试

🎯 任务完成:
-  5.0 健康检查接口 - 实现系统和依赖健康状态监控
-  7.0 Swagger文档完善 - 增加全局响应示例和错误码说明

📁 新增文件:
- src/controllers/health.controller.ts - 健康检查控制器
- src/services/health.service.ts - 健康检查服务层
- src/type/health.type.ts - 健康检查类型定义
- src/validators/health.response.ts - 健康检查响应验证
- src/validators/global.response.ts - 全局响应Schema定义
- src/tests/health.test.ts - 健康检查功能测试
- src/tests/redis.test.ts - Redis连接测试
- src/tests/swagger.test.ts - Swagger文档功能测试
2025-06-28 22:09:02 +08:00

82 lines
3.0 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// @ts-nocheck
// ESLint 9.x Flat Config for Elysia + TypeScript 项目
// 详细注释,含风格规范(四空格缩进、分号、单引号等)
import js from '@eslint/js';
import tseslint from '@typescript-eslint/eslint-plugin';
import tsparser from '@typescript-eslint/parser';
/**
* @type {import("eslint").Linter.FlatConfig[]}
* FlatConfig 方式配置兼容ESLint 9.x及TypeScript
*/
export default [
// 基础JS推荐规则
js.configs.recommended,
{
// 仅检查src和tests目录下的ts文件
files: ['src/**/*.ts', 'tests/**/*.ts', '*.ts'],
languageOptions: {
// TypeScript解析器
parser: tsparser,
parserOptions: {
sourceType: 'module', // ES模块
ecmaVersion: 'latest', // 最新ECMAScript
},
// 全局变量声明避免no-undef
globals: {
Request: 'readonly',
console: 'readonly',
process: 'readonly',
Bun: 'readonly',
Response: 'readonly',
Blob: 'readonly',
File: 'readonly',
TextEncoder: 'readonly',
},
},
plugins: {
// TypeScript插件
'@typescript-eslint': tseslint,
},
rules: {
// 关闭原生no-unused-vars使用TS版本
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': 'warn',
// 关闭强制函数返回类型
'@typescript-eslint/explicit-function-return-type': 'off',
// 允许any
'@typescript-eslint/no-explicit-any': 'off',
// 允许ts-ignore等注释
'@typescript-eslint/ban-ts-comment': 'off',
// ===== 禁用与Prettier冲突的格式化规则 =====
indent: 'off', // 让Prettier处理缩进
'max-len': 'off', // 让Prettier处理行长度
'comma-spacing': 'off', // 让Prettier处理逗号空格
'object-curly-spacing': 'off', // 让Prettier处理对象空格
'array-bracket-spacing': 'off', // 让Prettier处理数组空格
// ===== 与Prettier兼容的规则 =====
// 强制分号与Prettier一致
semi: ['error', 'always'],
// 强制单引号与Prettier一致
quotes: ['error', 'single'],
// 末尾逗号与Prettier一致
'comma-dangle': ['error', 'always-multiline'],
// 对象key统一加引号与Prettier一致
'quote-props': ['error', 'as-needed'],
// ===== 其他代码质量规则 =====
// 关键字前后空格
'keyword-spacing': ['error', { before: true, after: true }],
// 禁止多余空行
'no-multiple-empty-lines': ['error', { max: 2, maxEOF: 1 }],
},
},
{
// 忽略目录和文件
ignores: ['node_modules/', 'dist/', 'bun.lockb', '*.config.js', '*.config.ts'],
},
];