@geoql/doctor-core
背后的审计引擎
@geoql/vue-doctor财务报告和审定财务报表@geoql/nuxt-doctor。 。 。 .
这是图书馆的工作。 两个CLI很薄 cac 包装;一切真实生活在这里:混合扫描,评分,记者,配置加载,以及项目检测. 您通常依赖CLI,而不是直接依赖此软件包. 到达 doctor-core 只有在你把审计嵌入你自己的工具时.
它会做什么
doctor-core 运行 a 混合双通扫描 超过 Vue 3 或 Nuxt 4 项目, 锁定在 docs/SPEC.md 第10节:
- 传出 1 — 模板 AST. 参数
.vue带有@vue/compiler-sfc,并在程序中行走模板 AST。 这是唯一能看见模板的通路,所以模板形状的规则(v-for缺少:key, (中文(简体) ),v-if编号 :v-for在同一节点上,列表中的内置对象道具)在这里活. - 传出 2 — 脚本 ESTree. 双胞胎
oxlint作为针对生成的子进程.oxlintrc.json打开牛林的本土vue插件加医生 JS 插件(@geoql/oxlint-plugin-vue-doctor, (中文(简体) ),@geoql/oxlint-plugin-nuxt-doctor. 牛林只手插 JS 所取出<script>,所以所有脚本级别的规则都在这里运行.
两个通行证的诊断结果合并并解开 (file, line, column, ruleId),然后崩溃成决定性的0-100分. 定重权重(error =5个, warn =2个, info = 0.5) 对累犯进行减分,所以一个吵闹的规则不能把整个分数压入. 同一码入,同分出:无随机分出,无相通相克分出.
它也拥有 CLI 表面的棋子: 配置加载器( :doctor.config.ts 通过 c12),用于闸门规则,规则登记册,以及每个记者格式的项目/能力检测.
安装
npm i @geoql/doctor-core
发表于 无 财务报告和审定财务报表 日 尔 与出处。 仅限无害环境管理. knip 财务报告和审定财务报表 oxlint 是同伴的依赖关系(死码和脚本向它们传递 shell).
API 密码
主要条目是 audit()。它返回载有诊断、数值分数、分数分数、检测到的项目信息以及进程退出代码的报告.
import { audit, format } from '@geoql/doctor-core';
const report = await audit({
rootDir: process.cwd(),
include: ['**/*.vue', '**/*.ts'],
exclude: ['node_modules', 'dist', '.nuxt', '.output'],
failOn: 'error',
});
for (const d of report.diagnostics) {
console.log(
`${d.file}:${d.line}:${d.column} ${d.severity} ${d.ruleId}: ${d.message}`,
);
}
console.log(`Score: ${report.score}/100`);
console.log(`Exit code: ${report.exitCode}`);
// Render any reporter format. `format()` takes a ReporterInput,
// which you assemble from the report.
process.stdout.write(
format(
{
toolName: '@geoql/vue-doctor',
toolVersion: '0.1.0',
rootDirectory: report.rootDir,
analyzedFileCount: report.filesScanned,
elapsedMs: report.elapsedMs,
diagnostics: report.diagnostics,
score: report.scoreResult,
projectInfo: report.projectInfo,
},
'agent',
),
);
严重性是 error | warn | info 整个. failOn 接受 error | warn | none。 。 。 .
主要出口
| 导出 | 目的 |
|---|---|
audit | 进行"双通"扫描,并返回完整报告. |
format | 将报告作为 agent, (中文(简体) ), pretty, (中文(简体) ), json, (中文(简体) ), json-compact, (中文(简体) ), sarif,或 html。 。 。 . |
loadDoctorConfig, (中文(简体) ), defineConfig, (中文(简体) ), mergeCliOverrides | 装入 doctor.config.ts (通过) c12)和上层 CLI 覆盖. |
detectProject | 检测门规则所用的框架、版本和能力标志. |
listRules, (中文(简体) ), RULE_REGISTRY, (中文(简体) ), loadRuleDoc | 检查规则登记处和规则文件. |
scoreDiagnostics | 与分解决定分出0-100分. |
listChangedFiles | 为渐进运行解析 diff/ stated 文件范围 . |
encodeAnnotations | 释放 GitHub 动作 ::error:: 编号 : ::warning:: 线条. |
船舶类型AuditConfig, (中文(简体) ), AuditReport, (中文(简体) ), Diagnostic, (中文(简体) ), Severity, (中文(简体) ), ReporterFormat, (中文(简体) ), ProjectInfo, (中文(简体) ), ScoreResult(还有更多).
范围
Vue 3和Nuxt 4仅限. Nuxt 检测预期 app/ 目录布局 compatibilityVersion: 4。 。 。 .
建筑
见 docs/SPEC.md §10 对于完整的 二通道设计, 经验性的牛林发现 塑造它,和犬科 Diagnostic 形状.
许可证
麻省理工学院