@2digits/oxlint-plugin 0.10.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/NOTICE CHANGED
@@ -13,7 +13,14 @@ Licensed under the MIT License.
13
13
  anti-slop
14
14
  Copyright (c) 2026 Dillon Mulroy
15
15
  https://github.com/dmmulroy/anti-slop
16
+ prefer-tagged-error-handling is adapted from the fork https://github.com/K-Mistele/anti-slop
16
17
  Licensed under the MIT License.
18
+ no-manual-tagged-type is adapted from the K-Mistele/anti-slop fork:
19
+ https://github.com/K-Mistele/anti-slop
20
+
21
+ preserve-caught-error adapts cases from require-cause-when-narrowing in the K-Mistele/anti-slop fork,
22
+ under the same license:
23
+ https://github.com/K-Mistele/anti-slop/blob/main/src/effect/rules/require-cause-when-narrowing.ts
17
24
 
18
25
  t3code (no-inline-schema-compile)
19
26
  Copyright (c) 2026 T3 Tools Inc.
package/README.md CHANGED
@@ -49,9 +49,28 @@ The package exports all rules as `rules`, their names as `RuleName`, and the def
49
49
  - Schema compiler hoisting from t3code: `no-inline-schema-compile` reports `Schema.decode*`, `Schema.encode*`,
50
50
  `Schema.is`, and `Schema.asserts` compilers that are built and invoked inside a function body when their schema
51
51
  could be hoisted to module scope.
52
+ - Typed dual APIs: `require-dual-type-arguments` reports every `Function.dual` call without type arguments in
53
+ TypeScript files, also as
54
+ `dual` imported from `effect/Function` and with an existing function such as `Fn.dual(2, BigDecimal.divideUnsafe)`.
55
+ Without them TypeScript does not check the implementation against an annotation on the constant (inline parameters
56
+ become `any`), and the data-last form returns `any`. Write
57
+ `Fn.dual<(that: B) => (self: A) => R, (self: A, that: B) => R>(2, (self, that) => …)` instead, which types both forms
58
+ and infers the parameters.
52
59
  - Log results: `no-effect-as-on-log` reports `Effect.as`, `Effect.asSome` and `Effect.asVoid` applied to an
53
60
  `Effect.log*` or `Console.*` log effect (`.pipe(Effect.as(x))`, `pipe(log, Effect.as(x))` or data-first). Write
54
61
  `Effect.gen` that `yield*`s the log and returns the value instead.
62
+ - Dropped causes: `preserve-caught-error` reports `Effect.mapError`, `Effect.catch` and `Effect.catchCause` handlers
63
+ (and the v3 `catchAll`), and the `catch` option of `Effect.try`/`Effect.tryPromise`, that construct a new error
64
+ without passing in the failure they receive. It counts `new XError(…)` and `XError.make(…)` anywhere in the handler,
65
+ and any PascalCase class the handler returns, passes to `Effect.fail` or `yield*`s, such as `new BadRequest(…)`.
66
+ Classes from Effect imports, such as `SchemaIssue.InvalidValue`, only count by their `Error` suffix. A
67
+ handler is exempt when the step right before it is an `Effect.tapError` or `Effect.tapCause` whose handler is, or
68
+ returns, an `Effect.log*` or `Console.*` call with the failure: in the same `.pipe`, `pipe` or `Effect.fn` pipeline, a
69
+ receiving `.pipe`, or the source of a data-first call. Only `Effect.map`, `Effect.as*` and `Effect.withSpan` may sit
70
+ in between; any other step, such as `Effect.flatMap`, can add a failure the tap never logged. An `Effect.catchCause`
71
+ handler also receives defects, so only `Effect.tapCause` exempts it. The `catchCause`, `.make`, PascalCase and logging cases are adapted from anti-slop's
72
+ [`require-cause-when-narrowing`](https://github.com/K-Mistele/anti-slop/blob/main/src/effect/rules/require-cause-when-narrowing.ts);
73
+ unlike upstream, a tap that does not log the failure, or that only logs one tag, does not exempt the handler.
55
74
  - Local dates: `no-utc-iso-slicing` reports `.slice`, `.substring`, `.substr`, `.split`, `.replace` and `.replaceAll`
56
75
  on `x.toISOString()` or `DateTime.formatIso(x)`, and the matching `effect/String` steps in `pipe`, `flow` and
57
76
  `.pipe`. Both strings are UTC, so a sliced date is the previous day just after midnight in Europe/Amsterdam. Format
@@ -524,10 +543,24 @@ Adapted from [`dmmulroy/anti-slop`](https://github.com/dmmulroy/anti-slop/tree/m
524
543
  `else if` chains `prefer-effect-match` reports.
525
544
  - `no-manual-tagged-construction`: prefer existing constructors over literal string `_tag` objects; direct
526
545
  `Match.when`/`Match.not` pattern objects are exempt.
546
+ - `no-manual-tagged-type`: report `_tag` written by hand in a type, such as `type Ready = { readonly _tag: 'Ready' }`;
547
+ define the value with a tagged Schema or Data constructor and infer the type, such as `typeof Ready.Type`. Adapted
548
+ from the [`K-Mistele/anti-slop`](https://github.com/K-Mistele/anti-slop/blob/main/src/effect/rules/no-manual-tagged-type.ts)
549
+ fork. Unlike upstream, it only reports `_tag` types that are string literals or unions of them: `string`, a type
550
+ parameter or another type reference describes any tagged value, as in `<A extends { readonly _tag: string }>`,
551
+ which no constructor defines.
552
+ Declaration files and `declare module`/`declare global` blocks are skipped, because they describe values defined
553
+ elsewhere. The filter of `Extract` or `Exclude`, as in `Extract<Payment, { _tag: 'Refund' }>`, is also skipped: it
554
+ selects members of an existing union, which no constructor replaces. A `_tag` type literal passed to any other
555
+ generic, such as `Array<{ _tag: 'A' }>`, is still reported.
527
556
  - `no-service-constructor-imports`: reject relative named `make[A-Z]` imports outside `.test`/`.spec` files.
528
557
  - `prefer-effect-match`: also reports chained literal ternaries comparing the same source expression, while retaining
529
558
  the existing Effect-file switch diagnostic. In Effect files it also reports `else if` chains; see
530
559
  [Effect Match](#effect-match).
560
+ - `prefer-tagged-error-handling`: prefer `Effect.catchTag`/`catchTags` (or `catchReason`/`catchReasons` for an
561
+ error's `reason`) over `Predicate.isTagged` checks, data-first or curried, in broad Effect catches. Adapted from
562
+ [`K-Mistele/anti-slop`](https://github.com/K-Mistele/anti-slop/blob/main/src/effect/rules/prefer-tagged-error-handling.ts),
563
+ a fork of anti-slop; it also recognizes `isTagged` through an Effect import such as `P.isTagged`.
531
564
 
532
565
  All are included in `recommendedRules`, without autofixes. Like upstream, these are syntactic policies: they do not
533
566
  require Effect imports, infer tagged types, or prove that constructors exist. Catch and pattern exemptions recognize
package/dist/index.d.mts CHANGED
@@ -1,3 +1,4 @@
1
+ import "effect/schema/SchemaJITCompiler/enable";
1
2
  import { Plugin } from "effect-oxlint";
2
3
  import * as Arr from "effect/Array";
3
4
  import * as Schema from "effect/Schema";
@@ -44,6 +45,7 @@ export declare const rules: {
44
45
  readonly 'no-manual-sse': import("effect-oxlint").CreateRule;
45
46
  readonly 'no-manual-tag-comparison': import("effect-oxlint").CreateRule;
46
47
  readonly 'no-manual-tagged-construction': import("effect-oxlint").CreateRule;
48
+ readonly 'no-manual-tagged-type': import("effect-oxlint").CreateRule;
47
49
  readonly 'no-millis-arithmetic': import("effect-oxlint").CreateRule;
48
50
  readonly 'no-multi-shot-effect-callback': import("effect-oxlint").CreateRule;
49
51
  readonly 'no-non-json-schema-annotation': import("effect-oxlint").CreateRule;
@@ -92,19 +94,21 @@ export declare const rules: {
92
94
  readonly 'prefer-hoisted-match': import("effect-oxlint").CreateRule;
93
95
  readonly 'prefer-equal': import("effect-oxlint").CreateRule;
94
96
  readonly 'prefer-struct-assign': import("effect-oxlint").CreateRule;
97
+ readonly 'prefer-tagged-error-handling': import("effect-oxlint").CreateRule;
95
98
  readonly 'prefer-uninterruptible': import("effect-oxlint").CreateRule;
96
99
  readonly 'prefer-with-span': import("effect-oxlint").CreateRule;
97
100
  readonly 'prefer-yield-now': import("effect-oxlint").CreateRule;
98
101
  readonly 'preserve-caught-error': import("effect-oxlint").CreateRule;
102
+ readonly 'require-dual-type-arguments': import("effect-oxlint").CreateRule;
99
103
  readonly 'require-schema-class-brand': import("effect-oxlint").CreateRule;
100
104
  readonly 'require-try-promise-abort-signal': import("effect-oxlint").CreateRule;
101
105
  readonly 'throw-in-effect-gen': import("effect-oxlint").CreateRule;
102
106
  readonly 'valid-directive': import("effect-oxlint").CreateRule;
103
107
  };
104
- declare const Options: Schema.Struct<{
108
+ declare const TagComparisonOptions: Schema.UndefinedOr<Schema.Struct<{
105
109
  readonly discriminants: Schema.optionalKey<Schema.$Array<Schema.String>>;
106
- }>;
107
- type NoManualTagComparisonOptions = typeof Options.Type;
110
+ }>>;
111
+ type NoManualTagComparisonOptions = NonNullable<typeof TagComparisonOptions.Type>;
108
112
  type PaddingType = 'any' | 'never' | 'always';
109
113
  type LineMode = 'any' | 'singleline' | 'multiline';
110
114
  interface SelectorOption {