♻️ Move type-aware config to .oxlintrc.json; use source-level disable directives

Cleaner separation of concerns:
- options.typeAware: true in .oxlintrc.json activates type-aware
  rules declaratively (equivalent to --type-aware CLI flag, but
  the script command stays clean: just 'oxlint ...')
- Remove the 3 type-aware rule disables from .oxlintrc.json
- Add source-level oxlint-disable directives instead:
  - 4x typescript/no-unsafe-type-assertion (pattern.ts: keysMatch
    Object.keys() cast, candidate[] cast; structuralMatcher value
    as S cast; match.ts: handler as ... cast in nextCases)
  - 1x typescript/no-unnecessary-type-parameters (pattern.ts:
    keysMatch <S extends object>)
  - 1x file-level typescript/no-floating-promises in index.test.ts
    (expectTypeOf() is a sync type-assertion library that the
    type-aware linter misidentifies)

Disabling rules at the source (next to the line that needs the
exemption) documents intent more clearly than a global config
override, and makes the trade-off visible to anyone reading the
code. Re-enabling a rule in the future only requires removing the
inline comment, not editing a central config.
This commit is contained in:
tmu committed 2026-09-04 23:27:58 +02:00
1 parent 2b3ef0f721
commit 34e9b52ee8
7 files changed
+38 -27

No files matched your search

+25 -19
View File
@@ -21,11 +21,14 @@ 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. Run with `--type-aware` to enable rules
that require TypeScript type information (powered by `oxlint-tsgolint`).
`style`. `nursery` is off. Type-aware rules are enabled via
`options.typeAware: true` in `.oxlintrc.json` (no CLI flag needed);
the linter then uses `oxlint-tsgolint` for rules that require type
information.
- **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).
Activated by `options.typeAware: true` in `.oxlintrc.json`. 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.
@@ -222,22 +225,25 @@ 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 --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
- `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. Type-aware rules are activated declaratively via
`options.typeAware: true` in `.oxlintrc.json` (not via a CLI flag),
so the script command stays clean. 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.
Source-level `oxlint-disable` directives are used to silence
type-aware false positives in the generic type machinery: 4× for
`typescript/no-unsafe-type-assertion` and 1× for
`typescript/no-unnecessary-type-parameters` in `src/pattern.ts` /
`src/match.ts` (legitimate type machinery that needs restructuring,
documented in the source); 1× file-level for
`typescript/no-floating-promises` in `src/index.test.ts`
(`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