✨ 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

+21 -9
View File
@@ -21,7 +21,11 @@ typescript-lib-starter-tiny => https://github.com/tmueller/typescript-lib-starte
- **oxlint**: Rust-based linter. Replaces ESLint. Config in `.oxlintrc.json`
with `typescript`, `unicorn`, `oxc`, `import` plugins. Categories enabled
as errors: `correctness`, `suspicious`, `restriction`. As warnings: `perf`,
`style`. `nursery` is off.
`style`. `nursery` is off. Run with `--type-aware` to enable rules
that require TypeScript type information (powered by `oxlint-tsgolint`).
- **oxlint-tsgolint**: TypeScript-Go-backed type-aware linter for oxlint.
Activated via `oxlint --type-aware`. Native bindings installed as
`optionalDependencies` per platform (same pattern as oxlint).
- **oxlint rules disabled by design** (in `.oxlintrc.json`):
- `eslint/no-undefined` — we use `undefined` as the no-match sentinel.
- `eslint/sort-keys` — handler/case order is semantic, not alphabetical.
@@ -218,14 +222,22 @@ script does not belong in the standard pipeline.
- `check`: Run all checks in order — `check:oxlint`, `check:oxfmt`,
`check:tsc`, `check:cspell`, `check:knip`, `check:outdated`.
- `check:oxlint`: `oxlint ${LEFTHOOK_FILES:-src}` — lints `src/`
by default; when invoked from the lefthook pre-commit hook with
`LEFTHOOK_FILES` set to the staged-files list, lints only those
files. This is the single source of truth for the oxlint command
and is shared between the manual `npm run check` and the pre-commit
hook. oxlint only understands JS/TS-family languages, so config
files (JSON/YAML/Markdown) are intentionally outside its scope;
they are checked only by oxfmt.
- `check:oxlint`: `oxlint --type-aware ${LEFTHOOK_FILES:-src}` — lints
`src/` by default; when invoked from the lefthook pre-commit hook
with `LEFTHOOK_FILES` set to the staged-files list, lints only those
files. The `--type-aware` flag enables type-aware rules via
`oxlint-tsgolint` (TypeScript-Go-backed). This is the single source
of truth for the oxlint command and is shared between the manual
`npm run check` and the pre-commit hook. oxlint only understands
JS/TS-family languages, so config files (JSON/YAML/Markdown) are
intentionally outside its scope; they are checked only by oxfmt.
Type-aware rules disabled (with rationale in `.oxlintrc.json`):
`no-unsafe-type-assertion` and `no-unnecessary-type-parameters`
fire on legitimate generic type machinery in `keysMatch` /
`MatchBuilder` that needs type-system restructuring (out of scope
for the tool-adoption commit); `no-floating-promises` is disabled
in test files because `expectTypeOf(...)` is a sync type assertion
library that oxlint-tsgolint misidentifies.
- `check:oxfmt`: `oxfmt --check ${LEFTHOOK_FILES:-.}` — formats the
whole project (`.`) by default, including JS/TS, JSON/JSONC,
YAML, Markdown, MDX and other supported file types. From lefthook