lint-and-validate

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Lint and Validate Skill

Lint 与 Validate 代码检查与验证

MANDATORY: Run appropriate validation tools after EVERY code change. Do not finish a task until the code is error-free.
**强制要求:**每次修改代码后运行相应的验证工具。代码无错误前不得完成任务。

Procedures by Ecosystem

各技术栈操作流程

Node.js / TypeScript

Node.js / TypeScript

  1. Lint/Fix:
    npm run lint
    or
    npx eslint "path" --fix
  2. Types:
    npx tsc --noEmit
  3. Security:
    npm audit --audit-level=high
  1. 代码检查/修复:
    npm run lint
    npx eslint "path" --fix
  2. 类型检查:
    npx tsc --noEmit
  3. 安全检查:
    npm audit --audit-level=high

Python

Python

  1. Linter (Ruff):
    ruff check "path" --fix
    (Fast & Modern)
  2. Security (Bandit):
    bandit -r "path" -ll
  3. Types (MyPy):
    mypy "path"
  1. 代码检查工具(Ruff):
    ruff check "path" --fix
    (快速且现代化)
  2. 安全检查(Bandit):
    bandit -r "path" -ll
  3. 类型检查(MyPy):
    mypy "path"

The Quality Loop

质量循环流程

  1. Write/Edit Code
  2. Run Audit:
    npm run lint && npx tsc --noEmit
  3. Analyze Report: Check the "FINAL AUDIT REPORT" section.
  4. Fix & Repeat: Submitting code with "FINAL AUDIT" failures is NOT allowed.
  1. 编写/编辑代码
  2. 运行审核:
    npm run lint && npx tsc --noEmit
  3. 分析报告: 查看「最终审核报告」部分。
  4. 修复并重复: 不允许提交未通过「最终审核」的代码。

Error Handling

错误处理

  • If
    lint
    fails: Fix the style or syntax issues immediately.
  • If
    tsc
    fails: Correct type mismatches before proceeding.
  • If no tool is configured: Check the project root for
    .eslintrc
    ,
    tsconfig.json
    ,
    pyproject.toml
    and suggest creating one.

Strict Rule: No code should be committed or reported as "done" without passing these checks.

  • lint
    检查失败:立即修复样式或语法问题。
  • tsc
    检查失败:在继续之前修正类型不匹配问题。
  • 若未配置任何工具:检查项目根目录下的
    .eslintrc
    tsconfig.json
    pyproject.toml
    文件,并建议创建相应配置文件。

**严格规定:**未通过这些检查的代码不得提交或标记为「已完成」。

Scripts

脚本工具

ScriptPurposeCommand
scripts/lint_runner.py
Unified lint check
python scripts/lint_runner.py <project_path>
scripts/type_coverage.py
Type coverage analysis
python scripts/type_coverage.py <project_path>
脚本用途命令
scripts/lint_runner.py
统一代码检查
python scripts/lint_runner.py <project_path>
scripts/type_coverage.py
类型覆盖率分析
python scripts/type_coverage.py <project_path>