feat: surface fix convergence warnings (#98) - #100
Merged
Conversation
Adapt @lint-md/core 2.1.5 (core #182) FixedResult.convergence (stable | cycle | max) in the CLI: - Report cycle / max as a stderr warning after the fix pass; exit code remains 0 (quality signal, not a hard error). - keepLintItem now also retains cycle / max items so the warning has a target; older cores that predate the field are unaffected (undefined === not incomplete). - --dev prints one Fix metrics line per file from the main thread to avoid interleaving with worker output. - stdin --fix reuses the same warning helper, writing the warning to stderr after the fixed Markdown is written to stdout. --fail-on-incomplete-fix is intentionally out of scope and tracked separately.
Follow-up to #100. - Drop the per-worker 'File 耗时' log and the LintWorkerOptions.isDev field; the worker no longer writes to stdout/stderr directly, which removes the multi-worker log interleaving, the duplicate-metric problem, and the unsanitized filePath terminal/CI injection. - batchLint now returns { allResults, actionableResults }: * allResults keeps every file (including clean ones) for --dev fix metrics, so perf diagnostics are no longer silently filtered. * actionableResults is the keepLintItem-filtered view used for I/O, warnings, and reporting. - --stdin --fix --dev now writes fix metrics to stderr (stdout stays pure Markdown) using the same helper as the file path. - keepLintItem tests now cover fixedResult: null and fixedResult: undefined, not just the 'no overrides' case that always built an empty FixedResult.
Contributor
Author
|
跟进 #100 评审反馈,P2-A/B/C + P3 全部处理: P2-A:删除 worker 旧 dev 日志
P2-B:stdin --dev 也输出 metrics
P2-C:干净文件不被 keepLintItem 过滤
P3:测试名实不符
验证
|
Follow-up to #100 review. The previous commit trimmed the test file to focus on the new batchLint signature, but in doing so deleted regression tests for getMaxFileSize, resolveAdaptiveConcurrency, and STAT_CONCURRENCY_LIMIT that pre-date this PR. The current 'clamps large file paths to a single thread' test only used a single file, so the file-count clamp made it pass even if the 5 MiB threshold logic broke. Restore all 9 original describe blocks and adapt only the 10 batchLint call sites to the new (threads, files, isFixMode, rules) signature returning { allResults, actionableResults }. This PR's contract is convergence + metrics; concurrency, file-size boundaries, and stat() backpressure are out of scope but must remain under test.
Contributor
Author
|
跟进评审 P1 反馈。承认:上一版删减 恢复范围(
只动 batchLint 调用处(10 处) 为什么那个 验证
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
适配 core #182(已随 @lint-md/core 2.1.5 发布)
FixedResult新增convergence: 'stable' | 'cycle' | 'max'可选字段。CLI 之前只读fixedResult.result,对未知字段天然兼容;本 PR 是功能增强而非兼容修复。行为
--fix通过后输出 stderr 警告,文案:[lint-md] Fix did not fully converge for <path>: cycle.路径经
sanitizeTerminalText清洗。默认不改变退出码(属质量警告,非硬错误)。-dev指标:主线程拿到BatchLintItem[]后输出,避开 worker 多线程日志交错:[lint-md] Fix metrics: <path>: convergence=<x>, rounds=<n>, wallTime=<x.xx>ms关键决定
keepLintItem增加isIncompleteFix(item)分支。显式判定convergence === 'cycle' | 'max',不使用convergence !== 'stable'——后者会让 pre-#182 core(convergence 为 undefined)被全部保留,破坏旧过滤语义。isIncompleteFix用 core 暴露的FixConvergence枚举做白名单,避免把中文文案当 API。--fail-on-incomplete-fix不在本 PR 范围,留作后续 issue:它会引入新的 CLI 契约、帮助文本与 CI 行为测试,与本期安全可观测性增强分开评审更稳。验证
npm run build && npm test:15 套件 / 133 用例全过npm run lint(tsc --noEmit + prettier --check):通过__tests__/report-incomplete-fixes.spec.ts(11 用例)与__tests__/keep-lint-item.spec.ts(7 用例),全部用构造BatchLintItem——不依赖无法序列化函数的.lintmdrcE2E,符合 issue 要求report-incomplete-fixes.ts100%文件
src/utils/report-incomplete-fixes.ts__tests__/report-incomplete-fixes.spec.ts、__tests__/keep-lint-item.spec.tssrc/utils/batch-lint.ts、src/lint-md.ts(2 处串入点)Closes #98