zero-tolerance-doctrine: noImplicitAny reported missing when strict is true

未关闭 适合新手
#506 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
72/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
typescript
领域
devtools

调研方向

false 的发现来自对 src/checkers/sacred-laws/zero-tolerance.ts 中 compilerOptions.strict 和 compilerOptions.noImplicitAny 的两项独立检查,所以请从那里开始。阅读现有检查如何处理 strict,然后思考 noImplicitAny 未设置与显式设为 false 时的区别。完成标准是:包含 strict: true 且没有 noImplicitAny 的测试夹具不产生任何发现,而包含 strict: true, noImplicitAny: false 的夹具仍然产生发现。

由索引模型根据 Issue 内容生成。

描述

bug

Version: develop, and #503 (bugfix/486-foreign-json-reader)
Law: Zero Tolerance Doctrine (SACRED LAW): src/checkers/sacred-laws/zero-tolerance.ts

What happens

The law reports TypeScript noImplicitAny not enabled for a tsconfig that sets "strict": true and does not repeat "noImplicitAny": true. strict turns noImplicitAny on, so the finding is false.

develop, zero-tolerance.ts:

if (!tsConfig || !compilerOptions.strict) {
  violations.push('TypeScript strict mode not enabled');
}
if (!tsConfig || !compilerOptions.noImplicitAny) {
  violations.push('TypeScript noImplicitAny not enabled');
}

#503 reads the extends chain, but it keeps the same two independent checks (for (const [flag, finding] of [['strict', …], ['noImplicitAny', …]])).

Reproduction

A project whose tsconfig.json is { "compilerOptions": { "strict": true } } gets TypeScript noImplicitAny not enabled.

What I ruled out

This repository's own self-audit is not affected, because its tsconfig sets both flags explicitly. I have only read the code path above and have not built a fixture yet.

Suggested direction

Treat noImplicitAny as enabled when it is true, or when it is unset and strict is true. Only an explicit "noImplicitAny": false should be reported. strictModeOf in #503's src/utils/tsconfig-chain.ts already models this "strict implies" rule the other way round. Red/green: a fixture with strict: true and no noImplicitAny produces no finding, and one with strict: true, noImplicitAny: false still produces it.

主要语言
TypeScript
星标
0
派生
0
平均合并
2 小时 36 分钟
30 天内合并 PR
168

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

Rule-Of-Code/RoC 的其他 Issue

查看 Rule-Of-Code/RoC 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。