cursor-init/eslint.config.js
expressgy 5b0b37ef78 chore: 项目初始化相关配置与文档归档优化
- Prettier 配置迁移为 .prettierrc.cjs,解决 ESM/CJS 兼容问题
- 优化 package.json,补全元信息、整理依赖、完善 Bun 热更新脚本
- 归档项目初始化 PRD 与任务清单到 tasks/archive,并加日期前缀
- 同步代码风格与格式化配置,提升团队协作一致性

归档文件:tasks/archive/20240610-prd-项目初始化.md, tasks/archive/20240610-tasks-prd-项目初始化.md
2025-06-28 02:03:40 +08:00

71 lines
2.4 KiB
JavaScript
Raw 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-check
// 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',
},
},
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',
// 强制四空格缩进
indent: ['error', 4],
// 强制分号
semi: ['error', 'always'],
// 强制单引号
quotes: ['error', 'single'],
// 末尾逗号(多行对象/数组)
'comma-dangle': ['error', 'always-multiline'],
// 对象key统一加引号
'quote-props': ['error', 'as-needed'],
// 关键字前后空格
'keyword-spacing': ['error', { before: true, after: true }],
// 大括号风格
'brace-style': ['error', '1tbs'],
// 禁止多余空行
'no-multiple-empty-lines': ['error', { max: 1 }],
},
},
{
// 忽略目录和文件
ignores: ['node_modules/', 'dist/', 'bun.lockb', '*.config.js', '*.config.ts'],
},
];