🔀 Merge chore/straighten-oxc-rules into main
CI / release-gate (push) Successful in 3s
CI / build (push) Successful in 23s
CI / publish (push) Skipped
CI / maintain (push) Failing after 14s

This commit is contained in:
tmu committed 2026-09-16 21:50:14 +00:00
commit 73e5bc0093
5 files changed
+47 -25

No files matched your search

+2
View File
@@ -13,6 +13,8 @@
"eslint/no-undefined": "off", "eslint/no-undefined": "off",
"eslint/sort-keys": "off", "eslint/sort-keys": "off",
"eslint/id-length": "off", "eslint/id-length": "off",
"eslint/capitalized-comments": "off",
"eslint/no-ternary": "off",
"import/no-named-export": "off", "import/no-named-export": "off",
"eslint/one-var": "off", "eslint/one-var": "off",
"import/group-exports": "off", "import/group-exports": "off",
+3
View File
@@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
- allow ternaries and lowercase comments in oxlint
- switch `src/primitive.ts` prose from block comments to line comments
## [0.1.8] - 2026-09-16 ## [0.1.8] - 2026-09-16
- upgrade dependencies - upgrade dependencies
+4 -4
View File
@@ -6,10 +6,10 @@ Backlog and tracking for tiny-pattern-ts. Managed in vscode-todotasks format.
Setup: Setup:
☐ Split off template into separate package => pi --session 01a07dde-7050-7054-bb36-1606d7eb2bc3 @high ☐ Split off template into separate package => pi --session 01a07dde-7050-7054-bb36-1606d7eb2bc3 @high
☐ straighten oxc rules ✔ straighten oxc rules @done
☐ oxc forbids ternary => remove oxc rule ✔ oxc forbids ternary => remove oxc rule @done
☐ oxc wants comments to start comments with a capital letter => remove oxc rule ✔ oxc wants comments to start comments with a capital letter => remove oxc rule @done
☐ there already exists a /* */ block comment in primitive.ts, => change to multi-line comment ✔ there already exists a /* */ block comment in primitive.ts, => change to multi-line comment @done
v1.0: v1.0:
☐ API surface is stable and fully typed ☐ API surface is stable and fully typed
+28 -5
View File
@@ -104,25 +104,48 @@ Type-aware oxlint is enabled via `options.typeAware: true` in `.oxlintrc.json`
#### Decision (2026-09) #### Decision (2026-09)
Known type-aware false positives are silenced with source-level `oxlint-disable` A type-aware rule that false-positives is silenced with a source-level
directives (see `src/pattern.ts`, `src/match.ts`, `src/index.test.ts`), not with `oxlint-disable` directive (see `src/pattern.ts`, `src/match.ts`,
rules disabled in `.oxlintrc.json`. `src/index.test.ts`), not by turning the rule off in `.oxlintrc.json`.
#### Why #### Why
- The disable sits next to the code it silences, visible to anyone reading the - The disable sits next to the code it silences, visible to anyone reading the
source. source.
- The rule stays on everywhere else, so only the mis-firing line is exempted.
#### Rejected #### Rejected
- A project-wide disable in `.oxlintrc.json`: it hides the suppression from the - A project-wide disable in `.oxlintrc.json` for a false positive: it hides the
reader of the affected code. exemption from the reader of the affected code and switches the rule off
repo-wide for a one-site problem.
#### Known issue #### Known issue
- A source-level disable is a _human_ last resort. AI agents must not add one; - A source-level disable is a _human_ last resort. AI agents must not add one;
they fix the type at its root (see [AGENTS.md § Never do](../AGENTS.md#never-do)). they fix the type at its root (see [AGENTS.md § Never do](../AGENTS.md#never-do)).
### Unwanted stylistic rules are turned off in the config
#### Decision (2026-09)
A stylistic rule the project rejects is `"off"` in the `.oxlintrc.json` `rules`
map, not silenced at a use site. Current entries: `eslint/capitalized-comments`
(comments may start lowercase) and `eslint/no-ternary` (ternaries are allowed),
joining the oxfmt-superseded rules already off.
#### Why
- The rule is wrong for the whole project, not mis-firing at one site, so there
is no line to annotate.
- Keeping the two mechanisms separate keeps a source-level `oxlint-disable`
meaningful: it marks a lone exception.
#### Rejected
- A source-level `oxlint-disable` per use: the same exemption repeated at every
site, and oxfmt can move the site.
### `check:tsc` runs first ### `check:tsc` runs first
#### Decision (2026-09) #### Decision (2026-09)
+10 -16
View File
@@ -19,10 +19,8 @@ export const getPrimitiveUnionMatcherW: <T extends string | number>() => <
>( >(
pattern: Simplify<P>, pattern: Simplify<P>,
) => UnaryFn<T, PatternReturns<P>> = () => (pattern) => (shape) => ) => UnaryFn<T, PatternReturns<P>> = () => (pattern) => (shape) =>
/* // Rewrite not to use any is possible, was evaluated and solutions were
Rewrite not to use any is possible, was evaluated and solutions were // more complex than the current solution.
more complex than the current solution.
*/
// oxlint-disable-next-line typescript/no-explicit-any typescript/no-unsafe-type-assertion // oxlint-disable-next-line typescript/no-explicit-any typescript/no-unsafe-type-assertion
(pattern[shape] as any)(shape); (pattern[shape] as any)(shape);
@@ -50,10 +48,8 @@ export const getPrimitiveUnionMatcherPartial: <T extends string | number>() => <
>( >(
pattern: Simplify<PatternPrimitiveUnionPartial<R, T>>, pattern: Simplify<PatternPrimitiveUnionPartial<R, T>>,
) => UnaryFn<T, R> = () => (pattern) => (shape) => ) => UnaryFn<T, R> = () => (pattern) => (shape) =>
/* // Rewrite not to use any is possible, was evaluated and solutions were
Rewrite not to use any is possible, was evaluated and solutions were // more complex than the current solution.
more complex than the current solution.
*/
// oxlint-disable-next-line typescript/no-explicit-any typescript/no-unsafe-type-assertion // oxlint-disable-next-line typescript/no-explicit-any typescript/no-unsafe-type-assertion
(pattern[shape] ?? (pattern as any)["_"])(shape); (pattern[shape] ?? (pattern as any)["_"])(shape);
@@ -65,13 +61,11 @@ export const getPrimitiveUnionMatcherPartial: <T extends string | number>() => <
export const getPrimitiveUnionMatcherPartialW: < export const getPrimitiveUnionMatcherPartialW: <
T extends string | number, T extends string | number,
>() => <P extends PatternPrimitiveUnionPartial<unknown, T>>( >() => <P extends PatternPrimitiveUnionPartial<unknown, T>>(
/* // `Simplify<P>` is the inference hook: callers infer `P` from the argument.
`Simplify<P>` is the inference hook: callers infer `P` from the argument. // the second half pins the impl parameter's `R` to `PatternReturns<P>`.
the second half pins the impl parameter's `R` to `PatternReturns<P>`. // that makes the `= getPrimitiveUnionMatcherPartial` assignment type-check.
that makes the `= getPrimitiveUnionMatcherPartial` assignment type-check. // neither half works alone.
neither half works alone. // without the witness the union's `_` arm demands `_ ∈ keyof P`.
without the witness the union's `_` arm demands `_ ∈ keyof P`. // without `Simplify<P>` the parameter types do not compare.
without `Simplify<P>` the parameter types do not compare.
*/
pattern: Simplify<P> & PatternPrimitiveUnionPartial<PatternReturns<P>, T>, pattern: Simplify<P> & PatternPrimitiveUnionPartial<PatternReturns<P>, T>,
) => UnaryFn<T, PatternReturns<P>> = getPrimitiveUnionMatcherPartial; ) => UnaryFn<T, PatternReturns<P>> = getPrimitiveUnionMatcherPartial;