chore(lint): reject chained type assertions in package source
Merged
OK
9d ago+219+219+012345678901234567890123456789-32-32-01234567890123456789
What and why
- New repo-local oxlint plugin in
scripts/oxlint-plugin/, loaded throughjsPlugins. Its one rule,e2e/no-chained-type-assertions, is on forpackages/*/src/**.- Adapted from dmmulroy/anti-slop (MIT). The license sits next to the rule.
- The rest of that rule set misfires here: blank-line spacing, the conditional spread that
exactOptionalPropertyTypesneeds, and blankettypeof/unknownbans.
x as unknown as Tturns off TypeScript's overlap check. 14 of the 16 hits insrcare fixed:internal/ai-trace.ts:225: six casts dropped. The structural event views are now checked against the AI SDK types, as the comment above them claims.agent/error.ts,internal/errors.ts: the cross-realm error guards narrow withininstead of casting.internal/source.ts: stack frame groups are checked instead of cast.oauth/device-code.ts:145: the RFC 8628 poll cast raw JSON toTokenResponse. Both token paths now go through one zodparseTokensinoauth/token-endpoint.ts.
- Two hits keep the double cast, each with a reasoned disable comment: the phantom
RedactedNodebrand mint and theEngineHandlebuilt key by key. @oxlint/pluginsis a root devDependency pinned to oxlint's version (1.83.0). Dependabot'sdev-toolinggroup moves the two together.- Tests are out of scope (195 hits, mostly fakes).
"jsPlugins": [{ "name": "e2e", "specifier": "./scripts/oxlint-plugin/index.ts" }],
"overrides": [{ "files": ["packages/*/src/**"], "rules": { "e2e/no-chained-type-assertions": "error" } }]
Verified
Ran it locally: yes
-
oxlinton a planted(process.env as unknown as { n: number }).n: it fires inpackages/e2e/srcand stays quiet inpackages/e2e/tests.packages/e2e/src/planted-lint-probe.ts:1:25: error e2e(no-chained-type-assertions): Chained assertions skip the compiler check. ... -
After type stripping,
observation.ts,manifest.ts,read-semantics.ts,ai-trace.tsandopenai.tsemit the same JS as main. -
requestTokensagainst a local server answeringnull:main this branch TypeError: Cannot read properties of nullOAuthError FLOW_FAILED -
Testbed suite on the built packages: 78 passed.
Checklist
- Changeset added (
pnpm changeset) for any change to a published package, or the change is testbed, docs, or CI only. - Breaking change: title carries
!, the changeset body names what breaks and what replaces it, and the deprecation warning landed a window earlier (stability policy in CONTRIBUTING.md). - Docs updated in the same PR: the
docs/**/*.mdxpage for the behavior, andskills/e2e/if the skill describes it. - Contract change: emitted
.d.tsreviewed,tests/types/sdk-types.tsupdated; wire change edits the schema and both fixtures. - Engine contract change (
e2e/engine): changesets fore2e,@e2e-dev/web, and@e2e-dev/mobile.