Repository navigation
chore: enforce explicit lint rules as errors and freeze existing findings - #5023
Conversation
lint-staged ran `oxlint --fix --quiet` before the type-aware check. `--quiet` only hides warnings: fixes from warn-level rules were still applied and staged into the commit without any output. Some of those fixes change behavior, e.g. unicorn/no-array-sort rewrites `xs.sort()` to `xs.toSorted()`, so callers relying on the in-place sort break. The type-aware step already runs every rule, so dropping the fix step only removes the silent rewrite. Errors still block the commit.
… lint pnpm lint now runs oxlint (errors only), the agent-core-v2 import boundary check, and scripts/checks/guards.mjs. The guards fail when the effective oxlint config drifts from the committed snapshot, when a registered check stops being invoked where it is registered, or when the pre-commit hook passes --fix again. CI runs the guards' tests in the lint job. The boundary check passed on main but nothing ran it, although AGENTS.md says it enforces the remote executor layering. check-service-naming.mjs is removed: no command or workflow ran it, half of its scan roots no longer exist, and no AGENTS.md rule refers to its naming convention. AGENTS.md and CONTRIBUTING now say how to run lint, that lint:fix is not a formatter, and that some of its fixes change behavior.
Upgrade oxlint 1.59.0 -> 1.94.0 and oxlint-tsgolint 0.20.0 -> 7.0.2007 (1.94 requires tsgolint >= 7.0.2007). With the config unchanged, the upgrade enabled new rules through the enabled categories, including vitest rules for test files that --print-config does not show, and started applying import/extensions options that 1.59 never reported: 1,176 errors and 34,910 warnings (before: 0 and 2,801). This change keeps what lint reports unchanged: - Turn off the 14 newly enabled rules that already report on existing code until the lint restructure decides each one. Newly enabled rules without findings stay on. - Allow `.js` import specifiers in minidb, klient, migration-legacy and one acp-server test helper, which 1.59 did not report. - Teach vitest/expect-expect the repository's assertion helpers (expect*, assert*, *.expect*) instead of turning it off. - Remove ten imports that were only re-exported from their source module, and rename two unicorn/no-thenable directives that 1.94 no longer matched. The guards now add the category rules of plugins enabled only in an override and compare every top-level key of the printed config, so the snapshot records changes like the hidden vitest rules. The pnpm dependency hash in flake.nix still needs the value reported by the Nix build.
All rule categories are now off and each enabled rule is listed in .oxlintrc.json as an error: 165 rules, plus 16 vitest rules for test files. The 1.94 upgrade moved rules between categories and enabled vitest rules that --print-config does not show, so with categories on an oxlint upgrade could change the rule set without this file changing. The rules come from the upstream recommended configs (eslint, typescript-eslint) or report bug patterns. All rules that were errors stay errors, and the 62 newly enabled ones have no findings today. The plugins list now includes oxc. Listing plugins replaces oxlint's defaults and the list had left oxc out, so oxlint's own bug detectors (const-comparisons, erasing-op and others) never ran. The warn level is gone: lint and the pre-commit hook run with --deny-warnings. Former warn rules are either errors now, off as style, or will be frozen at their current findings by a follow-up change. Rules kept off on purpose are listed with the reason.
Remove 82 disable directives that no rule uses, checked against the full rule set: the enabled rules plus the rules a follow-up change freezes at their current findings. - 54 Event2 headers also named eslint-plugin-import/namespace, which no config enables. The no-unsafe-declaration-merging suppression and its reason stay. - 27 standalone directives and one trailing directive suppressed rules that are off: style rules, rules the team keeps off, or rules whose checks no longer report the line. Five directives that only suppress rules frozen by the follow-up stay, including the documented switch-exhaustiveness exception in the TUI notify controller. Only comments change.
…count Thirty-two rules that report bugs or bug-prone patterns already have findings in existing code, and fixing those changes behavior. Instead of leaving them off, .oxlintrc.ratchet.json turns them on over the main config and scripts/checks/ratchet.mjs holds each file to its current count: 1,542 findings in 429 files. Frozen rules include no-explicit-any (outside tests), switch exhaustiveness, empty blocks, in-place array sort, || where ?? may be meant, console calls in packages/*/src and apps/*/src, conditional expects and skipped tests. The check fails when a file gains findings (listing its locations), when the baseline allows more than the code has, when a disable directive suppresses nothing with all rules on, and when the ratchet config's ignorePatterns drift from the main config, since extends does not carry them over. --update only lowers the baseline; raising it needs --allow-increase. pnpm lint runs the check and the registry keeps it wired. The pre-commit hook and editors keep using the main config.
Remove 91 explicit type arguments that equal the type parameter's default, in 16 files, and enforce typescript/no-unnecessary-type-arguments. Type arguments are erased at compile time, so runtime behavior does not change; type-checking passes for every project CI checks.
Remove `| undefined` from 31 optional parameters in 8 files, where the `?` already allows undefined, and enforce typescript/no-duplicate-type-constituents. All 31 sites are function or method parameters, including methods of the node-sdk and oauth packages; parameter types are unaffected by exactOptionalPropertyTypes, so the published signatures stay equivalent.
Change 11 let declarations that are never reassigned to const, which does not change behavior, and freeze eslint/prefer-const in the ratchet for the other 41. Those declare a binding early and assign it later (for example a TUI referenced by closures created before it exists); making them const means moving the declaration, which can change when the value is first read.
Merge 59 duplicate imports in 46 files into one statement per module and enforce import/no-duplicates. Under verbatimModuleSyntax a declaration that is not `import type` still loads its module, so every touched file was checked: the set of modules loaded at runtime is unchanged for all 1,293 imports. Merged statements follow the existing layout: one line up to 100 characters, otherwise one specifier per line.
Applying this rule's fixes removed 1,135 assertions and broke type-checking with 97 errors in 41 files: assertions it reports as unnecessary are needed by tsc in this codebase, mostly for index-signature access and properties absent from the declared type. Its findings are not reliable here, so the rule stays off with the reason in .oxlintrc.json.
AGENTS.md now lists what pnpm lint runs, forbids editing the ratchet config or raising its baseline to get a passing run, says how a needed disable directive gives its reason, and explains that rules frozen in the ratchet must not gain findings and that the baseline is lowered after fixing them. CONTRIBUTING describes the ratchet in pnpm lint.
Resolve the conflicts with the comment check from #5019: - package.json and ci.yml: keep the comment check in pnpm lint and lint-staged, and its tests in CI, next to the new lint steps. lint-staged runs the comment check and then oxlint --type-aware --deny-warnings. - pnpm-lock.yaml: main's lockfile plus the oxlint upgrade. - scripts/check-service-naming.mjs: stays deleted. - Five source files: drop both the explanatory comments that main removed and the disable directives that this branch removed because they no longer suppress anything. - openai-responses/decode.ts: keep the merged import, without the file header comment.
Register the comment check in pnpm lint and lint-staged, and its tests in CI, in the wiring registry, so the guards report it if it is unwired. List it in the pnpm lint descriptions in AGENTS.md and CONTRIBUTING. Empty catch blocks used to carry a comment such as `// ignore`, which eslint/no-empty accepts. #5019 removed those comments and comments are no longer allowed, so after the merge the rule reported 116 more findings, all of them empty catch blocks, and new code had no way to write one. Allow empty catch blocks instead of freezing them. The rule has two findings left, both empty for-await loops in tests, and the ratchet baseline drops from 1,583 findings in 442 files to 1,412 in 368. Also reword a config comment that still called the lint restructure a future step.
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
commit: |
|
❌ Nix build failed Hash mismatch in
Please update |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3d72dd690b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
The oxlint and oxlint-tsgolint upgrade changed pnpm-lock.yaml, so the fixed-output hash of pnpmDeps no longer matched and `nix build .#kimi-code` failed. Use the hash that the CI build reported.
ToolBubble returned null for non-tool messages before it called useState, so its hook order depended on the message role, which React does not allow. Call useState first. Tool messages start with the same state as before.
Remove five rules from the ratchet and record why in .oxlintrc.json: - unicorn/require-post-message-target-origin: every call here is a Worker, MessagePort, or VS Code webview postMessage, which takes no target origin. - eslint/no-promise-executor-return: every finding was a one-line executor such as `new Promise((resolve) => setTimeout(resolve, ms))`. - eslint/no-unmodified-loop-condition: every finding was a compound condition whose other operand changes in the loop, or a flag that a callback sets while the loop awaits. - eslint/no-loop-func: every finding was a callback that runs within the same iteration or shares state with the loop on purpose. - typescript/prefer-nullish-coalescing: its fix turns || into ??, which changes the result for '' and 0, and many || here fall back on an empty string on purpose. Add three rules that have no findings today: eslint/radix, unicorn/no-abusive-eslint-disable, so every disable directive names the rules it disables, and react/rules-of-hooks for the two React apps. Freeze typescript/no-deprecated at its current count so new code does not add more uses of deprecated APIs, most of them zod 3 ones. In tests, freeze no-unused-vars and no-unsafe-optional-chaining instead of exempting tests from them. The ratchet now freezes 31 rules at 1,629 findings in 422 files. lint:fix only runs the main config, which no longer has the rules behind the old `||` to `??` and `sort()` to `toSorted()` examples. Replace them in AGENTS.md, CONTRIBUTING, and the wiring registry with one that applies.
Resolve the conflict in packages/agent-core-v2/src/agent/prompt/promptEvents.ts: keep main's PromptOrigin import and this branch's narrower disable directive, which no longer lists eslint-plugin-import/namespace.
The 2.6.3 release sync removed the code in idle-notification-repro.test.ts that used one of its imports, so the ratchet reported a new unused import. Drop createMockProvider and the TestAgentOptions type from the harness import, which still loads the same module, and lower the baseline for that file and for the two findings the release sync fixed.
oxlint reports the react hooks rules under the react-hooks prefix while the config names them react/..., so the ratchet dropped those findings without a word: a frozen react/exhaustive-deps would never have been counted or enforced. Map that prefix, and fail with a clear message on any finding that matches no rule in the ratchet config instead of skipping it.
…s rules Freeze these rules in the ratchet without changing existing code: - all files: use-unknown-in-catch-callback-variable (108), import/no-named-as-default-member (27), oxc/no-accumulating-spread (8) and no-unnecessary-template-expression (5); - typed source only (packages/*/src, apps/*/src, apps/vis/*/src and apps/vscode/webview-ui/src; tests, JS scripts and bench excluded): no-unsafe-argument, no-unsafe-call, no-unsafe-member-access, no-unsafe-assignment and no-unsafe-return (317 together) and no-unnecessary-type-parameters (32); - the React apps: react/exhaustive-deps (7). Add 18 React correctness rules that have no findings to the React override. Move six rules from "off for now" to "off on purpose", with the reason found when sampling their findings: no-unsafe-type-assertion, no-unnecessary-condition, require-await, no-invalid-void-type, no-dynamic-delete and no-confusing-void-expression. The ratchet now freezes 42 rules at 2,129 findings in 538 files.
|
Codex Review: Didn't find any major issues. Keep them coming! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Requirement or Bug
没有对应的 issue。现状有三个问题:
pnpm lint在 main 上输出两千多条 warning,但 warning 从不让 CI 失败,没人处理;agent 在本地跑 lint 时,这些输出全部进入上下文。plugins列表还让 oxlint 自带的 bug 检测插件oxc一直没有运行。AGENTS.md写着 remote executor 的边界「由lint:imports强制」,但它不在任何命令或 CI 里。pre-commit 自动改写代码的问题已经由 #5019 解决。这个 PR 在它的基础上,让 hook 里的 oxlint 和 CI 保持同样的严格度。
这个 PR 之后:lint 只有 error 一档,每条规则显式列出;已有违规的规则冻结存量、拦住新增;lint 配置和各道检查(包括 #5019 的注释检查)的接线由守卫保护。
Bug Reproduction Steps
只针对第 2 个问题里的 oxc 插件,在
main上:在仓库根目录新建
t.ts:运行
pnpm exec oxlint t.ts:没有 error,尽管这个Error创建了却没有抛出。在
.oxlintrc.json的plugins里加上"oxc"后再运行:oxc(missing-throw)报出这一行。Root Cause
.oxlintrc.json里的plugins会替换 oxlint 的默认插件集合,而列表里没有oxc,所以oxc的规则一条都没有启用(--print-config里也没有)。根本修复:把oxc加回插件列表,并逐条写出要开启的 oxc 规则。Code Changes
核心思路:把 lint 从「整类开启、一半是 warn」改成「每条规则显式写成 error」。已有违规、而且修复可能改变行为的规则不改代码,而是由一个棘轮按文件冻结现有数量:新代码不许增加,修掉以后基线只降不升。lint 自身的配置和各道检查的接线由守卫脚本保护,任何变化都会出现在 diff 里。
flowchart LR subgraph lint["pnpm lint(CI 的 lint job 运行它)"] Z["check-comments.mjs<br/>注释检查"] --> A["oxlint --type-aware --deny-warnings<br/>.oxlintrc.json:170 条 error 规则"] A --> B["agent-core-v2 import 边界检查"] B --> C["guards.mjs<br/>配置快照 + 接线清单"] C --> D["ratchet.mjs<br/>主配置 + 42 条冻结规则"] end H["pre-commit:lint-staged"] --> Y["check-comments.mjs"] Y --> E["oxlint --type-aware --deny-warnings<br/>只检查,不修复"] C --> G[("baselines/oxlint-config.json<br/>生效配置快照")] D --> F[("baselines/oxlint-ratchet.json<br/>每个文件每条规则的数量")]主配置是唯一会拦住编辑器和 pre-commit 的配置,所以只放现在 0 违规的规则;冻结规则放在单独的棘轮配置里,只在
pnpm lint和 CI 中运行,这样日常编辑和提交不受存量违规干扰。规则的取舍参考了几个同类 TypeScript 开源项目的 lint 配置:被两个以上项目共同使用、而这里没有开启的通用规则,都是有意关闭并写明了原因的;剩下的差距在项目自定义的分层禁令上,留给后续改动。
关键决策
--print-config看不到,一下子多出 589 个 error)。逐条写出后,升级不会再悄悄改变规则集合--suppress-all等开关在帮助和文档里是隐藏的,官方给可能的破坏性变更留了余地.oxlintrc.ratchet.jsonrequire-post-message-target-origin的 9 处全是 Worker 和 webview 的postMessage;no-promise-executor-return的 33 处全是new Promise((r) => setTimeout(r, ms))一类写法;no-unmodified-loop-condition和no-loop-func的发现也都不是 bug。prefer-nullish-coalescing会推动把||改成??,在空串和 0 上改变行为no-unsafe-*等)expect.any()和 mock。限定范围后冻结 317 处;新代码通常只要先标成unknown再收窄no-unnecessary-condition抽查的 39 处里,有 21 处守护的是类型没有建模的运行时状态(取消信号、外部 JSON);require-await要防的漏写 await,已被no-floating-promises等规则覆盖react-hooks(...),和配置里的react/...对不上,原来会被静默丢弃no-deprecated冻结在现有的 136 处--allow-increase更新基线catch块no-empty加上allowEmptyCatch: true// ignore这类注释,以后也不能再写注释,所以新代码没有办法写出合法的空 catch。新增的 116 处全是空 catch;放开后这条规则只剩 2 处,都是测试里空的for await循环no-unnecessary-type-assertionAGENTS.md里提示先pnpm installverify-deps-before-run=errorpnpm build);而且在这个仓库里,只要 touch 一下package.json就会误报 overrides 过期ratchet.mjs --update--allow-increase,并在 PR 里说明代价:
pnpm lint在本地从约 6 秒变成约 10 秒,多出来的主要是棘轮那一次类型感知运行。不在这个 PR 里:两条自写规则(禁止
as unknown as T、禁止条件展开空对象,用 oxlint 的 JS 插件实现)和 TypeScript 的noImplicitReturns,留给后续改动。后者现在会报 45 处,都在 agent-core-v2 和 core;而有 9 个项目通过路径映射直接编译这两个包的源码,所以没法只对这两个包关掉,要先把这 45 处改成显式返回。阅读指南
.oxlintrc.json:完整规则集,按插件分组;末尾两组是「暂缓」和「有意关闭」,都写了理由。.oxlintrc.ratchet.json和scripts/checks/ratchet.mjs:冻结哪些规则、怎么比对、失败时怎么提示。scripts/checks/guards.mjs和scripts/checks/registry.json:配置快照(包括隐式开启的规则)和接线清单,清单里也登记了注释检查。scripts/checks/*.test.mjs:26 个测试,由 CI 的 lint job 运行。可以略读:两个生成的基线 JSON、
pnpm-lock.yaml,以及下面折叠块里的机械改动。改动后的规则一览
规则分四层,越靠前拦得越早:
.oxlintrc.jsonapps/vis/web、apps/vscode/webview-ui).oxlintrc.ratchet.jsonpnpm lint和 CI另外 19 条有意关闭或暂缓,原因写在配置里,见下面最后一个折叠块。
前三层的 205 条规则,按防的问题分组:
eslint/no-self-compare、oxc/const-comparisons、eslint/no-dupe-else-iftypescript/no-floating-promises、typescript/no-misused-promises、typescript/await-thenabletypescript/no-non-null-asserted-optional-chain、typescript/no-unsafe-enum-assignment、typescript/no-duplicate-type-constituentsimport/no-cycle、import/no-self-import、import/no-duplicatestypescript/only-throw-error、eslint/preserve-caught-error、oxc/missing-throweslint/no-invalid-regexp、eslint/no-misleading-character-class、oxc/bad-replace-all-argunicorn/no-instanceof-array、unicorn/no-array-fill-with-reference-type、oxc/uninvoked-array-callbackthis用错eslint/no-var、eslint/no-const-assign、eslint/no-this-before-supereslint/no-implied-eval、eslint/no-global-assign、eslint/no-callertypescript/ban-ts-comment、typescript/prefer-ts-expect-error、unicorn/no-abusive-eslint-disablereact/rules-of-hooks、react/jsx-key、react/no-direct-mutation-statevitest/no-focused-tests、vitest/expect-expect、vitest/no-identical-title完整清单:立即生效的 205 条规则
逻辑写错(36 条)
eslint/eqeqeq:==/!=会做隐式类型转换(如'' == 0为真),应改用===/!==(严格模式,== null也不允许)eslint/for-direction:for (i = 0; i < 10; i--)这类计数器朝反方向变化,循环永远不会结束eslint/no-compare-neg-zero:x === -0对+0同样成立,区分不了负零,本意应是Object.is(x, -0)eslint/no-cond-assign:if (a = b)这类条件里的赋值,多半是把比较运算符误写成了=eslint/no-constant-binary-expression:结果恒定的比较或短路运算(如x === []恒为 false),多为笔误或误判优先级eslint/no-constant-condition:if (false)这类恒定不变的条件,多为笔误或遗留的调试开关eslint/no-debugger:遗留的debugger语句,多是调试残留,挂上调试器时会让程序停住eslint/no-dupe-else-if:if-else-if 链中出现重复条件,后面那个分支永远不会执行eslint/no-dupe-keys:对象字面量里同一个 key 写了两次,后写的值会静默覆盖前面的eslint/no-duplicate-case:switch里有重复的case值,后一个分支永远走不到,多为复制粘贴忘改eslint/no-empty-pattern:const { a: {} } = foo这类空解构不声明任何变量,多半本想写默认值a = {}eslint/no-extra-boolean-cast:在if (!!x)等本就会转布尔的位置再写!!或Boolean(),纯属多余eslint/no-loss-of-precision:数字字面量超出双精度可表示范围(如9007199254740993),实际值与所写不同eslint/no-self-assign:foo = foo这类自己赋值给自己的语句没有效果,多为重构未完成eslint/no-self-compare:x === x这类变量与自身比较,多为笔误或重构遗漏,也让读者困惑eslint/no-unexpected-multiline:不写分号时以(、[或模板串开头的行会接到上一行,意外变成调用或取下标eslint/no-unneeded-ternary:a === 1 ? true : false这种多余的三元表达式,直接用条件本身即可eslint/no-unreachable:return/throw/break/continue之后的代码永远不会执行eslint/no-unsafe-negation:!key in obj实为(!key) in obj,取反只作用到左操作数,并非本意eslint/no-unsafe-optional-chaining:在不能接受 undefined 的位置用可选链(如const { a } = obj?.b),短路时抛 TypeErroreslint/no-unused-expressions:a === b;这类求值后结果被丢弃的表达式语句,多为漏写赋值或调用eslint/no-unused-labels:声明了却从未被break/continue引用的标签,多为重构残留oxc/bad-char-at-comparison:s.charAt(i) === 'ab'这类单个字符与多字符字符串比较,结果恒为 falseoxc/bad-min-max-func:Math.min(Math.max(100, x), 0)这类上下界写反的截断,结果恒为常量oxc/bad-object-literal-comparison:x === {}、x === []与新建字面量按引用比较,结果恒为 falseoxc/const-comparisons:x <= 400 && x > 500这类恒真/恒假比较或a < a自比较,说明运算符或变量写错oxc/double-comparisons:x === y || x < y这类可合并为x <= y的冗余双重比较,读起来易混淆oxc/erasing-op:x * 0这类结果恒为 0 的运算,另一操作数毫无意义,多半是写错oxc/misrefactored-assign-op:a += a + b这类复合赋值右侧又写了一遍目标变量,本意多为a += boxc/only-used-in-recursion:参数只在递归调用里原样传递、从未真正使用,多为错误,徒增理解成本eslint/require-yield:function*生成器里一个yield都没有,多半是写错了typescript/no-duplicate-enum-values:枚举成员取值重复(如A = 0, B = 0),两个成员无法区分,易出隐蔽 bugtypescript/no-meaningless-void-operator:对本就返回 void 或 undefined 的表达式再加void(如void foo()),毫无意义unicorn/no-negation-in-equality-check:!foo === bar实际是(!foo) === bar,本意多半是foo !== bareslint/use-isnan:x === NaN这类与 NaN 的比较永远为假,应改用Number.isNaN(x)eslint/valid-typeof:typeof x === 'strnig'与非法类型名比较,结果恒为 false,多为拼写错误异步与 Promise(13 条)
eslint/no-async-promise-executor:new Promise(async (resolve) => …)内抛出的错误不会让 Promise reject,会被吞掉promise/no-multiple-resolved:Promise 执行器中某条路径会先后调用reject和resolve,后一次调用无效,说明逻辑有误promise/no-new-statics:new Promise.resolve(x)对 Promise 静态方法用new,运行时抛 TypeErrorpromise/no-return-in-finally:promise.finally()回调里的return值会被忽略,写了只会误导读者promise/valid-params:Promise.resolve(1, 2)这类参数个数不对的 Promise 方法调用,行为与预期不符typescript/await-thenable:await一个不是 Promise 的值,常是漏了调用(如await getPromise)typescript/no-floating-promises:Promise 既没 await、也没.catch或返回,执行顺序会错乱、拒绝无人处理typescript/no-misused-promises:在if (promise)、forEach(async …)等不会等待 Promise 的位置使用 Promise,多为漏了 awaittypescript/return-await:try 中return p不加 await,catch 就捕获不到它的 reject;try 外则不应加 awaitunicorn/no-await-in-promise-methods:Promise.all([await p, q])在数组里先 await,会推迟后续元素求值、失去并发unicorn/no-single-promise-in-promise-methods:Promise.all([p])只包了一个 Promise,包装多余,直接await p即可unicorn/no-thenable:对象或类定义了then属性,一旦被误await就会被当成 Promise 处理,引发问题unicorn/no-unnecessary-await:await非 Promise 值没有意义,如await [p1, p2]并不会等待数组里的 Promise类型安全与类型写法(20 条)
typescript/consistent-type-assertions:使用<Foo>x尖括号类型断言,与 JSX 语法冲突,统一改写为x as Footypescript/no-base-to-string:String(obj)、obj + ''等把没有自定义 toString 的对象转字符串,只得到[object Object]typescript/no-confusing-non-null-assertion:a! == b中非空断言!紧挨==,容易被误读成!=typescript/no-duplicate-type-constituents:联合或交叉类型里重复的成员(如A | A | B),毫无作用且多为笔误typescript/no-extra-non-null-assertion:foo!!.bar这类对同一个值叠加多个非空断言,多出的!毫无作用typescript/no-misused-new:class 里定义new方法或 interface 里声明constructor,构造签名写错了typescript/no-mixed-enums:同一个 enum 里混用数字和字符串成员,编译后的运行时行为容易出乎意料typescript/no-non-null-asserted-nullish-coalescing:foo! ?? bar既断言非空又给空值兜底,自相矛盾,说明混淆了!与??typescript/no-non-null-asserted-optional-chain:foo?.bar!可选链本就可能得到 undefined,再用!断言非空自相矛盾typescript/no-redundant-type-constituents:联合类型里不改变结果的冗余成员,如与any/unknown并列的类型,徒增阅读负担typescript/no-unnecessary-type-arguments:显式写出与泛型默认值相同的类型参数,如默认就是 string 还写f<string>()typescript/no-unnecessary-type-constraint:<T extends any>、<T extends unknown>的约束多余,泛型参数默认就是 unknowntypescript/no-unsafe-declaration-merging:同名interface与class声明合并,TS 不检查接口属性是否初始化,可能运行时出错typescript/no-unsafe-enum-assignment:把裸数字或字符串当 enum 值用,如const f: Fruit = 0,绕过了枚举类型约束typescript/no-unsafe-unary-minus:对非 number/bigint 的值取负(如-str),会隐式类型转换,结果出人意料typescript/no-wrapper-object-types:用String、Number、Object等包装对象类型做注解,应改用小写原始类型typescript/prefer-as-const:let x: 'a' = 'a'把字面量类型重复写一遍,应改用as consttypescript/prefer-literal-enum-member:enum 成员值用变量或表达式计算,枚举自带作用域会让取值出乎意料typescript/restrict-plus-operands:+两侧类型不一致(如num + str),会隐式转换成字符串拼接等意外结果typescript/restrict-template-expressions:模板字符串插入对象、数组等非原始类型,会得到[object Object]之类无意义文本模块与导入(16 条)
import/default:对没有 default 导出的模块做默认导入,运行时拿到 undefined 或直接报错import/extensions:相对导入带.js/.ts/.tsx后缀(如'./foo.js'),按本仓库配置应省略扩展名import/namespace:import * as ns后访问模块并未导出的ns.foo,运行时会出错import/no-absolute-path:用/foo这类绝对路径导入模块,换台机器或发布到 npm 就会失效import/no-cycle:模块间存在循环依赖,导入时可能拿到尚未初始化的undefined,架构也难以理清import/no-duplicates:同一模块被拆成多条import重复导入,冗余且易造成用法不一致import/no-empty-named-blocks:import {} from 'mod'这类空的具名导入块毫无作用,多是删导入后的残留import/no-self-import:模块导入自身(foo.js中import './foo.js'),形成循环依赖,可能拿到 undefinedeslint/no-import-assign:给 import 进来的绑定或命名空间成员赋值,ES 模块导入是只读的,运行时报错node/no-exports-assign:exports = {}赋的新对象并不会被导出,应改写module.exportstypescript/no-useless-empty-export:文件已有其他 import/export 时多余的export {},不起任何作用typescript/prefer-namespace-keyword:用module Foo {}声明命名空间是过时写法,应改写为namespace Foo {}typescript/triple-slash-reference:用/// <reference path>或与 import 重复的/// <reference types>引入依赖,应改用importunicorn/no-empty-file:只有注释、空白或指令、没有实际代码的文件,多为重构遗留unicorn/prefer-node-protocol:导入 Node 内置模块不带node:前缀(如'fs'),易与同名模块混淆unicorn/require-module-specifiers:import {} from 'foo'、export {}这类空说明符列表毫无作用,徒增困惑错误处理与异常(7 条)
eslint/no-ex-assign:在catch (e)里给e重新赋值,原始异常就此丢失、无从追查eslint/no-unsafe-finally:finally里的return/throw/break会覆盖 try/catch 中已有的返回值或异常eslint/no-useless-catch:只把错误原样throw e重新抛出的 catch 块毫无作用oxc/missing-throw:new Error()前漏写throw,错误对象创建后直接被丢弃,并没有抛出eslint/preserve-caught-error:catch 中重新throw new Error()却没带{ cause: err },原始错误信息丢失typescript/only-throw-error:throw 'error'这类抛出非 Error 的值,没有调用栈,难以排查unicorn/no-useless-error-capture-stack-trace:Error子类构造函数里调用Error.captureStackTrace,父构造函数已自动完成,属多余正则与字符串(10 条)
eslint/no-empty-character-class:正则里的空字符类[](如/^abc[]/)匹配不到任何字符,多为笔误eslint/no-invalid-regexp:new RegExp('[')这类非法正则字符串,要到运行时才抛 SyntaxErroreslint/no-irregular-whitespace:代码中混入 NBSP、零宽空格等不可见的异常空白字符,难以察觉且可能干扰解析eslint/no-misleading-character-class:正则字符类里写[👍🏻]这类多码点字符,会被拆成单个码点分别匹配eslint/no-nonoctal-decimal-escape:字符串里的\8、\9是规范遗留语法,实际就等于8、9,不应再使用eslint/no-useless-backreference:正则中永远只能匹配空串的反向引用,如/\1(a)/在分组之前就引用eslint/no-useless-escape:字符串或正则中多余的转义(如'\e'就是'e'),不改变含义却干扰阅读oxc/bad-match-all-arg:str.matchAll(/x/)传入不带g标志的正则,运行时直接抛 TypeErroroxc/bad-replace-all-arg:str.replaceAll(/x/, y)传入不带g标志的正则,运行时直接抛 TypeErrorunicorn/prefer-string-starts-ends-with:用/^abc/.test(s)判断前后缀,应改用不需解析正则、更易读的startsWith/endsWith数组、对象与内置 API 的误用(28 条)
eslint/no-array-constructor:用new Array(a, b)代替[a, b]建数组,单参数时含义却变成长度,易混淆eslint/no-iterator:使用已废弃的非标准__iterator__属性,应改用Symbol.iteratoreslint/no-new-native-nonconstructor:new Symbol()、new BigInt()会直接抛 TypeError,它们不是构造器eslint/no-new-wrappers:new String/Number/Boolean()得到对象而非原始值,new Boolean(false)也是真值eslint/no-obj-calls:把Math()、JSON()、Reflect()等全局对象当函数调用,运行时抛 TypeErroreslint/no-object-constructor:用无参new Object()建空对象,应写{},且全局Object可能被改写eslint/no-prototype-builtins:直接调obj.hasOwnProperty(k),遇到Object.create(null)或同名属性遮蔽时会出错eslint/no-sparse-arrays:[1, , 2]这类带空位的稀疏数组,空位上并没有元素,易引起混淆oxc/bad-array-method-on-arguments:对arguments直接调用数组方法(如arguments.reduce),它不是真数组,会抛 TypeErroroxc/number-arg-out-of-range:n.toString(64)这类数字方法的进制或精度参数越界,进制超出 2–36 会抛 RangeErroroxc/uninvoked-array-callback:new Array(5).map(fn)作用在全是空槽的数组上,回调根本不会执行eslint/prefer-spread:fn.apply(null, args)是 ES2015 之前的写法,应改用展开语法fn(...args)eslint/radix:parseInt(s)不传进制时会把0x开头的串按十六进制解析,结果出乎意料typescript/no-array-delete:delete arr[i]只在数组里留下空洞、长度不变,应改用splicetypescript/no-for-in-array:用for...in遍历数组,会连带遍历到原型和实例上额外的可枚举属性typescript/no-misused-spread:{...promise}、{...fn}、{...map}这类展开拿不到预期内容,本意多是 await、调用或转换typescript/require-array-sort-compare:nums.sort()不传比较函数会按字符串排序,[1, 10, 2]排不成[1, 2, 10]unicorn/no-array-fill-with-reference-type:new Array(3).fill({})让所有元素共享同一个对象,改一处全跟着变unicorn/no-confusing-array-with:arr.with(arr.length, v)必然越界抛 RangeError,arr.with(-1, v)的负下标含义易被误解unicorn/no-instanceof-array:x instanceof Array跨 iframe 或 vm 上下文时判断失效,应改用Array.isArrayunicorn/no-instanceof-builtins:对Array、String等内置构造器用instanceof,跨 iframe/vm 或遇到原始值时会判断错误unicorn/no-invalid-fetch-options:fetch/new Request在 GET、HEAD 请求中带body,运行时直接抛 TypeErrorunicorn/no-invalid-remove-event-listener:removeEventListener('click', () => {})传入新建函数,原监听器根本移除不掉unicorn/no-new-array:new Array(n)只传一个参数时,分不清是指定长度还是唯一元素unicorn/no-useless-fallback-in-spread:{ ...(foo ?? {}) }里的空对象兜底多余,展开 null/undefined 本就不会添加属性unicorn/no-useless-length-check:arr.length === 0 || arr.every(f)中的长度检查多余,every对空数组本就返回 trueunicorn/no-useless-spread:[...[1, 2]]、Promise.all([...iterable])这类多余展开,原值本可直接使用unicorn/prefer-set-size:[...set].length为了计数新建数组,应直接用set.size声明、作用域、类与 this(30 条)
eslint/accessor-pairs:对象或类里只有 setter 没有 getter 的属性,写进去的值永远读不到eslint/block-scoped-var:var在块内声明却在块外使用(如循环后读i),依赖变量提升,作用域易被误读eslint/constructor-super:派生类构造函数漏调super(),或非派生类误调super(),运行时会直接报错eslint/getter-return:getter 没有return值,读取该属性只得到 undefined,多半是漏写了eslint/no-case-declarations:在case里直接写let/const/函数声明,作用域覆盖整个 switch 却可能未初始化eslint/no-class-assign:给 class 声明的类名重新赋值(如class A {}后A = 0),几乎都是笔误eslint/no-const-assign:给const变量重新赋值(包括+=),运行时直接抛 TypeErroreslint/no-constructor-return:构造函数里return一个值,会被忽略或替换掉new的结果,多为误写eslint/no-delete-var:对变量用delete x:delete 只用于删除对象属性,用在变量上行为出乎意料eslint/no-dupe-class-members:类中同名成员重复声明,后者静默覆盖前者(如方法被同名字段覆盖)eslint/no-empty-static-block:空的static {}块什么也不做,多为未完成的重构eslint/no-extra-bind:对箭头函数或不使用this的函数调用.bind(),绑定不起任何作用eslint/no-func-assign:给函数声明重新赋值(如function foo() {}后foo = bar),多为笔误eslint/no-setter-return:setter 里return一个值会被静默忽略,多半是写错了eslint/no-shadow-restricted-names:用undefined、NaN、eval等作变量或参数名,遮蔽了内置含义,易引发混乱eslint/no-this-before-super:派生类构造函数在super()之前使用this/super,运行时抛 ReferenceErroreslint/no-unassigned-vars:let/var变量只被读取从未赋值,读到的永远是 undefined,多为漏写赋值eslint/no-unused-private-class-members:声明了却从未被读取的#私有字段或方法,多为重构残留eslint/no-unused-vars:声明后从未被使用的变量、导入、参数或类型,多为重构残留eslint/no-useless-rename:import { foo as foo }、{ a: a } = obj这种改成同名的重命名纯属多余eslint/no-var:var是函数作用域,块内声明会泄漏到块外,应改用let/consteslint/no-with:with把对象属性混入当前作用域,看不出变量指向谁,严格模式下已禁止oxc/no-this-in-exported-function:导出函数里使用this,被其他模块导入调用时 this 通常是 undefinedeslint/prefer-rest-params:用arguments取可变参数,它不是真数组、用起来别扭,应改用...argstypescript/no-extraneous-class:只有静态成员或只有构造函数的类没有存在必要,应改用模块级函数或常量typescript/no-this-alias:const self = this给 this 起别名,用箭头函数即可直接捕获 thistypescript/no-unnecessary-parameter-property-assignment:参数属性(constructor(public name))已自动赋值,再写this.name = name多余typescript/unbound-method:把方法单独取出调用(const f = obj.method; f()),会丢失this导致运行时出错unicorn/no-accessor-recursion:getter/setter 里读写自身属性(如get bar() { return this.bar }),会无限递归导致栈溢出unicorn/no-this-assignment:const self = this把 this 存进变量,徒增间接、让代码更难追踪运行环境与安全(7 条)
eslint/no-caller:使用已废弃的arguments.callee/arguments.caller,严格模式下直接报错且妨碍引擎优化eslint/no-eval:用eval()执行字符串代码,处理不可信输入时有注入风险,而且慢eslint/no-extend-native:Object.prototype.x = …这类扩展内置对象,会影响所有代码并污染for…in遍历eslint/no-global-assign:给只读全局变量重新赋值(如Object = null),会丢掉内置功能eslint/no-implied-eval:setTimeout('code()', 100)传字符串会像 eval 一样执行,有安全与性能隐患typescript/no-implied-eval:setTimeout('code')、new Function(...)把字符串当代码执行,等同 eval,有安全和性能风险unicorn/no-new-buffer:new Buffer()已被 Node 废弃,应改用Buffer.from()或Buffer.alloc()lint 指令与类型检查指令(3 条)
typescript/ban-ts-comment:@ts-ignore、@ts-nocheck会压制类型错误,一律禁止;@ts-expect-error须附 ≥10 字符说明typescript/prefer-ts-expect-error:@ts-ignore在错误修好后仍会留着并压制新错误,应改用无错时会报错的@ts-expect-errorunicorn/no-abusive-eslint-disable:不带规则名的eslint-disable/oxlint-disable注释会屏蔽全部规则,掩盖真实问题React(19 条)
react/forward-ref-uses-ref(React 目录):forwardRef((props) => ...)回调没接收ref参数,forwardRef 形同虚设react/jsx-key(React 目录):list.map(x => <Item />)生成的元素没有key,React 无法正确识别列表项的增删改react/jsx-no-duplicate-props(React 目录):同一 JSX 元素重复写同名属性(<App a a />),多为笔误且行为难料react/jsx-no-undef(React 目录):JSX 里用了未声明的组件如<Foo />,多为拼写错误,运行时抛 ReferenceErrorreact/jsx-props-no-spread-multi(React 目录):同一元素上重复展开同一对象(如{...props} a="1" {...props}),夹在中间的属性会被覆盖react/no-children-prop(React 目录):用children属性传子节点(<div children='x' />),应写在开闭标签之间react/no-danger-with-children(React 目录):同一元素同时传children和dangerouslySetInnerHTML,React 会因冲突发出警告react/no-did-mount-set-state(React 目录):componentDidMount里调用setState会立即触发第二次 render,造成性能问题和布局抖动react/no-did-update-set-state(React 目录):在componentDidUpdate里调用setState会再触发一次 render,可能导致布局抖动react/no-direct-mutation-state(React 目录):直接改this.state.x = ...,改动可能被随后的setState()覆盖掉react/no-find-dom-node(React 目录):使用已废弃、React 19 已移除的findDOMNode,它会穿透组件封装react/no-is-mounted(React 目录):this.isMounted()是反模式,class 组件与函数组件中均不可用react/no-render-return-value(React 目录):使用ReactDOM.render()的返回值是遗留用法,React 19 已彻底移除该 APIreact/no-string-refs(React 目录):ref="hello"这类字符串 ref 自 React 16.3 起废弃,React 19 已移除react/no-this-in-sfc(React 目录):函数组件里使用this.props,函数组件的 props 来自参数而非thisreact/no-unsafe(React 目录):使用UNSAFE_componentWillMount等遗留生命周期,常被误用,在异步渲染下易出问题react/no-will-update-set-state(React 目录):componentWillUpdate里调用setState,在更新阶段改状态会让组件状态不可预测react/rules-of-hooks(React 目录):在条件、循环或非组件函数里调用 Hook,渲染间调用顺序不一致会让状态错乱react/void-dom-elements-no-children(React 目录):给<br>、<img>等空元素传入 children,这类元素只能自闭合、不能有子节点测试(vitest)(16 条)
vitest/expect-expect(测试文件):测试里没有任何expect/assert断言,被测代码坏了测试也照样通过(把expect*、assert*、*.expect*等辅助函数也算作断言)vitest/hoisted-apis-on-top(测试文件):vi.mock等会被提升到文件顶部先于导入执行,写在条件或测试体内会误导读者vitest/no-commented-out-tests(测试文件):被注释掉的测试(如// it(...))容易被遗忘,应改用 skip 或直接删除vitest/no-conditional-tests(测试文件):用if包住it/test/describe,测试是否注册取决于运行时条件,结果不确定vitest/no-focused-tests(测试文件):提交了it.only/describe.only,构建时其余测试会被跳过vitest/no-identical-title(测试文件):同一层级的describe/test标题重复,失败时难以分辨是哪一个出错vitest/no-import-node-test(测试文件):误从node:test导入测试函数,与 Vitest 混用会导致测试结果不一致vitest/no-interpolation-in-snapshots(测试文件):内联快照里写${}插值会使快照无法更新,应改用属性匹配器vitest/no-mocks-import(测试文件):直接 import__mocks__目录里的文件,绕过了框架的自动 mock 机制vitest/no-standalone-expect(测试文件):expect写在it/test之外(如describe体内),不属于任何测试,断言形同虚设vitest/no-unneeded-async-expect-function(测试文件):expect(async () => await f())多包了一层 async 函数,直接expect(f())即可vitest/prefer-snapshot-hint(测试文件):同一作用域多个toMatchSnapshot()未写提示名,增删一个就让后续快照编号错位vitest/require-awaited-expect-poll(测试文件):expect.poll/expect.element返回的 Promise 未被 await,测试会在断言完成前结束vitest/require-local-test-context-for-concurrent-snapshots(测试文件):并发测试中用全局expect做快照,全局 expect 追踪不了并发测试,须用上下文的expectvitest/valid-describe-callback(测试文件):describe的回调带参数、含return或根本不是函数,会导致测试意外出错vitest/valid-expect-in-promise(测试文件):在.then()回调里调用expect却没有 await 或 return 该 Promise,断言可能还没跑测试就结束了冻结的 42 条规则:防什么、新代码怎么写
typescript/no-explicit-anyany会关闭该处的类型检查,类型错误被推迟到运行时unknown再收窄,或写出具体类型eslint/no-unused-varsvitest/no-conditional-expectexpect写在 if/catch 等条件分支里,分支没执行时测试会静默通过expect(...).rejects、toThrow,或拆成多个用例unicorn/no-array-sortarr.sort()的返回值,它会原地改动原数组,应改用toSorted()toSorted()typescript/no-deprecated@deprecated的 API;TS 只在编辑器里划线、不报错,容易被忽视z.url()、z.looseObject()typescript/no-unsafe-assignmentany值赋给有类型的变量或属性(如const s: string = anyValue),绕过了类型检查unknown,再收窄或用 zod 校验typescript/use-unknown-in-catch-callback-variable.catch(err => …)回调的参数没标成unknown,拒绝值实为任意类型却可不经检查直接使用.catch((error: unknown) => ...)typescript/no-unsafe-member-accessany值上访问成员如anyValue.foo,成员是否存在完全无从检查unknown,再收窄或用 zod 校验typescript/no-unsafe-argumentany类型的值作为参数传给函数,绕过了参数的类型检查unknown,再收窄或用 zod 校验typescript/prefer-promise-reject-errorsPromise.reject('error')这类用非 Error 值拒绝,没有调用栈,难以排查reject(new Error(...))typescript/switch-exhaustiveness-checkswitch时漏掉某个成员的case,即使有default也照样报default兜底eslint/no-unsafe-optional-chainingconst { a } = obj?.b),短路时抛 TypeErroreslint/prefer-constlet应改为const,让读者一眼确定它不会被改consttypescript/no-unsafe-returnany值,把类型不安全传给调用方,声明的返回类型形同虚设typescript/no-unnecessary-type-parametersparse<T>(s: string): T)关联不了任何类型,还可能掩盖不安全的类型断言unknown,再用 zod 校验import/no-named-as-default-memberfoo.bar),可能拿到 undefined,应改为import { bar }import { join } from 'pathe'typescript/no-unnecessary-boolean-literal-comparetrue/false字面量比较(如ok === true),比较多余=== truetypescript/no-unnecessary-type-conversionString('a'),类型和值都不变String()、Number()等转换eslint/no-consoleconsole.log等调试输出,不应进入发布的产品代码typescript/no-unsafe-function-typeFunction类型,可用任意参数调用且返回any,失去类型检查Functionoxc/no-accumulating-spread{ ...acc }展开累加器,时间和内存退化到 O(n²)Object.fromEntries(...),或在局部可变的累加器上修改eslint/no-regex-spaces/foo bar/)看不清个数,应写成/foo {3}bar// {3}/react/exhaustive-depsuseEffect等 Hook 的依赖数组缺失或不全,effect 会多跑或该跑时不跑typescript/no-useless-default-assignment[1].map((a = 0) => a),永不生效typescript/no-require-importsrequire()导入模块,路径等错误要到运行时才暴露,应改用静态importimporttypescript/no-unnecessary-template-expression${'b'}),属多余插值`${x}`unicorn/no-array-reversearr.reverse()会原地修改原数组,应改用返回新数组的toReversed()toReversed()vitest/valid-titleit('it foo')),会误导读者eslint/no-sequencesx = a(), b,常掩盖副作用,且多半是误用promise/no-callback-in-promise.then()/.catch()里调用回调cb(),回调抛错会进入.catch导致它再被调用一次then里调用回调promise/no-promise-in-callback(err, val) => {}式错误优先回调里使用 Promise,混用两种异步模式使错误处理混乱typescript/no-namespacenamespace这种过时的组织方式,应改用 ES 模块的 import/exporteslint/no-emptyif (x) {}这类空代码块(空 catch 与含注释的块除外),多为未写完的残留catch {}允许)eslint/array-callback-returnarr.map(x => { f(x); })这类 map/filter/reduce 等回调漏写return,多半是写错了eslint/no-useless-constructorsuper(...)的构造函数,删掉后行为不变import/no-named-as-defaultoxc/bad-comparison-sequencea == b == c实际是先比a == b,再拿布尔结果和c比较a < b && b < ctypescript/no-unsafe-enum-comparisonstatus === 'unknown'),绕过了枚举的类型保护typescript/related-getter-setter-pairso.x = o.x都不成立typescript/no-unsafe-callany类型的值,TS 无法检查它是否可调用、参数和返回值是否正确unknown,再收窄或用 zod 校验vitest/no-disabled-testsit.skip、xtest、无回调的it('x')等被禁用的测试,容易被遗忘而提交eslint/no-fallthroughcase末尾既无break也无// falls through注释,会意外落入下一个分支break、return或throw结束有意关闭或暂缓的 19 条
typescript/no-non-null-assertioneslint/no-redeclaretypescript/no-empty-object-typetypescript/no-unnecessary-type-assertioneslint/no-control-regexpromise/catch-or-returnno-floating-promises已经覆盖未处理的 Promiseunicorn/require-post-message-target-originwindow.postMessage;这里全是 Worker、MessagePort 和 VS Code webview,9 处全是误报eslint/no-promise-executor-returnnew Promise((r) => setTimeout(r, ms))一类无害写法eslint/no-unmodified-loop-conditioneslint/no-loop-functypescript/prefer-nullish-coalescing||改成??,对空串和 0 的结果不同;这里很多||是有意的空串回退typescript/no-unsafe-type-assertion(error as NodeJS.ErrnoException).code这类惯用法,逼出自写类型守卫或 disable 指令typescript/no-unnecessary-conditiontypescript/require-awaitno-floating-promises、no-misused-promises和 tsc 覆盖;去掉 async 会把 reject 变成同步抛错typescript/no-invalid-void-typeX | void,和 ACP、fastify 的类型一致typescript/no-dynamic-deletein的结果typescript/no-confusing-void-expression() => voidCall()这类简写;加花括号可能丢掉 void 类型调用实际返回的 Promisepromise/always-returnunicorn/prefer-add-event-listener代码文件的改动(160 个文件;除了 ToolBubble 的修复,都不改变运行时行为)
核对方式:把每个文件在 main 上和本分支上的版本,用仓库相同的编译选项(
verbatimModuleSyntax、experimentalDecorators、ES2024)转译成 JS 后比对。159 个机械改动的文件里,117 个完全相同,11 个只差let/const,31 个只差 import 语句;这 31 个文件运行时加载的模块和加载顺序也都和 main 一致。删掉的注释全是 lint 指令,没有影响打包或覆盖率的注释。remove type arguments that repeat their defaultsdrop redundant undefined from optional parameters?本来就允许 undefined,而且不受exactOptionalPropertyTypes影响use const for bindings that are never reassignedmerge duplicate imports of the same moduleupgrade oxlint to 1.94 without changing what lint reportsno-thenable指令改用新的规则名remove lint suppression comments that suppress nothingopenai-responses/decode.ts用本分支合并后的 import,不带文件头注释。第二次:promptEvents.ts保留 main 新加的PromptOrigin导入和本分支收窄后的 disable 指令remove imports a merged test no longer usesidle-notification-repro.test.ts里 2 个没被使用的导入名fix(vis): call useState before the early return in ToolBubble提交列表(21 个)
chore: stop the pre-commit hook from rewriting staged codechore: guard the lint setup and run the import-boundary check in pnpm lintchore: upgrade oxlint to 1.94 without changing what lint reportschore: list every oxlint rule explicitly and enforce them as errorschore: remove lint suppression comments that suppress nothingchore: freeze lint rules that already have findings at their current countchore: remove type arguments that repeat their defaultschore: drop redundant undefined from optional parameterschore: use const for bindings that are never reassignedchore: merge duplicate imports of the same modulechore: keep no-unnecessary-type-assertion offdocs: describe the lint ratchet and suppression rules for agentschore: fit the comment check into the lint guardsbuild(nix): update the pnpm dependency hash for the oxlint upgradefix(vis): call useState before the early return in ToolBubblechore: drop noisy lint rules, add rules-of-hooks, freeze deprecated APIspromptEvents.ts的冲突chore: remove imports a merged test no longer useschore: fail the ratchet on findings it cannot attribute to a rulechore: freeze type-safety rules for new code and add React correctness rulesBehavior Changes and Affected Users
oxlint --type-aware --quiet:warning 被隐藏,也不会让提交失败oxlint --type-aware --deny-warnings;规则只有 error 一档,和 CI 一致pnpm lint包含的检查oxlint --type-aware--deny-warnings)、agent-core-v2 import 边界检查、守卫、棘轮rules-of-hooks);oxc 插件生效;测试文件另有 16 条 vitest 规则.oxlintrc.json并更新快照no-empty允许空catch块;no-deprecated挡住新增的废弃 API;no-unsafe-*等类型安全规则只管有类型的源码;测试里的no-unused-vars、no-unsafe-optional-chaining从豁免改为冻结node scripts/checks/ratchet.mjs --update;挪动已有代码或升级依赖带来新的废弃项时加--allow-increasepnpm lint:fixpnpm run lint --fix:先跑注释检查,再oxlint --type-aware --fixoxlint --type-aware --fix,不再先跑注释检查(它本来也不修复注释)lint:fix的开发者pnpm lint仍然会跑注释检查ToolBubble组件null,再调用useState,hook 顺序取决于消息角色useState再返回;tool 消息的初始状态不变scripts/check-service-naming.mjspackages/services/src也已不存在flake.nix的 pnpm 依赖哈希let改const、合并重复 import、删除无用的 import 和注释,核对方式见上面的折叠块x?: T | undefinedx?: Tpackages/node-sdk/src/index.ts(对外契约文件)import type受影响模块与验证
pnpm lint通过(守卫:189 条规则、5 个 override、13 项接线;棘轮:42 条规则、2,129 处)。scripts/checks/*.test.mjs共 26 个测试,加上 CI 一起运行的注释检查测试,本地 38 个全部通过。另外对守卫和棘轮做了反向验证,以下情况都会被拦住:把规则从 error 降为 off、新增忽略目录、从 lint 命令里删掉某项检查、给 lint-staged 加回--fix、拿掉测试覆盖项里的 vitest 插件、新增违规、基线大于实际、两份配置的忽略列表不一致、有违规时直接--update、诊断对不上任何冻结规则(去掉react-hooks的映射后,棘轮报出 7 处并失败)。那 5 个在 main 上也失败的测试
在不带本 PR 改动的 HEAD 上,以及在 main(2931c7efd)的临时 worktree 里,单独运行都能复现,失败位置完全一致:
packages/node-sdk/test/sdk-rpc-client-v2.test.ts›serves suggestFiles through the workspace handler fs servicepackages/kap-server/test/hosts.test.ts›lets a managed host sign in and renew with its own Kimi loginpackages/agent-core-v2/test/tool/tool.test.ts里 3 个... subagents without a deadline ...相关的测试(假定时器,30 秒超时)它们在 CI 上都能通过,看起来和本机环境有关。
Checklist
/approve).gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.没有 changeset:改动是开发工具、和原来等价的代码改动,以及 vis 调试工具里的一处修复(vis 不发布),用户感知不到。不需要更新用户文档:
AGENTS.md和 CONTRIBUTING 已同步修改。没有关联 issue:这是维护者发起的内部改动。