@2digits/oxlint-plugin 0.11.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 +7 -0
- package/README.md +26 -0
- package/dist/index.d.mts +6 -3
- package/dist/index.mjs +6 -6
- package/package.json +2 -2
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
|
@@ -59,6 +59,18 @@ The package exports all rules as `rules`, their names as `RuleName`, and the def
|
|
|
59
59
|
- Log results: `no-effect-as-on-log` reports `Effect.as`, `Effect.asSome` and `Effect.asVoid` applied to an
|
|
60
60
|
`Effect.log*` or `Console.*` log effect (`.pipe(Effect.as(x))`, `pipe(log, Effect.as(x))` or data-first). Write
|
|
61
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.
|
|
62
74
|
- Local dates: `no-utc-iso-slicing` reports `.slice`, `.substring`, `.substr`, `.split`, `.replace` and `.replaceAll`
|
|
63
75
|
on `x.toISOString()` or `DateTime.formatIso(x)`, and the matching `effect/String` steps in `pipe`, `flow` and
|
|
64
76
|
`.pipe`. Both strings are UTC, so a sliced date is the previous day just after midnight in Europe/Amsterdam. Format
|
|
@@ -531,10 +543,24 @@ Adapted from [`dmmulroy/anti-slop`](https://github.com/dmmulroy/anti-slop/tree/m
|
|
|
531
543
|
`else if` chains `prefer-effect-match` reports.
|
|
532
544
|
- `no-manual-tagged-construction`: prefer existing constructors over literal string `_tag` objects; direct
|
|
533
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.
|
|
534
556
|
- `no-service-constructor-imports`: reject relative named `make[A-Z]` imports outside `.test`/`.spec` files.
|
|
535
557
|
- `prefer-effect-match`: also reports chained literal ternaries comparing the same source expression, while retaining
|
|
536
558
|
the existing Effect-file switch diagnostic. In Effect files it also reports `else if` chains; see
|
|
537
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`.
|
|
538
564
|
|
|
539
565
|
All are included in `recommendedRules`, without autofixes. Like upstream, these are syntactic policies: they do not
|
|
540
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,6 +94,7 @@ 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;
|
|
@@ -102,10 +105,10 @@ export declare const rules: {
|
|
|
102
105
|
readonly 'throw-in-effect-gen': import("effect-oxlint").CreateRule;
|
|
103
106
|
readonly 'valid-directive': import("effect-oxlint").CreateRule;
|
|
104
107
|
};
|
|
105
|
-
declare const
|
|
108
|
+
declare const TagComparisonOptions: Schema.UndefinedOr<Schema.Struct<{
|
|
106
109
|
readonly discriminants: Schema.optionalKey<Schema.$Array<Schema.String>>;
|
|
107
|
-
}
|
|
108
|
-
type NoManualTagComparisonOptions = typeof
|
|
110
|
+
}>>;
|
|
111
|
+
type NoManualTagComparisonOptions = NonNullable<typeof TagComparisonOptions.Type>;
|
|
109
112
|
type PaddingType = 'any' | 'never' | 'always';
|
|
110
113
|
type LineMode = 'any' | 'singleline' | 'multiline';
|
|
111
114
|
interface SelectorOption {
|