feat(typescript): add standards docs and sync rewrite coverage

This commit is contained in:
csh
2026-02-24 17:30:43 +08:00
parent 872c1afc24
commit 1f46203299
12 changed files with 360 additions and 12 deletions
+88
View File
@@ -0,0 +1,88 @@
# TypeScript 配置清单
本文件汇总 TypeScript 项目常用配置文件说明。
## 1) `tsconfig.json`
关键编译选项:
```json
{
"compilerOptions": {
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"strict": true,
"noUncheckedIndexedAccess": true,
"noImplicitOverride": true,
"exactOptionalPropertyTypes": true,
"skipLibCheck": true,
"outDir": "dist",
"rootDir": "src"
},
"include": ["src"]
}
```
- `strict: true`:启用全部严格检查(必须)
- `noUncheckedIndexedAccess`:数组/对象索引访问返回 `T | undefined`(推荐)
- `skipLibCheck`:跳过 `.d.ts` 检查,加快编译
## 2) `.prettierrc`
```json
{
"semi": false,
"singleQuote": true,
"printWidth": 100,
"trailingComma": "all",
"tabWidth": 2
}
```
## 3) `eslint.config.js`Flat Config
```js
import tseslint from 'typescript-eslint'
export default tseslint.config(
...tseslint.configs.recommendedTypeChecked,
{
languageOptions: {
parserOptions: { projectService: true },
},
rules: {
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-floating-promises': 'error',
},
},
)
```
## 4) `.editorconfig`
```ini
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
[*.{ts,tsx,js,jsx,json}]
indent_style = space
indent_size = 2
max_line_length = 100
```
## 5) `.vscode/settings.json`
```json
{
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.rulers": [100],
"typescript.tsdk": "node_modules/typescript/lib"
}
```