✨ Add oxlint-tsgolint for type-aware linting

Activates type-aware rules via oxlint --type-aware, backed by
oxlint-tsgolint (TypeScript-Go). Catches unsafe type assertions,
unnecessary type parameters, and other issues regular oxlint
cannot see.

- Add oxlint-tsgolint devDep + 6 platform-specific native bindings
  as optionalDependencies (same pattern as oxlint)
- Add --type-aware flag to check:oxlint
- Add 6 @oxlint-tsgolint/* platforms to check:outdated ignore list
- Disable 3 type-aware rules in .oxlintrc.json with rationale:
  - typescript/no-unsafe-type-assertion, typescript/no-unnecessary-type-parameters:
    fire on legitimate generic type machinery in keysMatch/MatchBuilder
    that needs type-system restructuring (deferred to a follow-up)
  - typescript/no-floating-promises in test files: expectTypeOf() is
    a sync type-assertion library that oxlint-tsgolint misidentifies

Code simplifications enabled by the new strict checks:
- src/match.ts: drop value as unknown casts (T is already assignable
  to unknown) and the redundant run(value) as R cast
- src/index.test.ts: drop unnecessary 'X' as 'X | Y' assertions in
  match<...>(...) calls (literals are already assignable to the union)

Documentation updates in project-specs.md and README.md. Add
'tsgolint' to cspell word list.
This commit is contained in:
tmu committed 2026-09-04 23:20:02 +02:00
1 parent ec98223f8d
commit 2b3ef0f721
8 files changed
+148 -25

No files matched your search

+3 -3
View File
@@ -27,7 +27,7 @@ test("P.type narrows to the typeof target", () => {
});
test("exhaustive() returns the union of handler return types", () => {
const result = match<"a" | "b">("a" as "a" | "b")
const result = match<"a" | "b">("a")
.with(P.literal("a"), () => 1 as const)
.with(P.literal("b"), () => "two" as const)
.exhaustive();
@@ -37,7 +37,7 @@ test("exhaustive() returns the union of handler return types", () => {
});
test("otherwise() falls back when no case matches", () => {
const result = match<"x" | "y" | "z">("z" as "x" | "y" | "z")
const result = match<"x" | "y" | "z">("z")
.with(P.literal("x"), (v): string => `got ${v}`)
.otherwise((v): string => `fallback ${v}`);
assert.equal(result, "fallback z");
@@ -46,7 +46,7 @@ test("otherwise() falls back when no case matches", () => {
test("exhaustive throws when no case matches", () => {
assert.throws(
() =>
match<"a" | "b" | "c">("c" as "a" | "b" | "c")
match<"a" | "b" | "c">("c")
.with(P.literal("a"), () => "A")
.with(P.literal("b"), () => "B")
.exhaustive(),