docfy lint
检查文档质量,而不只是检查是否存在。能捕捉到 check 和 coverage 不会标记出来的、不完整的 ApiOperation、ApiResponse 和 ApiBody 装饰器。
用法
bash
npx nestjs-docfy lint [options]选项
| Option | Default | Description |
|---|---|---|
--root <path> | . | Project root directory |
--tsconfig <path> | auto-detected | Path to tsconfig.json |
--pattern <glob> | **/*.controller.ts | Glob pattern to find controllers |
--format <format> | ts | 要查找的 docs 文件格式:ts 或 js |
--quiet | false | Suppress all output except errors |
检查内容
对 docs 文件中已经存在的每个方法:
ApiOperation缺少summary- 带
@Body()参数的端点缺少ApiResponse400 - 带
@Body()参数的端点缺少ApiBody的description
没有 companion 文件的控制器,或者尚未文档化的方法,都留给 check 去处理;lint 只评判已有内容的质量。
输出示例
text
✖ POST /users
Missing 400 response
✖ GET /users
Missing operation summary
✖ PATCH /users/:id
Missing request body description
✖ 3 issue(s) found.发现任何问题时以退出码 1 结束,专为 CI 设计,和 check 一致。
.github/workflows/*.yml
# GitHub Actions example
- name: Lint documentation quality
run: npx nestjs-docfy lint