lint-and-validate
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseLint 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
- Lint/Fix: or
npm run lintnpx eslint "path" --fix - Types:
npx tsc --noEmit - Security:
npm audit --audit-level=high
- 代码检查/修复: 或
npm run lintnpx eslint "path" --fix - 类型检查:
npx tsc --noEmit - 安全检查:
npm audit --audit-level=high
Python
Python
- Linter (Ruff): (Fast & Modern)
ruff check "path" --fix - Security (Bandit):
bandit -r "path" -ll - Types (MyPy):
mypy "path"
- 代码检查工具(Ruff): (快速且现代化)
ruff check "path" --fix - 安全检查(Bandit):
bandit -r "path" -ll - 类型检查(MyPy):
mypy "path"
The Quality Loop
质量循环流程
- Write/Edit Code
- Run Audit:
npm run lint && npx tsc --noEmit - Analyze Report: Check the "FINAL AUDIT REPORT" section.
- Fix & Repeat: Submitting code with "FINAL AUDIT" failures is NOT allowed.
- 编写/编辑代码
- 运行审核:
npm run lint && npx tsc --noEmit - 分析报告: 查看「最终审核报告」部分。
- 修复并重复: 不允许提交未通过「最终审核」的代码。
Error Handling
错误处理
- If fails: Fix the style or syntax issues immediately.
lint - If fails: Correct type mismatches before proceeding.
tsc - If no tool is configured: Check the project root for ,
.eslintrc,tsconfig.jsonand suggest creating one.pyproject.toml
Strict Rule: No code should be committed or reported as "done" without passing these checks.
- 若检查失败:立即修复样式或语法问题。
lint - 若检查失败:在继续之前修正类型不匹配问题。
tsc - 若未配置任何工具:检查项目根目录下的、
.eslintrc、tsconfig.json文件,并建议创建相应配置文件。pyproject.toml
**严格规定:**未通过这些检查的代码不得提交或标记为「已完成」。
Scripts
脚本工具
| Script | Purpose | Command |
|---|---|---|
| Unified lint check | |
| Type coverage analysis | |
| 脚本 | 用途 | 命令 |
|---|---|---|
| 统一代码检查 | |
| 类型覆盖率分析 | |