typescript-quality-checker
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseTypeScript Quality Checker Skill
TypeScript代码质量检查Skill
Purpose
用途
This skill provides comprehensive TypeScript/JavaScript code quality validation including formatting (Prettier), linting (ESLint), type checking (tsc), security analysis (npm audit), and code complexity analysis. Ensures code meets TypeScript best practices and project standards.
本Skill提供全面的TypeScript/JavaScript代码质量验证,包括格式化(Prettier)、代码检查(ESLint)、类型检查(tsc)、安全分析(npm audit)以及代码复杂度分析。确保代码符合TypeScript最佳实践和项目标准。
When to Use
使用场景
- Validating TypeScript/JavaScript code quality before commit
- Running pre-commit quality checks
- CI/CD quality gate validation
- Code review preparation
- Ensuring code style compliance
- Type safety validation
- Security vulnerability detection in dependencies
- 提交代码前验证TypeScript/JavaScript代码质量
- 运行提交前的质量检查
- CI/CD质量门验证
- 代码评审准备
- 确保代码风格合规
- 类型安全性验证
- 检测依赖中的安全漏洞
Quality Check Workflow
质量检查流程
1. Environment Setup
1. 环境搭建
Verify Tools Installed:
bash
undefined验证工具是否已安装:
bash
undefinedCheck Node.js and npm versions
Check Node.js and npm versions
node --version
npm --version
node --version
npm --version
Check TypeScript compiler
Check TypeScript compiler
npx tsc --version
npx tsc --version
Check quality tools
Check quality tools
npx eslint --version
npx prettier --version
**Install Development Dependencies:**
```bashnpx eslint --version
npx prettier --version
**安装开发依赖:**
```bashInstall all dev dependencies
Install all dev dependencies
npm install --save-dev
npm install --save-dev
Or install quality tools specifically
Or install quality tools specifically
npm install --save-dev
typescript
eslint
prettier
@typescript-eslint/parser
@typescript-eslint/eslint-plugin
eslint-config-prettier
eslint-plugin-prettier
typescript
eslint
prettier
@typescript-eslint/parser
@typescript-eslint/eslint-plugin
eslint-config-prettier
eslint-plugin-prettier
**Deliverable:** Quality tools ready
---npm install --save-dev
typescript
eslint
prettier
@typescript-eslint/parser
@typescript-eslint/eslint-plugin
eslint-config-prettier
eslint-plugin-prettier
typescript
eslint
prettier
@typescript-eslint/parser
@typescript-eslint/eslint-plugin
eslint-config-prettier
eslint-plugin-prettier
**交付成果:** 质量检查工具准备就绪
---2. Code Formatting Check (Prettier)
2. 代码格式化检查(Prettier)
Check Formatting:
bash
undefined检查格式化情况:
bash
undefinedCheck if code is formatted
Check if code is formatted
npx prettier --check "src/**/*.{ts,tsx,js,jsx,json,css,md}"
npx prettier --check "src/**/*.{ts,tsx,js,jsx,json,css,md}"
Check specific files
Check specific files
npx prettier --check src/index.ts
npx prettier --check src/index.ts
Check with detailed output
Check with detailed output
npx prettier --check --log-level debug "src/**/*.ts"
**Auto-Format Code:**
```bashnpx prettier --check --log-level debug "src/**/*.ts"
**自动格式化代码:**
```bashFormat all code
Format all code
npx prettier --write "src/**/*.{ts,tsx,js,jsx,json,css,md}"
npx prettier --write "src/**/*.{ts,tsx,js,jsx,json,css,md}"
Format specific directory
Format specific directory
npx prettier --write "src/components/**/*.tsx"
npx prettier --write "src/components/**/*.tsx"
Check what would change (dry run)
Check what would change (dry run)
npx prettier --check --list-different "src/**/*.ts"
**Configuration (.prettierrc.json):**
```json
{
"semi": true,
"trailingComma": "all",
"singleQuote": true,
"printWidth": 100,
"tabWidth": 2,
"useTabs": false,
"arrowParens": "always",
"endOfLine": "lf"
}.prettierignore:
node_modules/
dist/
build/
coverage/
*.min.js
package-lock.jsonDeliverable: Formatting validation report
npx prettier --check --list-different "src/**/*.ts"
**配置文件(.prettierrc.json):**
```json
{
"semi": true,
"trailingComma": "all",
"singleQuote": true,
"printWidth": 100,
"tabWidth": 2,
"useTabs": false,
"arrowParens": "always",
"endOfLine": "lf"
}.prettierignore:
node_modules/
dist/
build/
coverage/
*.min.js
package-lock.json交付成果: 格式化验证报告
3. Type Checking (TypeScript Compiler)
3. 类型检查(TypeScript编译器)
Run Type Checks:
bash
undefined运行类型检查:
bash
undefinedCheck types
Check types
npx tsc --noEmit
npx tsc --noEmit
Check with specific config
Check with specific config
npx tsc --noEmit --project tsconfig.json
npx tsc --noEmit --project tsconfig.json
Check and show all errors
Check and show all errors
npx tsc --noEmit --pretty
npx tsc --noEmit --pretty
Incremental type checking
Incremental type checking
npx tsc --noEmit --incremental
**Watch Mode for Development:**
```bashnpx tsc --noEmit --incremental
**开发模式下的监听模式:**
```bashWatch and type check continuously
Watch and type check continuously
npx tsc --noEmit --watch
npx tsc --noEmit --watch
With specific project
With specific project
npx tsc --noEmit --watch --project tsconfig.json
**Configuration (tsconfig.json):**
```json
{
"compilerOptions": {
"target": "ES2020",
"module": "ESNext",
"lib": ["ES2020", "DOM"],
"jsx": "react-jsx",
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"moduleResolution": "node",
"resolveJsonModule": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"declaration": true,
"declarationMap": true,
"sourceMap": true
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist", "build"]
}Deliverable: Type checking report
npx tsc --noEmit --watch --project tsconfig.json
**配置文件(tsconfig.json):**
```json
{
"compilerOptions": {
"target": "ES2020",
"module": "ESNext",
"lib": ["ES2020", "DOM"],
"jsx": "react-jsx",
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"moduleResolution": "node",
"resolveJsonModule": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"declaration": true,
"declarationMap": true,
"sourceMap": true
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist", "build"]
}交付成果: 类型检查报告
4. Linting (ESLint)
4. 代码检查(ESLint)
Run ESLint:
bash
undefined运行ESLint:
bash
undefinedLint entire codebase
Lint entire codebase
npx eslint "src/**/*.{ts,tsx,js,jsx}"
npx eslint "src/**/*.{ts,tsx,js,jsx}"
Lint with auto-fix
Lint with auto-fix
npx eslint "src/**/*.{ts,tsx,js,jsx}" --fix
npx eslint "src/**/*.{ts,tsx,js,jsx}" --fix
Lint with detailed output
Lint with detailed output
npx eslint "src/**/*.{ts,tsx,js,jsx}" --format=stylish
npx eslint "src/**/*.{ts,tsx,js,jsx}" --format=stylish
Generate HTML report
Generate HTML report
npx eslint "src/**/*.{ts,tsx,js,jsx}" --format=html --output-file=eslint-report.html
**Check Specific Rules:**
```bashnpx eslint "src/**/*.{ts,tsx,js,jsx}" --format=html --output-file=eslint-report.html
**检查特定规则:**
```bashCheck for unused variables
Check for unused variables
npx eslint "src/**/*.ts" --rule '@typescript-eslint/no-unused-vars: error'
npx eslint "src/**/*.ts" --rule '@typescript-eslint/no-unused-vars: error'
Check complexity
Check complexity
npx eslint "src/**/*.ts" --rule 'complexity: ["error", 10]'
npx eslint "src/**/*.ts" --rule 'complexity: ["error", 10]'
Check max lines
Check max lines
npx eslint "src/**/*.ts" --rule 'max-lines: ["error", 500]'
**Configuration (.eslintrc.json):**
```json
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2020,
"sourceType": "module",
"project": "./tsconfig.json"
},
"plugins": ["@typescript-eslint", "prettier"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"prettier"
],
"rules": {
"prettier/prettier": "error",
"@typescript-eslint/explicit-function-return-type": "error",
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-unused-vars": ["error", {
"argsIgnorePattern": "^_"
}],
"complexity": ["error", 10],
"max-lines": ["error", 500],
"max-lines-per-function": ["error", 50],
"no-console": ["warn", {
"allow": ["warn", "error"]
}]
},
"ignorePatterns": ["dist/", "build/", "node_modules/", "*.config.js"]
}Deliverable: Linting report
npx eslint "src/**/*.ts" --rule 'max-lines: ["error", 500]'
**配置文件(.eslintrc.json):**
```json
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2020,
"sourceType": "module",
"project": "./tsconfig.json"
},
"plugins": ["@typescript-eslint", "prettier"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"prettier"
],
"rules": {
"prettier/prettier": "error",
"@typescript-eslint/explicit-function-return-type": "error",
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-unused-vars": ["error", {
"argsIgnorePattern": "^_"
}],
"complexity": ["error", 10],
"max-lines": ["error", 500],
"max-lines-per-function": ["error", 50],
"no-console": ["warn", {
"allow": ["warn", "error"]
}]
},
"ignorePatterns": ["dist/", "build/", "node_modules/", "*.config.js"]
}交付成果: 代码检查报告
5. Security Analysis
5. 安全分析
npm Audit:
bash
undefinednpm审计:
bash
undefinedCheck for vulnerabilities
Check for vulnerabilities
npm audit
npm audit
Detailed audit
Detailed audit
npm audit --json
npm audit --json
Production dependencies only
Production dependencies only
npm audit --production
npm audit --production
Fix vulnerabilities
Fix vulnerabilities
npm audit fix
npm audit fix
Fix including breaking changes
Fix including breaking changes
npm audit fix --force
**Check for Outdated Packages:**
```bashnpm audit fix --force
**检查过时包:**
```bashList outdated packages
List outdated packages
npm outdated
npm outdated
Check specific package
Check specific package
npm outdated typescript
npm outdated typescript
Update packages
Update packages
npm update
**Dependency License Check:**
```bashnpm update
**依赖许可证检查:**
```bashInstall license checker
Install license checker
npm install --save-dev license-checker
npm install --save-dev license-checker
Check licenses
Check licenses
npx license-checker --summary
npx license-checker --summary
Exclude specific licenses
Exclude specific licenses
npx license-checker --exclude "MIT,Apache-2.0"
**Deliverable:** Security analysis report
---npx license-checker --exclude "MIT,Apache-2.0"
**交付成果:** 安全分析报告
---6. Code Complexity Analysis
6. 代码复杂度分析
ESLint Complexity Rules:
bash
undefinedESLint复杂度规则:
bash
undefinedCheck cyclomatic complexity
Check cyclomatic complexity
npx eslint "src/**/*.ts" --rule 'complexity: ["error", 10]'
npx eslint "src/**/*.ts" --rule 'complexity: ["error", 10]'
Check max depth
Check max depth
npx eslint "src/**/*.ts" --rule 'max-depth: ["error", 4]'
npx eslint "src/**/*.ts" --rule 'max-depth: ["error", 4]'
Check max nested callbacks
Check max nested callbacks
npx eslint "src/**/*.ts" --rule 'max-nested-callbacks: ["error", 3]'
**TypeScript-Specific Complexity:**
```bashnpx eslint "src/**/*.ts" --rule 'max-nested-callbacks: ["error", 3]'
**TypeScript特定复杂度分析:**
```bashInstall complexity tool
Install complexity tool
npm install --save-dev ts-complex
npm install --save-dev ts-complex
Analyze complexity
Analyze complexity
npx ts-complexity src/
**Deliverable:** Complexity analysis report
---npx ts-complexity src/
**交付成果:** 复杂度分析报告
---7. Import/Export Validation
7. 导入/导出验证
Check Unused Exports:
bash
undefined检查未使用的导出:
bash
undefinedInstall ts-prune
Install ts-prune
npm install --save-dev ts-prune
npm install --save-dev ts-prune
Find unused exports
Find unused exports
npx ts-prune
npx ts-prune
Exclude specific files
Exclude specific files
npx ts-prune --ignore "index.ts"
**Check Import Order:**
```bashnpx ts-prune --ignore "index.ts"
**检查导入顺序:**
```bashInstall eslint-plugin-import
Install eslint-plugin-import
npm install --save-dev eslint-plugin-import
npm install --save-dev eslint-plugin-import
Add to .eslintrc.json
Add to .eslintrc.json
{
"plugins": ["import"],
"rules": {
"import/order": ["error", {
"groups": [
"builtin",
"external",
"internal",
"parent",
"sibling",
"index"
],
"newlines-between": "always"
}]
}
}
**Deliverable:** Import validation report
---{
"plugins": ["import"],
"rules": {
"import/order": ["error", {
"groups": [
"builtin",
"external",
"internal",
"parent",
"sibling",
"index"
],
"newlines-between": "always"
}]
}
}
**交付成果:** 导入验证报告
---8. Comprehensive Quality Check
8. 全面质量检查
Run All Checks:
bash
#!/bin/bash运行所有检查:
bash
#!/bin/bashscripts/quality-check.sh
scripts/quality-check.sh
set -e # Exit on first error
echo "=== TypeScript Quality Checks ==="
echo "1. Code Formatting (Prettier)..."
npx prettier --check "src/**/*.{ts,tsx,js,jsx}"
echo "2. Type Checking (tsc)..."
npx tsc --noEmit
echo "3. Linting (ESLint)..."
npx eslint "src/**/*.{ts,tsx}" --max-warnings=0
echo "4. Security Audit..."
npm audit --production
echo "5. Unused Exports..."
npx ts-prune || true # Don't fail on unused exports
echo "=== All Quality Checks Passed ✅ ==="
**package.json Scripts:**
```json
{
"scripts": {
"lint": "eslint 'src/**/*.{ts,tsx}' --max-warnings=0",
"lint:fix": "eslint 'src/**/*.{ts,tsx}' --fix",
"format": "prettier --write 'src/**/*.{ts,tsx,json,css,md}'",
"format:check": "prettier --check 'src/**/*.{ts,tsx,json,css,md}'",
"type-check": "tsc --noEmit",
"quality": "npm run format:check && npm run type-check && npm run lint",
"test": "jest",
"test:coverage": "jest --coverage"
}
}Deliverable: Comprehensive quality report
set -e # Exit on first error
echo "=== TypeScript Quality Checks ==="
echo "1. Code Formatting (Prettier)..."
npx prettier --check "src/**/*.{ts,tsx,js,jsx}"
echo "2. Type Checking (tsc)..."
npx tsc --noEmit
echo "3. Linting (ESLint)..."
npx eslint "src/**/*.{ts,tsx}" --max-warnings=0
echo "4. Security Audit..."
npm audit --production
echo "5. Unused Exports..."
npx ts-prune || true # Don't fail on unused exports
echo "=== All Quality Checks Passed ✅ ==="
**package.json脚本:**
```json
{
"scripts": {
"lint": "eslint 'src/**/*.{ts,tsx}' --max-warnings=0",
"lint:fix": "eslint 'src/**/*.{ts,tsx}' --fix",
"format": "prettier --write 'src/**/*.{ts,tsx,json,css,md}'",
"format:check": "prettier --check 'src/**/*.{ts,tsx,json,css,md}'",
"type-check": "tsc --noEmit",
"quality": "npm run format:check && npm run type-check && npm run lint",
"test": "jest",
"test:coverage": "jest --coverage"
}
}交付成果: 全面质量报告
Quality Standards
质量标准
Code Formatting
代码格式化
- All code formatted with Prettier
- Consistent use of semicolons
- Consistent quote style (single/double)
- Trailing commas in multiline
- Line length ≤ 100 characters
- 所有代码使用Prettier格式化
- 一致使用分号
- 一致的引号风格(单引号/双引号)
- 多行代码使用尾随逗号
- 行长度 ≤ 100字符
Type Checking
类型检查
- All functions have return types
- No implicit types
any - Strict null checks enabled
- No unused parameters
- No unused variables
- 所有函数都有返回类型
- 无隐式类型
any - 启用严格空值检查
- 无未使用的参数
- 无未使用的变量
Linting
代码检查
- No ESLint errors
- Max warnings: 0
- Complexity ≤ 10 per function
- Max lines ≤ 500 per file
- Imports properly ordered
- 无ESLint错误
- 最大警告数:0
- 每个函数的复杂度 ≤ 10
- 每个文件的最大行数 ≤ 500
- 导入顺序正确
Security
安全
- No critical vulnerabilities
- No high-severity vulnerabilities
- Dependencies up to date
- Licenses compliant
- No hardcoded secrets
- 无严重漏洞
- 无高危漏洞
- 依赖项保持最新
- 许可证合规
- 无硬编码密钥
Code Quality
代码质量
- Functions < 50 lines
- Files < 500 lines
- Max nesting depth: 4
- Cyclomatic complexity < 10
- No unused exports
- 函数行数 < 50
- 文件行数 < 500
- 最大嵌套深度:4
- 圈复杂度 < 10
- 无未使用的导出
Quality Check Matrix
质量检查矩阵
| Check | Tool | Threshold | Auto-Fix |
|---|---|---|---|
| Formatting | Prettier | Must pass | Yes |
| Type checking | tsc | 0 errors | No |
| Linting | ESLint | 0 errors | Partial |
| Security | npm audit | 0 critical | Partial |
| Complexity | ESLint | ≤ 10 | No |
| Unused exports | ts-prune | Warning only | No |
| 检查项 | 工具 | 阈值 | 自动修复 |
|---|---|---|---|
| 格式化 | Prettier | 必须通过 | 是 |
| 类型检查 | tsc | 0错误 | 否 |
| 代码检查 | ESLint | 0错误 | 部分支持 |
| 安全 | npm audit | 0严重漏洞 | 部分支持 |
| 复杂度 | ESLint | ≤10 | 否 |
| 未使用导出 | ts-prune | 仅警告 | 否 |
Pre-commit Integration
提交前集成
Setup Husky and lint-staged:
bash
undefined设置Husky和lint-staged:
bash
undefinedInstall tools
Install tools
npm install --save-dev husky lint-staged
npm install --save-dev husky lint-staged
Initialize husky
Initialize husky
npx husky-init && npm install
npx husky-init && npm install
Add pre-commit hook
Add pre-commit hook
npx husky add .husky/pre-commit "npx lint-staged"
**Configuration (package.json):**
```json
{
"lint-staged": {
"*.{ts,tsx}": [
"prettier --write",
"eslint --fix",
"tsc-files --noEmit"
],
"*.{json,css,md}": [
"prettier --write"
]
}
}Deliverable: Pre-commit hooks configured
npx husky add .husky/pre-commit "npx lint-staged"
**配置文件(package.json):**
```json
{
"lint-staged": {
"*.{ts,tsx}": [
"prettier --write",
"eslint --fix",
"tsc-files --noEmit"
],
"*.{json,css,md}": [
"prettier --write"
]
}
}交付成果: 提交前钩子已配置
CI/CD Integration
CI/CD集成
GitHub Actions Example:
yaml
undefinedGitHub Actions示例:
yaml
undefined.github/workflows/quality.yml
.github/workflows/quality.yml
name: TypeScript Quality Checks
on: [push, pull_request]
jobs:
quality:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Check formatting
run: npm run format:check
- name: Type checking
run: npm run type-check
- name: Linting
run: npm run lint
- name: Security audit
run: npm audit --production --audit-level=high
- name: Run tests
run: npm test
- name: Check coverage
run: npm run test:coverage
**Deliverable:** CI/CD quality pipeline
---name: TypeScript Quality Checks
on: [push, pull_request]
jobs:
quality:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Check formatting
run: npm run format:check
- name: Type checking
run: npm run type-check
- name: Linting
run: npm run lint
- name: Security audit
run: npm audit --production --audit-level=high
- name: Run tests
run: npm test
- name: Check coverage
run: npm run test:coverage
**交付成果:** CI/CD质量流水线
---Quality Check Troubleshooting
质量检查故障排除
Prettier Formatting Failures
Prettier格式化失败
bash
undefinedbash
undefinedCheck what would change
Check what would change
npx prettier --check --list-different "src/**/*.ts"
npx prettier --check --list-different "src/**/*.ts"
Apply fixes
Apply fixes
npx prettier --write "src/**/*.ts"
npx prettier --write "src/**/*.ts"
Check specific file
Check specific file
npx prettier --check src/index.ts
undefinednpx prettier --check src/index.ts
undefinedTypeScript Type Errors
TypeScript类型错误
bash
undefinedbash
undefinedShow detailed errors
Show detailed errors
npx tsc --noEmit --pretty
npx tsc --noEmit --pretty
Check specific file
Check specific file
npx tsc --noEmit src/component.tsx
npx tsc --noEmit src/component.tsx
Skip lib check (faster)
Skip lib check (faster)
npx tsc --noEmit --skipLibCheck
undefinednpx tsc --noEmit --skipLibCheck
undefinedESLint Violations
ESLint违规
bash
undefinedbash
undefinedShow detailed violations
Show detailed violations
npx eslint "src/**/*.ts" --format=stylish
npx eslint "src/**/*.ts" --format=stylish
Auto-fix safe violations
Auto-fix safe violations
npx eslint "src/**/*.ts" --fix
npx eslint "src/**/*.ts" --fix
Ignore specific line (last resort)
Ignore specific line (last resort)
// eslint-disable-next-line rule-name
undefined// eslint-disable-next-line rule-name
undefinednpm Audit Issues
npm审计问题
bash
undefinedbash
undefinedShow detailed audit
Show detailed audit
npm audit --json
npm audit --json
Fix non-breaking changes
Fix non-breaking changes
npm audit fix
npm audit fix
Override (use with caution)
Override (use with caution)
npm audit fix --force
---npm audit fix --force
---Quality Report Template
质量报告模板
markdown
undefinedmarkdown
undefinedTypeScript Quality Check Report
TypeScript质量检查报告
Summary
摘要
- Status: ✅ All checks passed
- Date: 2024-01-15
- Code Base: src/
- 状态: ✅ 所有检查通过
- 日期: 2024-01-15
- 代码库: src/
Checks Performed
执行的检查
Formatting (Prettier)
格式化(Prettier)
- Status: ✅ PASS
- Files Checked: 87
- Issues: 0
- 状态: ✅ 通过
- 检查文件数: 87
- 问题数: 0
Type Checking (tsc)
类型检查(tsc)
- Status: ✅ PASS
- Files Checked: 87
- Errors: 0
- Warnings: 0
- 状态: ✅ 通过
- 检查文件数: 87
- 错误数: 0
- 警告数: 0
Linting (ESLint)
代码检查(ESLint)
- Status: ✅ PASS
- Files Checked: 87
- Errors: 0
- Warnings: 0
- 状态: ✅ 通过
- 检查文件数: 87
- 错误数: 0
- 警告数: 0
Security (npm audit)
安全(npm audit)
- Status: ✅ PASS
- Dependencies: 342
- Vulnerabilities: 0 critical, 0 high, 2 moderate
- 状态: ✅ 通过
- 依赖项数: 342
- 漏洞数: 0个严重,0个高危,2个中危
Complexity
复杂度
- Status: ✅ PASS
- Average Complexity: 3.8
- Max Complexity: 9
- Files > 10: 0
- 状态: ✅ 通过
- 平均复杂度: 3.8
- 最大复杂度: 9
- 复杂度超10的文件数: 0
Details
详情
All TypeScript quality checks passed successfully. Code is well-formatted, type-safe, lint-free, secure, and maintainable.
所有TypeScript质量检查已成功通过。代码格式规范、类型安全、无代码检查违规、安全可靠且易于维护。
Recommendations
建议
- Continue using strict TypeScript settings
- Keep complexity below 10
- Run pre-commit hooks before commits
- Update moderate-severity vulnerabilities when possible
---- 继续使用严格的TypeScript配置
- 保持复杂度低于10
- 提交代码前运行提交前钩子
- 尽可能更新中危漏洞
---Integration with Code Quality Specialist
与代码质量专家集成
Input: TypeScript/JavaScript codebase quality check request
Process: Run all TypeScript quality tools and analyze results
Output: Comprehensive quality report with pass/fail status
Next Step: Report to code-quality-specialist for consolidation
输入: TypeScript/JavaScript代码库质量检查请求
流程: 运行所有TypeScript质量工具并分析结果
输出: 包含通过/失败状态的全面质量报告
下一步: 将报告提交给code-quality-specialist进行整合
Best Practices
最佳实践
Development
开发阶段
- Enable Prettier on save (IDE integration)
- Enable ESLint in IDE for real-time feedback
- Use strict TypeScript settings
- Fix type errors immediately
- Use pre-commit hooks
- 在IDE中启用Prettier自动保存格式化
- 在IDE中启用ESLint以获取实时反馈
- 使用严格的TypeScript配置
- 立即修复类型错误
- 使用提交前钩子
Pre-Commit
提交前
- Run full quality check script
- Ensure all checks pass
- Fix issues before pushing
- Review security warnings
- 运行完整的质量检查脚本
- 确保所有检查通过
- 推送前修复所有问题
- 查看安全警告
CI/CD
CI/CD
- Run quality checks on every PR
- Fail build on quality violations
- Generate quality reports
- Track quality metrics over time
- 对每个PR运行质量检查
- 质量违规时构建失败
- 生成质量报告
- 随时间跟踪质量指标
Code Review
代码评审
- Verify quality checks passed
- Review type definitions
- Check security scan results
- Validate complexity metrics
- 验证质量检查已通过
- 评审类型定义
- 查看安全扫描结果
- 验证复杂度指标
Supporting Resources
支持资源
- TypeScript: https://www.typescriptlang.org/docs
- ESLint: https://eslint.org/docs
- Prettier: https://prettier.io/docs
- typescript-eslint: https://typescript-eslint.io
- npm audit: https://docs.npmjs.com/cli/v8/commands/npm-audit
- TypeScript: https://www.typescriptlang.org/docs
- ESLint: https://eslint.org/docs
- Prettier: https://prettier.io/docs
- typescript-eslint: https://typescript-eslint.io
- npm audit: https://docs.npmjs.com/cli/v8/commands/npm-audit
Success Metrics
成功指标
- All code formatted with Prettier
- All type checks passing
- Zero linting violations
- No critical security issues
- Complexity under threshold
- All quality checks automated
- 所有代码使用Prettier格式化
- 所有类型检查通过
- 零代码检查违规
- 无严重安全问题
- 复杂度低于阈值
- 所有质量检查自动化