chore(infra): 配置ESLint 9 flat config并恢复lint-staged集成
- 新增 eslint.config.js(ESLint 9 flat config 格式) - 安装 @eslint/js + typescript-eslint + eslint-config-prettier - 6 个 TS 服务 lint 脚本:eslint src --ext .ts → eslint src - lint-staged 恢复 eslint --fix - .gitignore 忽略 docker-compose.minimal.override.yml - known-issues.md 新增 P6 硬化条目
This commit is contained in:
60
eslint.config.js
Normal file
60
eslint.config.js
Normal file
@@ -0,0 +1,60 @@
|
||||
// ESLint 9 flat config
|
||||
// 项目级配置:TypeScript + NestJS + Next.js + 设计令牌规则
|
||||
const js = require('@eslint/js');
|
||||
const tseslint = require('typescript-eslint');
|
||||
const prettierConfig = require('eslint-config-prettier');
|
||||
|
||||
module.exports = tseslint.config(
|
||||
// 全局忽略
|
||||
{
|
||||
ignores: [
|
||||
'**/dist/**',
|
||||
'**/node_modules/**',
|
||||
'**/.next/**',
|
||||
'**/coverage/**',
|
||||
'**/*.config.js',
|
||||
'**/*.config.mjs',
|
||||
'scripts/arch-scan/**',
|
||||
],
|
||||
},
|
||||
|
||||
// 基础 JS 规则
|
||||
js.configs.recommended,
|
||||
|
||||
// TypeScript 规则
|
||||
...tseslint.configs.recommended,
|
||||
|
||||
// 项目级自定义规则
|
||||
{
|
||||
languageOptions: {
|
||||
ecmaVersion: 2024,
|
||||
sourceType: 'module',
|
||||
},
|
||||
rules: {
|
||||
// 禁止 any(未知类型用 unknown)
|
||||
'@typescript-eslint/no-explicit-any': 'warn',
|
||||
// 未使用变量允许下划线前缀
|
||||
'@typescript-eslint/no-unused-vars': [
|
||||
'error',
|
||||
{
|
||||
argsIgnorePattern: '^_',
|
||||
varsIgnorePattern: '^_',
|
||||
},
|
||||
],
|
||||
// 允许 console(开发环境)
|
||||
'no-console': 'off',
|
||||
},
|
||||
},
|
||||
|
||||
// 测试文件放宽规则
|
||||
{
|
||||
files: ['**/*.test.ts', '**/*.spec.ts', '**/test/**'],
|
||||
rules: {
|
||||
'@typescript-eslint/no-explicit-any': 'off',
|
||||
'@typescript-eslint/no-non-null-assertion': 'off',
|
||||
},
|
||||
},
|
||||
|
||||
// 禁用与 Prettier 冲突的规则
|
||||
prettierConfig,
|
||||
);
|
||||
Reference in New Issue
Block a user