@opsydyn/oxlint-effect 1.0.0 → 2.0.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.
Files changed (44) hide show
  1. package/README.md +458 -80
  2. package/dist/index.d.mts +6596 -279
  3. package/dist/index.mjs +1 -1
  4. package/dist/index.mjs.map +1 -1
  5. package/package.json +12 -6
  6. package/skills/oxlint-effect/SKILL.md +114 -0
  7. package/skills/oxlint-effect/assets/contracts.ts +39 -0
  8. package/skills/oxlint-effect/assets/domain-context.bad.ts +18 -0
  9. package/skills/oxlint-effect/assets/domain-context.good.ts +32 -0
  10. package/skills/oxlint-effect/assets/domain-decisions.bad.ts +26 -0
  11. package/skills/oxlint-effect/assets/domain-decisions.good.ts +71 -0
  12. package/skills/oxlint-effect/assets/domain-shapes.bad.ts +22 -0
  13. package/skills/oxlint-effect/assets/domain-shapes.good.ts +39 -0
  14. package/skills/oxlint-effect/assets/domain.bad.ts +16 -0
  15. package/skills/oxlint-effect/assets/domain.good.ts +32 -0
  16. package/skills/oxlint-effect/assets/effect4/contracts.ts +39 -0
  17. package/skills/oxlint-effect/assets/effect4/domain-context.bad.ts +18 -0
  18. package/skills/oxlint-effect/assets/effect4/domain-context.good.ts +32 -0
  19. package/skills/oxlint-effect/assets/effect4/domain-decisions.bad.ts +26 -0
  20. package/skills/oxlint-effect/assets/effect4/domain-decisions.good.ts +71 -0
  21. package/skills/oxlint-effect/assets/effect4/domain-shapes.bad.ts +22 -0
  22. package/skills/oxlint-effect/assets/effect4/domain-shapes.good.ts +39 -0
  23. package/skills/oxlint-effect/assets/effect4/domain.bad.ts +16 -0
  24. package/skills/oxlint-effect/assets/effect4/domain.good.ts +32 -0
  25. package/skills/oxlint-effect/assets/effect4/error-preservation.bad.ts +21 -0
  26. package/skills/oxlint-effect/assets/effect4/error-preservation.good.ts +18 -0
  27. package/skills/oxlint-effect/assets/effect4/expected-state.bad.ts +28 -0
  28. package/skills/oxlint-effect/assets/effect4/expected-state.good.ts +19 -0
  29. package/skills/oxlint-effect/assets/effect4/public-errors.bad.ts +20 -0
  30. package/skills/oxlint-effect/assets/effect4/public-errors.good.ts +33 -0
  31. package/skills/oxlint-effect/assets/error-preservation.bad.ts +21 -0
  32. package/skills/oxlint-effect/assets/error-preservation.good.ts +18 -0
  33. package/skills/oxlint-effect/assets/expected-state.bad.ts +28 -0
  34. package/skills/oxlint-effect/assets/expected-state.good.ts +19 -0
  35. package/skills/oxlint-effect/assets/public-errors.bad.ts +20 -0
  36. package/skills/oxlint-effect/assets/public-errors.good.ts +33 -0
  37. package/skills/oxlint-effect/references/configuration.md +117 -0
  38. package/skills/oxlint-effect/references/domain-context.md +84 -0
  39. package/skills/oxlint-effect/references/domain-decisions.md +93 -0
  40. package/skills/oxlint-effect/references/domain-modeling.md +140 -0
  41. package/skills/oxlint-effect/references/error-preservation.md +76 -0
  42. package/skills/oxlint-effect/references/expected-state.md +78 -0
  43. package/skills/oxlint-effect/references/public-errors.md +80 -0
  44. package/skills/oxlint-effect/references/versioned-rules.md +309 -0
@@ -0,0 +1,71 @@
1
+ // Effect 4 first-class asset; qualify against the pinned current consumer.
2
+ import { Match, Predicate, Schema } from "effect";
3
+
4
+ const ApprovedStatus = Schema.Literal("approved");
5
+ export const OrderStatus = Schema.Union([
6
+ Schema.Literals(["pending", "shipped", "cancelled"]),
7
+ ApprovedStatus,
8
+ ]);
9
+ export type OrderStatus = typeof OrderStatus.Type;
10
+ export const decodeOrderStatus = Schema.decodeUnknownSync(OrderStatus);
11
+ const matchesApprovedStatus = Schema.is(ApprovedStatus);
12
+
13
+ export function isApproved(status: OrderStatus) {
14
+ return matchesApprovedStatus(status);
15
+ }
16
+
17
+ const exceedsMinimumTotal = (total: number) => total > 100;
18
+ const meetsItemMinimum = (itemCount: number) => itemCount >= 2;
19
+ const withinDiscountCap = (discountPercentage: number) => discountPercentage <= 20;
20
+
21
+ export const canApplyDiscount = Predicate.Struct({
22
+ total: exceedsMinimumTotal,
23
+ itemCount: meetsItemMinimum,
24
+ discountPercentage: withinDiscountCap,
25
+ });
26
+
27
+ export const Open = Schema.TaggedStruct("Open", {});
28
+ export type Open = typeof Open.Type;
29
+ export const Shipped = Schema.TaggedStruct("Shipped", {});
30
+ export const Cancelled = Schema.TaggedStruct("Cancelled", {});
31
+ export const OrderState = Schema.Union([Open, Shipped, Cancelled]);
32
+ export type OrderState = typeof OrderState.Type;
33
+
34
+ const LegacyOrderState = Schema.Union([
35
+ Schema.Struct({ cancelled: Schema.Literal(false), shipped: Schema.Literal(false) }),
36
+ Schema.Struct({ cancelled: Schema.Literal(true), shipped: Schema.Literal(false) }),
37
+ Schema.Struct({ cancelled: Schema.Literal(false), shipped: Schema.Literal(true) }),
38
+ ]);
39
+ const decodeLegacyFlags = Schema.decodeUnknownSync(LegacyOrderState, {
40
+ onExcessProperty: "error",
41
+ });
42
+
43
+ export function decodeLegacyOrderState(input: unknown): OrderState {
44
+ const flags = decodeLegacyFlags(input);
45
+ return Match.value(flags).pipe(
46
+ Match.when({ cancelled: true }, () => Cancelled.make({})),
47
+ Match.when({ shipped: true }, () => Shipped.make({})),
48
+ Match.orElse(() => Open.make({})),
49
+ );
50
+ }
51
+
52
+ export function encodeLegacyOrderState(state: OrderState) {
53
+ const validated = Schema.decodeUnknownSync(OrderState, { onExcessProperty: "error" })(state);
54
+ return Match.value(validated).pipe(Match.tagsExhaustive({
55
+ Open: () => ({ cancelled: false, shipped: false }),
56
+ Shipped: () => ({ cancelled: false, shipped: true }),
57
+ Cancelled: () => ({ cancelled: true, shipped: false }),
58
+ }));
59
+ }
60
+
61
+ const validateOpen = Schema.decodeUnknownSync(Open, { onExcessProperty: "error" });
62
+
63
+ export function shipOrder(state: Open) {
64
+ validateOpen(state);
65
+ return Shipped.make({});
66
+ }
67
+
68
+ export function cancelOrder(state: Open) {
69
+ validateOpen(state);
70
+ return Cancelled.make({});
71
+ }
@@ -0,0 +1,22 @@
1
+ // Effect 4 first-class asset; qualify against the pinned current consumer.
2
+ import { Schema } from "effect";
3
+
4
+ // EXPECT: linteffect/no-raw-domain-primitive-params
5
+ // QA: Positional strings and numbers do not express account and amount contracts.
6
+ export function transferFunds(fromAccountId: string, toAccountId: string, transferAmount: number) {
7
+ return { fromAccountId, toAccountId, transferAmount };
8
+ }
9
+
10
+ // EXPECT: linteffect/no-raw-time-domain-field
11
+ // QA: This contract uses epoch milliseconds, but a raw number does not encode the unit.
12
+ export interface SessionLease {
13
+ readonly expiresAt: number;
14
+ }
15
+
16
+ // EXPECT: linteffect/no-overloaded-options-object
17
+ // QA: Intended fields are invoiceId, amount, and optional memo; any cannot enforce them.
18
+ export function createPaymentIntent(opts: any) {
19
+ return opts;
20
+ }
21
+
22
+ void Schema;
@@ -0,0 +1,39 @@
1
+ // Effect 4 first-class asset; qualify against the pinned current consumer.
2
+ import { Schema } from "effect";
3
+
4
+ export const AccountId = Schema.String.pipe(Schema.brand("AccountId"));
5
+ export const TransferAmount = Schema.Number.pipe(Schema.brand("TransferAmount"));
6
+
7
+ export const TransferCommand = Schema.Struct({
8
+ fromAccountId: AccountId,
9
+ toAccountId: AccountId,
10
+ transferAmount: TransferAmount,
11
+ });
12
+ export type TransferCommand = typeof TransferCommand.Type;
13
+ export const decodeTransferCommand = Schema.decodeUnknownSync(TransferCommand);
14
+ export const encodeTransferCommand = Schema.encodeSync(TransferCommand);
15
+
16
+ export function transferFunds(command: TransferCommand) {
17
+ return command;
18
+ }
19
+
20
+ export const EpochMillis = Schema.Number.pipe(Schema.brand("EpochMillis"));
21
+ export const SessionLease = Schema.Struct({ expiresAt: EpochMillis });
22
+ export type SessionLease = typeof SessionLease.Type;
23
+ export const decodeSessionLease = Schema.decodeUnknownSync(SessionLease);
24
+ export const encodeSessionLease = Schema.encodeSync(SessionLease);
25
+
26
+ export const PaymentIntent = Schema.Struct({
27
+ invoiceId: Schema.String,
28
+ amount: Schema.Number,
29
+ memo: Schema.optionalKey(Schema.UndefinedOr(Schema.String)),
30
+ });
31
+ export type PaymentIntent = typeof PaymentIntent.Type;
32
+ export const decodePaymentIntent = Schema.decodeUnknownSync(PaymentIntent, {
33
+ onExcessProperty: "error",
34
+ });
35
+ export const encodePaymentIntent = Schema.encodeSync(PaymentIntent);
36
+
37
+ export function createPaymentIntent(options: PaymentIntent) {
38
+ return options;
39
+ }
@@ -0,0 +1,16 @@
1
+ // Effect 4 first-class asset; qualify against the pinned current consumer.
2
+ import { Effect } from "effect";
3
+
4
+ // EXPECT: linteffect/no-raw-domain-id-alias
5
+ // QA: Raw aliases do not distinguish user identifiers from other strings.
6
+ export type UserId = string;
7
+
8
+ // EXPECT: linteffect/no-boolean-domain-flag
9
+ // QA: The caller must remember what true and false mean.
10
+ export function settleInvoice(invoiceId: string, shouldNotifyCustomer: boolean) {
11
+ return { invoiceId, shouldNotifyCustomer };
12
+ }
13
+
14
+ // EXPECT: linteffect/no-adhoc-domain-error
15
+ // QA: String failures lose structured operation context.
16
+ export const rejectedTransfer = Effect.fail("not allowed");
@@ -0,0 +1,32 @@
1
+ // Effect 4 first-class asset; qualify against the pinned current consumer.
2
+ import { Data, Effect, Schema } from "effect";
3
+
4
+ export const UserId = Schema.NonEmptyString.pipe(Schema.brand("UserId"));
5
+ export type UserId = typeof UserId.Type;
6
+ export const decodeUserId = Schema.decodeUnknownSync(UserId);
7
+
8
+ export const InvoiceId = Schema.NonEmptyString.pipe(Schema.brand("InvoiceId"));
9
+ export type InvoiceId = typeof InvoiceId.Type;
10
+ export const decodeInvoiceId = Schema.decodeUnknownSync(InvoiceId);
11
+
12
+ export const NotificationMode = Schema.Literals(["Notify", "Silent"]);
13
+ export type NotificationMode = typeof NotificationMode.Type;
14
+
15
+ const notificationSettings: Record<NotificationMode, boolean> = {
16
+ Notify: true,
17
+ Silent: false,
18
+ };
19
+
20
+ export function settleInvoice(invoiceId: InvoiceId, notification: NotificationMode) {
21
+ return { invoiceId, shouldNotifyCustomer: notificationSettings[notification] };
22
+ }
23
+
24
+ export class TransferRejected extends Data.TaggedError("TransferRejected")<{
25
+ readonly userId: UserId;
26
+ readonly reason: string;
27
+ }> {}
28
+
29
+ export function rejectTransfer(userId: UserId) {
30
+ const error = new TransferRejected({ userId, reason: "not allowed" });
31
+ return Effect.fail(error);
32
+ }
@@ -0,0 +1,21 @@
1
+ // Effect 4 first-class asset; qualify against the pinned current consumer.
2
+ import { Effect } from "effect";
3
+ import { type ProfileUnavailable } from "./public-errors.good";
4
+
5
+ // EXPECT: linteffect/no-effect-fail-error-message
6
+ // QA: Converting the structured error to its message loses the tag and cause.
7
+ export function rejectProfile(error: ProfileUnavailable) {
8
+ return Effect.fail(error.message);
9
+ }
10
+
11
+ // EXPECT: linteffect/no-catchall-generic-rethrow
12
+ // QA: Replacing every typed failure with a generic error erases the original.
13
+ export function rethrowProfile(operation: Effect.Effect<string, ProfileUnavailable>) {
14
+ return Effect.catch(operation, () => Effect.fail(new Error("profile failed")));
15
+ }
16
+
17
+ // EXPECT: linteffect/no-log-only-error-handling
18
+ // QA: This handler turns the original failure into successful void after logging.
19
+ export function observeProfile(operation: Effect.Effect<string, ProfileUnavailable>) {
20
+ return Effect.catch(operation, (error) => Effect.logError(error));
21
+ }
@@ -0,0 +1,18 @@
1
+ // Effect 4 first-class asset; qualify against the pinned current consumer.
2
+ import { Effect } from "effect";
3
+ import { type ProfileUnavailable } from "./public-errors.good";
4
+
5
+ export function rejectProfile(error: ProfileUnavailable) {
6
+ return Effect.fail(error);
7
+ }
8
+
9
+ export function rethrowProfile(operation: Effect.Effect<string, ProfileUnavailable>) {
10
+ return operation;
11
+ }
12
+
13
+ export function observeProfile(operation: Effect.Effect<string, ProfileUnavailable>) {
14
+ return Effect.catch(operation, (error) => Effect.gen(function* () {
15
+ yield* Effect.logError(error);
16
+ return yield* Effect.fail(error);
17
+ }));
18
+ }
@@ -0,0 +1,28 @@
1
+ // Effect 4 first-class asset; qualify against the pinned current consumer.
2
+ import { Effect } from "effect";
3
+ import { type ProfileUnavailable } from "./public-errors.good";
4
+ import { CheckoutRejectedError } from "./expected-state.good";
5
+
6
+ export function lookupSelection(selection: string | undefined) {
7
+ if (selection === undefined) {
8
+ // EXPECT: linteffect/no-expected-state-as-error
9
+ // EXPECT: linteffect/no-adhoc-domain-error
10
+ // QA: Ordinary absence is represented as a string failure; both rules apply.
11
+ return Effect.fail("NotFound");
12
+ }
13
+ return Effect.succeed(selection);
14
+ }
15
+
16
+ // EXPECT: linteffect/no-early-catchall-null
17
+ // QA: Storage failures become indistinguishable from successful absence.
18
+ export function recoverProfile(operation: Effect.Effect<string, ProfileUnavailable>) {
19
+ return Effect.catch(operation, () => Effect.succeed(null));
20
+ }
21
+
22
+ // EXPECT: linteffect/no-exception-domain-error
23
+ // QA: This documented expected rejection becomes a defect, not a typed failure.
24
+ export function rejectCheckout(reason: string) {
25
+ return Effect.gen(function* () {
26
+ throw new CheckoutRejectedError({ reason });
27
+ });
28
+ }
@@ -0,0 +1,19 @@
1
+ // Effect 4 first-class asset; qualify against the pinned current consumer.
2
+ import { Data, Effect, Option } from "effect";
3
+ import { type ProfileUnavailable } from "./public-errors.good";
4
+
5
+ export function lookupSelection(selection: string | undefined) {
6
+ return Effect.succeed(Option.fromNullishOr(selection));
7
+ }
8
+
9
+ export function recoverProfile(operation: Effect.Effect<string, ProfileUnavailable>) {
10
+ return operation;
11
+ }
12
+
13
+ export class CheckoutRejectedError extends Data.TaggedError("CheckoutRejectedError")<{
14
+ readonly reason: string;
15
+ }> {}
16
+
17
+ export function rejectCheckout(reason: string) {
18
+ return Effect.fail(new CheckoutRejectedError({ reason }));
19
+ }
@@ -0,0 +1,20 @@
1
+ // Effect 4 first-class asset; qualify against the pinned current consumer.
2
+ import { Effect } from "effect";
3
+
4
+ // EXPECT: linteffect/no-error-as-public-effect-error
5
+ // QA: The public contract cannot distinguish a profile operation failure by tag.
6
+ export function loadProfile(operation: Effect.Effect<string, Error>): Effect.Effect<string, Error> {
7
+ return operation;
8
+ }
9
+
10
+ // EXPECT: linteffect/no-unknown-public-error-channel
11
+ // QA: Callers receive opaque failures with no operation-specific error contract.
12
+ export function refreshSession(operation: Effect.Effect<string, unknown>): Effect.Effect<string, unknown> {
13
+ return operation;
14
+ }
15
+
16
+ // EXPECT: linteffect/no-mixed-effect-error-shapes
17
+ // QA: This adapter uses strings for validation details and numbers for upstream codes.
18
+ export function readInventory(operation: Effect.Effect<number, string | number>): Effect.Effect<number, string | number> {
19
+ return operation;
20
+ }
@@ -0,0 +1,33 @@
1
+ // Effect 4 first-class asset; qualify against the pinned current consumer.
2
+ import { Data, Effect, Match } from "effect";
3
+
4
+ export class ProfileUnavailable extends Data.TaggedError("ProfileUnavailable")<{
5
+ readonly cause: Error;
6
+ }> {}
7
+
8
+ export class SessionRefreshFailed extends Data.TaggedError("SessionRefreshFailed")<{
9
+ readonly cause: unknown;
10
+ }> {}
11
+
12
+ export class InventoryRejected extends Data.TaggedError("InventoryRejected")<{
13
+ readonly detail: string;
14
+ }> {}
15
+
16
+ export class InventoryUnavailable extends Data.TaggedError("InventoryUnavailable")<{
17
+ readonly code: number;
18
+ }> {}
19
+
20
+ export function loadProfile(operation: Effect.Effect<string, Error>): Effect.Effect<string, ProfileUnavailable> {
21
+ return Effect.mapError(operation, (cause) => new ProfileUnavailable({ cause }));
22
+ }
23
+
24
+ export function refreshSession(operation: Effect.Effect<string, unknown>): Effect.Effect<string, SessionRefreshFailed> {
25
+ return Effect.mapError(operation, (cause) => new SessionRefreshFailed({ cause }));
26
+ }
27
+
28
+ export function readInventory(operation: Effect.Effect<number, string | number>): Effect.Effect<number, InventoryRejected | InventoryUnavailable> {
29
+ return Effect.mapError(operation, (failure) => Match.value(failure).pipe(
30
+ Match.when(Match.string, (detail) => new InventoryRejected({ detail })),
31
+ Match.orElse((code) => new InventoryUnavailable({ code })),
32
+ ));
33
+ }
@@ -0,0 +1,21 @@
1
+ // Legacy Effect 3 asset; use assets/effect4 for current policy.
2
+ import { Effect } from "effect";
3
+ import { type ProfileUnavailable } from "./public-errors.good";
4
+
5
+ // EXPECT: linteffect/no-effect-fail-error-message
6
+ // QA: Converting the structured error to its message loses the tag and cause.
7
+ export function rejectProfile(error: ProfileUnavailable) {
8
+ return Effect.fail(error.message);
9
+ }
10
+
11
+ // EXPECT: linteffect/no-catchall-generic-rethrow
12
+ // QA: Replacing every typed failure with a generic error erases the original.
13
+ export function rethrowProfile(operation: Effect.Effect<string, ProfileUnavailable>) {
14
+ return Effect.catchAll(operation, () => Effect.fail(new Error("profile failed")));
15
+ }
16
+
17
+ // EXPECT: linteffect/no-log-only-error-handling
18
+ // QA: This handler turns the original failure into successful void after logging.
19
+ export function observeProfile(operation: Effect.Effect<string, ProfileUnavailable>) {
20
+ return Effect.catchAll(operation, (error) => Effect.logError(error));
21
+ }
@@ -0,0 +1,18 @@
1
+ // Legacy Effect 3 asset; use assets/effect4 for current policy.
2
+ import { Effect } from "effect";
3
+ import { type ProfileUnavailable } from "./public-errors.good";
4
+
5
+ export function rejectProfile(error: ProfileUnavailable) {
6
+ return Effect.fail(error);
7
+ }
8
+
9
+ export function rethrowProfile(operation: Effect.Effect<string, ProfileUnavailable>) {
10
+ return operation;
11
+ }
12
+
13
+ export function observeProfile(operation: Effect.Effect<string, ProfileUnavailable>) {
14
+ return Effect.catchAll(operation, (error) => Effect.gen(function* () {
15
+ yield* Effect.logError(error);
16
+ return yield* Effect.fail(error);
17
+ }));
18
+ }
@@ -0,0 +1,28 @@
1
+ // Legacy Effect 3 asset; use assets/effect4 for current policy.
2
+ import { Effect } from "effect";
3
+ import { type ProfileUnavailable } from "./public-errors.good";
4
+ import { CheckoutRejectedError } from "./expected-state.good";
5
+
6
+ export function lookupSelection(selection: string | undefined) {
7
+ if (selection === undefined) {
8
+ // EXPECT: linteffect/no-expected-state-as-error
9
+ // EXPECT: linteffect/no-adhoc-domain-error
10
+ // QA: Ordinary absence is represented as a string failure; both rules apply.
11
+ return Effect.fail("NotFound");
12
+ }
13
+ return Effect.succeed(selection);
14
+ }
15
+
16
+ // EXPECT: linteffect/no-early-catchall-null
17
+ // QA: Storage failures become indistinguishable from successful absence.
18
+ export function recoverProfile(operation: Effect.Effect<string, ProfileUnavailable>) {
19
+ return Effect.catchAll(operation, () => Effect.succeed(null));
20
+ }
21
+
22
+ // EXPECT: linteffect/no-exception-domain-error
23
+ // QA: This documented expected rejection becomes a defect, not a typed failure.
24
+ export function rejectCheckout(reason: string) {
25
+ return Effect.gen(function* () {
26
+ throw new CheckoutRejectedError({ reason });
27
+ });
28
+ }
@@ -0,0 +1,19 @@
1
+ // Legacy Effect 3 asset; use assets/effect4 for current policy.
2
+ import { Data, Effect, Option } from "effect";
3
+ import { type ProfileUnavailable } from "./public-errors.good";
4
+
5
+ export function lookupSelection(selection: string | undefined) {
6
+ return Effect.succeed(Option.fromNullable(selection));
7
+ }
8
+
9
+ export function recoverProfile(operation: Effect.Effect<string, ProfileUnavailable>) {
10
+ return operation;
11
+ }
12
+
13
+ export class CheckoutRejectedError extends Data.TaggedError("CheckoutRejectedError")<{
14
+ readonly reason: string;
15
+ }> {}
16
+
17
+ export function rejectCheckout(reason: string) {
18
+ return Effect.fail(new CheckoutRejectedError({ reason }));
19
+ }
@@ -0,0 +1,20 @@
1
+ // Legacy Effect 3 asset; use assets/effect4 for current policy.
2
+ import { Effect } from "effect";
3
+
4
+ // EXPECT: linteffect/no-error-as-public-effect-error
5
+ // QA: The public contract cannot distinguish a profile operation failure by tag.
6
+ export function loadProfile(operation: Effect.Effect<string, Error>): Effect.Effect<string, Error> {
7
+ return operation;
8
+ }
9
+
10
+ // EXPECT: linteffect/no-unknown-public-error-channel
11
+ // QA: Callers receive opaque failures with no operation-specific error contract.
12
+ export function refreshSession(operation: Effect.Effect<string, unknown>): Effect.Effect<string, unknown> {
13
+ return operation;
14
+ }
15
+
16
+ // EXPECT: linteffect/no-mixed-effect-error-shapes
17
+ // QA: This adapter uses strings for validation details and numbers for upstream codes.
18
+ export function readInventory(operation: Effect.Effect<number, string | number>): Effect.Effect<number, string | number> {
19
+ return operation;
20
+ }
@@ -0,0 +1,33 @@
1
+ // Legacy Effect 3 asset; use assets/effect4 for current policy.
2
+ import { Data, Effect, Match } from "effect";
3
+
4
+ export class ProfileUnavailable extends Data.TaggedError("ProfileUnavailable")<{
5
+ readonly cause: Error;
6
+ }> {}
7
+
8
+ export class SessionRefreshFailed extends Data.TaggedError("SessionRefreshFailed")<{
9
+ readonly cause: unknown;
10
+ }> {}
11
+
12
+ export class InventoryRejected extends Data.TaggedError("InventoryRejected")<{
13
+ readonly detail: string;
14
+ }> {}
15
+
16
+ export class InventoryUnavailable extends Data.TaggedError("InventoryUnavailable")<{
17
+ readonly code: number;
18
+ }> {}
19
+
20
+ export function loadProfile(operation: Effect.Effect<string, Error>): Effect.Effect<string, ProfileUnavailable> {
21
+ return Effect.mapError(operation, (cause) => new ProfileUnavailable({ cause }));
22
+ }
23
+
24
+ export function refreshSession(operation: Effect.Effect<string, unknown>): Effect.Effect<string, SessionRefreshFailed> {
25
+ return Effect.mapError(operation, (cause) => new SessionRefreshFailed({ cause }));
26
+ }
27
+
28
+ export function readInventory(operation: Effect.Effect<number, string | number>): Effect.Effect<number, InventoryRejected | InventoryUnavailable> {
29
+ return Effect.mapError(operation, (failure) => Match.value(failure).pipe(
30
+ Match.when(Match.string, (detail) => new InventoryRejected({ detail })),
31
+ Match.orElse((code) => new InventoryUnavailable({ code })),
32
+ ));
33
+ }
@@ -0,0 +1,117 @@
1
+ # Consumer Configuration
2
+
3
+ ## Effect Major
4
+
5
+ In this unreleased 2.0 checkout default groups target Effect 4; published 1.x
6
+ remains legacy. Every preset and rules-only companion is available under
7
+ `effect3` for Effect 3. See [all versioned groups](versioned-rules.md) for the
8
+ matching failure/repair corpus. Verify the installed package before selecting it.
9
+
10
+ ```ts
11
+ import { defineConfig } from "oxlint";
12
+ import { effect3 } from "@opsydyn/oxlint-effect";
13
+
14
+ export default defineConfig({
15
+ jsPlugins: [...effect3.ddd.jsPlugins],
16
+ rules: effect3.dddRules,
17
+ });
18
+ ```
19
+
20
+ Sensitive manual entries default to Effect 4. Preserve the selected major when
21
+ overriding severity, `boundaryPaths` or `configPaths`; apply overrides after maps.
22
+ An explicit override does not make removed APIs applicable to current Effect.
23
+
24
+ ## Install Or Upgrade
25
+
26
+ Use the consumer's package manager and lockfile. Inspect the installed Oxlint
27
+ and plugin versions and their supported configuration APIs. Update the existing
28
+ dependency instead of introducing a second plugin copy. Do not upgrade Effect or
29
+ TypeScript as a side effect of ordinary lint configuration.
30
+
31
+ For a new Bun consumer:
32
+
33
+ ```bash
34
+ bun add -d oxlint @opsydyn/oxlint-effect
35
+ ```
36
+
37
+ The package supplies its own runtime dependencies. A consumer does not need to
38
+ vendor plugin source or copy this repository's development dependencies.
39
+
40
+ ## Select Policy
41
+
42
+ `recommended` selects the package's broad default policy. `ddd` combines Domain
43
+ Modeling and Error Modeling; `domainModeling` selects just Domain Modeling.
44
+ They are alternative starting policies, not escalating installation steps.
45
+ Keep a consumer's selected policy and explicit rule overrides unless changing
46
+ them is requested. Inspect other group exports in the installed package docs.
47
+
48
+ Focused DDD configuration:
49
+
50
+ ```ts
51
+ import { defineConfig } from "oxlint";
52
+ import { ddd } from "@opsydyn/oxlint-effect";
53
+
54
+ export default defineConfig({
55
+ plugins: ["typescript"],
56
+ jsPlugins: [...ddd.jsPlugins],
57
+ rules: ddd.rules,
58
+ });
59
+ ```
60
+
61
+ This is a new-config example. When adapting an existing config, merge its
62
+ plugin array rather than replacing it, deduplicate the `linteffect` entry, and
63
+ preserve unrelated entries. The spread converts the readonly tuple to the
64
+ mutable array expected by Oxlint.
65
+
66
+ Compose rule maps when multiple groups were requested:
67
+
68
+ ```ts
69
+ import { defineConfig } from "oxlint";
70
+ import { domainModeling, domainModelingRules, errorModelingRules } from "@opsydyn/oxlint-effect";
71
+
72
+ export default defineConfig({
73
+ plugins: ["typescript"],
74
+ jsPlugins: [...domainModeling.jsPlugins],
75
+ rules: { ...domainModelingRules, ...errorModelingRules },
76
+ });
77
+ ```
78
+
79
+ Apply retained explicit rule settings after preset maps so that the migration
80
+ does not silently override the consumer's policy. Preserve file overrides too.
81
+
82
+ ## Type-Aware Opt-In
83
+
84
+ Only enable type-aware linting when requested and supported by the installed
85
+ Oxlint. Consult that version's requirements for `oxlint-tsgolint`, TypeScript,
86
+ project resolution, and editor integration. The consumer owns the engine
87
+ dependency and must build workspace dependencies whose declarations are needed.
88
+
89
+ ```ts
90
+ import { defineConfig } from "oxlint";
91
+ import { typeAware } from "@opsydyn/oxlint-effect";
92
+
93
+ export default defineConfig({
94
+ options: typeAware.options,
95
+ jsPlugins: [...typeAware.jsPlugins],
96
+ plugins: ["typescript"],
97
+ rules: {
98
+ ...typeAware.rules,
99
+ "typescript/no-floating-promises": "error",
100
+ "typescript/no-misused-promises": "error",
101
+ },
102
+ });
103
+ ```
104
+
105
+ Verify both built-in rule names exist in the installed Oxlint. Merge root
106
+ options with existing options. `typeAware` keeps recommended syntax rules and
107
+ enables the engine; typed TypeScript rules are consumer selections. `typeCheck`
108
+ is a separate compiler-diagnostics opt-in. Custom `linteffect` rules do not gain
109
+ resolved type information merely by enabling the engine.
110
+
111
+ ## Validation
112
+
113
+ Run the existing lint/typecheck scripts from the relevant workspace. Record
114
+ baseline diagnostics before modifying policy, then distinguish newly introduced
115
+ findings from existing ones. Assessment or configuration work does not imply a
116
+ full application migration. Do not create ignore patterns for owned application
117
+ code merely to make the setup pass.