@2digits/oxlint-plugin 0.5.0 → 0.6.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/README.md CHANGED
@@ -134,6 +134,49 @@ There is **no autofix**: the constant changes from `number` to `Duration`. Conve
134
134
  `Duration.toMillis` or `Duration.toSeconds`, read configurable durations with `Config.Duration`, and use
135
135
  `Schema.DurationFromMillis` for schema fields.
136
136
 
137
+ ### Millisecond parameters, fields, and arithmetic
138
+
139
+ `prefer-effect-duration-types` reports parameters and fields named `*Ms`, `*Millis`, or `*Milliseconds` that are typed as
140
+ `number` (optionally `| undefined` or `| null`, or with a number default) or decoded with `Schema.Number`, `Schema.Int`,
141
+ or `Schema.Finite` (also inside `optional`, `optionalKey`, `NullOr` and `.check(...)`, or piped only through modifiers,
142
+ checks, brands, annotations and defaults):
143
+
144
+ ```ts
145
+ import * as Schema from 'effect/Schema';
146
+
147
+ function poll(intervalMs: number) {} // Type it as Duration.Input
148
+ interface Options {
149
+ readonly timeoutMs: number;
150
+ } // Type it as Duration.Duration
151
+ const Job = Schema.Struct({ backoffMs: Schema.Number }); // Use Schema.DurationFromMillis or Schema.Duration
152
+ ```
153
+
154
+ It only targets code the file owns. Callback parameters of non-Effect APIs (`sdk.on('done', (elapsedMs: number) => ...)`),
155
+ ambient declarations (`.d.ts`/`.d.mts`/`.d.cts` files and `declare` modules, globals, classes and variables), overload signatures, and timestamp names (`*AtMs`,
156
+ `startMs`, `deadlineMs`, `lastSeenMs`) are skipped. For schemas that decode external data, `Schema.DurationFromMillis`
157
+ keeps milliseconds in the encoded data while the decoded field is a `Duration`, so the advice also holds at a boundary.
158
+
159
+ `no-millis-arithmetic` reports `+ - * /`, `< <= > >=`, and `=== !==` when an operand is a millisecond number:
160
+ a `Duration.toMillis(...)` or `DateTime.toEpochMillis(...)` call, a `yield* Clock.currentTimeMillis` result, a local
161
+ binding named `*Ms`/`*Millis`/`*_MS`, a `this.*Ms` field, or a `const` that holds one of these. The message names the
162
+ replacement, such as `Duration.sum`, `Duration.times`, `Duration.isGreaterThan`, `DateTime.addDuration`,
163
+ `DateTime.distance`, or `DateTime.isLessThan`:
164
+
165
+ ```ts
166
+ import * as DateTime from 'effect/DateTime';
167
+ import * as Duration from 'effect/Duration';
168
+
169
+ Duration.toMillis(timeout) + Duration.toMillis(delay); // Duration.sum
170
+ DateTime.toEpochMillis(now) > expiresAtMs; // DateTime.isGreaterThan
171
+ const elapsed = endMs - startMs; // DateTime.distance
172
+ ```
173
+
174
+ To keep false positives from code that only relays someone else's milliseconds, it ignores fields of other objects
175
+ (`response.durationMs`), bindings destructured from objects (`const { durationMs } = response`), callback parameters of
176
+ non-Effect APIs, string concatenation, and `=== undefined`/`=== null` presence checks. A conversion passed straight to a
177
+ non-Effect API (`setTimeout(run, Duration.toMillis(delay))`) is the intended boundary and is not reported. A chain such as
178
+ `toMillis(a) + toMillis(b) > limitMs` is reported once.
179
+
137
180
  ### Function-valued Config defaults
138
181
 
139
182
  `no-function-config-default` reports inline zero-parameter functions passed to Effect's eager `Config.withDefault` API,
package/dist/index.d.mts CHANGED
@@ -36,6 +36,7 @@ export declare const rules: {
36
36
  readonly 'no-manual-effect-error-tag': import("effect-oxlint").OxlintRule;
37
37
  readonly 'no-manual-tag-comparison': import("effect-oxlint").OxlintRule;
38
38
  readonly 'no-manual-tagged-construction': import("effect-oxlint").OxlintRule;
39
+ readonly 'no-millis-arithmetic': import("effect-oxlint").OxlintRule;
39
40
  readonly 'no-multi-shot-effect-callback': import("effect-oxlint").OxlintRule;
40
41
  readonly 'no-non-json-schema-annotation': import("effect-oxlint").OxlintRule;
41
42
  readonly 'no-option-of-service': import("effect-oxlint").OxlintRule;
@@ -51,6 +52,7 @@ export declare const rules: {
51
52
  readonly 'prefer-effect-datetime': import("effect-oxlint").OxlintRule;
52
53
  readonly 'prefer-effect-duration': import("effect-oxlint").OxlintRule;
53
54
  readonly 'prefer-effect-duration-constants': import("effect-oxlint").OxlintRule;
55
+ readonly 'prefer-effect-duration-types': import("effect-oxlint").OxlintRule;
54
56
  readonly 'prefer-effect-encoding': import("effect-oxlint").OxlintRule;
55
57
  readonly 'prefer-effect-filesystem': import("effect-oxlint").OxlintRule;
56
58
  readonly 'prefer-effect-filter': import("effect-oxlint").OxlintRule;
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import{defineRule as e,eslintCompatPlugin as t}from"@oxlint/plugins";import*as n from"effect/Record";import*as r from"effect/Array";import*as i from"effect/String";import*as a from"effect/Effect";import*as o from"effect/Function";import*as s from"effect/Match";import*as c from"effect/Option";import*as l from"effect/Predicate";import*as u from"effect/Schema";import*as d from"effect/Result";import*as f from"effect/Number";import*as p from"effect/Struct";import{Rule as m,RuleContext as h,Visitor as ee}from"effect-oxlint";import*as g from"effect/Ref";var te=class extends u.Class(`FileState`)({bindings:u.ReadonlyMap(u.String,u.Array(u.String)).pipe(u.withConstructorDefault(a.succeed(/* @__PURE__ */ new Map))),hasEffectImport:u.Boolean.pipe(u.withConstructorDefault(a.succeed(!1)))}){};const _=te.make(),v=s.type().pipe(s.discriminatorsExhaustive(`type`)({Identifier:({name:e})=>e,Literal:({value:e})=>e}));function ne(e){let t=r.lastNonEmpty(i.split(e,`/`));return/^\p{Ll}/u.test(t)?[]:[t]}const re=s.type().pipe(s.withReturnType(),s.when(`alchemy`,o.constant([`Alchemy`])),s.when(`@alchemy.run/domain`,o.constant([`Domain`])),s.when(s.is(`effect`,`@effect/platform`),o.constant([])),s.whenOr(i.startsWith(`effect/`),i.startsWith(`alchemy/`),i.startsWith(`@effect/`),ne),s.orElse(o.constUndefined));function ie(e){let t=/* @__PURE__ */ new Map,n=!1;for(let r of e.body){if(r.type!==`ImportDeclaration`)continue;let e=r.source.value;(e===`effect`||i.startsWith(`effect/`)(e)||i.startsWith(`@effect/`)(e))&&(n=!0);let a=re(e);if(a!==void 0)for(let e of r.specifiers)e.type===`ImportNamespaceSpecifier`||e.type===`ImportDefaultSpecifier`?t.set(e.local.name,a):t.set(e.local.name,[...a,v(e.imported)])}return te.make({bindings:t,hasEffectImport:n})}function y(t,n){return e({meta:t,createOnce:n})}function b(t,n){return e({meta:t,createOnce(e){let t=_,{before:r,Program:i,...a}=n(e,()=>t);return{before(){t=_,r?.()},Program(e){t=ie(e),i?.(e)},...a}}})}function x(e,t,n,r){return{type:e,docs:{description:t,recommended:!0,...r===void 0?{}:{url:r}},schema:[],messages:n}}const S=s.type().pipe(s.when({computed:!1,property:{type:`Identifier`}},({property:e})=>e.name),s.when({computed:!0,property:{type:`Literal`,value:i.isString}},({property:e})=>e.value),s.orElse(o.constUndefined));function C(e){let t=[],n=e;for(;n.type===`ChainExpression`||n.type===`MemberExpression`;){if(n.type===`ChainExpression`){n=n.expression;continue}let e=S(n);if(e===void 0)return;t.unshift(e),n=n.object}return n.type===`Identifier`?[n.name,...t]:void 0}function w(e,t,n){for(let r=e.sourceCode.getScope(t);r!==null;r=r.upper){let e=r.set.get(n);if(e!==void 0)return e}}function T(e){return e?.defs.length===1?e.defs[0]:void 0}function E(e,t,n){return e.type===`Identifier`&&e.name===n&&w(t,e,n)===void 0}function D(e,t){let n=C(e),r=n?.[0];if(n===void 0||r===void 0)return;let i=t.bindings.get(r);return i===void 0?void 0:[...i,...n.slice(1)]}function O(e,t,n,r){let i=D(e,t);return i?.length===2&&i[0]===n&&i[1]===r}function k(e,t,n,i){let a=D(e,t);return a?.length===2&&a[0]===n&&r.contains(i,a[1])}function A(e,t,n){let i=D(e,t);return i?.length===n.length&&r.every(i,(e,t)=>e===n[t])}const ae=s.type().pipe(s.when({type:s.is(`ArrowFunctionExpression`,`FunctionExpression`)},o.constTrue),s.orElse(o.constFalse));function j(e){return ae(e)}function M(e,t){let n=e.arguments[t];return n===void 0||n.type===`SpreadElement`?void 0:n}const N=s.type().pipe(s.when({computed:!1,key:{type:`Identifier`}},({key:e})=>e.name),s.when({key:{type:`Literal`,value:i.isString}},({key:e})=>e.value),s.orElse(o.constUndefined));function P(e,t){return c.getOrUndefined(r.findFirst(e.properties,e=>e.type===`Property`&&N(e)===t))}const oe=/* @__PURE__ */ new Set([`ParenthesizedExpression`,`TSAsExpression`,`TSNonNullExpression`,`TSSatisfiesExpression`,`TSTypeAssertion`]);function se(e){return oe.has(e.type)}const ce=/* @__PURE__ */ new Set([`loc`,`parent`,`range`]);function F(e){let t=e;for(;se(t);)t=t.expression;return t}function le(e,t){if(r.isArray(e))for(let n of e)t.push(n);else for(let[r,i]of n.toEntries(e))ce.has(r)||t.push(i)}function I(e,t){let n=[e],r=/* @__PURE__ */ new WeakSet;for(;n.length>0;){let e=n.pop();if(l.isObjectOrArray(e)&&!r.has(e)){if(r.add(e),l.hasProperty(e,`type`)&&l.isString(e.type)&&t(e)===!0)return!0;le(e,n)}}return!1}function ue(e,t){return I(e,e=>e.type===`Identifier`&&e.name===t)}function L(e){let t=e.params[0];return t?.type===`Identifier`?t:void 0}function de(e){let t=L(e);return t===void 0||!e.body||i.startsWith(`_`)(t.name)?!1:ue(e.body,t.name)}function fe(e,t){for(let n=e.parent;n;n=n.parent)if(t(n))return n}function R(e){return fe(e,j)}function z(e){let t=e.parent;if(t.type===`CallExpression`&&t.arguments.includes(e))return t}function pe(e,t){return e.range[0]<=t.range[0]&&t.range[1]<=e.range[1]}function B(e){return e.type===`Literal`&&i.isString(e.value)}const me=/* @__PURE__ */ new Set([`==`,`===`,`!=`,`!==`]);function he(e){return me.has(e)}function V(e,t){return e.type===`Literal`&&e.value===t}function ge(e){let t=e.parent;return t?t.type===`ExpressionStatement`||t.type===`UnaryExpression`&&t.operator===`void`||t.type===`SequenceExpression`&&t.expressions.at(-1)!==e:!1}const _e=l.mapInput(l.compose(l.isString,i.endsWith(`Error`)),e=>C(e.callee)?.at(-1)),ve=[`Aggregate`,`Api`,`Command`,`Event`,`ExternalSystem`,`Model`,`Policy`,`Projection`,`Rejection`,`RequestContext`,`Saga`,`Stream`,`View`];function ye(e){return r.contains(ve,e)}function be(e,t,n){let r=Se(e.callee,t,n),i=r?.[1];return r?.length===2&&r[0]===`Domain`&&ye(i)?i:void 0}function xe(e,t){let n=e.parent;return n.type===`MemberExpression`&&n.property===e&&!n.computed||n.type===`Property`&&n.key===e&&n.value!==e?!1:T(w(t,n,e.name))?.type===`ImportBinding`}function Se(e,t,n){let r=C(e)?.[0];return r!==void 0&&T(w(n,e,r))?.type===`ImportBinding`?D(e,t):void 0}function Ce(e,t,n){for(let r=e,i=e.parent;i;r=i,i=i.parent){if(i.type!==`Property`||i.value!==r)continue;let e=i.parent,a=e.parent;for(;a!==null&&oe.has(a.type);)a=a.parent;let o=a?.type===`CallExpression`?M(a,1):void 0;if(o===void 0||e.type!==`ObjectExpression`||a?.type!==`CallExpression`||F(o)!==e)continue;let s=be(a,t,n);if(s===void 0)continue;let c=N(i);return c===void 0?void 0:{block:s,section:c}}}const we={Aggregate:`aggregate`,Api:`api`,Command:`command`,ExternalSystem:`external`,Model:`model`,Policy:`policy`,Projection:`projection`,RequestContext:`context`,Saga:`saga`,Stream:`stream`,View:`view`},Te={Event:`event`,Rejection:`rejection`},Ee=/* @__PURE__ */ new Set([`command`,`external`,`stream`]),De=/\.(?:test|spec|stories?)\.[cm]?[jt]sx?$/u,Oe=b(x(`suggestion`,"Require one Alchemy Domain block per file, named `<Noun>.<kind>.ts`.",{fileName:"Declare this {{block}} in its own `<Noun>.{{kind}}.ts` file.",oneBlock:"Move this {{block}} to its own `<Noun>.{{kind}}.ts` file. Each file declares one Domain block."},`https://alchemy.run/domain`),(e,t)=>{let n=!1,a=[],o=!1;return{before(){n=!1,a=[],o=!1},"Program:exit":function(){if(!o)for(let{node:t,block:n,kind:r}of a)e.report({node:t,messageId:`fileName`,data:{block:n,kind:r}})},CallExpression(s){let c=be(s,t(),e),l=r.lastNonEmpty(i.split(e.filename,/[/\\]/u)),u=i.split(l,`.`),d=u.length>=3&&u[0]!==``?u.at(-2):void 0,f=c===void 0?void 0:we[c]??Te[c];c===void 0||f===void 0||De.test(l)||(Ee.has(d)&&Te[c]!==void 0?a.push({node:s.callee,block:c,kind:f}):(d===f&&Ee.has(d)&&(o=!0),n?e.report({node:s.callee,messageId:`oneBlock`,data:{block:c,kind:f}}):d!==f&&e.report({node:s.callee,messageId:`fileName`,data:{block:c,kind:f}}),n=!0))}}}),ke=/* @__PURE__ */ new Map([[`Date.now`,`time`],[`performance.now`,`time`],[`performance.timeOrigin`,`time`],[`Math.random`,`random`],[`crypto.randomUUID`,`random`],[`crypto.getRandomValues`,`random`]]),Ae=/* @__PURE__ */ new Map([[`Clock`,`time`],[`Random`,`random`],[`SecureRandom`,`random`]]),je=/* @__PURE__ */ new Map([[`DateTime.now`,`time`],[`DateTime.nowAsDate`,`time`],[`DateTime.nowInCurrentZone`,`time`],[`DateTime.nowUnsafe`,`time`],[`DateTime.isFuture`,`time`],[`DateTime.isFutureUnsafe`,`time`],[`DateTime.isPast`,`time`],[`DateTime.isPastUnsafe`,`time`],[`Aead.Aead`,`random`],[`Cipher.Cipher`,`random`],[`Signature.Signature`,`random`],[`KeyAgreement.KeyAgreement`,`random`],[`KeyWrap.KeyWrap`,`random`],[`Jwk.generateKeyPair`,`random`],[`Jwk.generateSecret`,`random`],[`Jwe.encrypt`,`random`],[`Jws.sign`,`random`],[`Jws.verifyWithKeySet`,`io`],[`Jwt.sign`,`random`],[`Jwt.encrypt`,`random`],[`Jwt.verify`,`time`],[`Jwt.verifyWithKeySet`,`time`],[`Jwt.decrypt`,`time`],[`Jwks.Jwks`,`io`],[`Jwks.makeRemote`,`io`],[`Jwks.layerRemote`,`io`]]),Me=[`promise`,`tryPromise`],Ne=b(x(`problem`,`Require Alchemy Domain aggregate decide handlers to be pure.`,{time:"`decide` reads time from its `now` argument, not {{api}}. Replays must decide the same way.",random:"`decide` must be deterministic, so it cannot use {{api}}. Take the value from the command input instead.",io:"`decide` never performs I/O such as {{api}}. Call external systems from a policy or saga and send the result as a command."},`https://alchemy.run/domain/aggregate`),(e,t)=>{function n(n,r,i){r!==void 0&&Ce(n,t(),e)?.section===`decide`&&e.report({node:n,messageId:r,data:{api:i}})}function i(i){let a=Se(i,t(),e),o=a?.[0];if(o===void 0||a?.length!==2)return;let s=r.join(a,`.`);n(i,je.get(s)??Ae.get(o),s)}function a(t){if(t.type===`Identifier`)return E(t,e,t.name)?t.name:void 0;let n=C(t);return t.type===`MemberExpression`&&n?.length===2&&E(t.object,e,`globalThis`)?n[1]:void 0}return{MemberExpression(t){let a=C(t),o=t;for(;o.type===`MemberExpression`||o.type===`ChainExpression`;)o=o.type===`ChainExpression`?o.expression:o.object;let s=a?.[0]===`globalThis`?a.slice(1):a;if(s?.length===2&&E(o,e,a?.[0]??``)){let e=r.join(s,`.`),i=t.parent.type===`CallExpression`&&t.parent.callee===t;n(t,ke.get(e),i?`${e}()`:e)}else i(t)},Identifier(t){xe(t,e)&&i(t)},NewExpression(e){e.arguments.length===0&&a(e.callee)===`Date`&&n(e,`time`,`new Date()`)},CallExpression(i){let o=a(i.callee);if(o===`Date`)n(i,`time`,`Date()`);else if(o===`fetch`)n(i,`io`,`fetch()`);else{let a=Se(i.callee,t(),e);a?.length===2&&a[0]===`Effect`&&Me.includes(a[1]??``)&&n(i,`io`,r.join(a,`.`))}}}}),Pe=/\.(?:aggregate|api|command|context|event|external|id|middleware|model|policy|projection|rejection|saga|stream|view)\.[cm]?tsx?$/u,Fe=`@alchemy.run/domain`;function Ie(e){return i.startsWith(`.`)(e)||e===`effect`||i.startsWith(`effect/`)(e)||e===Fe||i.startsWith(`${Fe}/`)(e)}function Le(e){return r.some(e.body,e=>e.type===`ImportDeclaration`&&e.source.value===Fe)}const Re=y(x(`problem`,"Restrict Alchemy Domain block files to imports from `@alchemy.run/domain`, `effect` and the domain package itself.",{import:"A domain block imports only `@alchemy.run/domain`, `effect` and relative files, not `{{source}}`. Put code that touches infrastructure in the server package.",dynamic:"A domain block imports only `@alchemy.run/domain`, `effect` and relative files, so its import sources must be string literals."},`https://alchemy.run/domain`),e=>{let t=!1;function n(n){t&&n.source!==null&&!Ie(n.source.value)&&e.report({node:n.source,messageId:`import`,data:{source:n.source.value}})}function r(n){t&&(n.type!==`Literal`||typeof n.value!=`string`?e.report({node:n,messageId:`dynamic`}):Ie(n.value)||e.report({node:n,messageId:`import`,data:{source:n.value}}))}return{Program(n){t=Pe.test(e.filename)&&Le(n)},ImportDeclaration:n,ExportAllDeclaration:n,ExportNamedDeclaration:n,ImportExpression(e){r(e.source)},TSImportEqualsDeclaration(e){e.moduleReference.type===`TSExternalModuleReference`&&r(e.moduleReference.expression)},CallExpression(t){t.arguments[0]!==void 0&&E(t.callee,e,`require`)&&r(t.arguments[0])}}}),ze=b(x(`suggestion`,`Require Alchemy Domain views to declare their version.`,{missing:"Declare `version` on this view (`version: 0` keeps the current default). Bump it whenever `evolve`, `emit`, `keyOf`, `state` or `from` changes, so the deploy rebuilds the view from its events.",overridden:"Move `version` after the spread, so the spread cannot override the version this view declares."},`https://alchemy.run/domain/model#change-a-view-bump-its-version`),(e,t)=>({CallExpression(n){let i=M(n,1),a=i===void 0?void 0:F(i);if(be(n,t(),e)!==`View`||a?.type!==`ObjectExpression`)return;let o=P(a,`version`);o===void 0?e.report({node:n.callee,messageId:`missing`}):r.some(a.properties.slice(a.properties.indexOf(o)+1),e=>e.type===`SpreadElement`)&&e.report({node:o,messageId:`overridden`})}})),Be=/* @__PURE__ */ new Map([[`Aggregate`,/* @__PURE__ */ new Set([`evolve`,`reply`])],[`View`,/* @__PURE__ */ new Set([`evolve`])]]),Ve=/* @__PURE__ */ new Set([`Option`,`Result`]),He=/* @__PURE__ */ new Set([`getOrThrow`,`getOrThrowWith`]),Ue=b(x(`problem`,`Require Alchemy Domain evolve and reply handlers to be total, and decide handlers to reject instead of throwing.`,{partial:'`{{section}}` must be total and never fail: {{api}} throws when the state is not what it expects. Keep any state the event cannot follow, such as `s._tag === "Open" ? { ...s, ... } : s`.',reject:"`decide` never throws: {{api}} becomes a defect the caller cannot handle. Return a rejection the command lists in `rejects` instead, or `return yield* rejection` in an `Effect.fn`."},`https://alchemy.run/domain/aggregate`),(e,t)=>{function n(n,r){let i=Ce(n,t(),e);i!==void 0&&(i.block===`Aggregate`&&i.section===`decide`?e.report({node:n,messageId:`reject`,data:{api:r}}):Be.get(i.block)?.has(i.section)===!0&&e.report({node:n,messageId:`partial`,data:{section:i.section,api:r}}))}function i(i){let a=Se(i,t(),e);a?.length===2&&Ve.has(a[0]??``)&&He.has(a[1]??``)&&n(i,`\`${r.join(a,`.`)}\``)}return{ThrowStatement(e){n(e,"`throw`")},MemberExpression:i,Identifier(t){xe(t,e)&&i(t)}}}),We=/* @__PURE__ */ new Set([`alarm`,`fetch`,`queue`,`rpc`,`scheduled`,`tail`,`trace`,`webSocketClose`,`webSocketError`,`webSocketMessage`]),Ge=[[`Cloudflare`,`Worker`],[`Cloudflare`,`Workers`,`Worker`]];function Ke(e,t){return r.some(Ge,n=>A(e,t,n))}function qe(e,t){return fe(e,e=>e.type===`CallExpression`&&Ke(e.callee,t))}function Je(e,t){let n=R(e),r=n===void 0?void 0:z(n);return r!==void 0&&O(r.callee,t,`Effect`,`gen`)?r:void 0}function Ye(e){let t=e.parent;for(;t;){if(j(t))return;if(t.type===`Property`){let e=N(t);if(e!==void 0&&We.has(e))return e}t=t.parent}}const Xe=b(x(`problem`,`Disallow finalizers in Cloudflare Worker initialization, where workerd never runs them.`,{finalizer:`A Cloudflare Worker init finalizer never runs because workerd has no isolate teardown hook. Acquire disposable resources inside an event handler.`},`https://alchemy.run/cloudflare/compute/workers`),(e,t)=>({CallExpression(n){let r=t();if(!O(n.callee,r,`Effect`,`addFinalizer`))return;let i=Je(n,r);i!==void 0&&qe(i,r)?.arguments.includes(i)&&e.report({node:n,messageId:`finalizer`})}}));function H(e,t){let n=C(t)?.[0],i=n===void 0?void 0:w(e,t,n);return r.some(i?.defs??[],e=>{let t=e.node;return e.type===`ImportBinding`&&t.parent?.type===`ImportDeclaration`&&t.parent.importKind!==`type`&&(t.type!==`ImportSpecifier`||t.importKind!==`type`)})}function Ze(e,t,n,i,a){let o=e.sourceCode.ast,s=r.findFirst(r.flatMap(o.body,e=>e.type===`ImportDeclaration`&&e.source.value===n&&e.importKind!==`type`?e.specifiers:[]),n=>n.type===`ImportNamespaceSpecifier`&&r.some(w(e,t,n.local.name)?.defs??[],e=>e.node===n));if(c.isSome(s))return{name:s.value.local.name,fixes:[]};let l=new Set(r.flatMap(e.sourceCode.scopeManager.scopes,e=>[...r.map(e.variables,e=>e.name),...r.map(e.references,e=>e.identifier.name)])),u=i,d=2;for(;l.has(u);)u=`${i}${d++}`;let f=`import * as ${u} from '${n}';\n`,p=c.getOrUndefined(r.findFirst(o.body,e=>e.type!==`ExpressionStatement`||!B(e.expression)));return{name:u,fixes:[p===void 0?a.insertTextAfter(o,`\n${f}`):a.insertTextBefore(p,f)]}}function Qe(e,t){let n=/* @__PURE__ */ new Set;return r.every(e.properties,e=>{if(e.type!==`Property`||e.computed||e.method||e.kind!==`init`||e.key.type!==`Identifier`&&e.key.type!==`Literal`)return!1;let r=e.key.type===`Identifier`?e.key.name:String(e.key.value);return r===t||n.has(r)?!1:(n.add(r),!0)})}const $e=b({...x(`problem`,`Disallow the deprecated top-level Docker Service constraints property.`,{constraints:`Docker.Service constraints is deprecated. Move it to placement: { constraints: ... }.`},`https://alchemy.run/providers/docker/service`),fixable:`code`},(e,t)=>({CallExpression(n){if(!O(n.callee,t(),`Docker`,`Service`))return;let r=M(n,1),i=r?.type===`ObjectExpression`?P(r,`constraints`):void 0;i!==void 0&&e.report({node:i,messageId:`constraints`,fix(t){if(H(e,n.callee)&&r?.type===`ObjectExpression`&&Qe(r,`placement`))return t.replaceText(i,`placement: { ${e.sourceCode.getText(i)} }`)}})}})),et=/* @__PURE__ */ new Map([[`Cloudflare.Access.Bookmark`,`Cloudflare.Access.Application with type: "bookmark"`],[`AWS.RDSData.ExecuteSql`,`AWS.RDSData.ExecuteStatement`],[`AWS.EKS.Deployment`,`Kubernetes.Deployment from alchemy/Kubernetes`],[`AWS.EKS.HelmChart`,`Kubernetes.HelmChart from alchemy/Kubernetes`],[`AWS.EKS.Job`,`Kubernetes.Job from alchemy/Kubernetes`],[`AWS.EKS.Manifest`,`Kubernetes.Manifest from alchemy/Kubernetes`]]),tt=b(x(`problem`,`Disallow deprecated Alchemy resource APIs that have supported replacements.`,{deprecated:`{{api}} is deprecated. Use {{replacement}}.`},`https://alchemy.run/llms-full.txt`),(e,t)=>({CallExpression(n){let i=D(n.callee,t());if(i===void 0)return;let a=r.join(i,`.`),o=et.get(a);o!==void 0&&e.report({node:n.callee,messageId:`deprecated`,data:{api:a,replacement:o}})}}));function nt(e,t){let n=F(e);if(B(n)||n.type===`TemplateLiteral`)return!0;let r=C(n);return r?.[0]===`process`&&r[1]===`env`||n.type===`CallExpression`&&O(n.callee,t,`Config`,`string`)}const rt=b(x(`problem`,`Require singular GitHub Secret values to use Redacted.`,{plaintext:`GitHub.Secret value must be Redacted so it stays out of logs and state. Use Redacted.make(...) or Config.redacted(...).`},`https://alchemy.run/providers/github/secret`),(e,t)=>({CallExpression(n){let r=t();if(!O(n.callee,r,`GitHub`,`Secret`))return;let i=M(n,1),a=i?.type===`ObjectExpression`?P(i,`value`):void 0;a!==void 0&&nt(a.value,r)&&e.report({node:a.value,messageId:`plaintext`})}})),it=b(x(`problem`,`Disallow removed Alchemy Secret and Variable APIs.`,{removed:`Alchemy.{{api}} was removed. Use effect/Config (Config.redacted for secrets, Config.string for variables).`},`https://alchemy.run/blog/2026-05-29-beta-45`),(e,t)=>({CallExpression(n){let r=D(n.callee,t());r?.[0]===`Alchemy`&&(r[1]===`Secret`||r[1]===`Variable`)&&e.report({node:n.callee,messageId:`removed`,data:{api:r[1]}})}})),at=b(x(`problem`,`Disallow creating an EventBridge bus with the reserved default name.`,{reserved:`EventBridge reserves the name "default". Omit the bus argument to use the account default, or choose another name.`},`https://alchemy.run/aws/messaging/eventbridge`),(e,t)=>({CallExpression(n){if(!A(n.callee,t(),[`AWS`,`EventBridge`,`EventBus`]))return;let r=M(n,1),i=r?.type===`ObjectExpression`?P(r,`name`):void 0;i!==void 0&&V(i.value,`default`)&&e.report({node:i.value,messageId:`reserved`})}})),ot=b(x(`problem`,`Require Effect Config values to be resolved during Alchemy Worker initialization.`,{runtime:`Config resolved inside the {{handler}} handler is invisible to Alchemy deployment. Resolve it in Worker init and close over the value, or put it in env.`},`https://alchemy.run/environments/secrets`),(e,t)=>({YieldExpression(n){let r=t(),i=n.argument;if(i?.type!==`CallExpression`||D(i.callee,r)?.[0]!==`Config`)return;let a=Je(n,r);if(a===void 0)return;let o=Ye(a);o!==void 0&&qe(a,r)!==void 0&&e.report({node:i,messageId:`runtime`,data:{handler:o}})}})),st=/* @__PURE__ */ new Map([[`alchemy/aws`,`alchemy/AWS`],[`alchemy/cloudflare`,`alchemy/Cloudflare`]]),ct=y(x(`problem`,`Disallow Alchemy v1 imports that bypass the Effect-based Stack API.`,{defaultImport:`The default alchemy() API is from v1. Use import * as Alchemy and Alchemy.Stack.`,providerImport:`Use the v2 provider entrypoint {{replacement}} (capitalization is significant).`},`https://alchemy.run/migrating-from-v1`),e=>({ImportDeclaration(t){let n=t.source.value;if(n===`alchemy`){let n=c.getOrUndefined(r.findFirst(t.specifiers,e=>e.type===`ImportDefaultSpecifier`));n!==void 0&&e.report({node:n,messageId:`defaultImport`});return}let i=st.get(n);i!==void 0&&e.report({node:t.source,messageId:`providerImport`,data:{replacement:i}})}})),lt=[[`entrypoint`,`main`],[`bindings`,`env`]],ut=b({...x(`problem`,`Disallow Alchemy v1 Cloudflare Worker property names.`,{property:`Cloudflare.Worker {{old}} was replaced in v2. Use {{replacement}}.`},`https://alchemy.run/migrating-from-v1`),fixable:`code`},(e,t)=>({CallExpression(n){if(!Ke(n.callee,t()))return;let r=M(n,1);if(r?.type===`ObjectExpression`)for(let[t,i]of lt){let a=P(r,t);a!==void 0&&e.report({node:a,messageId:`property`,data:{old:t,replacement:i},fix(o){if(H(e,n.callee)&&Qe(r,i))return o.replaceText(a.key,a.shorthand?`${i}: ${t}`:i)}})}}})),dt=b(x(`suggestion`,`Prefer schema-based tagged errors so errors have a serializable contract.`,{taggedError:`Prefer Schema.TaggedError over Data.TaggedError.`}),(e,t)=>({CallExpression(n){O(n.callee,t(),`Data`,`TaggedError`)&&e.report({node:n.callee,messageId:`taggedError`})}})),ft=/* @__PURE__ */ new Set([`error`,`err`,`e`,`cause`,`exception`,`ex`]);function pt(e){return e?.type===`Identifier`&&ft.has(e.name)?e.name:void 0}function mt(e){if(e.type!==`CallExpression`||e.arguments.length!==1)return!1;let t=C(e.callee);return t?.at(-1)===`String`&&t.length<=2}const ht=y({...x(`problem`,`Disallow string coercion that discards an error value’s stack, type, and cause chain.`,{errorString:`Do not stringify {{name}}. Preserve the original error as an Error cause instead.`,useCause:`Replace {{pattern}} with {{replacement}} to preserve the original error.`}),hasSuggestions:!0},e=>({NewExpression(t){let n=M(t,0);if(n===void 0||!mt(n)||!_e(t))return;let r=M(n,0);if(r===void 0)return;let i=e.sourceCode.getText(r),a=`'Error occurred', { cause: ${i} }`;e.report({node:n,messageId:`errorString`,data:{name:i},suggest:[{messageId:`useCause`,data:{pattern:e.sourceCode.getText(n),replacement:a},fix:e=>e.replaceText(n,a)}]})},CallExpression(t){if(mt(t)){if(t.parent.type===`NewExpression`&&t.parent.arguments[0]===t&&_e(t.parent))return;let n=pt(t.arguments[0]);n!==void 0&&e.report({node:t,messageId:`errorString`,data:{name:n}});return}if(t.callee.type!==`MemberExpression`||C(t.callee)?.at(-1)!==`toString`||t.arguments.length>0)return;let n=pt(t.callee.object);n!==void 0&&e.report({node:t,messageId:`errorString`,data:{name:n}})},TemplateLiteral(t){let[n,r]=t.quasis,i=pt(t.expressions[0]);i!==void 0&&t.quasis.length===2&&n?.value.raw===``&&r?.value.raw===``&&e.report({node:t,messageId:`errorString`,data:{name:i}})}})),gt=/* @__PURE__ */ new Set(/* @__PURE__ */ `flip.fromFormData.fromJsonString.fromURLSearchParams.mutable.mutableKey.NullishOr.NullOr.optional.optionalKey.OptionFromNullishOr.OptionFromNullOr.OptionFromOptional.OptionFromOptionalKey.OptionFromOptionalNullOr.OptionFromUndefinedOr.readonlyKey.RedactedFromValue.required.requiredKey.toCodecArrayFromSingle.toCodecGoJson.toCodecIso.toCodecJson.toCodecStringTree.toEncoded.toType.UndefinedOr`.split(`.`)),_t=/* @__PURE__ */ new Set([`Array`,`ArrayEnsure`,`Chunk`,`HashSet`,`NonEmptyArray`,`Option`,`ReadonlySet`,`Redacted`,`Tree`,`UniqueArray`]),vt=/* @__PURE__ */ new Set(/* @__PURE__ */ `annotate.annotateEncoded.annotateKey.brand.catchDecoding.catchDecodingWithContext.catchEncoding.catchEncodingWithContext.check.decode.decodeTo.encode.encodeKeys.encodeTo.extendTo.fieldsAssign.fromBrand.middlewareDecoding.middlewareEncoding.overrideToCodecIso.overrideToEquivalence.overrideToFormatter.refine.toTaggedUnion.withConstructorDefault.withDecodingDefault.withDecodingDefaultKey.withDecodingDefaultType.withDecodingDefaultTypeKey`.split(`.`)),yt=/* @__PURE__ */ new Set([`annotate`,`annotateKey`,`check`,`mapFields`]),bt=/* @__PURE__ */ new Set([`CallExpression`,`Identifier`,`MemberExpression`,`ThisExpression`]),xt=/^\p{Lu}/u;function U(e,t,n){let r=D(e,n);return C(e)?.length===2&&r?.length===2&&r[0]===`Schema`&&H(t,e)?r[1]:void 0}function St(e){return e!==void 0&&_t.has(e)}function Ct(e){return e!==void 0&&(gt.has(e)||_t.has(e))}const wt=/* @__PURE__ */ new Set([`ArrowFunctionExpression`,`FunctionExpression`,`Identifier`,`Literal`,`ThisExpression`]);function Tt(e,t,n){return r.every(e,e=>e===null||W(e,t,n))}function W(e,t,n){if(wt.has(e.type))return!0;if(e.type===`MemberExpression`)return W(e.object,t,n)&&(!e.computed||W(e.property,t,n));if(e.type===`TemplateLiteral`)return Tt(e.expressions,t,n);if(e.type===`ArrayExpression`)return Tt(e.elements,t,n);if(e.type===`ObjectExpression`)return r.every(e.properties,e=>e.type===`SpreadElement`?W(e.argument,t,n):(!e.computed||W(e.key,t,n))&&W(e.value,t,n));if(e.type!==`CallExpression`)return!1;let i=e.callee.type===`CallExpression`?e.callee.callee:e.callee;return U(i,t,n)!==void 0&&(e.callee===i||W(e.callee,t,n))&&Tt(e.arguments,t,n)}function Et(e,t){if(e.type===`Identifier`)return t.bindings.get(e.name);if(e.type!==`TSQualifiedName`)return;let n=Et(e.left,t);return n===void 0?void 0:[...n,e.right.name]}function Dt(e,t){for(let n=t.parent;n!==null;n=n.parent){let t=`typeParameters`in n&&n.typeParameters?.type===`TSTypeParameterDeclaration`?o.pipe(n.typeParameters.params,r.findFirst(t=>t.name.name===e),c.getOrUndefined):void 0;if(t!==void 0)return t}}function Ot(e,t,n){let r=/* @__PURE__ */ new Set,a=e,o=t;for(;a?.type===`TSTypeReference`;){let e=Et(a.typeName,n),t=e?.length===2&&e[0]===`Schema`?e[1]:void 0;if(t!==void 0)return!i.startsWith(`Constraint`)(t);let s=a.typeName.type===`Identifier`?Dt(a.typeName.name,o):void 0;if(s===void 0||r.has(s))return r.size===0&&void 0;r.add(s),a=s.constraint,o=s}return r.size===0&&void 0}function kt(e,t){let n=w(t,e,e.name)?.defs[0]?.name;return n!==void 0&&`typeAnnotation`in n?n.typeAnnotation??void 0:void 0}function At(e,t,n){let r=e;for(;r.type===`TSSatisfiesExpression`||r.type===`TSNonNullExpression`;)r=r.expression;if(r.type===`TSAsExpression`)return Ot(r.typeAnnotation,r,n)===!1;let i=r.type===`Identifier`?kt(r,t):void 0;return i!==void 0&&Ot(i.typeAnnotation,i,n)===!1}function jt(e){return r.some(e.arguments,e=>e.type===`SpreadElement`)}function Mt(e){let[t]=e.arguments;return e.arguments.length===1&&t?.type!==`SpreadElement`&&!e.typeArguments?t:void 0}function Nt(e){return e.callee.type===`MemberExpression`&&!e.callee.optional&&S(e.callee)===`pipe`&&!e.typeArguments&&!jt(e)}function Pt(e,t,n){return(A(e.callee,n,[`pipe`])||A(e.callee,n,[`Function`,`pipe`]))&&H(t,e.callee)}function Ft(e,t,n){return Ct(U(e,t,n))?!0:e.type===`CallExpression`&&vt.has(U(e.callee,t,n)??``)}function It(e,t,n){if(xt.test(U(e,t,n)??``)||G(e,t,n)!==void 0)return!0;if(e.type!==`CallExpression`)return!1;let r=U(e.callee,t,n);return r===void 0?e.callee.type===`MemberExpression`&&yt.has(S(e.callee)??``)&&It(e.callee.object,t,n):xt.test(r)||Ct(r)}function Lt(e,t,n){let[r,i]=e.arguments;if(!(r===void 0||i===void 0||r.type===`SpreadElement`||e.typeArguments||jt(e)||!It(r,t,n)&&!Ft(i,t,n)))return[r,e.arguments.slice(1)]}function Rt(e,t,n,r,i,a){let o=Ht(e,i,a);return{head:o.head,steps:[...o.steps,t],violation:o.violation??n,reordersEffects:o.reordersEffects||r}}function zt(e,t,n){let r=Mt(e);if(r===void 0)return;let i=U(e.callee,t,n);if(Ct(i)){let a=St(i);return Rt(r,{text:t.sourceCode.getText(e.callee),wrapper:a},a?void 0:{kind:`modifierCall`,name:i},!1,t,n)}let a=e.callee.type===`CallExpression`?U(e.callee.callee,t,n):void 0;if(a!==void 0&&vt.has(a))return Rt(r,{text:t.sourceCode.getText(e.callee),wrapper:!1},{kind:`dataLastCall`,name:a},!W(e.callee,t,n)&&!W(r,t,n),t,n)}function Bt(e,t,n){let i=Pt(e,t,n),a=i?Lt(e,t,n):Nt(e)?[e.callee.object,e.arguments]:void 0;if(a===void 0)return;let[s,l]=a,u=r.map(l,e=>U(e,t,n)),d=o.pipe(u,r.findFirst(St),c.getOrUndefined),f=d!==void 0&&r.some(l.slice(u.indexOf(d)+1),e=>!W(e,t,n));return Vt(s,r.map(l,(e,n)=>({text:t.sourceCode.getText(e),wrapper:St(u[n])})),i?{kind:`functionPipe`}:d===void 0?void 0:{kind:`wrapperPipe`,name:d},f,t,n)}function Vt(e,t,n,r,i,a){let o=Ht(e,i,a);return{head:o.head,steps:[...o.steps,...t],violation:o.violation??n,reordersEffects:o.reordersEffects||r}}function G(e,t,n){return e.type===`CallExpression`?zt(e,t,n)??Bt(e,t,n):void 0}function Ht(e,t,n){return G(e,t,n)??{head:e,steps:[],violation:void 0,reordersEffects:!1}}function Ut(e,t,n){let r=e.parent;return r.type===`MemberExpression`&&r.object===e&&r.parent.type===`CallExpression`?r.parent.callee===r&&Nt(r.parent):r.type===`CallExpression`&&r.arguments[0]===e&&(Pt(r,t,n)||!Nt(r))&&G(r,t,n)!==void 0}function Wt(e,t,n){return r.isReadonlyArrayNonEmpty(t)?`${e===`\0`&&!bt.has(n.type)?`(\0)`:e}.pipe(${r.join(t,`, `)})`:e}function Gt(e,t){let n=`\0`,r=[];for(let i of t)if(i.wrapper){let t=Wt(n,r,e),a=t===`\0`&&e.type===`SequenceExpression`?`(${t})`:t;n=`${i.text}(${a})`,r=[]}else r.push(i.text);return Wt(n,r,e)}const Kt=b({...x(`suggestion`,"Apply Schema modifiers with `.pipe(...)` and call Schema wrappers directly.",{modifierCall:"Apply Schema.{{name}} with `.pipe(...)` instead of calling it.",dataLastCall:"Apply Schema.{{name}}(...) with `.pipe(...)` instead of calling it on the schema.",functionPipe:"Call `.pipe(...)` on the schema instead of passing it to `pipe(...)`.",wrapperPipe:`Call Schema.{{name}}(...) directly instead of piping into it.`},`https://github.com/2digits-agency/configs/blob/main/docs/adr/0001-schema-modifiers-pipe-wrappers-call.md`),fixable:`code`},(e,t)=>({CallExpression(n){let a=t();if(!a.hasEffectImport)return;let o=G(n,e,a);if(o?.violation===void 0||Ut(n,e,a))return;let{head:s}=o;if(o.steps[0]?.wrapper===!1&&At(s,e,a))return;let c=r.some(e.sourceCode.getCommentsInside(n),e=>!pe(s,e)),[l,u=``]=i.split(Gt(s,o.steps),`\0`);e.report({node:n,messageId:o.violation.kind,data:{name:o.violation.name??``},fix:c||o.reordersEffects?void 0:e=>[e.replaceTextRange([n.range[0],s.range[0]],l),e.replaceTextRange([s.range[1],n.range[1]],u)]})}}));function qt(e){return c.getOrUndefined(r.findFirst(e.arguments,e=>e.type===`ObjectExpression`))}function Jt(e,t){let n=e.parent;if(n.type!==`Property`||N(n)!==t)return;let r=n.parent,i=r.parent;return r.type===`ObjectExpression`&&i?.type===`CallExpression`?i:void 0}function Yt(e,t){let n=z(e);return n===void 0?void 0:D(n.callee,t)}const Xt=/* @__PURE__ */ new Set([`catch`,`finally`,`then`]);function Zt(e){let t=C(e.callee);return t!==void 0&&r.join(t,`.`)===`Promise`}function Qt(e){let t=C(e.callee);return t!==void 0&&r.join(t,`.`)===`fetch`||t?.[0]===`Promise`&&t[1]!==`withResolvers`||Xt.has(t?.at(-1)??``)||j(e.callee)&&e.callee.async}const $t=s.type().pipe(s.discriminators(`type`)({CallExpression:Qt,NewExpression:Zt}),s.orElse(o.constFalse));function en(e){return $t(F(e))}function tn(e){if(e.body){if(e.body.type!==`BlockStatement`)return F(e.body);if(e.body.body.length===1&&e.body.body[0]?.type===`ReturnStatement`&&e.body.body[0].argument)return F(e.body.body[0].argument)}}function nn(e){let t=e?.type===`ObjectExpression`?P(e,`try`)?.value:e;return j(t)?t:void 0}function rn(e){let t=F(e);return V(t,`*`)?!0:t.type===`ArrayExpression`&&(t.elements.length===0||r.some(t.elements,e=>e!==null&&V(e,`*`)))}const an=b(x(`problem`,`Disallow credentialed CORS with wildcard origins because browsers reject that combination.`,{wildcard:`Credentialed CORS cannot use a wildcard origin. Set allowedOrigins to explicit trusted origins or disable credentials.`},`https://github.com/Effect-TS/tsgo/issues/400`),(e,t)=>({CallExpression(n){let r=t();if(!O(n.callee,r,`HttpMiddleware`,`cors`)&&!O(n.callee,r,`HttpRouter`,`cors`)&&!O(n.callee,r,`HttpApiBuilder`,`middlewareCors`))return;let i=qt(n);if(i===void 0||!V(P(i,`credentials`)?.value??i,!0))return;let a=P(i,`allowedOrigins`);(a===void 0||rn(a.value))&&e.report({node:n,messageId:`wildcard`})}}));function on(e){return e.type===`AssignmentPattern`||e.type===`RestElement`||e.optional===!0}const sn=b(x(`problem`,`Disallow numeric dual arity with optional or rest parameters because dispatch becomes ambiguous.`,{unsafeArity:`Function.dual with numeric arity misdispatches an implementation with optional/default/rest parameters. Use predicate dispatch.`},`https://github.com/Effect-TS/tsgo/issues/401`),(e,t)=>({CallExpression(n){let i=M(n,0),a=M(n,1);a!==void 0&&O(n.callee,t(),`Function`,`dual`)&&i?.type===`Literal`&&l.isNumber(i.value)&&j(a)&&r.some(a.params,on)&&e.report({node:i,messageId:`unsafeArity`})}})),cn=b(x(`problem`,`Require Effect.tryPromise so Promise rejections enter the typed error channel.`,{tryPromise:`Use Effect.tryPromise instead of Effect.promise so rejections are typed failures.`}),(e,t)=>({CallExpression(n){O(n.callee,t(),`Effect`,`promise`)&&e.report({node:n.callee,messageId:`tryPromise`})}}));function ln(e,t){if(k(e.callee,t,`Effect`,[`promise`,`tryPromise`]))return nn(M(e,0))}const un=b(x(`problem`,`Ensure Effect Promise thunks start fresh asynchronous work rather than reusing an already-started Promise.`,{prestarted:`This thunk returns an already-started Promise. Start the asynchronous work inside the thunk so retries and repeats run it again.`},`https://github.com/Effect-TS/tsgo/issues/475`),(e,t)=>{let n=/* @__PURE__ */ new Set;return{before(){n=/* @__PURE__ */ new Set},VariableDeclarator(e){e.id.type===`Identifier`&&e.init&&en(e.init)&&n.add(e.id.name)},CallExpression(r){let i=ln(r,t()),a=i===void 0?void 0:tn(i);a?.type===`Identifier`&&n.has(a.name)&&e.report({node:a,messageId:`prestarted`})}}}),dn=b(x(`problem`,`Disallow async thunks in Effect.try because rejected Promises bypass its catch mapper.`,{asyncTry:`Effect.try does not await Promises. Use Effect.tryPromise so rejection enters the typed error channel.`},`https://github.com/Effect-TS/tsgo/issues/657`),(e,t)=>({CallExpression(n){if(!O(n.callee,t(),`Effect`,`try`))return;let r=M(n,0),i=r!==void 0&&j(r)?r:void 0;if(i===void 0&&r?.type===`ObjectExpression`){let e=P(r,`try`)?.value;e!==void 0&&j(e)&&(i=e)}let a=i===void 0?void 0:tn(i);i!==void 0&&(i.async||a!==void 0&&en(a))&&e.report({node:i,messageId:`asyncTry`})}})),fn=b(x(`problem`,`Disallow discarded Effect.runPromise results that can become unhandled rejections.`,{discarded:`The Promise returned by Effect.runPromise is discarded. Await/return/handle it, or use Effect.runFork for fire-and-forget work.`},`https://github.com/Effect-TS/tsgo/issues/643`),(e,t)=>({CallExpression(n){let r=t(),i=O(n.callee,r,`Effect`,`runPromise`),a=n.callee.type===`CallExpression`&&O(n.callee.callee,r,`Effect`,`runPromiseWith`);(i||a)&&ge(n)&&e.report({node:n,messageId:`discarded`})}})),pn=/* @__PURE__ */ new Set([`mapElements`,`mapFields`,`mapMembers`]);function mn(e,t){let n=F(e);if(n.type===`CallExpression`&&n.callee.type===`MemberExpression`&&S(n.callee)===t)return n}const hn=b(x(`problem`,`Disallow schema mapping that silently drops checks attached to the receiver.`,{discarded:`{{method}} creates a new schema and drops the preceding check. Re-attach the check after mapping or explicitly preserve it.`},`https://github.com/Effect-TS/tsgo/issues/435`),(e,t)=>({CallExpression(n){if(!t().hasEffectImport||n.callee.type!==`MemberExpression`)return;let i=S(n.callee);i!==void 0&&pn.has(i)&&mn(n.callee.object,`check`)!==void 0&&(r.findFirst(n.arguments,e=>e.type===`ObjectExpression`).pipe(c.flatMapNullishOr(e=>P(e,`unsafePreserveChecks`)),c.exists(e=>V(e.value,!0)))||e.report({node:n,messageId:`discarded`,data:{method:i}}))}})),gn={Array:`Arr`,Boolean:`Bool`,Equal:`Eq`,Function:`Fn`,Number:`Num`,Option:`Opt`,Predicate:`P`,Record:`R`,String:`Str`},_n=/^\p{Lu}[^_]*$/u;function vn(e){return _n.test(e)}function yn(e){return e===`@effect/vitest`||i.startsWith(`@effect/vitest/`)(e)}function K(e,t){return e.importKind===`type`||t?.importKind===`type`}function bn(e){return c.getOrElse(n.get(gn,e),()=>e)}function xn(e,t){if(e===`effect`||e===`alchemy`||/^@effect\/[^/]+$/u.test(e)&&!yn(e))return`${e}/${t}`}function Sn(e){if(yn(e)||!(i.startsWith(`effect/`)(e)||i.startsWith(`alchemy/`)(e)||/^@effect\/[^/]+\//u.test(e)))return;let t=r.lastNonEmpty(i.split(e,`/`));return vn(t)?t:void 0}function Cn(e,t,n){let i=t.specifiers;if(e.sourceCode.getCommentsInside(t).length>0||t.attributes.length>0||!r.every(i,e=>e.type===`ImportSpecifier`))return;let[a,o]=r.partition(i,n=>{let r=v(n.imported),i=vn(r)&&!K(t,n)?xn(t.source.value,r):void 0;return i===void 0?d.fail(e.sourceCode.getText(n)):d.succeed(`import * as ${n.local.name} from '${i}';`)}),s=r.isReadonlyArrayNonEmpty(o)?r.prepend(a,`import { ${r.join(o,`, `)} } from ${e.sourceCode.getText(t.source)};`):a;return[n.replaceText(t,r.join(s,`
2
- `))]}function wn(e,t,n){let i=Sn(t.source.value);if(i===void 0||t.attributes.length>0||e.sourceCode.getCommentsInside(t).length>0)return;let a=bn(i),o=e.sourceCode.getDeclaredVariables(t),s=c.getOrUndefined(r.findFirst(o,e=>e.name===a));if(r.some(e.sourceCode.scopeManager.scopes,e=>r.some(e.variables,e=>e.name===a&&e!==s)||r.some(e.references,e=>e.identifier.name===a&&e.resolved!==s)))return;let l=[],u=[];for(let r of t.specifiers){if(r.type===`ImportDefaultSpecifier`)return;if(r.type===`ImportSpecifier`&&K(t,r)){if(r.local.name===a)return;u.push(e.sourceCode.getText(r));continue}let i=Tn(r,o,a,n);if(i===void 0)return;l.push(...i)}let d=e.sourceCode.getText(t.source),f=`import * as ${a} from ${d};${u.length===0?``:`\nimport { ${r.join(u,`, `)} } from ${d};`}`;return[n.replaceText(t,f),...l]}function Tn(e,t,n,i){let a=c.getOrUndefined(r.findFirst(t,t=>t.name===e.local.name));if(a!==void 0){if(e.type===`ImportNamespaceSpecifier`)return En(a,n,!1,i);if(e.imported.type===`Identifier`)return En(a,`${n}.${e.imported.name}`,!0,i)}}function En(e,t,n,r){let a=[],o=/* @__PURE__ */ new Set;for(let s of e.references){let e=s.identifier;if(o.has(e.range[0]))continue;o.add(e.range[0]);let c=e.parent;if(s.isWrite()||c.type===`ExportSpecifier`||i.startsWith(`JSX`)(c.type))return;let l=c.type===`Property`&&c.shorthand?`${e.name}: ${t}`:t;n&&(c.type===`CallExpression`&&c.callee===e||c.type===`TaggedTemplateExpression`&&c.tag===e)&&(l=`(0, ${t})`),a.push(r.replaceText(e,l))}return a}const Dn=y({...x(`suggestion`,`Import Effect and Alchemy module namespaces from their submodule entrypoints instead of root barrels.`,{barrelImport:'Import this module as `import * as {{alias}} from "{{source}}"` instead of from the root barrel.'},`https://github.com/Effect-TS/language-service/blob/main/packages/language-service/src/diagnostics/importFromBarrel.ts`),fixable:`code`},e=>({ImportDeclaration(t){for(let n of t.specifiers){if(n.type!==`ImportSpecifier`||K(t,n))continue;let r=v(n.imported),i=vn(r)?xn(t.source.value,r):void 0;i!==void 0&&e.report({node:n,messageId:`barrelImport`,data:{alias:bn(r),source:i},fix:n=>Cn(e,t,n)})}}})),On=[`log`,`logDebug`,`logError`,`logFatal`,`logInfo`,`logTrace`,`logWarning`],kn=[`debug`,`error`,`info`,`log`,`trace`,`warn`],An=[`as`,`asSome`,`asVoid`];function jn(e,t){let n=F(e);if(n.type!==`CallExpression`)return;let i=F(n.callee);if(i.type===`CallExpression`&&A(i.callee,t,[`Effect`,`logWithLevel`]))return`Effect.logWithLevel`;if(k(i,t,`Effect`,On)||k(i,t,`Console`,kn))return r.join(D(i,t)??[],`.`)}function Mn(e,t){if(e===void 0)return;let n=F(e);return n.type===`CallExpression`&&n.arguments.length===1&&A(n.callee,t,[`Effect`,`as`])?`as`:k(n,t,`Effect`,[`asSome`,`asVoid`])?D(n,t)?.[1]:void 0}function Nn(e,t){return A(e,t,[`pipe`])||A(e,t,[`Function`,`pipe`])}function Pn(e,t){let n=F(e.callee);if(n.type===`MemberExpression`&&S(n)===`pipe`){let r=M(e,0),i=jn(n.object,t),a=Mn(r,t);return r===void 0||i===void 0||a===void 0?void 0:{logger:i,method:a,node:r}}if(Nn(n,t)){let n=M(e,0),r=n===void 0?void 0:jn(n,t),i=M(e,1),a=Mn(i,t);return i===void 0||r===void 0||a===void 0?void 0:{logger:r,method:a,node:i}}let r=k(n,t,`Effect`,An)?D(n,t)?.[1]:void 0,i=M(e,0);if(r===void 0||i===void 0||r===`as`&&e.arguments.length!==2)return;let a=jn(i,t);return a===void 0?void 0:{logger:a,method:r,node:e}}const Fn=b(x(`suggestion`,`Disallow Effect.as, Effect.asSome and Effect.asVoid on log effects.`,{asOnLog:"Do not swap the result of {{logger}} with Effect.{{method}}. Use Effect.gen: `yield*` the log, then return the value.",asVoidOnLog:`{{logger}} already succeeds with void; remove Effect.asVoid.`}),(e,t)=>({CallExpression(n){let r=Pn(n,t());r!==void 0&&e.report({node:r.node,messageId:r.method===`asVoid`?`asVoidOnLog`:`asOnLog`,data:{logger:r.logger,method:r.method}})}})),In=b({...x(`suggestion`,`Prefer Effect.never to an empty Effect.callback registration.`,{emptyCallback:`An empty Effect.callback registration is Effect.never. Use the explicit primitive.`},`https://github.com/Effect-TS/tsgo/issues/636`),fixable:`code`},(e,t)=>({CallExpression(n){if(!O(n.callee,t(),`Effect`,`callback`)&&!O(n.callee,t(),`Effect`,`async`))return;let i=M(n,0);i!==void 0&&j(i)&&i.body?.type===`BlockStatement`&&i.body.body.length===0&&e.report({node:n,messageId:`emptyCallback`,fix(t){if(!H(e,n.callee)||n.arguments.length!==1||i.async||i.generator||r.some(i.params,e=>e.type!==`Identifier`)||e.sourceCode.getCommentsInside(n).length>0)return;let a=Ze(e,n,`effect/Effect`,`Effect`,t);return[...a.fixes,t.replaceText(n,`${a.name}.never`)]}})}})),Ln=b(x(`problem`,`Disallow Schema.Struct({}), which accepts every non-null object-like value.`,{emptyStruct:`Schema.Struct({}) does not validate an exact empty object. Define the intended fields explicitly.`},`https://github.com/Effect-TS/tsgo/issues/403`),(e,t)=>({CallExpression(n){let r=M(n,0);O(n.callee,t(),`Schema`,`Struct`)&&r?.type===`ObjectExpression`&&r.properties.length===0&&e.report({node:n,messageId:`emptyStruct`})}}));function Rn(e,t){let n=F(e),i=/* @__PURE__ */ new Set;for(;n.type===`Identifier`;){let e=w(t,n,n.name),a=T(e),o=a?.node;if(e===void 0||i.has(e)||o?.type!==`VariableDeclarator`||o.id.type!==`Identifier`||a?.parent?.type!==`VariableDeclaration`||a.parent.kind!==`const`||!o.init||r.some(e.references,e=>e.isWrite()&&!e.init))return;i.add(e),n=F(o.init)}return n}function zn(e){if(e.arguments.length===2)return M(e,0);let t=e.parent;if(e.arguments.length===1&&t.type===`CallExpression`&&t.arguments[0]===e&&t.callee.type===`MemberExpression`&&S(t.callee)===`pipe`)return t.callee.object}const Bn=b(x(`problem`,`Disallow obsolete lazy callbacks passed to the now-eager Config.withDefault API.`,{functionDefault:`Config.withDefault takes an eager value. This callback becomes the configured value; pass the returned value directly.`},`https://github.com/Effect-TS/tsgo/issues/408`),(e,t)=>({CallExpression(n){if(!O(n.callee,t(),`Config`,`withDefault`)||!H(e,n.callee))return;let r=M(n,n.arguments.length-1),i=zn(n),a=i===void 0?void 0:Rn(i,e);a?.type===`CallExpression`&&O(a.callee,t(),`Config`,`succeed`)&&H(e,a.callee)&&j(M(a,0))||j(r)&&r.params.length===0&&e.report({node:r,messageId:`functionDefault`})}})),Vn=/* @__PURE__ */ new Set([`delete`,`get`,`has`,`set`]);function Hn(e,t){return e.type===`CallExpression`&&O(e.callee,t,`Hash`,`hash`)}const Un=b(x(`problem`,`Disallow using Hash.hash output as collision-free identity.`,{hashIdentity:`Hash.hash is a bucketing hint, not a unique identity. Use HashMap/Equal.equals or a real identifier instead.`},`https://github.com/Effect-TS/tsgo/issues/482`),(e,t)=>{let n=/* @__PURE__ */ new Set;function r(e){return Hn(e,t())||e.type===`Identifier`&&n.has(e.name)}return{before(){n=/* @__PURE__ */ new Set},VariableDeclarator(e){e.id.type===`Identifier`&&e.init&&Hn(e.init,t())&&n.add(e.id.name)},CallExpression(t){if(t.callee.type!==`MemberExpression`||!Vn.has(C(t.callee)?.at(-1)??``))return;let n=M(t,0);n!==void 0&&r(n)&&e.report({node:n,messageId:`hashIdentity`})},BinaryExpression(t){he(t.operator)&&r(t.left)&&r(t.right)&&e.report({node:t,messageId:`hashIdentity`})},MemberExpression(t){t.computed&&r(t.property)&&e.report({node:t.property,messageId:`hashIdentity`})}}}),Wn=/* @__PURE__ */ new Set(/* @__PURE__ */ `asserts.decodeEffect.decodeExit.decodeOption.decodePromise.decodeResult.decodeSync.decodeUnknownEffect.decodeUnknownExit.decodeUnknownOption.decodeUnknownPromise.decodeUnknownResult.decodeUnknownSync.encodeEffect.encodeExit.encodeOption.encodePromise.encodeResult.encodeSync.encodeUnknownEffect.encodeUnknownExit.encodeUnknownOption.encodeUnknownPromise.encodeUnknownResult.encodeUnknownSync.is`.split(`.`)),Gn=/* @__PURE__ */ new Set([`global`,`module`]),Kn=/* @__PURE__ */ new Set([`ArrowFunctionExpression`,`FunctionDeclaration`,`FunctionExpression`]),qn=/* @__PURE__ */ new Set([`AssignmentExpression`,`AwaitExpression`,`ImportExpression`,`TaggedTemplateExpression`,`UpdateExpression`,`YieldExpression`]),Jn=/* @__PURE__ */ new Set([`ParenthesizedExpression`,`TSAsExpression`,`TSNonNullExpression`]);function Yn(e,t,n){let i=D(e,t),a=i?.length===2&&i[0]===`Schema`?i[1]:void 0,o=C(e)?.[0];if(a===void 0||o===void 0||!Wn.has(a))return;let s=w(n,e,o);return s!==void 0&&r.every(s.defs,e=>e.type===`ImportBinding`)?a:void 0}function Xn(e){let t=e.parent;for(;t;){if(Kn.has(t.type))return!0;t=t.parent}return!1}function Zn(e){let t=e,n=e.parent;for(;Jn.has(n.type)&&n.parent!==null;)t=n,n=n.parent;return n.type===`CallExpression`&&n.callee===t}function Qn(e,t){return e.type===`CallExpression`&&D(e.callee,t)?.[0]===`Schema`}function $n(e){let t=e,n=e.parent;for(;n?.type===`MemberExpression`&&n.object===t;)t=n,n=n.parent;return t!==e&&(n?.type===`AssignmentExpression`&&n.left===t||n?.type===`UpdateExpression`&&n.argument===t||n?.type===`UnaryExpression`&&n.operator===`delete`&&n.argument===t)}function er(e){return r.every(e.references,e=>(!e.isWrite()||e.init)&&!$n(e.identifier))}function tr(e,t,n,r){let i=w(r,e,t);return i===void 0||pe(n,i.scope.block)?!0:Gn.has(i.scope.type)&&er(i)}function nr(e){let t=e.parent;return t?.type===`MemberExpression`&&t.property===e&&!t.computed||t?.type===`Property`&&t.key===e&&!t.computed&&!t.shorthand}function rr(e,t){if(e===t)return!1;let n=e.parent;for(;n!==null&&n!==t;){if(Kn.has(n.type))return!0;n=n.parent}return!1}function ir(e,t,n){return rr(e,t)?!1:e.type===`CallExpression`||e.type===`NewExpression`?D(e.callee,n)===void 0:qn.has(e.type)}function ar(e,t,n){return!I(e,r=>r.type===`ThisExpression`||r.type===`Super`||r.type===`MetaProperty`&&r.meta.name===`new`||ir(r,e,t)||r.type===`Identifier`&&!nr(r)&&!tr(r,r.name,e,n))}const or=b(x(`problem`,`Disallow compiling Schema decoders, encoders, and guards inside function bodies.`,{inlineSchema:`Hoist Schema.{{method}}(...) to module scope: both the inline schema and the compiled function are rebuilt on every call. Move the compiled function to a module-level const.`,inlineCompile:`Hoist Schema.{{method}}(...) to module scope: the compiled function is rebuilt on every call. Move it to a module-level const.`},`https://github.com/pingdotgg/t3code/blob/main/oxlint-plugin-t3code/rules/no-inline-schema-compile.ts`),(e,t)=>({CallExpression(n){let i=t();if(!i.hasEffectImport)return;let a=Yn(n.callee,i,e),[o]=n.arguments;if(a===void 0||o===void 0||o.type===`SpreadElement`||r.some(n.arguments,e=>e.type===`SpreadElement`)||!Zn(n)||!Xn(n))return;let s=F(o),c=Qn(s,i);(c||s.type===`Identifier`||s.type===`MemberExpression`)&&r.every(n.arguments,t=>ar(t,i,e))&&e.report({node:n.callee,messageId:c?`inlineSchema`:`inlineCompile`,data:{method:a}})}})),sr=/* @__PURE__ */ new Set([`catch`,`catchIf`,`catchTag`,`orElseSucceed`,`catchAll`,`catchAllCause`,`catchSome`,`catchSomeCause`,`orElse`,`orElseFail`]),cr=/* @__PURE__ */ new Set([`log`,`logDebug`,`logError`,`logInfo`,`logTrace`,`logWarning`]);function lr(e,t){let n=e.parent;for(;n;){if(j(n)){let e=z(n);if(e?.arguments.at(-1)===n){let n=D(e.callee,t),r=n?.[1];if(r!==void 0&&n?.[0]===`Effect`&&sr.has(r))return{method:r}}}n=n.parent}}const ur=b(x(`suggestion`,`Keep logging separate from Effect recovery handlers.`,{logging:`Move {{logger}} out of Effect.{{catchMethod}} and use Effect.tapError before recovery.`}),(e,t)=>({CallExpression(n){let i=t(),a=D(n.callee,i),o=a?.[1]!==void 0&&a[0]===`Effect`&&cr.has(a[1])?r.join(a,`.`):void 0;if(o===void 0)return;let s=lr(n,i);s!==void 0&&e.report({node:n,messageId:`logging`,data:{logger:o,catchMethod:s.method}})}})),dr=s.type().pipe(s.when({type:`MemberExpression`,computed:!1,object:{type:`Identifier`,name:`Effect`},property:{type:`Identifier`,name:s.is(`catch`,`catchAll`,`catchIf`)}},o.constTrue),s.orElse(o.constFalse)),fr=s.type().pipe(s.when({type:`MemberExpression`,computed:!1,object:{type:`Identifier`,name:`Match`},property:{type:`Identifier`,name:s.is(`when`,`not`)}},o.constTrue),s.orElse(o.constFalse)),q=s.type().pipe(s.when({type:`MemberExpression`,computed:!1,property:{type:`Identifier`,name:`_tag`}},o.constTrue),s.when({type:`MemberExpression`,computed:!0,property:{type:`Literal`,value:`_tag`}},o.constTrue),s.orElse(o.constFalse));function pr(e){if(he(e.operator)){if(q(e.left)&&B(e.right))return e.left;if(q(e.right)&&B(e.left))return e.right}}function J(e){let t=R(e),n=t===void 0?void 0:z(t);return n!==void 0&&dr(n.callee)}function mr(e){return e.object.type===`MemberExpression`&&S(e.object)===`reason`}function hr(e){let t=e.parent;return t.type===`CallExpression`&&t.arguments.includes(e)&&fr(t.callee)}const gr=y(x(`problem`,"Use Effect tagged error handlers instead of manually branching on `_tag` in a catch handler.",{tag:`Use Effect.catchTag or Effect.catchTags instead of manually discriminating a tagged error in a broad Effect catch handler.`,reason:"Use Effect.catchReason or Effect.catchReasons instead of manually discriminating a tagged `reason` in a broad Effect catch handler."},`https://github.com/dmmulroy/anti-slop/blob/main/src/effect/rules/no-manual-effect-error-tag.ts`),e=>({BinaryExpression(t){let n=pr(t);n!==void 0&&J(t)&&e.report({node:t,messageId:mr(n)?`reason`:`tag`})},SwitchStatement(t){q(t.discriminant)&&J(t)&&e.report({node:t,messageId:mr(t.discriminant)?`reason`:`tag`})}})),_r=y(x(`problem`,"Use Effect Match or Predicate helpers instead of manually branching on `_tag`.",{manualComparison:`Use Match.tag/Match.tags for tagged-value branching, or Predicate.isTagged for a simple reusable predicate.`,manualSwitch:"Use Match.value(value).pipe(Match.tag/Match.tags/Match.tagsExhaustive) or the tagged enum `$match` helper instead of switching on `_tag`."},`https://github.com/dmmulroy/anti-slop/blob/main/src/effect/rules/no-manual-tag-comparison.ts`),e=>({BinaryExpression(t){pr(t)===void 0||J(t)||e.report({node:t,messageId:`manualComparison`})},SwitchStatement(t){q(t.discriminant)&&!J(t)&&e.report({node:t,messageId:`manualSwitch`})}})),vr=y(x(`problem`,"Construct tagged values with their existing Effect constructor instead of writing `_tag` manually.",{manualConstruction:"Use the existing Schema tagged `.make`, tagged class/error constructor, or Data.taggedEnum variant constructor instead of writing a literal `_tag` object."},`https://github.com/dmmulroy/anti-slop/blob/main/src/effect/rules/no-manual-tagged-construction.ts`),e=>({ObjectExpression(t){if(hr(t))return;let n=c.getOrUndefined(r.findFirst(t.properties,e=>e.type===`Property`&&N(e)===`_tag`&&B(e.value)));n!==void 0&&e.report({node:n,messageId:`manualConstruction`})}})),yr=/* @__PURE__ */ new Map([[`addEventListener`,1],[`on`,1],[`setInterval`,0]]);function br(e,t){let n=C(e.callee)?.at(-1),r=n===void 0?void 0:yr.get(n);if(r===void 0)return!1;if(n===`addEventListener`){let t=M(e,2);if(t?.type===`ObjectExpression`){let e=P(t,`once`);if(e!==void 0&&V(e.value,!0))return!1}}let i=M(e,r);return i!==void 0&&ue(i,t)}const xr=b(x(`problem`,`Disallow attaching Effect.callback resume to repeating event sources.`,{multiShot:`Effect.callback is single-shot, but this source emits repeatedly. Use a once-style subscription or Stream.callback.`},`https://github.com/Effect-TS/tsgo/issues/484`),(e,t)=>({CallExpression(n){if(!O(n.callee,t(),`Effect`,`callback`))return;let r=M(n,0);if(r===void 0||!j(r))return;let i=L(r)?.name,a=r.body;i!==void 0&&a&&I(a,e=>e.type===`CallExpression`&&br(e,i))&&e.report({node:n,messageId:`multiShot`})}})),Sr=/* @__PURE__ */ new Set([`NaN`,`Infinity`,`undefined`]),Cr=/* @__PURE__ */ new Set([`annotate`,`annotateEncoded`,`annotateKey`]),wr=[`default`,`examples`];function Tr(e){return e.type===`Literal`&&l.isBigInt(e.value)||e.type===`Identifier`&&Sr.has(e.name)||j(e)||e.type===`CallExpression`&&C(e.callee)?.at(-1)===`Symbol`}function Er(e,t){if(e.type===`ArrayExpression`)for(let n of e.elements)n&&n.type!==`SpreadElement`&&t.push(n);else if(e.type===`ObjectExpression`)for(let n of e.properties)n.type===`Property`&&t.push(n.value)}function Dr(e){let t=[e];for(;t.length>0;){let e=t.pop();if(e===void 0)continue;let n=F(e);if(Tr(n))return n;Er(n,t)}}const Or=b(x(`problem`,`Disallow schema examples and defaults that cannot be represented in JSON Schema.`,{nonJson:`This schema annotation value is not JSON-serializable and will be omitted from or corrupt generated JSON Schema.`},`https://github.com/Effect-TS/tsgo/issues/440`),(e,t)=>({CallExpression(n){let r=t();if(!r.hasEffectImport)return;let i=D(n.callee,r),a=n.callee.type===`MemberExpression`?S(n.callee):i?.[0]===`Schema`?i[1]:void 0;if(a===void 0||!Cr.has(a))return;let o=qt(n);if(o!==void 0&&P(o,`jsonSchema`)===void 0)for(let t of wr){let n=P(o,t);if(n===void 0)continue;let r=Dr(n.value);r!==void 0&&e.report({node:r,messageId:`nonJson`})}}})),kr=[`option`,`either`],Ar=b(x(`problem`,`Disallow wrapping infallible Effect.service access in Option or Either.`,{mandatory:`Effect.service never fails, so this wrapper is always present and keeps the service requirement. Use Effect.serviceOption.`},`https://github.com/Effect-TS/tsgo/issues/648`),(e,t)=>({CallExpression(n){let r=t(),i=k(n.callee,r,`Effect`,kr),a=M(n,0);if(i&&a?.type===`CallExpression`&&O(a.callee,r,`Effect`,`service`)){e.report({node:n,messageId:`mandatory`});return}if(n.callee.type!==`MemberExpression`||C(n.callee)?.at(-1)!==`pipe`)return;let o=F(n.callee.object),s=M(n,0);s!==void 0&&o.type===`CallExpression`&&O(o.callee,r,`Effect`,`service`)&&k(s,r,`Effect`,kr)&&e.report({node:n,messageId:`mandatory`})}})),jr=b(x(`problem`,`Ensure a later object spread cannot overwrite an explicitly assigned _tag.`,{overwritten:`A later spread can overwrite _tag at runtime. Move _tag after all spreads.`},`https://github.com/Effect-TS/tsgo/issues/426`),e=>({ObjectExpression(t){let n=r.findFirstWithIndex(t.properties,e=>e.type===`Property`&&N(e)===`_tag`);if(c.isNone(n))return;let[i,a]=n.value;r.some(r.drop(t.properties,a+1),e=>e.type===`SpreadElement`)&&e.report({node:i,messageId:`overwritten`})}})),Mr=/^make[A-Z]/u,Nr=/\.(?:test|spec)\.[cm]?[jt]sx?$/u,Pr=y(x(`problem`,`Disallow project-local make<CapabilityName> imports outside test and spec files.`,{serviceConstructorImport:`Do not import Effect service constructor "{{name}}" into runtime code. Import the owning Layer, yield the contextual service, and allow its requirements to propagate to the composition root.`},`https://github.com/dmmulroy/anti-slop/blob/main/src/effect/rules/no-service-constructor-imports.ts`),e=>({ImportDeclaration(t){if(!Nr.test(i.replaceAll(`\\`,`/`)(e.filename))&&(i.startsWith(`./`)(t.source.value)||i.startsWith(`../`)(t.source.value)))for(let n of t.specifiers){if(n.type!==`ImportSpecifier`)continue;let t=v(n.imported);Mr.test(t)&&e.report({node:n,messageId:`serviceConstructorImport`,data:{name:t}})}}})),Fr=[`getOrThrow`,`getOrThrowWith`],Ir=b(x(`problem`,`Disallow turning missing Effect services into untyped Option defects.`,{getOrThrow:`Option.getOrThrow after Effect.serviceOption hides a mandatory service until runtime. Use Effect.service so it remains a typed requirement.`},`https://github.com/Effect-TS/tsgo/issues/650`),(e,t)=>({CallExpression(n){let r=t();if(k(n.callee,r,`Option`,Fr)){let t=M(n,0),i=t?.type===`YieldExpression`?t.argument:t;i?.type===`CallExpression`&&O(i.callee,r,`Effect`,`serviceOption`)&&e.report({node:n,messageId:`getOrThrow`});return}if(n.callee.type!==`MemberExpression`||C(n.callee)?.at(-1)!==`pipe`)return;let i=F(n.callee.object),a=M(n,0);if(i.type!==`CallExpression`||!O(i.callee,r,`Effect`,`serviceOption`)||a?.type!==`CallExpression`||!O(a.callee,r,`Effect`,`map`))return;let o=M(a,0);o!==void 0&&k(o,r,`Option`,Fr)&&e.report({node:n,messageId:`getOrThrow`})}})),Lr=/* @__PURE__ */ new Set([`andThen`,`map`,`mapError`,`tap`,`tapError`,`tapErrorCause`]),Rr=b(x(`problem`,`Disallow throw in Effect callbacks that cannot add the thrown value to the typed error channel.`,{callbackThrow:`Throwing in this Effect callback creates an untyped defect. Return Effect.fail(...) or return the mapped error value instead.`},`https://github.com/Effect-TS/tsgo/issues/406`),(e,t)=>({ThrowStatement(n){let r=R(n);if(r===void 0)return;let i=t(),a=Yt(r,i),o=Jt(r,`catch`);(a?.[0]===`Effect`&&a[1]!==void 0&&Lr.has(a[1])||o!==void 0&&k(o.callee,i,`Effect`,[`try`,`tryPromise`]))&&e.report({node:n,messageId:`callbackThrow`})}})),zr=/* @__PURE__ */ new Set([`get`,`post`,`put`,`patch`,`delete`,`head`,`options`]);function Br(e,t){let n=e.parent,r=e.node;if(e.type!==`ImportBinding`||n?.type!==`ImportDeclaration`||K(n,r.type===`ImportSpecifier`?r:void 0))return!1;let i=n.source.value;return r.type===`ImportNamespaceSpecifier`?i===`effect/unstable/httpapi/HttpApiEndpoint`&&t.length===2||i===`effect/unstable/httpapi`&&t.length===3&&t[1]===`HttpApiEndpoint`:r.type===`ImportSpecifier`&&r.imported.type===`Identifier`&&r.imported.name===`HttpApiEndpoint`&&i===`effect/unstable/httpapi`&&t.length===2}function Vr(e,t){let n=C(e.callee),r=n?.[0],i=n?.at(-1);if(n===void 0||r===void 0||i===void 0||!zr.has(i))return!1;let a=T(w(t,e,r));return a!==void 0&&Br(a,n)}function Hr(e){if(e?.type!==`ObjectExpression`)return;let t=/* @__PURE__ */ new Set,n=[];for(let r of e.properties){if(r.type!==`Property`||r.computed||r.method||r.kind!==`init`)return;let e=N(r)??(r.key.type===`Literal`&&l.isNumber(r.key.value)?String(r.key.value):void 0);if(e===void 0||t.has(e))return;t.add(e),n.push(r)}return n}const Ur=y(x(`problem`,`Require lowercase static keys in Effect v4 endpoint header field schemas.`,{uppercase:`Header schema key "{{name}}" contains ASCII uppercase letters. Incoming headers use exact lowercase runtime lookup; review the schema and its consumers before renaming this key.`},`https://github.com/Effect-TS/tsgo/issues/413`),e=>({CallExpression(t){if(r.some(t.arguments,e=>e.type===`SpreadElement`)||!Vr(t,e))return;let n=Hr(M(t,2)),i=Hr(c.getOrUndefined(r.findFirst(n??[],e=>N(e)===`headers`))?.value);if(i!==void 0)for(let t of i){let n=N(t);n!==void 0&&/[A-Z]/u.test(n)&&e.report({node:t.key,messageId:`uppercase`,data:{name:n}})}}})),Wr=b(x(`problem`,`Disallow no-op retry and repeat wrappers with times: 0.`,{zeroTimes:`times: 0 performs no retries or repeats. Remove the wrapper or use a positive count.`},`https://github.com/Effect-TS/tsgo/issues/412`),(e,t)=>({CallExpression(n){let r=t();if(!k(n.callee,r,`Effect`,[`retry`,`repeat`]))return;let i=qt(n);if(i===void 0)return;let a=P(i,`times`);a!==void 0&&V(a.value,0)&&e.report({node:a,messageId:`zeroTimes`})}})),Gr=y({...x(`suggestion`,`Use consistently aliased namespace imports for Effect and Alchemy submodule entrypoints.`,{alias:"Import {{source}} as the canonical namespace alias `{{alias}}`.",namespace:'Use `import * as {{alias}} from "{{source}}"` instead of importing values directly.'},`https://github.com/Effect-TS/language-service/blob/main/packages/language-service/src/core/AutoImport.ts`),fixable:`code`},e=>({ImportDeclaration(t){let n=Sn(t.source.value);if(n===void 0||t.importKind===`type`)return;let r=bn(n);for(let n of t.specifiers)n.type===`ImportSpecifier`&&K(t,n)||(n.type===`ImportNamespaceSpecifier`?n.local.name!==r&&e.report({node:n.local,messageId:`alias`,data:{alias:r,source:t.source.value},fix:n=>wn(e,t,n)}):e.report({node:n,messageId:`namespace`,data:{alias:r,source:t.source.value},fix:n=>wn(e,t,n)}))}})),Kr=b(x(`suggestion`,`Prefer immutable, Order-based Effect Array sorting in Effect projects.`,{effectArraySort:`Use Arr.sort with an Order instead of the mutable native Array.sort method.`},`https://www.effect.website/docs/v4/api/effect/Array#sort`),(e,t)=>({CallExpression(n){let r=t();r.hasEffectImport&&n.callee.type===`MemberExpression`&&S(n.callee)===`sort`&&!O(n.callee,r,`Array`,`sort`)&&e.report({node:n,messageId:`effectArraySort`})}})),qr=/* @__PURE__ */ new Set([`toISOString`,`toLocaleDateString`,`toLocaleTimeString`]),Jr=b(x(`suggestion`,`Prefer Effect DateTime formatting so time-zone behavior is explicit and composable.`,{effectDateTime:`Convert to DateTime and use DateTime.format, DateTime.formatIso, or another explicit formatter.`},`https://www.effect.website/docs/v4/api/effect/DateTime`),(e,t)=>({CallExpression(n){t().hasEffectImport&&n.callee.type===`MemberExpression`&&qr.has(S(n.callee)??``)&&e.report({node:n,messageId:`effectDateTime`})}})),Yr=/* @__PURE__ */ new Map([[`Effect.cachedInvalidateWithTTL`,`last`],[`Effect.cachedWithTTL`,`last`],[`Effect.delay`,`last`],[`Effect.sleep`,`last`],[`Effect.timeout`,`last`],[`Effect.timeoutOption`,`last`],[`Effect.timeoutOrElse`,`options.duration`],[`Schedule.duration`,`last`],[`Schedule.during`,`last`],[`Schedule.exponential`,`first`],[`Schedule.fibonacci`,`last`],[`Schedule.fixed`,`last`],[`Schedule.spaced`,`last`],[`Schedule.windowed`,`last`],[`Stream.debounce`,`last`],[`Stream.groupedWithin`,`last`],[`Stream.throttle`,`options.duration`],[`Stream.timeout`,`last`],[`TestClock.adjust`,`last`]]),Xr={first:e=>M(e,0),last:e=>M(e,e.arguments.length-1),"options.duration":e=>{let t=M(e,e.arguments.length-1);return t?.type===`ObjectExpression`?P(t,`duration`)?.value:void 0}};function Zr(e,t,n){let i=D(e.callee,n),a=i===void 0?void 0:Yr.get(r.join(i,`.`));return a!==void 0&&H(t,e.callee)?Xr[a](e):void 0}function Qr(e,t){return e**t}const $r=s.type().pipe(s.withReturnType(),s.when(`*`,()=>f.multiply),s.when(`+`,()=>f.sum),s.when(`-`,()=>f.subtract),s.when(`/`,()=>f.divideUnsafe),s.when(`%`,()=>f.remainder),s.when(`**`,()=>Qr),s.orElse(o.constUndefined));function Y(e){let t=F(e);if(t.type===`Literal`)return l.isNumber(t.value)?t.value:void 0;if(t.type===`UnaryExpression`&&(t.operator===`-`||t.operator===`+`)){let e=Y(t.argument);return e===void 0||t.operator===`+`?e:-e}if(t.type!==`BinaryExpression`||t.left.type===`PrivateIdentifier`)return;let n=Y(t.left),r=Y(t.right);if(n!==void 0&&r!==void 0)return $r(t.operator)?.(n,r)}function ei(e){let t=F(e);if(t.type===`Literal`)return l.isNumber(t.value)?[t.value]:void 0;if(t.type!==`BinaryExpression`||t.operator!==`*`)return;let n=ei(t.left),i=ei(t.right);return n===void 0||i===void 0?void 0:r.appendAll(n,i)}const ti=/* @__PURE__ */ new Set([6e4,36e5,864e5]),ni=/* @__PURE__ */ new Set([60,3600,86400]),ri=/* @__PURE__ */ new Set([7,24,60,1e3,3600,86400]);function ii(e){let t=ei(e);if(!(t===void 0||t.length<2)&&(r.some(t,e=>ti.has(e))||r.some(t,e=>ni.has(e))&&r.filter(t,e=>ri.has(e)).length>=2))return{millis:r.contains(t,1e3)||r.some(t,e=>e%6e4==0)}}const ai=[[`weeks`,6048e5],[`days`,864e5],[`hours`,36e5],[`minutes`,6e4],[`seconds`,1e3],[`millis`,1]];function oi(e){return!Number.isSafeInteger(e)||Math.abs(e)<1e4?String(e):i.replaceAll(/\B(?=(?:\d{3})+$)/gu,`_`)(String(e))}function si(e,t){let n=e*r.findFirst(ai,([e])=>e===t).pipe(c.map(([,e])=>e),c.getOrElse(()=>1));return n===0?`Duration.zero`:r.findFirst(ai,([,e])=>Number.isSafeInteger(n/e)).pipe(c.match({onNone:()=>`Duration.millis(${oi(n)})`,onSome:([e,t])=>`Duration.${e}(${oi(n/t)})`}))}const ci=b({...x(`suggestion`,`Prefer explicit Effect Duration constructors over ambiguous millisecond literals.`,{effectDuration:`Wrap this number with Duration.millis or use a more descriptive Duration constructor.`},`https://www.effect.website/docs/v4/api/effect/Duration`),fixable:`code`},(e,t)=>({CallExpression(n){let r=Zr(n,e,t());r!==void 0&&Y(r)!==void 0&&e.report({node:r,messageId:`effectDuration`,fix(t){let i=Ze(e,n,`effect/Duration`,`Duration`,t);return[...i.fixes,t.replaceText(r,`${i.name}.millis(${e.sourceCode.getText(r)})`)]}})}})),li=/* @__PURE__ */ new Map([[`ms`,`millis`],[`milli`,`millis`],[`millis`,`millis`],[`millisecond`,`millis`],[`milliseconds`,`millis`],[`sec`,`seconds`],[`secs`,`seconds`],[`seconds`,`seconds`],[`mins`,`minutes`],[`minutes`,`minutes`],[`hr`,`hours`],[`hrs`,`hours`],[`hours`,`hours`],[`days`,`days`],[`weeks`,`weeks`]]),ui=/* @__PURE__ */ new Set([`day`,`hour`,`minute`,`second`,`week`]),di=/* @__PURE__ */ new Set([`backoff`,`cooldown`,`day`,`debounce`,`delay`,`duration`,`expiration`,`expiry`,`hour`,`interval`,`lifetime`,`minute`,`second`,`throttle`,`timeout`,`ttl`,`week`]),fi=o.flow(i.split(/[_$]+|(?<=[\da-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])/u),r.filter(i.isNonEmpty),r.map(i.toLowerCase)),pi=/* @__PURE__ */ new Set([`at`,`epoch`,`per`,`timestamp`]);function mi(e){return e!==void 0&&e!==`excluded`&&e!==`unknown`}function hi(e){let t=fi(e),n=t.indexOf(`in`),i=t[n-1]??``;if(n>0&&n<t.length-1&&(li.has(i)||ui.has(i))||r.some(t,e=>pi.has(e)))return`excluded`;let a=t.at(-1),o=t.at(-2);if(a===void 0)return;let s=li.get(a);if(s!==void 0)return s;if(di.has(a)||a===`age`&&o===`max`||a===`in`&&o===`expires`)return`unknown`}function gi(e,t,n){return r.some(w(n,e,t)?.defs??[],e=>e.type===`ImportBinding`)}const _i=s.type().pipe(s.withReturnType(),s.discriminators(`type`)({Identifier:o.flow(p.get(`name`),r.make),TSQualifiedName:({left:e,right:t})=>{let n=_i(e);return n===void 0?void 0:r.append(n,t.name)}}),s.orElse(o.constUndefined));function vi(e,t,n){return I(e,e=>{if(e.type!==`TSTypeReference`)return!1;let[r,...i]=_i(e.typeName)??[],a=r===void 0||!gi(e,r,t)?void 0:n.bindings.get(r);return a!==void 0&&[...a,...i][0]===`Duration`})}function yi(e){return e.parent.type===`VariableDeclaration`&&e.parent.kind===`const`&&e.id.type===`Identifier`&&e.init!==null&&Y(e.init)!==void 0}function bi(e,t){let n=F(e);if(n.type!==`Identifier`)return;let r=T(w(t,n,n.name))?.node;return r?.type===`VariableDeclarator`&&yi(r)?r:void 0}const xi=b(x(`suggestion`,`Prefer Effect Duration values over plain-number duration constants.`,{durationConstant:`{{name}} holds a duration as a plain number. Declare it as {{replacement}} and convert at non-Effect boundaries with Duration.toMillis or Duration.toSeconds.`},`https://www.effect.website/docs/v4/api/effect/Duration`),(e,t)=>{let n=/* @__PURE__ */ new Map;function r(n,r){if(n.id.typeAnnotation&&vi(n.id.typeAnnotation,e,t()))return`none`;let i=hi(n.id.name);if(r)return mi(i)?i:`millis`;if(i===`excluded`||(Y(n.init)??0)<=0)return`none`;if(mi(i))return i;let a=ii(n.init);return a?.millis===!0?`millis`:a!==void 0||i===`unknown`?void 0:`none`}return{before(){n.clear()},VariableDeclarator(e){t().hasEffectImport&&yi(e)&&!n.has(e)&&n.set(e,!1)},CallExpression(r){let i=Zr(r,e,t()),a=i===void 0?void 0:bi(i,e);a!==void 0&&n.set(a,!0)},"Program:exit":function(){for(let[t,i]of n){let n=r(t,i),a=Y(t.init);n!==`none`&&e.report({node:t.id,messageId:`durationConstant`,data:{name:t.id.name,replacement:n===void 0||a===void 0?`a Duration constructor such as Duration.seconds`:si(a,n)}})}}}}),Si=/* @__PURE__ */ new Set([`base64`,`base64url`,`hex`]);function Ci(e){return e!==void 0&&B(e)&&Si.has(e.value)}const wi=b(x(`suggestion`,`Prefer Effect Encoding for portable Base64, Base64Url, and hexadecimal encoding.`,{effectEncoding:`Use Encoding encode/decode helpers; decoders return Result instead of throwing.`},`https://www.effect.website/docs/v4/api/effect/Encoding`),(e,t)=>({CallExpression(n){if(!t().hasEffectImport)return;if((E(n.callee,e,`atob`)||E(n.callee,e,`btoa`))&&n.arguments.length>0){e.report({node:n,messageId:`effectEncoding`});return}let i=C(n.callee),a=i!==void 0&&r.join(i,`.`)===`Buffer.from`&&Ci(M(n,1)),o=i?.at(-1)===`toString`&&Ci(M(n,0));(a||o)&&e.report({node:n,messageId:`effectEncoding`})}})),Ti=/* @__PURE__ */ new Set([`fs`,`fs/promises`,`node:fs`,`node:fs/promises`]),Ei=b(x(`suggestion`,`Prefer the Effect FileSystem service over direct Node.js filesystem imports in Effect projects.`,{effectFileSystem:`Use the FileSystem service from effect/FileSystem instead of {{source}}.`},`https://www.effect.website/docs/v4/api/effect/FileSystem`),(e,t)=>({ImportDeclaration(n){t().hasEffectImport&&Ti.has(n.source.value)&&e.report({node:n.source,messageId:`effectFileSystem`,data:{source:n.source.value}})}}));function Di(e,t,n){return e.type===`CallExpression`&&O(e.callee,t,`Result`,n)?M(e,0):void 0}function Oi(e,t,n){let r=L(t),i=tn(t);if(r===void 0||i?.type!==`ConditionalExpression`)return;let a=Di(i.consequent,n,`succeed`),o=Di(i.alternate,n,`fail`);a?.type===`Identifier`&&a.name===r.name&&o?.type===`Identifier`&&o.name===r.name&&e.report({node:t,messageId:`effectFilter`})}const ki=b(x(`suggestion`,`Prefer Effect Filter constructors for reusable Result-valued predicates.`,{effectFilter:`Use Filter.fromPredicate for this Result-valued predicate so it composes as a Filter.`},`https://www.effect.website/docs/v4/api/effect/Filter`),(e,t)=>({ArrowFunctionExpression(n){Oi(e,n,t())},FunctionExpression(n){Oi(e,n,t())}})),Ai=b(x(`suggestion`,`Prefer immutable Effect Headers values in Effect projects.`,{effectHeaders:`Use Headers.fromInput to construct normalized, immutable Effect headers.`},`https://www.effect.website/docs/v4/api/effect/unstable/http/Headers`),(e,t)=>({NewExpression(n){t().hasEffectImport&&E(n.callee,e,`Headers`)&&e.report({node:n,messageId:`effectHeaders`})}}));function ji(e){return e.type===`Literal`||e.type===`TemplateLiteral`&&e.expressions.length===0}function Mi(e,t){if(e.type===`BinaryExpression`&&he(e.operator)){if(ji(e.left))return t.sourceCode.getText(e.right);if(ji(e.right))return t.sourceCode.getText(e.left)}}const Ni=b(x(`suggestion`,`Prefer Effect Match for composable and exhaustive branching in Effect projects.`,{effectMatch:`Use Match.type, Match.value, or Match.tags with Match.exhaustive instead of switch.`,preferMatch:`Use Match from Effect instead of a chained literal ternary.`},`https://www.effect.website/docs/v4/api/effect/Match`),(e,t)=>({SwitchStatement(n){t().hasEffectImport&&e.report({node:n,messageId:`effectMatch`})},ConditionalExpression(t){if(t.parent.type===`ConditionalExpression`)return;let n=Mi(t.test,e);if(n===void 0)return;let r=t.alternate,i=1;for(;r.type===`ConditionalExpression`;){if(Mi(r.test,e)!==n)return;i+=1,r=r.alternate}i>1&&e.report({node:t,messageId:`preferMatch`})}})),Pi=/* @__PURE__ */ new Set([`node:path`,`path`]),Fi=b(x(`suggestion`,`Prefer the Effect Path service over direct Node.js path imports in Effect projects.`,{effectPath:`Use the Path service from effect/Path instead of {{source}}.`},`https://www.effect.website/docs/v4/api/effect/Path`),(e,t)=>({ImportDeclaration(n){t().hasEffectImport&&Pi.has(n.source.value)&&e.report({node:n.source,messageId:`effectPath`,data:{source:n.source.value}})}})),Ii=/* @__PURE__ */ new Set([`canParse`,`parse`]),Li=b(x(`suggestion`,`Prefer Effect Url helpers for safe URL parsing in Effect projects.`,{effectUrl:`Use Url.fromString or Url.make so invalid URLs are represented as Result failures.`},`https://www.effect.website/docs/v4/api/effect/unstable/http/Url`),(e,t)=>({NewExpression(n){t().hasEffectImport&&E(n.callee,e,`URL`)&&e.report({node:n,messageId:`effectUrl`})},CallExpression(n){let r=C(n.callee);t().hasEffectImport&&r?.[0]===`URL`&&Ii.has(r[1]??``)&&n.callee.type===`MemberExpression`&&E(n.callee.object,e,`URL`)&&e.report({node:n,messageId:`effectUrl`})}})),Ri=/* @__PURE__ */ new Map([[`interruptibleMask`,`interruptible`],[`uninterruptibleMask`,`uninterruptible`]]),zi=b(x(`suggestion`,`Prefer the non-mask interruptibility API when the restore callback is unused.`,{unusedRestore:`The mask callback never uses restore, so the mask is equivalent to {{replacement}} and misleadingly suggests a restored region.`},`https://github.com/Effect-TS/tsgo/issues/659`),(e,t)=>({CallExpression(n){let r=D(n.callee,t()),i=r?.length===2&&r[0]===`Effect`?Ri.get(r[1]??``):void 0,a=M(n,0);i!==void 0&&a!==void 0&&j(a)&&!de(a)&&e.report({node:n,messageId:`unusedRestore`,data:{replacement:`Effect.${i}`}})}})),Bi=b(x(`suggestion`,`Prefer Effect.withSpan when the callback does not use the span handle.`,{unusedSpan:`The useSpan callback ignores its span. Use Effect.withSpan so nested spans are parented beneath this span.`},`https://github.com/Effect-TS/tsgo/issues/663`),(e,t)=>({CallExpression(n){if(!O(n.callee,t(),`Effect`,`useSpan`))return;let r=M(n,n.arguments.length-1);r!==void 0&&j(r)&&!de(r)&&e.report({node:n,messageId:`unusedSpan`})}}));function Vi(e,t){let n=F(e);if(V(n,0))return!0;if(B(n))return/^0\s*(?:nanos?|micros?|millis?|seconds?|minutes?|hours?|days?|weeks?)$/i.test(n.value);if(O(n,t,`Duration`,`zero`))return!0;if(n.type===`CallExpression`){let e=D(n.callee,t),r=M(n,0);return r!==void 0&&e?.[0]===`Duration`&&V(r,0)}return!1}const Hi=b(x(`suggestion`,`Prefer scheduler yielding to a zero-duration Clock sleep.`,{zeroSleep:`Effect.sleep(0) uses Clock and interacts with TestClock. Use Effect.yieldNow for a cooperative scheduler yield.`},`https://github.com/Effect-TS/tsgo/issues/661`),(e,t)=>({CallExpression(n){let r=t(),i=M(n,0);i!==void 0&&O(n.callee,r,`Effect`,`sleep`)&&Vi(i,r)&&e.report({node:n,messageId:`zeroSleep`})}})),Ui=/* @__PURE__ */ new Set([`catch`,`mapError`,`catchAll`]);function Wi(e,t){let n=Yt(e,t),r=Jt(e,`catch`);if(!(n?.[0]===`Effect`&&n[1]!==void 0&&Ui.has(n[1])||r!==void 0&&k(r.callee,t,`Effect`,[`try`,`tryPromise`]))||!e.body)return!1;let i=L(e);return I(e.body,e=>e.type===`NewExpression`&&_e(e)&&(i===void 0||!ue(e,i.name)))}const Gi=b(x(`suggestion`,`Preserve the underlying cause when wrapping an Effect failure.`,{droppedCause:`This handler constructs a new error but drops the caught failure. Accept it as a parameter and attach it as cause.`},`https://github.com/Effect-TS/tsgo/issues/490`),(e,t)=>({ArrowFunctionExpression(n){Wi(n,t())&&e.report({node:n,messageId:`droppedCause`})},FunctionExpression(n){Wi(n,t())&&e.report({node:n,messageId:`droppedCause`})}})),Ki=b(x(`problem`,`Require Schema.Class declarations to carry a nominal brand.`,{missingBrand:`Schema.Class without a second type parameter is structural. Add a unique brand so plain objects cannot masquerade as instances.`},`https://github.com/Effect-TS/tsgo/issues/468`),(e,t)=>({CallExpression(n){O(n.callee,t(),`Schema`,`Class`)&&(n.typeArguments?.params.length??0)<2&&e.report({node:n,messageId:`missingBrand`})}}));function qi(e,t){if(O(e.callee,t,`Effect`,`tryPromise`))return nn(M(e,0))}const Ji=b(x(`suggestion`,`Require Effect.tryPromise thunks to accept and use their AbortSignal for interruption.`,{missingSignal:"Accept the AbortSignal parameter and pass it to the Promise API. Name it `_signal` only when cancellation is unsupported.",unusedSignal:"Pass this AbortSignal to the Promise API, or rename it to `_signal` to explicitly acknowledge that cancellation is unsupported."},`https://www.effect.website/docs/v4/api/effect/Effect#tryPromise`),(e,t)=>({CallExpression(n){let r=qi(n,t());if(r===void 0)return;let a=L(r);a===void 0?e.report({node:r,messageId:`missingSignal`}):!i.startsWith(`_`)(a.name)&&!de(r)&&e.report({node:a,messageId:`unusedSignal`})}})),Yi=[`fn`,`fnUntraced`,`gen`],Xi=[`fn`,`fnUntraced`],Zi=[`try`,`tryPromise`];function Qi(e,t){let n=e.parent;if(n.type===`CallExpression`&&M(n,0)===e)return k(n.callee,t,`Effect`,Zi);if(n.type!==`Property`||n.key.type!==`Identifier`||n.key.name!==`try`)return!1;let r=n.parent;return r.type===`ObjectExpression`&&r.parent.type===`CallExpression`&&k(r.parent.callee,t,`Effect`,Zi)}const $i=b(x(`problem`,`Disallow throw in Effect generator APIs because it creates an untyped defect.`,{throwInGen:`Use yield* Effect.fail(...) instead of throw so the failure stays in the typed error channel.`}),(e,t)=>({ThrowStatement(n){let i=t(),a=R(n);if(a===void 0||Qi(a,i))return;let o=z(a),s=o!==void 0&&r.some(Yi,e=>O(o.callee,i,`Effect`,e)),c=o?.callee,l=c?.type===`CallExpression`&&r.some(Xi,e=>O(c.callee,i,`Effect`,e));(s||l)&&e.report({node:n,messageId:`throwInGen`})}})),ea=String.raw`(?:\r\n|\r(?!\n)|[\n\u2028\u2029])`,ta=String.raw`[^\S\r\n\u2028\u2029]*`,na=RegExp(`^(${ta}${ea})(?:${ta}${ea})+(${ta};?)$`,`u`),ra=/^(?:module\s*\.\s*)?exports(?:\s*\.|\s*\[|$)/u,ia=/* @__PURE__ */ new Set([`FunctionDeclaration`,`FunctionExpression`,`ArrowFunctionExpression`]),aa=/* @__PURE__ */ new Set([`any`,`never`,`always`]),oa=/* @__PURE__ */ new Set([`any`,`singleline`,`multiline`]),sa=/* @__PURE__ */ new Set([`blankLine`,`prev`,`next`]),ca=/* @__PURE__ */ new Set([`selector`,`lineMode`]);function la(e){return e.type===`Punctuator`&&e.value===`;`}function ua(e,t){return e.loc.end.line===t.loc.start.line}function da(e){return e.loc.start.line===e.loc.end.line}function fa(e){return ia.has(e.type)}function pa(e){return e.type===`ChainExpression`?e.expression:e}function X(e,t){let n=new Set(r.ensure(e));return(e,r)=>r.getFirstToken(e)?.value===t&&n.has(e.type)}function Z(e){return t=>t.type===e}function Q(e,t){return(n,r)=>e(n,r)&&da(n)===(t===`singleline`)}function ma(e){if(e.type!==`ExpressionStatement`)return!1;let t=pa(e.expression);if(t.type===`UnaryExpression`&&(t=pa(t.argument)),t.type!==`CallExpression`)return!1;let n=t.callee;for(;n.type===`SequenceExpression`;)n=c.getOrThrowWith(r.last(n.expressions),()=>/* @__PURE__ */ Error(`Padding rule invariant: sequence expression is empty`));return fa(n)}function ha(e){if(e.type!==`VariableDeclaration`)return!1;let t=e.declarations[0]?.init;if(t==null)return!1;for(;t.type===`MemberExpression`;)t=t.object;return t.type===`CallExpression`&&t.callee.type===`Identifier`&&t.callee.name===`require`}function ga(e,t){if(e.type===`DoWhileStatement`&&e.body.type===`BlockStatement`||ma(e))return!0;let n=t.getLastToken(e,e=>!la(e)),r=n?.type===`Punctuator`&&n.value===`}`?t.getNodeByRangeIndex(n.range[0]):null;return r?.type===`BlockStatement`||r?.type===`SwitchStatement`}function _a(e,t){return e.type===`ExpressionStatement`&&(e.parent.type===`Program`||e.parent.type===`BlockStatement`&&fa(e.parent.parent))&&e.expression.type===`Literal`&&l.isString(e.expression.value)&&(t.getTokenBefore(e.expression)?.value!==`(`||t.getTokenAfter(e.expression)?.value!==`)`)}function va(e,t){if(!_a(e,t)||!e.parent||!(`body`in e.parent)||!r.isArray(e.parent.body))return!1;let n=e.parent.body;return o.pipe(n,r.takeWhile(t=>t!==e),r.every(e=>_a(e,t)))}function ya(e){if(e.type!==`ExpressionStatement`||e.expression.type!==`AssignmentExpression`)return!1;let t=e.expression.left;if(t.type!==`MemberExpression`)return!1;for(;t.object.type===`MemberExpression`;)t=t.object;return t.object.type===`Identifier`&&(t.object.name===`exports`||t.object.name===`module`&&t.property.type===`Identifier`&&t.property.name===`exports`)}function ba(e,t){let n=t.getLastToken(e);if(n===null)throw Error(`Padding rule invariant: statement has no token`);let r=t.getTokenBefore(n),i=t.getTokenAfter(n);return r&&i&&r.range[0]>=e.range[0]&&la(n)&&!ua(r,n)&&ua(n,i)?r:n}function xa(e,t){if(da(e))return e.loc;let n=e.loc.start.line,r=t.lines[n-1];if(r===void 0)throw Error(`Padding rule invariant: statement source line is missing`);return{start:e.loc.start,end:{line:n,column:r.length}}}const $={"block-like":ga,expression:(e,t)=>e.type===`ExpressionStatement`&&!va(e,t),return:X(`ReturnStatement`,`return`),export:X([`ExportAllDeclaration`,`ExportDefaultDeclaration`,`ExportNamedDeclaration`],`export`),var:X(`VariableDeclaration`,`var`),let:X(`VariableDeclaration`,`let`),const:X(`VariableDeclaration`,`const`),using:e=>e.type===`VariableDeclaration`&&(e.kind===`using`||e.kind===`await using`),type:X(`TSTypeAliasDeclaration`,`type`)},Sa={"*":()=>!0,exports:ya,require:ha,directive:va,iife:ma,block:Z(`BlockStatement`),empty:Z(`EmptyStatement`),function:Z(`FunctionDeclaration`),"ts-method":Z(`TSMethodSignature`),break:X(`BreakStatement`,`break`),case:X(`SwitchCase`,`case`),class:X(`ClassDeclaration`,`class`),continue:X(`ContinueStatement`,`continue`),debugger:X(`DebuggerStatement`,`debugger`),default:X([`SwitchCase`,`ExportDefaultDeclaration`],`default`),do:X(`DoWhileStatement`,`do`),for:X([`ForStatement`,`ForInStatement`,`ForOfStatement`],`for`),if:X(`IfStatement`,`if`),import:X(`ImportDeclaration`,`import`),switch:X(`SwitchStatement`,`switch`),throw:X(`ThrowStatement`,`throw`),try:X(`TryStatement`,`try`),while:X([`WhileStatement`,`DoWhileStatement`],`while`),with:X(`WithStatement`,`with`),"cjs-export":(e,t)=>e.type===`ExpressionStatement`&&e.expression.type===`AssignmentExpression`&&ra.test(t.getText(e.expression.left)),"cjs-import":(e,t)=>e.type===`VariableDeclaration`&&e.declarations[0]?.init!=null&&i.startsWith(`require(`)(t.getText(e.declarations[0].init)),enum:X(`TSEnumDeclaration`,`enum`),interface:X(`TSInterfaceDeclaration`,`interface`),"function-overload":Z(`TSDeclareFunction`),...$,"singleline-block-like":Q($[`block-like`],`singleline`),"multiline-block-like":Q($[`block-like`],`multiline`),"singleline-expression":Q($.expression,`singleline`),"multiline-expression":Q($.expression,`multiline`),"singleline-return":Q($.return,`singleline`),"multiline-return":Q($.return,`multiline`),"singleline-export":Q($.export,`singleline`),"multiline-export":Q($.export,`multiline`),"singleline-var":Q($.var,`singleline`),"multiline-var":Q($.var,`multiline`),"singleline-let":Q($.let,`singleline`),"multiline-let":Q($.let,`multiline`),"singleline-const":Q($.const,`singleline`),"multiline-const":Q($.const,`multiline`),"singleline-using":Q($.using,`singleline`),"multiline-using":Q($.using,`multiline`),"singleline-type":Q($.type,`singleline`),"multiline-type":Q($.type,`multiline`)};function Ca(e){return oa.has(e)}function wa(e){return aa.has(e)}function Ta(e){return l.isString(e)&&n.has(Sa,e)}function Ea(e){return r.isArray(e)}function Da(e){if(Ta(e))return e;if(l.isObject(e)&&l.isString(e.selector)&&r.every(n.keys(e),e=>ca.has(e))){if(!(`lineMode`in e))return{selector:e.selector};if(Ca(e.lineMode))return{selector:e.selector,lineMode:e.lineMode}}throw Error(`Invalid padding-line-between-statements statement matcher`)}function Oa(e){if(!r.isArray(e))return Da(e);let t=e;if(!r.isReadonlyArrayNonEmpty(t))throw Error(`Padding statement matcher arrays must not be empty`);return r.map(t,e=>Da(e))}function ka(e){return r.map(e,e=>{if(!l.isObject(e)||!(`blankLine`in e)||!(`prev`in e)||!(`next`in e)||r.some(n.keys(e),e=>!sa.has(e))||!wa(e.blankLine))throw Error(`Invalid padding-line-between-statements configuration`);return{blankLine:e.blankLine,prev:Oa(e.prev),next:Oa(e.next)}})}function Aa(e,t,n){let r=[],i=ba(e,n);if(t.loc.start.line-i.loc.end.line>=2)do{let e=n.getTokenAfter(i,{includeComments:!0});if(e===null)throw Error(`Padding rule invariant: next statement token is missing`);e.loc.start.line-i.loc.end.line>=2&&r.push([i,e]),i=e}while(i.range[0]<t.range[0]);return r}function ja(e,t,n){return a.gen(function*(){if(n===`any`)return yield*a.void;let s=yield*h,c=s.sourceCode,l=Aa(e,t,c);return n===`never`?r.isArrayNonEmpty(l)?yield*s.report({node:t,messageId:`unexpectedBlankLine`,loc:xa(t,c),fix(e){if(l.length>=2)return null;let t=r.headNonEmpty(l),n=t[0].range[1],a=t[1].range[0];return e.replaceTextRange([n,a],o.pipe(c.text,i.slice(n,a),i.replace(na,`$1$2`)))}}):yield*a.void:r.isArrayNonEmpty(l)?yield*a.void:yield*s.report({node:t,messageId:`expectedBlankLine`,loc:xa(t,c),fix(n){let r=ba(e,c),i=c.getFirstTokenBetween(r,t,{includeComments:!0,filter(e){return!ua(r,e)||(r=e,!1)}})??t;return n.insertTextAfter(r,ua(r,i)?`
1
+ import{defineRule as e,eslintCompatPlugin as t}from"@oxlint/plugins";import*as n from"effect/Record";import*as r from"effect/Array";import*as i from"effect/String";import*as a from"effect/Effect";import*as o from"effect/Function";import*as s from"effect/Match";import*as c from"effect/Option";import*as l from"effect/Predicate";import*as u from"effect/Schema";import*as d from"effect/Result";import*as f from"effect/Duration";import*as p from"effect/Number";import*as m from"effect/Struct";import{Rule as h,RuleContext as ee,Visitor as te}from"effect-oxlint";import*as g from"effect/Ref";var ne=class extends u.Class(`FileState`)({bindings:u.ReadonlyMap(u.String,u.Array(u.String)).pipe(u.withConstructorDefault(a.succeed(/* @__PURE__ */ new Map))),hasEffectImport:u.Boolean.pipe(u.withConstructorDefault(a.succeed(!1)))}){};const _=ne.make(),v=s.type().pipe(s.discriminatorsExhaustive(`type`)({Identifier:({name:e})=>e,Literal:({value:e})=>e}));function re(e){let t=r.lastNonEmpty(i.split(e,`/`));return/^\p{Ll}/u.test(t)?[]:[t]}const ie=s.type().pipe(s.withReturnType(),s.when(`alchemy`,o.constant([`Alchemy`])),s.when(`@alchemy.run/domain`,o.constant([`Domain`])),s.when(s.is(`effect`,`@effect/platform`),o.constant([])),s.whenOr(i.startsWith(`effect/`),i.startsWith(`alchemy/`),i.startsWith(`@effect/`),re),s.orElse(o.constUndefined));function ae(e){let t=/* @__PURE__ */ new Map,n=!1;for(let r of e.body){if(r.type!==`ImportDeclaration`)continue;let e=r.source.value;(e===`effect`||i.startsWith(`effect/`)(e)||i.startsWith(`@effect/`)(e))&&(n=!0);let a=ie(e);if(a!==void 0)for(let e of r.specifiers)e.type===`ImportNamespaceSpecifier`||e.type===`ImportDefaultSpecifier`?t.set(e.local.name,a):t.set(e.local.name,[...a,v(e.imported)])}return ne.make({bindings:t,hasEffectImport:n})}function y(t,n){return e({meta:t,createOnce:n})}function b(t,n){return e({meta:t,createOnce(e){let t=_,{before:r,Program:i,...a}=n(e,()=>t);return{before(){t=_,r?.()},Program(e){t=ae(e),i?.(e)},...a}}})}function x(e,t,n,r){return{type:e,docs:{description:t,recommended:!0,...r===void 0?{}:{url:r}},schema:[],messages:n}}const S=s.type().pipe(s.when({computed:!1,property:{type:`Identifier`}},({property:e})=>e.name),s.when({computed:!0,property:{type:`Literal`,value:i.isString}},({property:e})=>e.value),s.orElse(o.constUndefined));function C(e){let t=[],n=e;for(;n.type===`ChainExpression`||n.type===`MemberExpression`;){if(n.type===`ChainExpression`){n=n.expression;continue}let e=S(n);if(e===void 0)return;t.unshift(e),n=n.object}return n.type===`Identifier`?[n.name,...t]:void 0}function w(e,t,n){for(let r=e.sourceCode.getScope(t);r!==null;r=r.upper){let e=r.set.get(n);if(e!==void 0)return e}}function T(e){return e?.defs.length===1?e.defs[0]:void 0}function E(e,t,n){return e.type===`Identifier`&&e.name===n&&w(t,e,n)===void 0}function D(e,t){let n=C(e),r=n?.[0];if(n===void 0||r===void 0)return;let i=t.bindings.get(r);return i===void 0?void 0:[...i,...n.slice(1)]}function O(e,t,n,r){let i=D(e,t);return i?.length===2&&i[0]===n&&i[1]===r}function k(e,t,n,i){let a=D(e,t);return a?.length===2&&a[0]===n&&r.contains(i,a[1])}function A(e,t,n){let i=D(e,t);return i?.length===n.length&&r.every(i,(e,t)=>e===n[t])}const oe=s.type().pipe(s.when({type:s.is(`ArrowFunctionExpression`,`FunctionExpression`)},o.constTrue),s.orElse(o.constFalse));function j(e){return oe(e)}function M(e,t){let n=e.arguments[t];return n===void 0||n.type===`SpreadElement`?void 0:n}const N=s.type().pipe(s.when({computed:!1,key:{type:`Identifier`}},({key:e})=>e.name),s.when({key:{type:`Literal`,value:i.isString}},({key:e})=>e.value),s.orElse(o.constUndefined));function P(e,t){return c.getOrUndefined(r.findFirst(e.properties,e=>e.type===`Property`&&N(e)===t))}const se=/* @__PURE__ */ new Set([`ParenthesizedExpression`,`TSAsExpression`,`TSNonNullExpression`,`TSSatisfiesExpression`,`TSTypeAssertion`]);function ce(e){return se.has(e.type)}const le=/* @__PURE__ */ new Set([`loc`,`parent`,`range`]);function F(e){let t=e;for(;ce(t);)t=t.expression;return t}function ue(e,t){if(r.isArray(e))for(let n of e)t.push(n);else for(let[r,i]of n.toEntries(e))le.has(r)||t.push(i)}function I(e,t){let n=[e],r=/* @__PURE__ */ new WeakSet;for(;n.length>0;){let e=n.pop();if(l.isObjectOrArray(e)&&!r.has(e)){if(r.add(e),l.hasProperty(e,`type`)&&l.isString(e.type)&&t(e)===!0)return!0;ue(e,n)}}return!1}function de(e,t){return I(e,e=>e.type===`Identifier`&&e.name===t)}function L(e){let t=e.params[0];return t?.type===`Identifier`?t:void 0}function fe(e){let t=L(e);return t===void 0||!e.body||i.startsWith(`_`)(t.name)?!1:de(e.body,t.name)}function pe(e,t){for(let n=e.parent;n;n=n.parent)if(t(n))return n}function R(e){return pe(e,j)}function z(e){let t=e.parent;if(t.type===`CallExpression`&&t.arguments.includes(e))return t}function me(e,t){return e.range[0]<=t.range[0]&&t.range[1]<=e.range[1]}function B(e){return e.type===`Literal`&&i.isString(e.value)}const he=/* @__PURE__ */ new Set([`==`,`===`,`!=`,`!==`]);function ge(e){return he.has(e)}function V(e,t){return e.type===`Literal`&&e.value===t}function _e(e){let t=e.parent;return t?t.type===`ExpressionStatement`||t.type===`UnaryExpression`&&t.operator===`void`||t.type===`SequenceExpression`&&t.expressions.at(-1)!==e:!1}const ve=l.mapInput(l.compose(l.isString,i.endsWith(`Error`)),e=>C(e.callee)?.at(-1)),ye=[`Aggregate`,`Api`,`Command`,`Event`,`ExternalSystem`,`Model`,`Policy`,`Projection`,`Rejection`,`RequestContext`,`Saga`,`Stream`,`View`];function be(e){return r.contains(ye,e)}function xe(e,t,n){let r=H(e.callee,t,n),i=r?.[1];return r?.length===2&&r[0]===`Domain`&&be(i)?i:void 0}function Se(e,t){let n=e.parent;return n.type===`MemberExpression`&&n.property===e&&!n.computed||n.type===`Property`&&n.key===e&&n.value!==e?!1:T(w(t,n,e.name))?.type===`ImportBinding`}function H(e,t,n){let r=C(e)?.[0];return r!==void 0&&T(w(n,e,r))?.type===`ImportBinding`?D(e,t):void 0}function Ce(e,t,n){for(let r=e,i=e.parent;i;r=i,i=i.parent){if(i.type!==`Property`||i.value!==r)continue;let e=i.parent,a=e.parent;for(;a!==null&&se.has(a.type);)a=a.parent;let o=a?.type===`CallExpression`?M(a,1):void 0;if(o===void 0||e.type!==`ObjectExpression`||a?.type!==`CallExpression`||F(o)!==e)continue;let s=xe(a,t,n);if(s===void 0)continue;let c=N(i);return c===void 0?void 0:{block:s,section:c}}}const we={Aggregate:`aggregate`,Api:`api`,Command:`command`,ExternalSystem:`external`,Model:`model`,Policy:`policy`,Projection:`projection`,RequestContext:`context`,Saga:`saga`,Stream:`stream`,View:`view`},Te={Event:`event`,Rejection:`rejection`},Ee=/* @__PURE__ */ new Set([`command`,`external`,`stream`]),De=/\.(?:test|spec|stories?)\.[cm]?[jt]sx?$/u,Oe=b(x(`suggestion`,"Require one Alchemy Domain block per file, named `<Noun>.<kind>.ts`.",{fileName:"Declare this {{block}} in its own `<Noun>.{{kind}}.ts` file.",oneBlock:"Move this {{block}} to its own `<Noun>.{{kind}}.ts` file. Each file declares one Domain block."},`https://alchemy.run/domain`),(e,t)=>{let n=!1,a=[],o=!1;return{before(){n=!1,a=[],o=!1},"Program:exit":function(){if(!o)for(let{node:t,block:n,kind:r}of a)e.report({node:t,messageId:`fileName`,data:{block:n,kind:r}})},CallExpression(s){let c=xe(s,t(),e),l=r.lastNonEmpty(i.split(e.filename,/[/\\]/u)),u=i.split(l,`.`),d=u.length>=3&&u[0]!==``?u.at(-2):void 0,f=c===void 0?void 0:we[c]??Te[c];c===void 0||f===void 0||De.test(l)||(Ee.has(d)&&Te[c]!==void 0?a.push({node:s.callee,block:c,kind:f}):(d===f&&Ee.has(d)&&(o=!0),n?e.report({node:s.callee,messageId:`oneBlock`,data:{block:c,kind:f}}):d!==f&&e.report({node:s.callee,messageId:`fileName`,data:{block:c,kind:f}}),n=!0))}}}),ke=/* @__PURE__ */ new Map([[`Date.now`,`time`],[`performance.now`,`time`],[`performance.timeOrigin`,`time`],[`Math.random`,`random`],[`crypto.randomUUID`,`random`],[`crypto.getRandomValues`,`random`]]),Ae=/* @__PURE__ */ new Map([[`Clock`,`time`],[`Random`,`random`],[`SecureRandom`,`random`]]),je=/* @__PURE__ */ new Map([[`DateTime.now`,`time`],[`DateTime.nowAsDate`,`time`],[`DateTime.nowInCurrentZone`,`time`],[`DateTime.nowUnsafe`,`time`],[`DateTime.isFuture`,`time`],[`DateTime.isFutureUnsafe`,`time`],[`DateTime.isPast`,`time`],[`DateTime.isPastUnsafe`,`time`],[`Aead.Aead`,`random`],[`Cipher.Cipher`,`random`],[`Signature.Signature`,`random`],[`KeyAgreement.KeyAgreement`,`random`],[`KeyWrap.KeyWrap`,`random`],[`Jwk.generateKeyPair`,`random`],[`Jwk.generateSecret`,`random`],[`Jwe.encrypt`,`random`],[`Jws.sign`,`random`],[`Jws.verifyWithKeySet`,`io`],[`Jwt.sign`,`random`],[`Jwt.encrypt`,`random`],[`Jwt.verify`,`time`],[`Jwt.verifyWithKeySet`,`time`],[`Jwt.decrypt`,`time`],[`Jwks.Jwks`,`io`],[`Jwks.makeRemote`,`io`],[`Jwks.layerRemote`,`io`]]),Me=[`promise`,`tryPromise`],Ne=b(x(`problem`,`Require Alchemy Domain aggregate decide handlers to be pure.`,{time:"`decide` reads time from its `now` argument, not {{api}}. Replays must decide the same way.",random:"`decide` must be deterministic, so it cannot use {{api}}. Take the value from the command input instead.",io:"`decide` never performs I/O such as {{api}}. Call external systems from a policy or saga and send the result as a command."},`https://alchemy.run/domain/aggregate`),(e,t)=>{function n(n,r,i){r!==void 0&&Ce(n,t(),e)?.section===`decide`&&e.report({node:n,messageId:r,data:{api:i}})}function i(i){let a=H(i,t(),e),o=a?.[0];if(o===void 0||a?.length!==2)return;let s=r.join(a,`.`);n(i,je.get(s)??Ae.get(o),s)}function a(t){if(t.type===`Identifier`)return E(t,e,t.name)?t.name:void 0;let n=C(t);return t.type===`MemberExpression`&&n?.length===2&&E(t.object,e,`globalThis`)?n[1]:void 0}return{MemberExpression(t){let a=C(t),o=t;for(;o.type===`MemberExpression`||o.type===`ChainExpression`;)o=o.type===`ChainExpression`?o.expression:o.object;let s=a?.[0]===`globalThis`?a.slice(1):a;if(s?.length===2&&E(o,e,a?.[0]??``)){let e=r.join(s,`.`),i=t.parent.type===`CallExpression`&&t.parent.callee===t;n(t,ke.get(e),i?`${e}()`:e)}else i(t)},Identifier(t){Se(t,e)&&i(t)},NewExpression(e){e.arguments.length===0&&a(e.callee)===`Date`&&n(e,`time`,`new Date()`)},CallExpression(i){let o=a(i.callee);if(o===`Date`)n(i,`time`,`Date()`);else if(o===`fetch`)n(i,`io`,`fetch()`);else{let a=H(i.callee,t(),e);a?.length===2&&a[0]===`Effect`&&Me.includes(a[1]??``)&&n(i,`io`,r.join(a,`.`))}}}}),Pe=/\.(?:aggregate|api|command|context|event|external|id|middleware|model|policy|projection|rejection|saga|stream|view)\.[cm]?tsx?$/u,Fe=`@alchemy.run/domain`;function Ie(e){return i.startsWith(`.`)(e)||e===`effect`||i.startsWith(`effect/`)(e)||e===Fe||i.startsWith(`${Fe}/`)(e)}function Le(e){return r.some(e.body,e=>e.type===`ImportDeclaration`&&e.source.value===Fe)}const Re=y(x(`problem`,"Restrict Alchemy Domain block files to imports from `@alchemy.run/domain`, `effect` and the domain package itself.",{import:"A domain block imports only `@alchemy.run/domain`, `effect` and relative files, not `{{source}}`. Put code that touches infrastructure in the server package.",dynamic:"A domain block imports only `@alchemy.run/domain`, `effect` and relative files, so its import sources must be string literals."},`https://alchemy.run/domain`),e=>{let t=!1;function n(n){t&&n.source!==null&&!Ie(n.source.value)&&e.report({node:n.source,messageId:`import`,data:{source:n.source.value}})}function r(n){t&&(n.type!==`Literal`||typeof n.value!=`string`?e.report({node:n,messageId:`dynamic`}):Ie(n.value)||e.report({node:n,messageId:`import`,data:{source:n.value}}))}return{Program(n){t=Pe.test(e.filename)&&Le(n)},ImportDeclaration:n,ExportAllDeclaration:n,ExportNamedDeclaration:n,ImportExpression(e){r(e.source)},TSImportEqualsDeclaration(e){e.moduleReference.type===`TSExternalModuleReference`&&r(e.moduleReference.expression)},CallExpression(t){t.arguments[0]!==void 0&&E(t.callee,e,`require`)&&r(t.arguments[0])}}}),ze=b(x(`suggestion`,`Require Alchemy Domain views to declare their version.`,{missing:"Declare `version` on this view (`version: 0` keeps the current default). Bump it whenever `evolve`, `emit`, `keyOf`, `state` or `from` changes, so the deploy rebuilds the view from its events.",overridden:"Move `version` after the spread, so the spread cannot override the version this view declares."},`https://alchemy.run/domain/model#change-a-view-bump-its-version`),(e,t)=>({CallExpression(n){let i=M(n,1),a=i===void 0?void 0:F(i);if(xe(n,t(),e)!==`View`||a?.type!==`ObjectExpression`)return;let o=P(a,`version`);o===void 0?e.report({node:n.callee,messageId:`missing`}):r.some(a.properties.slice(a.properties.indexOf(o)+1),e=>e.type===`SpreadElement`)&&e.report({node:o,messageId:`overridden`})}})),Be=/* @__PURE__ */ new Map([[`Aggregate`,/* @__PURE__ */ new Set([`evolve`,`reply`])],[`View`,/* @__PURE__ */ new Set([`evolve`])]]),Ve=/* @__PURE__ */ new Set([`Option`,`Result`]),He=/* @__PURE__ */ new Set([`getOrThrow`,`getOrThrowWith`]),Ue=b(x(`problem`,`Require Alchemy Domain evolve and reply handlers to be total, and decide handlers to reject instead of throwing.`,{partial:'`{{section}}` must be total and never fail: {{api}} throws when the state is not what it expects. Keep any state the event cannot follow, such as `s._tag === "Open" ? { ...s, ... } : s`.',reject:"`decide` never throws: {{api}} becomes a defect the caller cannot handle. Return a rejection the command lists in `rejects` instead, or `return yield* rejection` in an `Effect.fn`."},`https://alchemy.run/domain/aggregate`),(e,t)=>{function n(n,r){let i=Ce(n,t(),e);i!==void 0&&(i.block===`Aggregate`&&i.section===`decide`?e.report({node:n,messageId:`reject`,data:{api:r}}):Be.get(i.block)?.has(i.section)===!0&&e.report({node:n,messageId:`partial`,data:{section:i.section,api:r}}))}function i(i){let a=H(i,t(),e);a?.length===2&&Ve.has(a[0]??``)&&He.has(a[1]??``)&&n(i,`\`${r.join(a,`.`)}\``)}return{ThrowStatement(e){n(e,"`throw`")},MemberExpression:i,Identifier(t){Se(t,e)&&i(t)}}}),We=/* @__PURE__ */ new Set([`alarm`,`fetch`,`queue`,`rpc`,`scheduled`,`tail`,`trace`,`webSocketClose`,`webSocketError`,`webSocketMessage`]),Ge=[[`Cloudflare`,`Worker`],[`Cloudflare`,`Workers`,`Worker`]];function Ke(e,t){return r.some(Ge,n=>A(e,t,n))}function qe(e,t){return pe(e,e=>e.type===`CallExpression`&&Ke(e.callee,t))}function Je(e,t){let n=R(e),r=n===void 0?void 0:z(n);return r!==void 0&&O(r.callee,t,`Effect`,`gen`)?r:void 0}function Ye(e){let t=e.parent;for(;t;){if(j(t))return;if(t.type===`Property`){let e=N(t);if(e!==void 0&&We.has(e))return e}t=t.parent}}const Xe=b(x(`problem`,`Disallow finalizers in Cloudflare Worker initialization, where workerd never runs them.`,{finalizer:`A Cloudflare Worker init finalizer never runs because workerd has no isolate teardown hook. Acquire disposable resources inside an event handler.`},`https://alchemy.run/cloudflare/compute/workers`),(e,t)=>({CallExpression(n){let r=t();if(!O(n.callee,r,`Effect`,`addFinalizer`))return;let i=Je(n,r);i!==void 0&&qe(i,r)?.arguments.includes(i)&&e.report({node:n,messageId:`finalizer`})}}));function U(e,t){let n=C(t)?.[0],i=n===void 0?void 0:w(e,t,n);return r.some(i?.defs??[],e=>{let t=e.node;return e.type===`ImportBinding`&&t.parent?.type===`ImportDeclaration`&&t.parent.importKind!==`type`&&(t.type!==`ImportSpecifier`||t.importKind!==`type`)})}function Ze(e,t,n,i,a){let o=e.sourceCode.ast,s=r.findFirst(r.flatMap(o.body,e=>e.type===`ImportDeclaration`&&e.source.value===n&&e.importKind!==`type`?e.specifiers:[]),n=>n.type===`ImportNamespaceSpecifier`&&r.some(w(e,t,n.local.name)?.defs??[],e=>e.node===n));if(c.isSome(s))return{name:s.value.local.name,fixes:[]};let l=new Set(r.flatMap(e.sourceCode.scopeManager.scopes,e=>[...r.map(e.variables,e=>e.name),...r.map(e.references,e=>e.identifier.name)])),u=i,d=2;for(;l.has(u);)u=`${i}${d++}`;let f=`import * as ${u} from '${n}';\n`,p=c.getOrUndefined(r.findFirst(o.body,e=>e.type!==`ExpressionStatement`||!B(e.expression)));return{name:u,fixes:[p===void 0?a.insertTextAfter(o,`\n${f}`):a.insertTextBefore(p,f)]}}function Qe(e,t){let n=/* @__PURE__ */ new Set;return r.every(e.properties,e=>{if(e.type!==`Property`||e.computed||e.method||e.kind!==`init`||e.key.type!==`Identifier`&&e.key.type!==`Literal`)return!1;let r=e.key.type===`Identifier`?e.key.name:String(e.key.value);return r===t||n.has(r)?!1:(n.add(r),!0)})}const $e=b({...x(`problem`,`Disallow the deprecated top-level Docker Service constraints property.`,{constraints:`Docker.Service constraints is deprecated. Move it to placement: { constraints: ... }.`},`https://alchemy.run/providers/docker/service`),fixable:`code`},(e,t)=>({CallExpression(n){if(!O(n.callee,t(),`Docker`,`Service`))return;let r=M(n,1),i=r?.type===`ObjectExpression`?P(r,`constraints`):void 0;i!==void 0&&e.report({node:i,messageId:`constraints`,fix(t){if(U(e,n.callee)&&r?.type===`ObjectExpression`&&Qe(r,`placement`))return t.replaceText(i,`placement: { ${e.sourceCode.getText(i)} }`)}})}})),et=/* @__PURE__ */ new Map([[`Cloudflare.Access.Bookmark`,`Cloudflare.Access.Application with type: "bookmark"`],[`AWS.RDSData.ExecuteSql`,`AWS.RDSData.ExecuteStatement`],[`AWS.EKS.Deployment`,`Kubernetes.Deployment from alchemy/Kubernetes`],[`AWS.EKS.HelmChart`,`Kubernetes.HelmChart from alchemy/Kubernetes`],[`AWS.EKS.Job`,`Kubernetes.Job from alchemy/Kubernetes`],[`AWS.EKS.Manifest`,`Kubernetes.Manifest from alchemy/Kubernetes`]]),tt=b(x(`problem`,`Disallow deprecated Alchemy resource APIs that have supported replacements.`,{deprecated:`{{api}} is deprecated. Use {{replacement}}.`},`https://alchemy.run/llms-full.txt`),(e,t)=>({CallExpression(n){let i=D(n.callee,t());if(i===void 0)return;let a=r.join(i,`.`),o=et.get(a);o!==void 0&&e.report({node:n.callee,messageId:`deprecated`,data:{api:a,replacement:o}})}}));function nt(e,t){let n=F(e);if(B(n)||n.type===`TemplateLiteral`)return!0;let r=C(n);return r?.[0]===`process`&&r[1]===`env`||n.type===`CallExpression`&&O(n.callee,t,`Config`,`string`)}const rt=b(x(`problem`,`Require singular GitHub Secret values to use Redacted.`,{plaintext:`GitHub.Secret value must be Redacted so it stays out of logs and state. Use Redacted.make(...) or Config.redacted(...).`},`https://alchemy.run/providers/github/secret`),(e,t)=>({CallExpression(n){let r=t();if(!O(n.callee,r,`GitHub`,`Secret`))return;let i=M(n,1),a=i?.type===`ObjectExpression`?P(i,`value`):void 0;a!==void 0&&nt(a.value,r)&&e.report({node:a.value,messageId:`plaintext`})}})),it=b(x(`problem`,`Disallow removed Alchemy Secret and Variable APIs.`,{removed:`Alchemy.{{api}} was removed. Use effect/Config (Config.redacted for secrets, Config.string for variables).`},`https://alchemy.run/blog/2026-05-29-beta-45`),(e,t)=>({CallExpression(n){let r=D(n.callee,t());r?.[0]===`Alchemy`&&(r[1]===`Secret`||r[1]===`Variable`)&&e.report({node:n.callee,messageId:`removed`,data:{api:r[1]}})}})),at=b(x(`problem`,`Disallow creating an EventBridge bus with the reserved default name.`,{reserved:`EventBridge reserves the name "default". Omit the bus argument to use the account default, or choose another name.`},`https://alchemy.run/aws/messaging/eventbridge`),(e,t)=>({CallExpression(n){if(!A(n.callee,t(),[`AWS`,`EventBridge`,`EventBus`]))return;let r=M(n,1),i=r?.type===`ObjectExpression`?P(r,`name`):void 0;i!==void 0&&V(i.value,`default`)&&e.report({node:i.value,messageId:`reserved`})}})),ot=b(x(`problem`,`Require Effect Config values to be resolved during Alchemy Worker initialization.`,{runtime:`Config resolved inside the {{handler}} handler is invisible to Alchemy deployment. Resolve it in Worker init and close over the value, or put it in env.`},`https://alchemy.run/environments/secrets`),(e,t)=>({YieldExpression(n){let r=t(),i=n.argument;if(i?.type!==`CallExpression`||D(i.callee,r)?.[0]!==`Config`)return;let a=Je(n,r);if(a===void 0)return;let o=Ye(a);o!==void 0&&qe(a,r)!==void 0&&e.report({node:i,messageId:`runtime`,data:{handler:o}})}})),st=/* @__PURE__ */ new Map([[`alchemy/aws`,`alchemy/AWS`],[`alchemy/cloudflare`,`alchemy/Cloudflare`]]),ct=y(x(`problem`,`Disallow Alchemy v1 imports that bypass the Effect-based Stack API.`,{defaultImport:`The default alchemy() API is from v1. Use import * as Alchemy and Alchemy.Stack.`,providerImport:`Use the v2 provider entrypoint {{replacement}} (capitalization is significant).`},`https://alchemy.run/migrating-from-v1`),e=>({ImportDeclaration(t){let n=t.source.value;if(n===`alchemy`){let n=c.getOrUndefined(r.findFirst(t.specifiers,e=>e.type===`ImportDefaultSpecifier`));n!==void 0&&e.report({node:n,messageId:`defaultImport`});return}let i=st.get(n);i!==void 0&&e.report({node:t.source,messageId:`providerImport`,data:{replacement:i}})}})),lt=[[`entrypoint`,`main`],[`bindings`,`env`]],ut=b({...x(`problem`,`Disallow Alchemy v1 Cloudflare Worker property names.`,{property:`Cloudflare.Worker {{old}} was replaced in v2. Use {{replacement}}.`},`https://alchemy.run/migrating-from-v1`),fixable:`code`},(e,t)=>({CallExpression(n){if(!Ke(n.callee,t()))return;let r=M(n,1);if(r?.type===`ObjectExpression`)for(let[t,i]of lt){let a=P(r,t);a!==void 0&&e.report({node:a,messageId:`property`,data:{old:t,replacement:i},fix(o){if(U(e,n.callee)&&Qe(r,i))return o.replaceText(a.key,a.shorthand?`${i}: ${t}`:i)}})}}})),dt=b(x(`suggestion`,`Prefer schema-based tagged errors so errors have a serializable contract.`,{taggedError:`Prefer Schema.TaggedError over Data.TaggedError.`}),(e,t)=>({CallExpression(n){O(n.callee,t(),`Data`,`TaggedError`)&&e.report({node:n.callee,messageId:`taggedError`})}})),ft=/* @__PURE__ */ new Set([`error`,`err`,`e`,`cause`,`exception`,`ex`]);function pt(e){return e?.type===`Identifier`&&ft.has(e.name)?e.name:void 0}function mt(e){if(e.type!==`CallExpression`||e.arguments.length!==1)return!1;let t=C(e.callee);return t?.at(-1)===`String`&&t.length<=2}const ht=y({...x(`problem`,`Disallow string coercion that discards an error value’s stack, type, and cause chain.`,{errorString:`Do not stringify {{name}}. Preserve the original error as an Error cause instead.`,useCause:`Replace {{pattern}} with {{replacement}} to preserve the original error.`}),hasSuggestions:!0},e=>({NewExpression(t){let n=M(t,0);if(n===void 0||!mt(n)||!ve(t))return;let r=M(n,0);if(r===void 0)return;let i=e.sourceCode.getText(r),a=`'Error occurred', { cause: ${i} }`;e.report({node:n,messageId:`errorString`,data:{name:i},suggest:[{messageId:`useCause`,data:{pattern:e.sourceCode.getText(n),replacement:a},fix:e=>e.replaceText(n,a)}]})},CallExpression(t){if(mt(t)){if(t.parent.type===`NewExpression`&&t.parent.arguments[0]===t&&ve(t.parent))return;let n=pt(t.arguments[0]);n!==void 0&&e.report({node:t,messageId:`errorString`,data:{name:n}});return}if(t.callee.type!==`MemberExpression`||C(t.callee)?.at(-1)!==`toString`||t.arguments.length>0)return;let n=pt(t.callee.object);n!==void 0&&e.report({node:t,messageId:`errorString`,data:{name:n}})},TemplateLiteral(t){let[n,r]=t.quasis,i=pt(t.expressions[0]);i!==void 0&&t.quasis.length===2&&n?.value.raw===``&&r?.value.raw===``&&e.report({node:t,messageId:`errorString`,data:{name:i}})}})),gt=/* @__PURE__ */ new Set(/* @__PURE__ */ `flip.fromFormData.fromJsonString.fromURLSearchParams.mutable.mutableKey.NullishOr.NullOr.optional.optionalKey.OptionFromNullishOr.OptionFromNullOr.OptionFromOptional.OptionFromOptionalKey.OptionFromOptionalNullOr.OptionFromUndefinedOr.readonlyKey.RedactedFromValue.required.requiredKey.toCodecArrayFromSingle.toCodecGoJson.toCodecIso.toCodecJson.toCodecStringTree.toEncoded.toType.UndefinedOr`.split(`.`)),_t=/* @__PURE__ */ new Set([`Array`,`ArrayEnsure`,`Chunk`,`HashSet`,`NonEmptyArray`,`Option`,`ReadonlySet`,`Redacted`,`Tree`,`UniqueArray`]),vt=/* @__PURE__ */ new Set(/* @__PURE__ */ `annotate.annotateEncoded.annotateKey.brand.catchDecoding.catchDecodingWithContext.catchEncoding.catchEncodingWithContext.check.decode.decodeTo.encode.encodeKeys.encodeTo.extendTo.fieldsAssign.fromBrand.middlewareDecoding.middlewareEncoding.overrideToCodecIso.overrideToEquivalence.overrideToFormatter.refine.toTaggedUnion.withConstructorDefault.withDecodingDefault.withDecodingDefaultKey.withDecodingDefaultType.withDecodingDefaultTypeKey`.split(`.`)),yt=/* @__PURE__ */ new Set([`annotate`,`annotateKey`,`check`,`mapFields`]),bt=/* @__PURE__ */ new Set([`CallExpression`,`Identifier`,`MemberExpression`,`ThisExpression`]),xt=/^\p{Lu}/u;function W(e,t,n){let r=D(e,n);return C(e)?.length===2&&r?.length===2&&r[0]===`Schema`&&U(t,e)?r[1]:void 0}function St(e){return e!==void 0&&_t.has(e)}function Ct(e){return e!==void 0&&(gt.has(e)||_t.has(e))}const wt=/* @__PURE__ */ new Set([`ArrowFunctionExpression`,`FunctionExpression`,`Identifier`,`Literal`,`ThisExpression`]);function Tt(e,t,n){return r.every(e,e=>e===null||G(e,t,n))}function G(e,t,n){if(wt.has(e.type))return!0;if(e.type===`MemberExpression`)return G(e.object,t,n)&&(!e.computed||G(e.property,t,n));if(e.type===`TemplateLiteral`)return Tt(e.expressions,t,n);if(e.type===`ArrayExpression`)return Tt(e.elements,t,n);if(e.type===`ObjectExpression`)return r.every(e.properties,e=>e.type===`SpreadElement`?G(e.argument,t,n):(!e.computed||G(e.key,t,n))&&G(e.value,t,n));if(e.type!==`CallExpression`)return!1;let i=e.callee.type===`CallExpression`?e.callee.callee:e.callee;return W(i,t,n)!==void 0&&(e.callee===i||G(e.callee,t,n))&&Tt(e.arguments,t,n)}function Et(e,t){if(e.type===`Identifier`)return t.bindings.get(e.name);if(e.type!==`TSQualifiedName`)return;let n=Et(e.left,t);return n===void 0?void 0:[...n,e.right.name]}function Dt(e,t){for(let n=t.parent;n!==null;n=n.parent){let t=`typeParameters`in n&&n.typeParameters?.type===`TSTypeParameterDeclaration`?o.pipe(n.typeParameters.params,r.findFirst(t=>t.name.name===e),c.getOrUndefined):void 0;if(t!==void 0)return t}}function Ot(e,t,n){let r=/* @__PURE__ */ new Set,a=e,o=t;for(;a?.type===`TSTypeReference`;){let e=Et(a.typeName,n),t=e?.length===2&&e[0]===`Schema`?e[1]:void 0;if(t!==void 0)return!i.startsWith(`Constraint`)(t);let s=a.typeName.type===`Identifier`?Dt(a.typeName.name,o):void 0;if(s===void 0||r.has(s))return r.size===0&&void 0;r.add(s),a=s.constraint,o=s}return r.size===0&&void 0}function kt(e,t){let n=w(t,e,e.name)?.defs[0]?.name;return n!==void 0&&`typeAnnotation`in n?n.typeAnnotation??void 0:void 0}function At(e,t,n){let r=e;for(;r.type===`TSSatisfiesExpression`||r.type===`TSNonNullExpression`;)r=r.expression;if(r.type===`TSAsExpression`)return Ot(r.typeAnnotation,r,n)===!1;let i=r.type===`Identifier`?kt(r,t):void 0;return i!==void 0&&Ot(i.typeAnnotation,i,n)===!1}function jt(e){return r.some(e.arguments,e=>e.type===`SpreadElement`)}function Mt(e){let[t]=e.arguments;return e.arguments.length===1&&t?.type!==`SpreadElement`&&!e.typeArguments?t:void 0}function Nt(e){return e.callee.type===`MemberExpression`&&!e.callee.optional&&S(e.callee)===`pipe`&&!e.typeArguments&&!jt(e)}function Pt(e,t,n){return(A(e.callee,n,[`pipe`])||A(e.callee,n,[`Function`,`pipe`]))&&U(t,e.callee)}function Ft(e,t,n){return Ct(W(e,t,n))?!0:e.type===`CallExpression`&&vt.has(W(e.callee,t,n)??``)}function It(e,t,n){if(xt.test(W(e,t,n)??``)||K(e,t,n)!==void 0)return!0;if(e.type!==`CallExpression`)return!1;let r=W(e.callee,t,n);return r===void 0?e.callee.type===`MemberExpression`&&yt.has(S(e.callee)??``)&&It(e.callee.object,t,n):xt.test(r)||Ct(r)}function Lt(e,t,n){let[r,i]=e.arguments;if(!(r===void 0||i===void 0||r.type===`SpreadElement`||e.typeArguments||jt(e)||!It(r,t,n)&&!Ft(i,t,n)))return[r,e.arguments.slice(1)]}function Rt(e,t,n,r,i,a){let o=Ht(e,i,a);return{head:o.head,steps:[...o.steps,t],violation:o.violation??n,reordersEffects:o.reordersEffects||r}}function zt(e,t,n){let r=Mt(e);if(r===void 0)return;let i=W(e.callee,t,n);if(Ct(i)){let a=St(i);return Rt(r,{text:t.sourceCode.getText(e.callee),wrapper:a},a?void 0:{kind:`modifierCall`,name:i},!1,t,n)}let a=e.callee.type===`CallExpression`?W(e.callee.callee,t,n):void 0;if(a!==void 0&&vt.has(a))return Rt(r,{text:t.sourceCode.getText(e.callee),wrapper:!1},{kind:`dataLastCall`,name:a},!G(e.callee,t,n)&&!G(r,t,n),t,n)}function Bt(e,t,n){let i=Pt(e,t,n),a=i?Lt(e,t,n):Nt(e)?[e.callee.object,e.arguments]:void 0;if(a===void 0)return;let[s,l]=a,u=r.map(l,e=>W(e,t,n)),d=o.pipe(u,r.findFirst(St),c.getOrUndefined),f=d!==void 0&&r.some(l.slice(u.indexOf(d)+1),e=>!G(e,t,n));return Vt(s,r.map(l,(e,n)=>({text:t.sourceCode.getText(e),wrapper:St(u[n])})),i?{kind:`functionPipe`}:d===void 0?void 0:{kind:`wrapperPipe`,name:d},f,t,n)}function Vt(e,t,n,r,i,a){let o=Ht(e,i,a);return{head:o.head,steps:[...o.steps,...t],violation:o.violation??n,reordersEffects:o.reordersEffects||r}}function K(e,t,n){return e.type===`CallExpression`?zt(e,t,n)??Bt(e,t,n):void 0}function Ht(e,t,n){return K(e,t,n)??{head:e,steps:[],violation:void 0,reordersEffects:!1}}function Ut(e,t,n){let r=e.parent;return r.type===`MemberExpression`&&r.object===e&&r.parent.type===`CallExpression`?r.parent.callee===r&&Nt(r.parent):r.type===`CallExpression`&&r.arguments[0]===e&&(Pt(r,t,n)||!Nt(r))&&K(r,t,n)!==void 0}function Wt(e,t,n){return r.isReadonlyArrayNonEmpty(t)?`${e===`\0`&&!bt.has(n.type)?`(\0)`:e}.pipe(${r.join(t,`, `)})`:e}function Gt(e,t){let n=`\0`,r=[];for(let i of t)if(i.wrapper){let t=Wt(n,r,e),a=t===`\0`&&e.type===`SequenceExpression`?`(${t})`:t;n=`${i.text}(${a})`,r=[]}else r.push(i.text);return Wt(n,r,e)}const Kt=b({...x(`suggestion`,"Apply Schema modifiers with `.pipe(...)` and call Schema wrappers directly.",{modifierCall:"Apply Schema.{{name}} with `.pipe(...)` instead of calling it.",dataLastCall:"Apply Schema.{{name}}(...) with `.pipe(...)` instead of calling it on the schema.",functionPipe:"Call `.pipe(...)` on the schema instead of passing it to `pipe(...)`.",wrapperPipe:`Call Schema.{{name}}(...) directly instead of piping into it.`},`https://github.com/2digits-agency/configs/blob/main/docs/adr/0001-schema-modifiers-pipe-wrappers-call.md`),fixable:`code`},(e,t)=>({CallExpression(n){let a=t();if(!a.hasEffectImport)return;let o=K(n,e,a);if(o?.violation===void 0||Ut(n,e,a))return;let{head:s}=o;if(o.steps[0]?.wrapper===!1&&At(s,e,a))return;let c=r.some(e.sourceCode.getCommentsInside(n),e=>!me(s,e)),[l,u=``]=i.split(Gt(s,o.steps),`\0`);e.report({node:n,messageId:o.violation.kind,data:{name:o.violation.name??``},fix:c||o.reordersEffects?void 0:e=>[e.replaceTextRange([n.range[0],s.range[0]],l),e.replaceTextRange([s.range[1],n.range[1]],u)]})}}));function qt(e){return c.getOrUndefined(r.findFirst(e.arguments,e=>e.type===`ObjectExpression`))}function Jt(e,t){let n=e.parent;if(n.type!==`Property`||N(n)!==t)return;let r=n.parent,i=r.parent;return r.type===`ObjectExpression`&&i?.type===`CallExpression`?i:void 0}function Yt(e,t){let n=z(e);return n===void 0?void 0:D(n.callee,t)}function Xt(e){let t=e.parent,n=t.type===`Property`&&t.value===e?t.parent:e,r=n.parent;return(r?.type===`CallExpression`||r?.type===`NewExpression`)&&r.arguments.includes(n)?r:void 0}function Zt(e,t){let n=Xt(e);if(n===void 0)return!1;let r=n.callee;for(;r.type===`CallExpression`;)r=r.callee;return D(r,t)===void 0}const Qt=/* @__PURE__ */ new Set([`catch`,`finally`,`then`]);function $t(e){let t=C(e.callee);return t!==void 0&&r.join(t,`.`)===`Promise`}function en(e){let t=C(e.callee);return t!==void 0&&r.join(t,`.`)===`fetch`||t?.[0]===`Promise`&&t[1]!==`withResolvers`||Qt.has(t?.at(-1)??``)||j(e.callee)&&e.callee.async}const tn=s.type().pipe(s.discriminators(`type`)({CallExpression:en,NewExpression:$t}),s.orElse(o.constFalse));function nn(e){return tn(F(e))}function rn(e){if(e.body){if(e.body.type!==`BlockStatement`)return F(e.body);if(e.body.body.length===1&&e.body.body[0]?.type===`ReturnStatement`&&e.body.body[0].argument)return F(e.body.body[0].argument)}}function an(e){let t=e?.type===`ObjectExpression`?P(e,`try`)?.value:e;return j(t)?t:void 0}function on(e){let t=F(e);return V(t,`*`)?!0:t.type===`ArrayExpression`&&(t.elements.length===0||r.some(t.elements,e=>e!==null&&V(e,`*`)))}const sn=b(x(`problem`,`Disallow credentialed CORS with wildcard origins because browsers reject that combination.`,{wildcard:`Credentialed CORS cannot use a wildcard origin. Set allowedOrigins to explicit trusted origins or disable credentials.`},`https://github.com/Effect-TS/tsgo/issues/400`),(e,t)=>({CallExpression(n){let r=t();if(!O(n.callee,r,`HttpMiddleware`,`cors`)&&!O(n.callee,r,`HttpRouter`,`cors`)&&!O(n.callee,r,`HttpApiBuilder`,`middlewareCors`))return;let i=qt(n);if(i===void 0||!V(P(i,`credentials`)?.value??i,!0))return;let a=P(i,`allowedOrigins`);(a===void 0||on(a.value))&&e.report({node:n,messageId:`wildcard`})}}));function cn(e){return e.type===`AssignmentPattern`||e.type===`RestElement`||e.optional===!0}const ln=b(x(`problem`,`Disallow numeric dual arity with optional or rest parameters because dispatch becomes ambiguous.`,{unsafeArity:`Function.dual with numeric arity misdispatches an implementation with optional/default/rest parameters. Use predicate dispatch.`},`https://github.com/Effect-TS/tsgo/issues/401`),(e,t)=>({CallExpression(n){let i=M(n,0),a=M(n,1);a!==void 0&&O(n.callee,t(),`Function`,`dual`)&&i?.type===`Literal`&&l.isNumber(i.value)&&j(a)&&r.some(a.params,cn)&&e.report({node:i,messageId:`unsafeArity`})}})),un=b(x(`problem`,`Require Effect.tryPromise so Promise rejections enter the typed error channel.`,{tryPromise:`Use Effect.tryPromise instead of Effect.promise so rejections are typed failures.`}),(e,t)=>({CallExpression(n){O(n.callee,t(),`Effect`,`promise`)&&e.report({node:n.callee,messageId:`tryPromise`})}}));function dn(e,t){if(k(e.callee,t,`Effect`,[`promise`,`tryPromise`]))return an(M(e,0))}const fn=b(x(`problem`,`Ensure Effect Promise thunks start fresh asynchronous work rather than reusing an already-started Promise.`,{prestarted:`This thunk returns an already-started Promise. Start the asynchronous work inside the thunk so retries and repeats run it again.`},`https://github.com/Effect-TS/tsgo/issues/475`),(e,t)=>{let n=/* @__PURE__ */ new Set;return{before(){n=/* @__PURE__ */ new Set},VariableDeclarator(e){e.id.type===`Identifier`&&e.init&&nn(e.init)&&n.add(e.id.name)},CallExpression(r){let i=dn(r,t()),a=i===void 0?void 0:rn(i);a?.type===`Identifier`&&n.has(a.name)&&e.report({node:a,messageId:`prestarted`})}}}),pn=b(x(`problem`,`Disallow async thunks in Effect.try because rejected Promises bypass its catch mapper.`,{asyncTry:`Effect.try does not await Promises. Use Effect.tryPromise so rejection enters the typed error channel.`},`https://github.com/Effect-TS/tsgo/issues/657`),(e,t)=>({CallExpression(n){if(!O(n.callee,t(),`Effect`,`try`))return;let r=M(n,0),i=r!==void 0&&j(r)?r:void 0;if(i===void 0&&r?.type===`ObjectExpression`){let e=P(r,`try`)?.value;e!==void 0&&j(e)&&(i=e)}let a=i===void 0?void 0:rn(i);i!==void 0&&(i.async||a!==void 0&&nn(a))&&e.report({node:i,messageId:`asyncTry`})}})),mn=b(x(`problem`,`Disallow discarded Effect.runPromise results that can become unhandled rejections.`,{discarded:`The Promise returned by Effect.runPromise is discarded. Await/return/handle it, or use Effect.runFork for fire-and-forget work.`},`https://github.com/Effect-TS/tsgo/issues/643`),(e,t)=>({CallExpression(n){let r=t(),i=O(n.callee,r,`Effect`,`runPromise`),a=n.callee.type===`CallExpression`&&O(n.callee.callee,r,`Effect`,`runPromiseWith`);(i||a)&&_e(n)&&e.report({node:n,messageId:`discarded`})}})),hn=/* @__PURE__ */ new Set([`mapElements`,`mapFields`,`mapMembers`]);function gn(e,t){let n=F(e);if(n.type===`CallExpression`&&n.callee.type===`MemberExpression`&&S(n.callee)===t)return n}const _n=b(x(`problem`,`Disallow schema mapping that silently drops checks attached to the receiver.`,{discarded:`{{method}} creates a new schema and drops the preceding check. Re-attach the check after mapping or explicitly preserve it.`},`https://github.com/Effect-TS/tsgo/issues/435`),(e,t)=>({CallExpression(n){if(!t().hasEffectImport||n.callee.type!==`MemberExpression`)return;let i=S(n.callee);i!==void 0&&hn.has(i)&&gn(n.callee.object,`check`)!==void 0&&(r.findFirst(n.arguments,e=>e.type===`ObjectExpression`).pipe(c.flatMapNullishOr(e=>P(e,`unsafePreserveChecks`)),c.exists(e=>V(e.value,!0)))||e.report({node:n,messageId:`discarded`,data:{method:i}}))}})),vn={Array:`Arr`,Boolean:`Bool`,Equal:`Eq`,Function:`Fn`,Number:`Num`,Option:`Opt`,Predicate:`P`,Record:`R`,String:`Str`},yn=/^\p{Lu}[^_]*$/u;function bn(e){return yn.test(e)}function xn(e){return e===`@effect/vitest`||i.startsWith(`@effect/vitest/`)(e)}function q(e,t){return e.importKind===`type`||t?.importKind===`type`}function Sn(e){return c.getOrElse(n.get(vn,e),()=>e)}function Cn(e,t){if(e===`effect`||e===`alchemy`||/^@effect\/[^/]+$/u.test(e)&&!xn(e))return`${e}/${t}`}function wn(e){if(xn(e)||!(i.startsWith(`effect/`)(e)||i.startsWith(`alchemy/`)(e)||/^@effect\/[^/]+\//u.test(e)))return;let t=r.lastNonEmpty(i.split(e,`/`));return bn(t)?t:void 0}function Tn(e,t,n){let i=t.specifiers;if(e.sourceCode.getCommentsInside(t).length>0||t.attributes.length>0||!r.every(i,e=>e.type===`ImportSpecifier`))return;let[a,o]=r.partition(i,n=>{let r=v(n.imported),i=bn(r)&&!q(t,n)?Cn(t.source.value,r):void 0;return i===void 0?d.fail(e.sourceCode.getText(n)):d.succeed(`import * as ${n.local.name} from '${i}';`)}),s=r.isReadonlyArrayNonEmpty(o)?r.prepend(a,`import { ${r.join(o,`, `)} } from ${e.sourceCode.getText(t.source)};`):a;return[n.replaceText(t,r.join(s,`
2
+ `))]}function En(e,t,n){let i=wn(t.source.value);if(i===void 0||t.attributes.length>0||e.sourceCode.getCommentsInside(t).length>0)return;let a=Sn(i),o=e.sourceCode.getDeclaredVariables(t),s=c.getOrUndefined(r.findFirst(o,e=>e.name===a));if(r.some(e.sourceCode.scopeManager.scopes,e=>r.some(e.variables,e=>e.name===a&&e!==s)||r.some(e.references,e=>e.identifier.name===a&&e.resolved!==s)))return;let l=[],u=[];for(let r of t.specifiers){if(r.type===`ImportDefaultSpecifier`)return;if(r.type===`ImportSpecifier`&&q(t,r)){if(r.local.name===a)return;u.push(e.sourceCode.getText(r));continue}let i=Dn(r,o,a,n);if(i===void 0)return;l.push(...i)}let d=e.sourceCode.getText(t.source),f=`import * as ${a} from ${d};${u.length===0?``:`\nimport { ${r.join(u,`, `)} } from ${d};`}`;return[n.replaceText(t,f),...l]}function Dn(e,t,n,i){let a=c.getOrUndefined(r.findFirst(t,t=>t.name===e.local.name));if(a!==void 0){if(e.type===`ImportNamespaceSpecifier`)return On(a,n,!1,i);if(e.imported.type===`Identifier`)return On(a,`${n}.${e.imported.name}`,!0,i)}}function On(e,t,n,r){let a=[],o=/* @__PURE__ */ new Set;for(let s of e.references){let e=s.identifier;if(o.has(e.range[0]))continue;o.add(e.range[0]);let c=e.parent;if(s.isWrite()||c.type===`ExportSpecifier`||i.startsWith(`JSX`)(c.type))return;let l=c.type===`Property`&&c.shorthand?`${e.name}: ${t}`:t;n&&(c.type===`CallExpression`&&c.callee===e||c.type===`TaggedTemplateExpression`&&c.tag===e)&&(l=`(0, ${t})`),a.push(r.replaceText(e,l))}return a}const kn=y({...x(`suggestion`,`Import Effect and Alchemy module namespaces from their submodule entrypoints instead of root barrels.`,{barrelImport:'Import this module as `import * as {{alias}} from "{{source}}"` instead of from the root barrel.'},`https://github.com/Effect-TS/language-service/blob/main/packages/language-service/src/diagnostics/importFromBarrel.ts`),fixable:`code`},e=>({ImportDeclaration(t){for(let n of t.specifiers){if(n.type!==`ImportSpecifier`||q(t,n))continue;let r=v(n.imported),i=bn(r)?Cn(t.source.value,r):void 0;i!==void 0&&e.report({node:n,messageId:`barrelImport`,data:{alias:Sn(r),source:i},fix:n=>Tn(e,t,n)})}}})),An=[`log`,`logDebug`,`logError`,`logFatal`,`logInfo`,`logTrace`,`logWarning`],jn=[`debug`,`error`,`info`,`log`,`trace`,`warn`],Mn=[`as`,`asSome`,`asVoid`];function Nn(e,t){let n=F(e);if(n.type!==`CallExpression`)return;let i=F(n.callee);if(i.type===`CallExpression`&&A(i.callee,t,[`Effect`,`logWithLevel`]))return`Effect.logWithLevel`;if(k(i,t,`Effect`,An)||k(i,t,`Console`,jn))return r.join(D(i,t)??[],`.`)}function Pn(e,t){if(e===void 0)return;let n=F(e);return n.type===`CallExpression`&&n.arguments.length===1&&A(n.callee,t,[`Effect`,`as`])?`as`:k(n,t,`Effect`,[`asSome`,`asVoid`])?D(n,t)?.[1]:void 0}function Fn(e,t){return A(e,t,[`pipe`])||A(e,t,[`Function`,`pipe`])}function In(e,t){let n=F(e.callee);if(n.type===`MemberExpression`&&S(n)===`pipe`){let r=M(e,0),i=Nn(n.object,t),a=Pn(r,t);return r===void 0||i===void 0||a===void 0?void 0:{logger:i,method:a,node:r}}if(Fn(n,t)){let n=M(e,0),r=n===void 0?void 0:Nn(n,t),i=M(e,1),a=Pn(i,t);return i===void 0||r===void 0||a===void 0?void 0:{logger:r,method:a,node:i}}let r=k(n,t,`Effect`,Mn)?D(n,t)?.[1]:void 0,i=M(e,0);if(r===void 0||i===void 0||r===`as`&&e.arguments.length!==2)return;let a=Nn(i,t);return a===void 0?void 0:{logger:a,method:r,node:e}}const Ln=b(x(`suggestion`,`Disallow Effect.as, Effect.asSome and Effect.asVoid on log effects.`,{asOnLog:"Do not swap the result of {{logger}} with Effect.{{method}}. Use Effect.gen: `yield*` the log, then return the value.",asVoidOnLog:`{{logger}} already succeeds with void; remove Effect.asVoid.`}),(e,t)=>({CallExpression(n){let r=In(n,t());r!==void 0&&e.report({node:r.node,messageId:r.method===`asVoid`?`asVoidOnLog`:`asOnLog`,data:{logger:r.logger,method:r.method}})}})),Rn=b({...x(`suggestion`,`Prefer Effect.never to an empty Effect.callback registration.`,{emptyCallback:`An empty Effect.callback registration is Effect.never. Use the explicit primitive.`},`https://github.com/Effect-TS/tsgo/issues/636`),fixable:`code`},(e,t)=>({CallExpression(n){if(!O(n.callee,t(),`Effect`,`callback`)&&!O(n.callee,t(),`Effect`,`async`))return;let i=M(n,0);i!==void 0&&j(i)&&i.body?.type===`BlockStatement`&&i.body.body.length===0&&e.report({node:n,messageId:`emptyCallback`,fix(t){if(!U(e,n.callee)||n.arguments.length!==1||i.async||i.generator||r.some(i.params,e=>e.type!==`Identifier`)||e.sourceCode.getCommentsInside(n).length>0)return;let a=Ze(e,n,`effect/Effect`,`Effect`,t);return[...a.fixes,t.replaceText(n,`${a.name}.never`)]}})}})),zn=b(x(`problem`,`Disallow Schema.Struct({}), which accepts every non-null object-like value.`,{emptyStruct:`Schema.Struct({}) does not validate an exact empty object. Define the intended fields explicitly.`},`https://github.com/Effect-TS/tsgo/issues/403`),(e,t)=>({CallExpression(n){let r=M(n,0);O(n.callee,t(),`Schema`,`Struct`)&&r?.type===`ObjectExpression`&&r.properties.length===0&&e.report({node:n,messageId:`emptyStruct`})}}));function Bn(e,t){let n=F(e),i=/* @__PURE__ */ new Set;for(;n.type===`Identifier`;){let e=w(t,n,n.name),a=T(e),o=a?.node;if(e===void 0||i.has(e)||o?.type!==`VariableDeclarator`||o.id.type!==`Identifier`||a?.parent?.type!==`VariableDeclaration`||a.parent.kind!==`const`||!o.init||r.some(e.references,e=>e.isWrite()&&!e.init))return;i.add(e),n=F(o.init)}return n}function Vn(e){if(e.arguments.length===2)return M(e,0);let t=e.parent;if(e.arguments.length===1&&t.type===`CallExpression`&&t.arguments[0]===e&&t.callee.type===`MemberExpression`&&S(t.callee)===`pipe`)return t.callee.object}const Hn=b(x(`problem`,`Disallow obsolete lazy callbacks passed to the now-eager Config.withDefault API.`,{functionDefault:`Config.withDefault takes an eager value. This callback becomes the configured value; pass the returned value directly.`},`https://github.com/Effect-TS/tsgo/issues/408`),(e,t)=>({CallExpression(n){if(!O(n.callee,t(),`Config`,`withDefault`)||!U(e,n.callee))return;let r=M(n,n.arguments.length-1),i=Vn(n),a=i===void 0?void 0:Bn(i,e);a?.type===`CallExpression`&&O(a.callee,t(),`Config`,`succeed`)&&U(e,a.callee)&&j(M(a,0))||j(r)&&r.params.length===0&&e.report({node:r,messageId:`functionDefault`})}})),Un=/* @__PURE__ */ new Set([`delete`,`get`,`has`,`set`]);function Wn(e,t){return e.type===`CallExpression`&&O(e.callee,t,`Hash`,`hash`)}const Gn=b(x(`problem`,`Disallow using Hash.hash output as collision-free identity.`,{hashIdentity:`Hash.hash is a bucketing hint, not a unique identity. Use HashMap/Equal.equals or a real identifier instead.`},`https://github.com/Effect-TS/tsgo/issues/482`),(e,t)=>{let n=/* @__PURE__ */ new Set;function r(e){return Wn(e,t())||e.type===`Identifier`&&n.has(e.name)}return{before(){n=/* @__PURE__ */ new Set},VariableDeclarator(e){e.id.type===`Identifier`&&e.init&&Wn(e.init,t())&&n.add(e.id.name)},CallExpression(t){if(t.callee.type!==`MemberExpression`||!Un.has(C(t.callee)?.at(-1)??``))return;let n=M(t,0);n!==void 0&&r(n)&&e.report({node:n,messageId:`hashIdentity`})},BinaryExpression(t){ge(t.operator)&&r(t.left)&&r(t.right)&&e.report({node:t,messageId:`hashIdentity`})},MemberExpression(t){t.computed&&r(t.property)&&e.report({node:t.property,messageId:`hashIdentity`})}}}),Kn=/* @__PURE__ */ new Set(/* @__PURE__ */ `asserts.decodeEffect.decodeExit.decodeOption.decodePromise.decodeResult.decodeSync.decodeUnknownEffect.decodeUnknownExit.decodeUnknownOption.decodeUnknownPromise.decodeUnknownResult.decodeUnknownSync.encodeEffect.encodeExit.encodeOption.encodePromise.encodeResult.encodeSync.encodeUnknownEffect.encodeUnknownExit.encodeUnknownOption.encodeUnknownPromise.encodeUnknownResult.encodeUnknownSync.is`.split(`.`)),qn=/* @__PURE__ */ new Set([`global`,`module`]),Jn=/* @__PURE__ */ new Set([`ArrowFunctionExpression`,`FunctionDeclaration`,`FunctionExpression`]),Yn=/* @__PURE__ */ new Set([`AssignmentExpression`,`AwaitExpression`,`ImportExpression`,`TaggedTemplateExpression`,`UpdateExpression`,`YieldExpression`]),Xn=/* @__PURE__ */ new Set([`ParenthesizedExpression`,`TSAsExpression`,`TSNonNullExpression`]);function Zn(e,t,n){let i=D(e,t),a=i?.length===2&&i[0]===`Schema`?i[1]:void 0,o=C(e)?.[0];if(a===void 0||o===void 0||!Kn.has(a))return;let s=w(n,e,o);return s!==void 0&&r.every(s.defs,e=>e.type===`ImportBinding`)?a:void 0}function Qn(e){let t=e.parent;for(;t;){if(Jn.has(t.type))return!0;t=t.parent}return!1}function $n(e){let t=e,n=e.parent;for(;Xn.has(n.type)&&n.parent!==null;)t=n,n=n.parent;return n.type===`CallExpression`&&n.callee===t}function er(e,t){return e.type===`CallExpression`&&D(e.callee,t)?.[0]===`Schema`}function tr(e){let t=e,n=e.parent;for(;n?.type===`MemberExpression`&&n.object===t;)t=n,n=n.parent;return t!==e&&(n?.type===`AssignmentExpression`&&n.left===t||n?.type===`UpdateExpression`&&n.argument===t||n?.type===`UnaryExpression`&&n.operator===`delete`&&n.argument===t)}function nr(e){return r.every(e.references,e=>(!e.isWrite()||e.init)&&!tr(e.identifier))}function rr(e,t,n,r){let i=w(r,e,t);return i===void 0||me(n,i.scope.block)?!0:qn.has(i.scope.type)&&nr(i)}function ir(e){let t=e.parent;return t?.type===`MemberExpression`&&t.property===e&&!t.computed||t?.type===`Property`&&t.key===e&&!t.computed&&!t.shorthand}function ar(e,t){if(e===t)return!1;let n=e.parent;for(;n!==null&&n!==t;){if(Jn.has(n.type))return!0;n=n.parent}return!1}function or(e,t,n){return ar(e,t)?!1:e.type===`CallExpression`||e.type===`NewExpression`?D(e.callee,n)===void 0:Yn.has(e.type)}function sr(e,t,n){return!I(e,r=>r.type===`ThisExpression`||r.type===`Super`||r.type===`MetaProperty`&&r.meta.name===`new`||or(r,e,t)||r.type===`Identifier`&&!ir(r)&&!rr(r,r.name,e,n))}const cr=b(x(`problem`,`Disallow compiling Schema decoders, encoders, and guards inside function bodies.`,{inlineSchema:`Hoist Schema.{{method}}(...) to module scope: both the inline schema and the compiled function are rebuilt on every call. Move the compiled function to a module-level const.`,inlineCompile:`Hoist Schema.{{method}}(...) to module scope: the compiled function is rebuilt on every call. Move it to a module-level const.`},`https://github.com/pingdotgg/t3code/blob/main/oxlint-plugin-t3code/rules/no-inline-schema-compile.ts`),(e,t)=>({CallExpression(n){let i=t();if(!i.hasEffectImport)return;let a=Zn(n.callee,i,e),[o]=n.arguments;if(a===void 0||o===void 0||o.type===`SpreadElement`||r.some(n.arguments,e=>e.type===`SpreadElement`)||!$n(n)||!Qn(n))return;let s=F(o),c=er(s,i);(c||s.type===`Identifier`||s.type===`MemberExpression`)&&r.every(n.arguments,t=>sr(t,i,e))&&e.report({node:n.callee,messageId:c?`inlineSchema`:`inlineCompile`,data:{method:a}})}})),lr=/* @__PURE__ */ new Set([`catch`,`catchIf`,`catchTag`,`orElseSucceed`,`catchAll`,`catchAllCause`,`catchSome`,`catchSomeCause`,`orElse`,`orElseFail`]),ur=/* @__PURE__ */ new Set([`log`,`logDebug`,`logError`,`logInfo`,`logTrace`,`logWarning`]);function dr(e,t){let n=e.parent;for(;n;){if(j(n)){let e=z(n);if(e?.arguments.at(-1)===n){let n=D(e.callee,t),r=n?.[1];if(r!==void 0&&n?.[0]===`Effect`&&lr.has(r))return{method:r}}}n=n.parent}}const fr=b(x(`suggestion`,`Keep logging separate from Effect recovery handlers.`,{logging:`Move {{logger}} out of Effect.{{catchMethod}} and use Effect.tapError before recovery.`}),(e,t)=>({CallExpression(n){let i=t(),a=D(n.callee,i),o=a?.[1]!==void 0&&a[0]===`Effect`&&ur.has(a[1])?r.join(a,`.`):void 0;if(o===void 0)return;let s=dr(n,i);s!==void 0&&e.report({node:n,messageId:`logging`,data:{logger:o,catchMethod:s.method}})}})),pr=s.type().pipe(s.when({type:`MemberExpression`,computed:!1,object:{type:`Identifier`,name:`Effect`},property:{type:`Identifier`,name:s.is(`catch`,`catchAll`,`catchIf`)}},o.constTrue),s.orElse(o.constFalse)),mr=s.type().pipe(s.when({type:`MemberExpression`,computed:!1,object:{type:`Identifier`,name:`Match`},property:{type:`Identifier`,name:s.is(`when`,`not`)}},o.constTrue),s.orElse(o.constFalse)),J=s.type().pipe(s.when({type:`MemberExpression`,computed:!1,property:{type:`Identifier`,name:`_tag`}},o.constTrue),s.when({type:`MemberExpression`,computed:!0,property:{type:`Literal`,value:`_tag`}},o.constTrue),s.orElse(o.constFalse));function hr(e){if(ge(e.operator)){if(J(e.left)&&B(e.right))return e.left;if(J(e.right)&&B(e.left))return e.right}}function gr(e){let t=R(e),n=t===void 0?void 0:z(t);return n!==void 0&&pr(n.callee)}function _r(e){return e.object.type===`MemberExpression`&&S(e.object)===`reason`}function vr(e){let t=e.parent;return t.type===`CallExpression`&&t.arguments.includes(e)&&mr(t.callee)}const yr=y(x(`problem`,"Use Effect tagged error handlers instead of manually branching on `_tag` in a catch handler.",{tag:`Use Effect.catchTag or Effect.catchTags instead of manually discriminating a tagged error in a broad Effect catch handler.`,reason:"Use Effect.catchReason or Effect.catchReasons instead of manually discriminating a tagged `reason` in a broad Effect catch handler."},`https://github.com/dmmulroy/anti-slop/blob/main/src/effect/rules/no-manual-effect-error-tag.ts`),e=>({BinaryExpression(t){let n=hr(t);n!==void 0&&gr(t)&&e.report({node:t,messageId:_r(n)?`reason`:`tag`})},SwitchStatement(t){J(t.discriminant)&&gr(t)&&e.report({node:t,messageId:_r(t.discriminant)?`reason`:`tag`})}})),br=y(x(`problem`,"Use Effect Match or Predicate helpers instead of manually branching on `_tag`.",{manualComparison:`Use Match.tag/Match.tags for tagged-value branching, or Predicate.isTagged for a simple reusable predicate.`,manualSwitch:"Use Match.value(value).pipe(Match.tag/Match.tags/Match.tagsExhaustive) or the tagged enum `$match` helper instead of switching on `_tag`."},`https://github.com/dmmulroy/anti-slop/blob/main/src/effect/rules/no-manual-tag-comparison.ts`),e=>({BinaryExpression(t){hr(t)===void 0||gr(t)||e.report({node:t,messageId:`manualComparison`})},SwitchStatement(t){J(t.discriminant)&&!gr(t)&&e.report({node:t,messageId:`manualSwitch`})}})),xr=y(x(`problem`,"Construct tagged values with their existing Effect constructor instead of writing `_tag` manually.",{manualConstruction:"Use the existing Schema tagged `.make`, tagged class/error constructor, or Data.taggedEnum variant constructor instead of writing a literal `_tag` object."},`https://github.com/dmmulroy/anti-slop/blob/main/src/effect/rules/no-manual-tagged-construction.ts`),e=>({ObjectExpression(t){if(vr(t))return;let n=c.getOrUndefined(r.findFirst(t.properties,e=>e.type===`Property`&&N(e)===`_tag`&&B(e.value)));n!==void 0&&e.report({node:n,messageId:`manualConstruction`})}})),Sr=/* @__PURE__ */ new Map([[`Effect.cachedInvalidateWithTTL`,`last`],[`Effect.cachedWithTTL`,`last`],[`Effect.delay`,`last`],[`Effect.sleep`,`last`],[`Effect.timeout`,`last`],[`Effect.timeoutOption`,`last`],[`Effect.timeoutOrElse`,`options.duration`],[`Schedule.duration`,`last`],[`Schedule.during`,`last`],[`Schedule.exponential`,`first`],[`Schedule.fibonacci`,`last`],[`Schedule.fixed`,`last`],[`Schedule.spaced`,`last`],[`Schedule.windowed`,`last`],[`Stream.debounce`,`last`],[`Stream.groupedWithin`,`last`],[`Stream.throttle`,`options.duration`],[`Stream.timeout`,`last`],[`TestClock.adjust`,`last`]]),Cr={first:e=>M(e,0),last:e=>M(e,e.arguments.length-1),"options.duration":e=>{let t=M(e,e.arguments.length-1);return t?.type===`ObjectExpression`?P(t,`duration`)?.value:void 0}};function wr(e,t,n){let i=D(e.callee,n),a=i===void 0?void 0:Sr.get(r.join(i,`.`));return a!==void 0&&U(t,e.callee)?Cr[a](e):void 0}function Tr(e,t){return e**t}const Er=s.type().pipe(s.withReturnType(),s.when(`*`,()=>p.multiply),s.when(`+`,()=>p.sum),s.when(`-`,()=>p.subtract),s.when(`/`,()=>p.divideUnsafe),s.when(`%`,()=>p.remainder),s.when(`**`,()=>Tr),s.orElse(o.constUndefined));function Y(e){let t=F(e);if(t.type===`Literal`)return l.isNumber(t.value)?t.value:void 0;if(t.type===`UnaryExpression`&&(t.operator===`-`||t.operator===`+`)){let e=Y(t.argument);return e===void 0||t.operator===`+`?e:-e}if(t.type!==`BinaryExpression`||t.left.type===`PrivateIdentifier`)return;let n=Y(t.left),r=Y(t.right);if(n!==void 0&&r!==void 0)return Er(t.operator)?.(n,r)}function Dr(e){let t=F(e);if(t.type===`Literal`)return l.isNumber(t.value)?[t.value]:void 0;if(t.type!==`BinaryExpression`||t.operator!==`*`)return;let n=Dr(t.left),i=Dr(t.right);return n===void 0||i===void 0?void 0:r.appendAll(n,i)}const Or=/* @__PURE__ */ new Set([6e4,36e5,864e5]),kr=/* @__PURE__ */ new Set([60,3600,86400]),Ar=/* @__PURE__ */ new Set([7,24,60,1e3,3600,86400]);function jr(e){let t=Dr(e);if(!(t===void 0||t.length<2)&&(r.some(t,e=>Or.has(e))||r.some(t,e=>kr.has(e))&&r.filter(t,e=>Ar.has(e)).length>=2))return{millis:r.contains(t,1e3)||r.some(t,e=>e%6e4==0)}}const Mr=o.flow(i.split(/[_$]+|(?<=[\da-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])/u),r.filter(i.isNonEmpty),r.map(i.toLowerCase)),Nr=/* @__PURE__ */ new Set([`millis`,`milliseconds`,`ms`]),Pr=/* @__PURE__ */ new Set([`at`,`created`,`deadline`,`end`,`ended`,`epoch`,`last`,`now`,`since`,`start`,`started`,`timestamp`,`until`,`updated`]);function Fr(e){let t=Mr(e);if(Nr.has(t.at(-1)??``))return r.some(t,e=>Pr.has(e))?`instant`:`duration`}const Ir={weeks:f.weeks,days:f.days,hours:f.hours,minutes:f.minutes,seconds:f.seconds,millis:f.millis},Lr=[[`weeks`,f.toWeeks],[`days`,f.toDays],[`hours`,f.toHours],[`minutes`,f.toMinutes],[`seconds`,f.toSeconds],[`millis`,f.toMillis]];function Rr(e){return!Number.isSafeInteger(e)||Math.abs(e)<1e4?String(e):i.replaceAll(/\B(?=(?:\d{3})+$)/gu,`_`)(String(e))}function zr(e,t){let n=Ir[t](e);return f.isZero(n)?`Duration.zero`:r.findFirst(Lr,([,e])=>Number.isSafeInteger(e(n))).pipe(c.match({onNone:()=>`Duration.millis(${n.pipe(f.toMillis,Rr)})`,onSome:([e,t])=>`Duration.${e}(${Rr(t(n))})`}))}const Br=/* @__PURE__ */ new Set([`*`,`+`,`-`,`/`]),Vr={"!==":`Duration.equals`,"*":`Duration.times`,"+":`Duration.sum`,"-":`Duration.subtract`,"/":`Duration.divide`,"<":`Duration.isLessThan`,"<=":`Duration.isLessThanOrEqualTo`,"===":`Duration.equals`,">":`Duration.isGreaterThan`,">=":`Duration.isGreaterThanOrEqualTo`},Hr={"!==":`DateTime.Equivalence`,"+":`DateTime.addDuration`,"-":`DateTime.subtractDuration`,"<":`DateTime.isLessThan`,"<=":`DateTime.isLessThanOrEqualTo`,"===":`DateTime.Equivalence`,">":`DateTime.isGreaterThan`,">=":`DateTime.isGreaterThanOrEqualTo`},Ur=`Duration.isPositive, Duration.isNegative or Duration.isZero`,Wr={"!==":`Duration.isZero`,"<":Ur,"<=":Ur,"===":`Duration.isZero`,">":Ur,">=":Ur},Gr=new Set(n.keys(Vr));function Kr(e){let t=F(e);return t.type===`TemplateLiteral`||t.type===`Literal`&&l.isString(t.value)?!0:t.type===`BinaryExpression`&&t.operator===`+`&&(Kr(t.left)||Kr(t.right))}function qr(e){let t=F(e);return t.type===`Identifier`&&t.name===`undefined`||t.type===`Literal`&&!l.isNumber(t.value)}function Jr(e,t){let n=e.name.parent;if((n.type===`AssignmentPattern`?n.parent:n).type===`Property`)return!0;if(e.type!==`Parameter`)return!1;let r=R(e.name);return r!==void 0&&Zt(r,t)}function Yr(e,t){let n=t.left===`instant`,r=t.right===`instant`;return e===`+`?n===r?`duration`:`instant`:n&&!r&&e===`-`?`instant`:`duration`}function Xr(e,t){let n=t.left===`instant`||t.right===`instant`;return t.right===`instant`&&e.operator===`-`?`DateTime.distance`:V(e.right,1e3)&&e.operator===`/`?n?`DateTime.toEpochSeconds`:`Duration.toSeconds`:(!n&&(V(e.left,0)||V(e.right,0))?Wr[e.operator]:void 0)??(n?Hr[e.operator]:void 0)??Vr[e.operator]??`Duration`}function Zr(e){return e?.type===`BinaryExpression`&&e.left.type!==`PrivateIdentifier`}function Qr(e){let t=e.parent;for(;t&&se.has(t.type);)t=t.parent;return Zr(t)?t:void 0}const $r=b(x(`suggestion`,`Disallow arithmetic and comparisons on millisecond numbers where Effect Duration or DateTime can do the math.`,{millisArithmetic:`{{operand}} is {{what}} in milliseconds. Keep it as a {{module}} and use {{suggestion}}; convert to milliseconds only where a non-Effect API needs them.`},`https://www.effect.website/docs/v4/api/effect/Duration`),(e,t)=>{function n(n){let r=D(n,t());if(r?.length!==2||!U(e,n))return;let i=`${r[0]}.${r[1]}`;return i===`Duration.toMillis`?`duration`:i===`DateTime.toEpochMillis`?`instant`:void 0}function r(n,r){let a=T(w(e,n,n.name));if(a!==void 0&&Jr(a,t()))return;let o=Fr(n.name);if(o!==void 0)return o;let s=a?.node;return s?.type===`VariableDeclarator`&&s.parent.type===`VariableDeclaration`&&s.parent.kind===`const`&&s.id===a?.name&&s.init!==null?i(s.init,r+1):void 0}function i(i,o=0){if(o>4)return;let s=F(i);if(s.type===`Identifier`)return r(s,o);if(s.type===`MemberExpression`){let e=s.object.type===`ThisExpression`?S(s):void 0;return e===void 0?void 0:Fr(e)}if(s.type===`CallExpression`)return n(s.callee);if(s.type===`YieldExpression`){let n=s.argument;return n!==null&&s.delegate&&A(n,t(),[`Clock`,`currentTimeMillis`])&&U(e,n)?`instant`:void 0}if(!Zr(s)||!Br.has(s.operator))return;let c=a(s,o);return c===void 0?void 0:Yr(s.operator,c)}function a(e,t){if(!Gr.has(e.operator)||e.operator===`+`&&(Kr(e.left)||Kr(e.right))||(e.operator===`===`||e.operator===`!==`)&&(qr(e.left)||qr(e.right)))return;let n=i(e.left,t),r=i(e.right,t);return n===void 0&&r===void 0?void 0:{left:n,right:r}}return{BinaryExpression(n){if(!t().hasEffectImport)return;let r=a(n,0),i=Qr(n);if(r===void 0||i!==void 0&&a(i,0)!==void 0)return;let o=r.left===`instant`||r.right===`instant`;e.report({node:n,messageId:`millisArithmetic`,data:{operand:e.sourceCode.getText(r.left===void 0?n.right:n.left),what:o?`a timestamp`:`a duration`,module:o?`DateTime`:`Duration`,suggestion:Xr(n,r)}})}}}),ei=/* @__PURE__ */ new Map([[`addEventListener`,1],[`on`,1],[`setInterval`,0]]);function ti(e,t){let n=C(e.callee)?.at(-1),r=n===void 0?void 0:ei.get(n);if(r===void 0)return!1;if(n===`addEventListener`){let t=M(e,2);if(t?.type===`ObjectExpression`){let e=P(t,`once`);if(e!==void 0&&V(e.value,!0))return!1}}let i=M(e,r);return i!==void 0&&de(i,t)}const ni=b(x(`problem`,`Disallow attaching Effect.callback resume to repeating event sources.`,{multiShot:`Effect.callback is single-shot, but this source emits repeatedly. Use a once-style subscription or Stream.callback.`},`https://github.com/Effect-TS/tsgo/issues/484`),(e,t)=>({CallExpression(n){if(!O(n.callee,t(),`Effect`,`callback`))return;let r=M(n,0);if(r===void 0||!j(r))return;let i=L(r)?.name,a=r.body;i!==void 0&&a&&I(a,e=>e.type===`CallExpression`&&ti(e,i))&&e.report({node:n,messageId:`multiShot`})}})),ri=/* @__PURE__ */ new Set([`NaN`,`Infinity`,`undefined`]),ii=/* @__PURE__ */ new Set([`annotate`,`annotateEncoded`,`annotateKey`]),ai=[`default`,`examples`];function oi(e){return e.type===`Literal`&&l.isBigInt(e.value)||e.type===`Identifier`&&ri.has(e.name)||j(e)||e.type===`CallExpression`&&C(e.callee)?.at(-1)===`Symbol`}function si(e,t){if(e.type===`ArrayExpression`)for(let n of e.elements)n&&n.type!==`SpreadElement`&&t.push(n);else if(e.type===`ObjectExpression`)for(let n of e.properties)n.type===`Property`&&t.push(n.value)}function ci(e){let t=[e];for(;t.length>0;){let e=t.pop();if(e===void 0)continue;let n=F(e);if(oi(n))return n;si(n,t)}}const li=b(x(`problem`,`Disallow schema examples and defaults that cannot be represented in JSON Schema.`,{nonJson:`This schema annotation value is not JSON-serializable and will be omitted from or corrupt generated JSON Schema.`},`https://github.com/Effect-TS/tsgo/issues/440`),(e,t)=>({CallExpression(n){let r=t();if(!r.hasEffectImport)return;let i=D(n.callee,r),a=n.callee.type===`MemberExpression`?S(n.callee):i?.[0]===`Schema`?i[1]:void 0;if(a===void 0||!ii.has(a))return;let o=qt(n);if(o!==void 0&&P(o,`jsonSchema`)===void 0)for(let t of ai){let n=P(o,t);if(n===void 0)continue;let r=ci(n.value);r!==void 0&&e.report({node:r,messageId:`nonJson`})}}})),ui=[`option`,`either`],di=b(x(`problem`,`Disallow wrapping infallible Effect.service access in Option or Either.`,{mandatory:`Effect.service never fails, so this wrapper is always present and keeps the service requirement. Use Effect.serviceOption.`},`https://github.com/Effect-TS/tsgo/issues/648`),(e,t)=>({CallExpression(n){let r=t(),i=k(n.callee,r,`Effect`,ui),a=M(n,0);if(i&&a?.type===`CallExpression`&&O(a.callee,r,`Effect`,`service`)){e.report({node:n,messageId:`mandatory`});return}if(n.callee.type!==`MemberExpression`||C(n.callee)?.at(-1)!==`pipe`)return;let o=F(n.callee.object),s=M(n,0);s!==void 0&&o.type===`CallExpression`&&O(o.callee,r,`Effect`,`service`)&&k(s,r,`Effect`,ui)&&e.report({node:n,messageId:`mandatory`})}})),fi=b(x(`problem`,`Ensure a later object spread cannot overwrite an explicitly assigned _tag.`,{overwritten:`A later spread can overwrite _tag at runtime. Move _tag after all spreads.`},`https://github.com/Effect-TS/tsgo/issues/426`),e=>({ObjectExpression(t){let n=r.findFirstWithIndex(t.properties,e=>e.type===`Property`&&N(e)===`_tag`);if(c.isNone(n))return;let[i,a]=n.value;r.some(r.drop(t.properties,a+1),e=>e.type===`SpreadElement`)&&e.report({node:i,messageId:`overwritten`})}})),pi=/^make[A-Z]/u,mi=/\.(?:test|spec)\.[cm]?[jt]sx?$/u,hi=y(x(`problem`,`Disallow project-local make<CapabilityName> imports outside test and spec files.`,{serviceConstructorImport:`Do not import Effect service constructor "{{name}}" into runtime code. Import the owning Layer, yield the contextual service, and allow its requirements to propagate to the composition root.`},`https://github.com/dmmulroy/anti-slop/blob/main/src/effect/rules/no-service-constructor-imports.ts`),e=>({ImportDeclaration(t){if(!mi.test(i.replaceAll(`\\`,`/`)(e.filename))&&(i.startsWith(`./`)(t.source.value)||i.startsWith(`../`)(t.source.value)))for(let n of t.specifiers){if(n.type!==`ImportSpecifier`)continue;let t=v(n.imported);pi.test(t)&&e.report({node:n,messageId:`serviceConstructorImport`,data:{name:t}})}}})),gi=[`getOrThrow`,`getOrThrowWith`],_i=b(x(`problem`,`Disallow turning missing Effect services into untyped Option defects.`,{getOrThrow:`Option.getOrThrow after Effect.serviceOption hides a mandatory service until runtime. Use Effect.service so it remains a typed requirement.`},`https://github.com/Effect-TS/tsgo/issues/650`),(e,t)=>({CallExpression(n){let r=t();if(k(n.callee,r,`Option`,gi)){let t=M(n,0),i=t?.type===`YieldExpression`?t.argument:t;i?.type===`CallExpression`&&O(i.callee,r,`Effect`,`serviceOption`)&&e.report({node:n,messageId:`getOrThrow`});return}if(n.callee.type!==`MemberExpression`||C(n.callee)?.at(-1)!==`pipe`)return;let i=F(n.callee.object),a=M(n,0);if(i.type!==`CallExpression`||!O(i.callee,r,`Effect`,`serviceOption`)||a?.type!==`CallExpression`||!O(a.callee,r,`Effect`,`map`))return;let o=M(a,0);o!==void 0&&k(o,r,`Option`,gi)&&e.report({node:n,messageId:`getOrThrow`})}})),vi=/* @__PURE__ */ new Set([`andThen`,`map`,`mapError`,`tap`,`tapError`,`tapErrorCause`]),yi=b(x(`problem`,`Disallow throw in Effect callbacks that cannot add the thrown value to the typed error channel.`,{callbackThrow:`Throwing in this Effect callback creates an untyped defect. Return Effect.fail(...) or return the mapped error value instead.`},`https://github.com/Effect-TS/tsgo/issues/406`),(e,t)=>({ThrowStatement(n){let r=R(n);if(r===void 0)return;let i=t(),a=Yt(r,i),o=Jt(r,`catch`);(a?.[0]===`Effect`&&a[1]!==void 0&&vi.has(a[1])||o!==void 0&&k(o.callee,i,`Effect`,[`try`,`tryPromise`]))&&e.report({node:n,messageId:`callbackThrow`})}})),bi=/* @__PURE__ */ new Set([`get`,`post`,`put`,`patch`,`delete`,`head`,`options`]);function xi(e,t){let n=e.parent,r=e.node;if(e.type!==`ImportBinding`||n?.type!==`ImportDeclaration`||q(n,r.type===`ImportSpecifier`?r:void 0))return!1;let i=n.source.value;return r.type===`ImportNamespaceSpecifier`?i===`effect/unstable/httpapi/HttpApiEndpoint`&&t.length===2||i===`effect/unstable/httpapi`&&t.length===3&&t[1]===`HttpApiEndpoint`:r.type===`ImportSpecifier`&&r.imported.type===`Identifier`&&r.imported.name===`HttpApiEndpoint`&&i===`effect/unstable/httpapi`&&t.length===2}function Si(e,t){let n=C(e.callee),r=n?.[0],i=n?.at(-1);if(n===void 0||r===void 0||i===void 0||!bi.has(i))return!1;let a=T(w(t,e,r));return a!==void 0&&xi(a,n)}function Ci(e){if(e?.type!==`ObjectExpression`)return;let t=/* @__PURE__ */ new Set,n=[];for(let r of e.properties){if(r.type!==`Property`||r.computed||r.method||r.kind!==`init`)return;let e=N(r)??(r.key.type===`Literal`&&l.isNumber(r.key.value)?String(r.key.value):void 0);if(e===void 0||t.has(e))return;t.add(e),n.push(r)}return n}const wi=y(x(`problem`,`Require lowercase static keys in Effect v4 endpoint header field schemas.`,{uppercase:`Header schema key "{{name}}" contains ASCII uppercase letters. Incoming headers use exact lowercase runtime lookup; review the schema and its consumers before renaming this key.`},`https://github.com/Effect-TS/tsgo/issues/413`),e=>({CallExpression(t){if(r.some(t.arguments,e=>e.type===`SpreadElement`)||!Si(t,e))return;let n=Ci(M(t,2)),i=Ci(c.getOrUndefined(r.findFirst(n??[],e=>N(e)===`headers`))?.value);if(i!==void 0)for(let t of i){let n=N(t);n!==void 0&&/[A-Z]/u.test(n)&&e.report({node:t.key,messageId:`uppercase`,data:{name:n}})}}})),Ti=b(x(`problem`,`Disallow no-op retry and repeat wrappers with times: 0.`,{zeroTimes:`times: 0 performs no retries or repeats. Remove the wrapper or use a positive count.`},`https://github.com/Effect-TS/tsgo/issues/412`),(e,t)=>({CallExpression(n){let r=t();if(!k(n.callee,r,`Effect`,[`retry`,`repeat`]))return;let i=qt(n);if(i===void 0)return;let a=P(i,`times`);a!==void 0&&V(a.value,0)&&e.report({node:a,messageId:`zeroTimes`})}})),Ei=y({...x(`suggestion`,`Use consistently aliased namespace imports for Effect and Alchemy submodule entrypoints.`,{alias:"Import {{source}} as the canonical namespace alias `{{alias}}`.",namespace:'Use `import * as {{alias}} from "{{source}}"` instead of importing values directly.'},`https://github.com/Effect-TS/language-service/blob/main/packages/language-service/src/core/AutoImport.ts`),fixable:`code`},e=>({ImportDeclaration(t){let n=wn(t.source.value);if(n===void 0||t.importKind===`type`)return;let r=Sn(n);for(let n of t.specifiers)n.type===`ImportSpecifier`&&q(t,n)||(n.type===`ImportNamespaceSpecifier`?n.local.name!==r&&e.report({node:n.local,messageId:`alias`,data:{alias:r,source:t.source.value},fix:n=>En(e,t,n)}):e.report({node:n,messageId:`namespace`,data:{alias:r,source:t.source.value},fix:n=>En(e,t,n)}))}})),Di=b(x(`suggestion`,`Prefer immutable, Order-based Effect Array sorting in Effect projects.`,{effectArraySort:`Use Arr.sort with an Order instead of the mutable native Array.sort method.`},`https://www.effect.website/docs/v4/api/effect/Array#sort`),(e,t)=>({CallExpression(n){let r=t();r.hasEffectImport&&n.callee.type===`MemberExpression`&&S(n.callee)===`sort`&&!O(n.callee,r,`Array`,`sort`)&&e.report({node:n,messageId:`effectArraySort`})}})),Oi=/* @__PURE__ */ new Set([`toISOString`,`toLocaleDateString`,`toLocaleTimeString`]),ki=b(x(`suggestion`,`Prefer Effect DateTime formatting so time-zone behavior is explicit and composable.`,{effectDateTime:`Convert to DateTime and use DateTime.format, DateTime.formatIso, or another explicit formatter.`},`https://www.effect.website/docs/v4/api/effect/DateTime`),(e,t)=>({CallExpression(n){t().hasEffectImport&&n.callee.type===`MemberExpression`&&Oi.has(S(n.callee)??``)&&e.report({node:n,messageId:`effectDateTime`})}})),Ai=b({...x(`suggestion`,`Prefer explicit Effect Duration constructors over ambiguous millisecond literals.`,{effectDuration:`Wrap this number with Duration.millis or use a more descriptive Duration constructor.`},`https://www.effect.website/docs/v4/api/effect/Duration`),fixable:`code`},(e,t)=>({CallExpression(n){let r=wr(n,e,t());r!==void 0&&Y(r)!==void 0&&e.report({node:r,messageId:`effectDuration`,fix(t){let i=Ze(e,n,`effect/Duration`,`Duration`,t);return[...i.fixes,t.replaceText(r,`${i.name}.millis(${e.sourceCode.getText(r)})`)]}})}})),ji=/* @__PURE__ */ new Map([[`ms`,`millis`],[`milli`,`millis`],[`millis`,`millis`],[`millisecond`,`millis`],[`milliseconds`,`millis`],[`sec`,`seconds`],[`secs`,`seconds`],[`seconds`,`seconds`],[`mins`,`minutes`],[`minutes`,`minutes`],[`hr`,`hours`],[`hrs`,`hours`],[`hours`,`hours`],[`days`,`days`],[`weeks`,`weeks`]]),Mi=/* @__PURE__ */ new Set([`day`,`hour`,`minute`,`second`,`week`]),Ni=/* @__PURE__ */ new Set([`backoff`,`cooldown`,`day`,`debounce`,`delay`,`duration`,`expiration`,`expiry`,`hour`,`interval`,`lifetime`,`minute`,`second`,`throttle`,`timeout`,`ttl`,`week`]),Pi=/* @__PURE__ */ new Set([`at`,`epoch`,`per`,`timestamp`]);function Fi(e){return e!==void 0&&e!==`excluded`&&e!==`unknown`}function Ii(e){let t=Mr(e),n=t.indexOf(`in`),i=t[n-1]??``;if(n>0&&n<t.length-1&&(ji.has(i)||Mi.has(i))||r.some(t,e=>Pi.has(e)))return`excluded`;let a=t.at(-1),o=t.at(-2);if(a===void 0)return;let s=ji.get(a);if(s!==void 0)return s;if(Ni.has(a)||a===`age`&&o===`max`||a===`in`&&o===`expires`)return`unknown`}function Li(e,t,n){return r.some(w(n,e,t)?.defs??[],e=>e.type===`ImportBinding`)}const Ri=s.type().pipe(s.withReturnType(),s.discriminators(`type`)({Identifier:o.flow(m.get(`name`),r.make),TSQualifiedName:({left:e,right:t})=>{let n=Ri(e);return n===void 0?void 0:r.append(n,t.name)}}),s.orElse(o.constUndefined));function zi(e,t,n){return I(e,e=>{if(e.type!==`TSTypeReference`)return!1;let[r,...i]=Ri(e.typeName)??[],a=r===void 0||!Li(e,r,t)?void 0:n.bindings.get(r);return a!==void 0&&[...a,...i][0]===`Duration`})}function Bi(e){return e.parent.type===`VariableDeclaration`&&e.parent.kind===`const`&&e.id.type===`Identifier`&&e.init!==null&&Y(e.init)!==void 0}function Vi(e,t){let n=F(e);if(n.type!==`Identifier`)return;let r=T(w(t,n,n.name))?.node;return r?.type===`VariableDeclarator`&&Bi(r)?r:void 0}const Hi=b(x(`suggestion`,`Prefer Effect Duration values over plain-number duration constants.`,{durationConstant:`{{name}} holds a duration as a plain number. Declare it as {{replacement}} and convert at non-Effect boundaries with Duration.toMillis or Duration.toSeconds.`},`https://www.effect.website/docs/v4/api/effect/Duration`),(e,t)=>{let n=/* @__PURE__ */ new Map;function r(n,r){if(n.id.typeAnnotation&&zi(n.id.typeAnnotation,e,t()))return`none`;let i=Ii(n.id.name);if(r)return Fi(i)?i:`millis`;if(i===`excluded`||(Y(n.init)??0)<=0)return`none`;if(Fi(i))return i;let a=jr(n.init);return a?.millis===!0?`millis`:a!==void 0||i===`unknown`?void 0:`none`}return{before(){n.clear()},VariableDeclarator(e){t().hasEffectImport&&Bi(e)&&!n.has(e)&&n.set(e,!1)},CallExpression(r){let i=wr(r,e,t()),a=i===void 0?void 0:Vi(i,e);a!==void 0&&n.set(a,!0)},"Program:exit":function(){for(let[t,i]of n){let n=r(t,i),a=Y(t.init);n!==`none`&&e.report({node:t.id,messageId:`durationConstant`,data:{name:t.id.name,replacement:n===void 0||a===void 0?`a Duration constructor such as Duration.seconds`:zr(a,n)}})}}}}),Ui=/* @__PURE__ */ new Set([`Finite`,`FiniteFromString`,`Int`,`Number`,`NumberFromString`]),Wi=/* @__PURE__ */ new Set([`NullOr`,`NullishOr`,`UndefinedOr`,`optional`,`optionalKey`]),Gi=/* @__PURE__ */ new Set([`annotate`,`annotateKey`,`brand`,`check`,`withConstructorDefault`,`withDecodingDefault`,`withDecodingDefaultKey`]);function Ki(e,t){let n=D(e,t);return n?.length===2&&n[0]===`Schema`?n[1]:void 0}function qi(e,t){if(e.type===`SpreadElement`)return!1;let n=F(e);return n.type===`CallExpression`?Gi.has(Ki(n.callee,t)??``):Wi.has(Ki(n,t)??``)}function Ji(e,t){let n=F(e);if(n.type!==`CallExpression`)return Ui.has(Ki(n,t)??``);let i=n.callee,a=n.arguments[0];if(Wi.has(Ki(i,t)??``))return a!==void 0&&a.type!==`SpreadElement`&&Ji(a,t);if(i.type!==`MemberExpression`||i.object.type===`Super`||!Ji(i.object,t))return!1;let o=S(i);return o===`pipe`?r.every(n.arguments,e=>qi(e,t)):o===`annotate`||o===`check`}function Yi(e){let t=e?.typeAnnotation;return t?.type===`TSNumberKeyword`||t?.type===`TSUnionType`&&r.some(t.types,e=>e.type===`TSNumberKeyword`)&&r.every(t.types,e=>[`TSNullKeyword`,`TSNumberKeyword`,`TSUndefinedKeyword`].includes(e.type))}function Xi(e){return e!==void 0&&Fr(e)===`duration`}function Zi(e){return e.computed?e.key.type===`Literal`&&typeof e.key.value==`string`?e.key.value:void 0:e.key.type===`Identifier`?e.key.name:void 0}function Qi(e,t,n){if(/\.d\.[cm]?ts$/u.test(t.filename)||pe(e,e=>l.hasProperty(e,`declare`)&&e.declare)!==void 0)return!0;let i=R(e);return i!==void 0&&Zt(i,n)&&r.some(i.params,t=>me(t,e))}function $i(e){let t=e.type===`TSParameterProperty`?e.parameter:e;if(t.type===`Identifier`)return Yi(t.typeAnnotation)?t:void 0;if(t.type!==`AssignmentPattern`||t.left.type!==`Identifier`)return;let n=F(t.right);return Yi(t.left.typeAnnotation)||!t.left.typeAnnotation&&n.type===`Literal`&&typeof n.value==`number`?t.left:void 0}const ea=b(x(`suggestion`,`Prefer Duration types over plain numbers for millisecond parameters and fields.`,{durationType:`{{name}} holds a duration as a number of milliseconds. Type it as Duration.Input (or Duration.Duration) and convert with Duration.toMillis only where a non-Effect API needs milliseconds.`,durationSchema:`{{name}} decodes a duration as a plain number. Use Schema.DurationFromMillis to keep milliseconds in the encoded data, or Schema.Duration.`},`https://www.effect.website/docs/v4/api/effect/Duration`),(e,t)=>{function n(t,n,r){e.report({node:t,messageId:r,data:{name:n}})}function r(r){if(t().hasEffectImport&&r.body&&!Zt(r,t())&&!Qi(r,e,t()))for(let e of r.params){let t=$i(e);t!==void 0&&Xi(t.name)&&n(t,t.name,`durationType`)}}function i(r){let i=Zi(r);t().hasEffectImport&&Xi(i)&&Yi(r.typeAnnotation)&&!Qi(r,e,t())&&n(r.key,i,`durationType`)}return{ArrowFunctionExpression:r,FunctionDeclaration:r,FunctionExpression:r,PropertyDefinition:i,TSPropertySignature:i,Property(e){let r=N(e);t().hasEffectImport&&e.parent.type===`ObjectExpression`&&Xi(r)&&Ji(e.value,t())&&n(e.key,r,`durationSchema`)}}}),ta=/* @__PURE__ */ new Set([`base64`,`base64url`,`hex`]);function na(e){return e!==void 0&&B(e)&&ta.has(e.value)}const ra=b(x(`suggestion`,`Prefer Effect Encoding for portable Base64, Base64Url, and hexadecimal encoding.`,{effectEncoding:`Use Encoding encode/decode helpers; decoders return Result instead of throwing.`},`https://www.effect.website/docs/v4/api/effect/Encoding`),(e,t)=>({CallExpression(n){if(!t().hasEffectImport)return;if((E(n.callee,e,`atob`)||E(n.callee,e,`btoa`))&&n.arguments.length>0){e.report({node:n,messageId:`effectEncoding`});return}let i=C(n.callee),a=i!==void 0&&r.join(i,`.`)===`Buffer.from`&&na(M(n,1)),o=i?.at(-1)===`toString`&&na(M(n,0));(a||o)&&e.report({node:n,messageId:`effectEncoding`})}})),ia=/* @__PURE__ */ new Set([`fs`,`fs/promises`,`node:fs`,`node:fs/promises`]),aa=b(x(`suggestion`,`Prefer the Effect FileSystem service over direct Node.js filesystem imports in Effect projects.`,{effectFileSystem:`Use the FileSystem service from effect/FileSystem instead of {{source}}.`},`https://www.effect.website/docs/v4/api/effect/FileSystem`),(e,t)=>({ImportDeclaration(n){t().hasEffectImport&&ia.has(n.source.value)&&e.report({node:n.source,messageId:`effectFileSystem`,data:{source:n.source.value}})}}));function oa(e,t,n){return e.type===`CallExpression`&&O(e.callee,t,`Result`,n)?M(e,0):void 0}function sa(e,t,n){let r=L(t),i=rn(t);if(r===void 0||i?.type!==`ConditionalExpression`)return;let a=oa(i.consequent,n,`succeed`),o=oa(i.alternate,n,`fail`);a?.type===`Identifier`&&a.name===r.name&&o?.type===`Identifier`&&o.name===r.name&&e.report({node:t,messageId:`effectFilter`})}const ca=b(x(`suggestion`,`Prefer Effect Filter constructors for reusable Result-valued predicates.`,{effectFilter:`Use Filter.fromPredicate for this Result-valued predicate so it composes as a Filter.`},`https://www.effect.website/docs/v4/api/effect/Filter`),(e,t)=>({ArrowFunctionExpression(n){sa(e,n,t())},FunctionExpression(n){sa(e,n,t())}})),la=b(x(`suggestion`,`Prefer immutable Effect Headers values in Effect projects.`,{effectHeaders:`Use Headers.fromInput to construct normalized, immutable Effect headers.`},`https://www.effect.website/docs/v4/api/effect/unstable/http/Headers`),(e,t)=>({NewExpression(n){t().hasEffectImport&&E(n.callee,e,`Headers`)&&e.report({node:n,messageId:`effectHeaders`})}}));function ua(e){return e.type===`Literal`||e.type===`TemplateLiteral`&&e.expressions.length===0}function da(e,t){if(e.type===`BinaryExpression`&&ge(e.operator)){if(ua(e.left))return t.sourceCode.getText(e.right);if(ua(e.right))return t.sourceCode.getText(e.left)}}const fa=b(x(`suggestion`,`Prefer Effect Match for composable and exhaustive branching in Effect projects.`,{effectMatch:`Use Match.type, Match.value, or Match.tags with Match.exhaustive instead of switch.`,preferMatch:`Use Match from Effect instead of a chained literal ternary.`},`https://www.effect.website/docs/v4/api/effect/Match`),(e,t)=>({SwitchStatement(n){t().hasEffectImport&&e.report({node:n,messageId:`effectMatch`})},ConditionalExpression(t){if(t.parent.type===`ConditionalExpression`)return;let n=da(t.test,e);if(n===void 0)return;let r=t.alternate,i=1;for(;r.type===`ConditionalExpression`;){if(da(r.test,e)!==n)return;i+=1,r=r.alternate}i>1&&e.report({node:t,messageId:`preferMatch`})}})),pa=/* @__PURE__ */ new Set([`node:path`,`path`]),ma=b(x(`suggestion`,`Prefer the Effect Path service over direct Node.js path imports in Effect projects.`,{effectPath:`Use the Path service from effect/Path instead of {{source}}.`},`https://www.effect.website/docs/v4/api/effect/Path`),(e,t)=>({ImportDeclaration(n){t().hasEffectImport&&pa.has(n.source.value)&&e.report({node:n.source,messageId:`effectPath`,data:{source:n.source.value}})}})),ha=/* @__PURE__ */ new Set([`canParse`,`parse`]),ga=b(x(`suggestion`,`Prefer Effect Url helpers for safe URL parsing in Effect projects.`,{effectUrl:`Use Url.fromString or Url.make so invalid URLs are represented as Result failures.`},`https://www.effect.website/docs/v4/api/effect/unstable/http/Url`),(e,t)=>({NewExpression(n){t().hasEffectImport&&E(n.callee,e,`URL`)&&e.report({node:n,messageId:`effectUrl`})},CallExpression(n){let r=C(n.callee);t().hasEffectImport&&r?.[0]===`URL`&&ha.has(r[1]??``)&&n.callee.type===`MemberExpression`&&E(n.callee.object,e,`URL`)&&e.report({node:n,messageId:`effectUrl`})}})),_a=/* @__PURE__ */ new Map([[`interruptibleMask`,`interruptible`],[`uninterruptibleMask`,`uninterruptible`]]),va=b(x(`suggestion`,`Prefer the non-mask interruptibility API when the restore callback is unused.`,{unusedRestore:`The mask callback never uses restore, so the mask is equivalent to {{replacement}} and misleadingly suggests a restored region.`},`https://github.com/Effect-TS/tsgo/issues/659`),(e,t)=>({CallExpression(n){let r=D(n.callee,t()),i=r?.length===2&&r[0]===`Effect`?_a.get(r[1]??``):void 0,a=M(n,0);i!==void 0&&a!==void 0&&j(a)&&!fe(a)&&e.report({node:n,messageId:`unusedRestore`,data:{replacement:`Effect.${i}`}})}})),ya=b(x(`suggestion`,`Prefer Effect.withSpan when the callback does not use the span handle.`,{unusedSpan:`The useSpan callback ignores its span. Use Effect.withSpan so nested spans are parented beneath this span.`},`https://github.com/Effect-TS/tsgo/issues/663`),(e,t)=>({CallExpression(n){if(!O(n.callee,t(),`Effect`,`useSpan`))return;let r=M(n,n.arguments.length-1);r!==void 0&&j(r)&&!fe(r)&&e.report({node:n,messageId:`unusedSpan`})}}));function ba(e,t){let n=F(e);if(V(n,0))return!0;if(B(n))return/^0\s*(?:nanos?|micros?|millis?|seconds?|minutes?|hours?|days?|weeks?)$/i.test(n.value);if(O(n,t,`Duration`,`zero`))return!0;if(n.type===`CallExpression`){let e=D(n.callee,t),r=M(n,0);return r!==void 0&&e?.[0]===`Duration`&&V(r,0)}return!1}const xa=b(x(`suggestion`,`Prefer scheduler yielding to a zero-duration Clock sleep.`,{zeroSleep:`Effect.sleep(0) uses Clock and interacts with TestClock. Use Effect.yieldNow for a cooperative scheduler yield.`},`https://github.com/Effect-TS/tsgo/issues/661`),(e,t)=>({CallExpression(n){let r=t(),i=M(n,0);i!==void 0&&O(n.callee,r,`Effect`,`sleep`)&&ba(i,r)&&e.report({node:n,messageId:`zeroSleep`})}})),Sa=/* @__PURE__ */ new Set([`catch`,`mapError`,`catchAll`]);function Ca(e,t){let n=Yt(e,t),r=Jt(e,`catch`);if(!(n?.[0]===`Effect`&&n[1]!==void 0&&Sa.has(n[1])||r!==void 0&&k(r.callee,t,`Effect`,[`try`,`tryPromise`]))||!e.body)return!1;let i=L(e);return I(e.body,e=>e.type===`NewExpression`&&ve(e)&&(i===void 0||!de(e,i.name)))}const wa=b(x(`suggestion`,`Preserve the underlying cause when wrapping an Effect failure.`,{droppedCause:`This handler constructs a new error but drops the caught failure. Accept it as a parameter and attach it as cause.`},`https://github.com/Effect-TS/tsgo/issues/490`),(e,t)=>({ArrowFunctionExpression(n){Ca(n,t())&&e.report({node:n,messageId:`droppedCause`})},FunctionExpression(n){Ca(n,t())&&e.report({node:n,messageId:`droppedCause`})}})),Ta=b(x(`problem`,`Require Schema.Class declarations to carry a nominal brand.`,{missingBrand:`Schema.Class without a second type parameter is structural. Add a unique brand so plain objects cannot masquerade as instances.`},`https://github.com/Effect-TS/tsgo/issues/468`),(e,t)=>({CallExpression(n){O(n.callee,t(),`Schema`,`Class`)&&(n.typeArguments?.params.length??0)<2&&e.report({node:n,messageId:`missingBrand`})}}));function Ea(e,t){if(O(e.callee,t,`Effect`,`tryPromise`))return an(M(e,0))}const Da=b(x(`suggestion`,`Require Effect.tryPromise thunks to accept and use their AbortSignal for interruption.`,{missingSignal:"Accept the AbortSignal parameter and pass it to the Promise API. Name it `_signal` only when cancellation is unsupported.",unusedSignal:"Pass this AbortSignal to the Promise API, or rename it to `_signal` to explicitly acknowledge that cancellation is unsupported."},`https://www.effect.website/docs/v4/api/effect/Effect#tryPromise`),(e,t)=>({CallExpression(n){let r=Ea(n,t());if(r===void 0)return;let a=L(r);a===void 0?e.report({node:r,messageId:`missingSignal`}):!i.startsWith(`_`)(a.name)&&!fe(r)&&e.report({node:a,messageId:`unusedSignal`})}})),Oa=[`fn`,`fnUntraced`,`gen`],ka=[`fn`,`fnUntraced`],Aa=[`try`,`tryPromise`];function ja(e,t){let n=e.parent;if(n.type===`CallExpression`&&M(n,0)===e)return k(n.callee,t,`Effect`,Aa);if(n.type!==`Property`||n.key.type!==`Identifier`||n.key.name!==`try`)return!1;let r=n.parent;return r.type===`ObjectExpression`&&r.parent.type===`CallExpression`&&k(r.parent.callee,t,`Effect`,Aa)}const Ma=b(x(`problem`,`Disallow throw in Effect generator APIs because it creates an untyped defect.`,{throwInGen:`Use yield* Effect.fail(...) instead of throw so the failure stays in the typed error channel.`}),(e,t)=>({ThrowStatement(n){let i=t(),a=R(n);if(a===void 0||ja(a,i))return;let o=z(a),s=o!==void 0&&r.some(Oa,e=>O(o.callee,i,`Effect`,e)),c=o?.callee,l=c?.type===`CallExpression`&&r.some(ka,e=>O(c.callee,i,`Effect`,e));(s||l)&&e.report({node:n,messageId:`throwInGen`})}})),Na=String.raw`(?:\r\n|\r(?!\n)|[\n\u2028\u2029])`,Pa=String.raw`[^\S\r\n\u2028\u2029]*`,Fa=RegExp(`^(${Pa}${Na})(?:${Pa}${Na})+(${Pa};?)$`,`u`),Ia=/^(?:module\s*\.\s*)?exports(?:\s*\.|\s*\[|$)/u,La=/* @__PURE__ */ new Set([`FunctionDeclaration`,`FunctionExpression`,`ArrowFunctionExpression`]),Ra=/* @__PURE__ */ new Set([`any`,`never`,`always`]),za=/* @__PURE__ */ new Set([`any`,`singleline`,`multiline`]),Ba=/* @__PURE__ */ new Set([`blankLine`,`prev`,`next`]),Va=/* @__PURE__ */ new Set([`selector`,`lineMode`]);function Ha(e){return e.type===`Punctuator`&&e.value===`;`}function Ua(e,t){return e.loc.end.line===t.loc.start.line}function Wa(e){return e.loc.start.line===e.loc.end.line}function Ga(e){return La.has(e.type)}function Ka(e){return e.type===`ChainExpression`?e.expression:e}function X(e,t){let n=new Set(r.ensure(e));return(e,r)=>r.getFirstToken(e)?.value===t&&n.has(e.type)}function Z(e){return t=>t.type===e}function Q(e,t){return(n,r)=>e(n,r)&&Wa(n)===(t===`singleline`)}function qa(e){if(e.type!==`ExpressionStatement`)return!1;let t=Ka(e.expression);if(t.type===`UnaryExpression`&&(t=Ka(t.argument)),t.type!==`CallExpression`)return!1;let n=t.callee;for(;n.type===`SequenceExpression`;)n=c.getOrThrowWith(r.last(n.expressions),()=>/* @__PURE__ */ Error(`Padding rule invariant: sequence expression is empty`));return Ga(n)}function Ja(e){if(e.type!==`VariableDeclaration`)return!1;let t=e.declarations[0]?.init;if(t==null)return!1;for(;t.type===`MemberExpression`;)t=t.object;return t.type===`CallExpression`&&t.callee.type===`Identifier`&&t.callee.name===`require`}function Ya(e,t){if(e.type===`DoWhileStatement`&&e.body.type===`BlockStatement`||qa(e))return!0;let n=t.getLastToken(e,e=>!Ha(e)),r=n?.type===`Punctuator`&&n.value===`}`?t.getNodeByRangeIndex(n.range[0]):null;return r?.type===`BlockStatement`||r?.type===`SwitchStatement`}function Xa(e,t){return e.type===`ExpressionStatement`&&(e.parent.type===`Program`||e.parent.type===`BlockStatement`&&Ga(e.parent.parent))&&e.expression.type===`Literal`&&l.isString(e.expression.value)&&(t.getTokenBefore(e.expression)?.value!==`(`||t.getTokenAfter(e.expression)?.value!==`)`)}function Za(e,t){if(!Xa(e,t)||!e.parent||!(`body`in e.parent)||!r.isArray(e.parent.body))return!1;let n=e.parent.body;return o.pipe(n,r.takeWhile(t=>t!==e),r.every(e=>Xa(e,t)))}function Qa(e){if(e.type!==`ExpressionStatement`||e.expression.type!==`AssignmentExpression`)return!1;let t=e.expression.left;if(t.type!==`MemberExpression`)return!1;for(;t.object.type===`MemberExpression`;)t=t.object;return t.object.type===`Identifier`&&(t.object.name===`exports`||t.object.name===`module`&&t.property.type===`Identifier`&&t.property.name===`exports`)}function $a(e,t){let n=t.getLastToken(e);if(n===null)throw Error(`Padding rule invariant: statement has no token`);let r=t.getTokenBefore(n),i=t.getTokenAfter(n);return r&&i&&r.range[0]>=e.range[0]&&Ha(n)&&!Ua(r,n)&&Ua(n,i)?r:n}function eo(e,t){if(Wa(e))return e.loc;let n=e.loc.start.line,r=t.lines[n-1];if(r===void 0)throw Error(`Padding rule invariant: statement source line is missing`);return{start:e.loc.start,end:{line:n,column:r.length}}}const $={"block-like":Ya,expression:(e,t)=>e.type===`ExpressionStatement`&&!Za(e,t),return:X(`ReturnStatement`,`return`),export:X([`ExportAllDeclaration`,`ExportDefaultDeclaration`,`ExportNamedDeclaration`],`export`),var:X(`VariableDeclaration`,`var`),let:X(`VariableDeclaration`,`let`),const:X(`VariableDeclaration`,`const`),using:e=>e.type===`VariableDeclaration`&&(e.kind===`using`||e.kind===`await using`),type:X(`TSTypeAliasDeclaration`,`type`)},to={"*":()=>!0,exports:Qa,require:Ja,directive:Za,iife:qa,block:Z(`BlockStatement`),empty:Z(`EmptyStatement`),function:Z(`FunctionDeclaration`),"ts-method":Z(`TSMethodSignature`),break:X(`BreakStatement`,`break`),case:X(`SwitchCase`,`case`),class:X(`ClassDeclaration`,`class`),continue:X(`ContinueStatement`,`continue`),debugger:X(`DebuggerStatement`,`debugger`),default:X([`SwitchCase`,`ExportDefaultDeclaration`],`default`),do:X(`DoWhileStatement`,`do`),for:X([`ForStatement`,`ForInStatement`,`ForOfStatement`],`for`),if:X(`IfStatement`,`if`),import:X(`ImportDeclaration`,`import`),switch:X(`SwitchStatement`,`switch`),throw:X(`ThrowStatement`,`throw`),try:X(`TryStatement`,`try`),while:X([`WhileStatement`,`DoWhileStatement`],`while`),with:X(`WithStatement`,`with`),"cjs-export":(e,t)=>e.type===`ExpressionStatement`&&e.expression.type===`AssignmentExpression`&&Ia.test(t.getText(e.expression.left)),"cjs-import":(e,t)=>e.type===`VariableDeclaration`&&e.declarations[0]?.init!=null&&i.startsWith(`require(`)(t.getText(e.declarations[0].init)),enum:X(`TSEnumDeclaration`,`enum`),interface:X(`TSInterfaceDeclaration`,`interface`),"function-overload":Z(`TSDeclareFunction`),...$,"singleline-block-like":Q($[`block-like`],`singleline`),"multiline-block-like":Q($[`block-like`],`multiline`),"singleline-expression":Q($.expression,`singleline`),"multiline-expression":Q($.expression,`multiline`),"singleline-return":Q($.return,`singleline`),"multiline-return":Q($.return,`multiline`),"singleline-export":Q($.export,`singleline`),"multiline-export":Q($.export,`multiline`),"singleline-var":Q($.var,`singleline`),"multiline-var":Q($.var,`multiline`),"singleline-let":Q($.let,`singleline`),"multiline-let":Q($.let,`multiline`),"singleline-const":Q($.const,`singleline`),"multiline-const":Q($.const,`multiline`),"singleline-using":Q($.using,`singleline`),"multiline-using":Q($.using,`multiline`),"singleline-type":Q($.type,`singleline`),"multiline-type":Q($.type,`multiline`)};function no(e){return za.has(e)}function ro(e){return Ra.has(e)}function io(e){return l.isString(e)&&n.has(to,e)}function ao(e){return r.isArray(e)}function oo(e){if(io(e))return e;if(l.isObject(e)&&l.isString(e.selector)&&r.every(n.keys(e),e=>Va.has(e))){if(!(`lineMode`in e))return{selector:e.selector};if(no(e.lineMode))return{selector:e.selector,lineMode:e.lineMode}}throw Error(`Invalid padding-line-between-statements statement matcher`)}function so(e){if(!r.isArray(e))return oo(e);let t=e;if(!r.isReadonlyArrayNonEmpty(t))throw Error(`Padding statement matcher arrays must not be empty`);return r.map(t,e=>oo(e))}function co(e){return r.map(e,e=>{if(!l.isObject(e)||!(`blankLine`in e)||!(`prev`in e)||!(`next`in e)||r.some(n.keys(e),e=>!Ba.has(e))||!ro(e.blankLine))throw Error(`Invalid padding-line-between-statements configuration`);return{blankLine:e.blankLine,prev:so(e.prev),next:so(e.next)}})}function lo(e,t,n){let r=[],i=$a(e,n);if(t.loc.start.line-i.loc.end.line>=2)do{let e=n.getTokenAfter(i,{includeComments:!0});if(e===null)throw Error(`Padding rule invariant: next statement token is missing`);e.loc.start.line-i.loc.end.line>=2&&r.push([i,e]),i=e}while(i.range[0]<t.range[0]);return r}function uo(e,t,n){return a.gen(function*(){if(n===`any`)return yield*a.void;let s=yield*ee,c=s.sourceCode,l=lo(e,t,c);return n===`never`?r.isArrayNonEmpty(l)?yield*s.report({node:t,messageId:`unexpectedBlankLine`,loc:eo(t,c),fix(e){if(l.length>=2)return null;let t=r.headNonEmpty(l),n=t[0].range[1],a=t[1].range[0];return e.replaceTextRange([n,a],o.pipe(c.text,i.slice(n,a),i.replace(Fa,`$1$2`)))}}):yield*a.void:r.isArrayNonEmpty(l)?yield*a.void:yield*s.report({node:t,messageId:`expectedBlankLine`,loc:eo(t,c),fix(n){let r=$a(e,c),i=c.getFirstTokenBetween(r,t,{includeComments:!0,filter(e){return!Ua(r,e)||(r=e,!1)}})??t;return n.insertTextAfter(r,Ua(r,i)?`
3
3
 
4
4
  `:`
5
- `)}})})}function*Ma(e,t){let n=e.sourceCode,i=r.fromIterable(new Set(o.pipe(t,r.flatMap(e=>[...r.ensure(e.prev),...r.ensure(e.next)]),r.flatMap(e=>l.isString(e)?[]:[e.selector])))),u=yield*g.make(new Map(r.map(i,e=>[e,/* @__PURE__ */ new Set]))),d=yield*g.make(r.empty()),f=yield*g.make(c.none());function p(){return g.update(f,e=>c.some({upper:e,prevNode:c.none()}))}function m(){return g.update(f,c.flatMap(e=>e.upper))}function h(e,t,i){let a=e;for(;a.type===`LabeledStatement`;)a=a.body;return Ea(t)?r.some(t,e=>h(a,e,i)):l.isString(t)?Sa[t](a,n):i.get(t.selector)?.has(a)===!0&&(t.lineMode===`singleline`?da(a):t.lineMode!==`multiline`||!da(a))}function te(e,n,i){return o.pipe(r.findLast(t,t=>h(e,t.prev,i)&&h(n,t.next,i)),c.match({onNone:()=>`any`,onSome:e=>e.blankLine}))}let _=s.type().pipe(s.when({parent:s.null},o.constant(a.void)),s.not({parent:{type:s.is(`BlockStatement`,`Program`,`StaticBlock`,`SwitchCase`,`SwitchStatement`,`TSInterfaceBody`,`TSModuleBlock`,`TSTypeLiteral`)}},o.constant(a.void)),s.orElse(e=>a.gen(function*(){let t=yield*g.get(f);if(c.isNone(t))return yield*a.die(/* @__PURE__ */ Error(`Padding rule invariant: statement scope is missing`));if(c.isSome(t.value.prevNode)){let n=t.value.prevNode.value;yield*g.update(d,t=>(t.push({prevNode:n,nextNode:e}),t))}yield*g.set(f,c.some({upper:t.value.upper,prevNode:c.some(e)}))})));function v(e){return a.andThen(_(e),p())}let ne={Program:p,"Program:exit":a.fn(`'Program:exit'`)(function*(){let e=yield*g.get(u);yield*g.get(d).pipe(a.flatMap(t=>a.all(r.map(t,({prevNode:t,nextNode:n})=>ja(t,n,te(t,n,e)))))),yield*m()}),BlockStatement:p,"BlockStatement:exit":m,SwitchStatement:p,"SwitchStatement:exit":m,SwitchCase:v,"SwitchCase:exit":m,StaticBlock:p,"StaticBlock:exit":m,TSInterfaceBody:p,"TSInterfaceBody:exit":m,TSModuleBlock:p,"TSModuleBlock:exit":m,TSTypeLiteral:p,"TSTypeLiteral:exit":m,TSDeclareFunction:v,"TSDeclareFunction:exit":m,TSMethodSignature:v,"TSMethodSignature:exit":m,":statement":_};return ee.merge(ne,...r.map(i,e=>ee.on(e,t=>g.update(u,n=>(n.get(e)?.add(t),n)))))}const Na={"alchemy-domain-block-file-name":Oe,"alchemy-domain-pure-decide":Ne,"alchemy-domain-pure-imports":Re,"alchemy-domain-require-view-version":ze,"alchemy-domain-total-handlers":Ue,"alchemy-no-cloudflare-init-finalizer":Xe,"alchemy-no-deprecated-docker-constraints":$e,"alchemy-no-deprecated-resource":tt,"alchemy-no-plaintext-github-secret":rt,"alchemy-no-removed-config-api":it,"alchemy-no-reserved-eventbridge-default-name":at,"alchemy-no-runtime-config":ot,"alchemy-no-v1-import":ct,"alchemy-no-v1-worker-properties":ut,"avoid-data-tagged-error":dt,"ban-error-string":ht,"consistent-schema-pipe":Kt,"cors-credentials-with-wildcard":an,"dual-numeric-arity-with-optional-parameter":sn,"effect-promise-vs-trypromise":cn,"no-already-started-promise":un,"no-async-effect-try":dn,"no-discarded-run-promise":fn,"no-discarded-schema-checks":hn,"no-effect-as-on-log":Fn,"no-empty-effect-callback":In,"no-empty-schema-struct":Ln,"no-effect-alchemy-barrel-imports":Dn,"no-function-config-default":Bn,"no-hash-as-identity":Un,"no-inline-schema-compile":or,"no-logging-in-catch":ur,"no-manual-effect-error-tag":gr,"no-manual-tag-comparison":_r,"no-manual-tagged-construction":vr,"no-multi-shot-effect-callback":xr,"no-non-json-schema-annotation":Or,"no-option-of-service":Ar,"no-overwritten-discriminant":jr,"no-service-option-get-or-throw":Ir,"no-service-constructor-imports":Pr,"no-throw-in-effect-callback":Rr,"no-uppercase-http-api-header":Ur,"no-zero-retry-times":Wr,"padding-line-between-statements":m.define({name:`padding-line-between-statements`,meta:{type:`layout`,docs:{description:`Require or disallow padding lines between statements`,url:`https://eslint.style/rules/padding-line-between-statements`,recommended:!0},fixable:`whitespace`,schema:{type:`array`,items:{type:`object`,properties:{blankLine:{enum:[`any`,`never`,`always`]},prev:{$ref:`#/$defs/statementOption`},next:{$ref:`#/$defs/statementOption`}},required:[`blankLine`,`prev`,`next`],additionalProperties:!1},$defs:{statementMatcher:{anyOf:[{type:`string`,enum:n.keys(Sa)},{type:`object`,properties:{selector:{type:`string`},lineMode:{enum:[`any`,`singleline`,`multiline`]}},required:[`selector`],additionalProperties:!1}]},statementOption:{anyOf:[{$ref:`#/$defs/statementMatcher`},{type:`array`,items:{$ref:`#/$defs/statementMatcher`},minItems:1,uniqueItems:!0}]}}},messages:{unexpectedBlankLine:`Unexpected blank line before this statement.`,expectedBlankLine:`Expected blank line before this statement.`}},*create(){let e=yield*h;return yield*Ma(e,ka(e.options))}}),"prefer-effect-alchemy-namespace-imports":Gr,"prefer-effect-array-sort":Kr,"prefer-effect-datetime":Jr,"prefer-effect-duration":ci,"prefer-effect-duration-constants":xi,"prefer-effect-encoding":wi,"prefer-effect-filesystem":Ei,"prefer-effect-filter":ki,"prefer-effect-headers":Ai,"prefer-effect-match":Ni,"prefer-effect-path":Fi,"prefer-effect-url":Li,"prefer-uninterruptible":zi,"prefer-with-span":Bi,"prefer-yield-now":Hi,"preserve-caught-error":Gi,"require-schema-class-brand":Ki,"require-try-promise-abort-signal":Ji,"throw-in-effect-gen":$i},Pa=/* @__PURE__ */ new Set([`prefer-effect-filesystem`,`prefer-effect-path`]),Fa=n.mapEntries(n.filter(Na,(e,t)=>!Pa.has(t)),(e,t)=>[`2digits/${t}`,`error`]),Ia=t({meta:{name:`@2digits/oxlint-plugin`},rules:Na});export{Ia as default,Fa as recommendedRules,Na as rules};
5
+ `)}})})}function*fo(e,t){let n=e.sourceCode,i=r.fromIterable(new Set(o.pipe(t,r.flatMap(e=>[...r.ensure(e.prev),...r.ensure(e.next)]),r.flatMap(e=>l.isString(e)?[]:[e.selector])))),u=yield*g.make(new Map(r.map(i,e=>[e,/* @__PURE__ */ new Set]))),d=yield*g.make(r.empty()),f=yield*g.make(c.none());function p(){return g.update(f,e=>c.some({upper:e,prevNode:c.none()}))}function m(){return g.update(f,c.flatMap(e=>e.upper))}function h(e,t,i){let a=e;for(;a.type===`LabeledStatement`;)a=a.body;return ao(t)?r.some(t,e=>h(a,e,i)):l.isString(t)?to[t](a,n):i.get(t.selector)?.has(a)===!0&&(t.lineMode===`singleline`?Wa(a):t.lineMode!==`multiline`||!Wa(a))}function ee(e,n,i){return o.pipe(r.findLast(t,t=>h(e,t.prev,i)&&h(n,t.next,i)),c.match({onNone:()=>`any`,onSome:e=>e.blankLine}))}let ne=s.type().pipe(s.when({parent:s.null},o.constant(a.void)),s.not({parent:{type:s.is(`BlockStatement`,`Program`,`StaticBlock`,`SwitchCase`,`SwitchStatement`,`TSInterfaceBody`,`TSModuleBlock`,`TSTypeLiteral`)}},o.constant(a.void)),s.orElse(e=>a.gen(function*(){let t=yield*g.get(f);if(c.isNone(t))return yield*a.die(/* @__PURE__ */ Error(`Padding rule invariant: statement scope is missing`));if(c.isSome(t.value.prevNode)){let n=t.value.prevNode.value;yield*g.update(d,t=>(t.push({prevNode:n,nextNode:e}),t))}yield*g.set(f,c.some({upper:t.value.upper,prevNode:c.some(e)}))})));function _(e){return a.andThen(ne(e),p())}let v={Program:p,"Program:exit":a.fn(`'Program:exit'`)(function*(){let e=yield*g.get(u);yield*g.get(d).pipe(a.flatMap(t=>a.all(r.map(t,({prevNode:t,nextNode:n})=>uo(t,n,ee(t,n,e)))))),yield*m()}),BlockStatement:p,"BlockStatement:exit":m,SwitchStatement:p,"SwitchStatement:exit":m,SwitchCase:_,"SwitchCase:exit":m,StaticBlock:p,"StaticBlock:exit":m,TSInterfaceBody:p,"TSInterfaceBody:exit":m,TSModuleBlock:p,"TSModuleBlock:exit":m,TSTypeLiteral:p,"TSTypeLiteral:exit":m,TSDeclareFunction:_,"TSDeclareFunction:exit":m,TSMethodSignature:_,"TSMethodSignature:exit":m,":statement":ne};return te.merge(v,...r.map(i,e=>te.on(e,t=>g.update(u,n=>(n.get(e)?.add(t),n)))))}const po={"alchemy-domain-block-file-name":Oe,"alchemy-domain-pure-decide":Ne,"alchemy-domain-pure-imports":Re,"alchemy-domain-require-view-version":ze,"alchemy-domain-total-handlers":Ue,"alchemy-no-cloudflare-init-finalizer":Xe,"alchemy-no-deprecated-docker-constraints":$e,"alchemy-no-deprecated-resource":tt,"alchemy-no-plaintext-github-secret":rt,"alchemy-no-removed-config-api":it,"alchemy-no-reserved-eventbridge-default-name":at,"alchemy-no-runtime-config":ot,"alchemy-no-v1-import":ct,"alchemy-no-v1-worker-properties":ut,"avoid-data-tagged-error":dt,"ban-error-string":ht,"consistent-schema-pipe":Kt,"cors-credentials-with-wildcard":sn,"dual-numeric-arity-with-optional-parameter":ln,"effect-promise-vs-trypromise":un,"no-already-started-promise":fn,"no-async-effect-try":pn,"no-discarded-run-promise":mn,"no-discarded-schema-checks":_n,"no-effect-as-on-log":Ln,"no-empty-effect-callback":Rn,"no-empty-schema-struct":zn,"no-effect-alchemy-barrel-imports":kn,"no-function-config-default":Hn,"no-hash-as-identity":Gn,"no-inline-schema-compile":cr,"no-logging-in-catch":fr,"no-manual-effect-error-tag":yr,"no-manual-tag-comparison":br,"no-manual-tagged-construction":xr,"no-millis-arithmetic":$r,"no-multi-shot-effect-callback":ni,"no-non-json-schema-annotation":li,"no-option-of-service":di,"no-overwritten-discriminant":fi,"no-service-option-get-or-throw":_i,"no-service-constructor-imports":hi,"no-throw-in-effect-callback":yi,"no-uppercase-http-api-header":wi,"no-zero-retry-times":Ti,"padding-line-between-statements":h.define({name:`padding-line-between-statements`,meta:{type:`layout`,docs:{description:`Require or disallow padding lines between statements`,url:`https://eslint.style/rules/padding-line-between-statements`,recommended:!0},fixable:`whitespace`,schema:{type:`array`,items:{type:`object`,properties:{blankLine:{enum:[`any`,`never`,`always`]},prev:{$ref:`#/$defs/statementOption`},next:{$ref:`#/$defs/statementOption`}},required:[`blankLine`,`prev`,`next`],additionalProperties:!1},$defs:{statementMatcher:{anyOf:[{type:`string`,enum:n.keys(to)},{type:`object`,properties:{selector:{type:`string`},lineMode:{enum:[`any`,`singleline`,`multiline`]}},required:[`selector`],additionalProperties:!1}]},statementOption:{anyOf:[{$ref:`#/$defs/statementMatcher`},{type:`array`,items:{$ref:`#/$defs/statementMatcher`},minItems:1,uniqueItems:!0}]}}},messages:{unexpectedBlankLine:`Unexpected blank line before this statement.`,expectedBlankLine:`Expected blank line before this statement.`}},*create(){let e=yield*ee;return yield*fo(e,co(e.options))}}),"prefer-effect-alchemy-namespace-imports":Ei,"prefer-effect-array-sort":Di,"prefer-effect-datetime":ki,"prefer-effect-duration":Ai,"prefer-effect-duration-constants":Hi,"prefer-effect-duration-types":ea,"prefer-effect-encoding":ra,"prefer-effect-filesystem":aa,"prefer-effect-filter":ca,"prefer-effect-headers":la,"prefer-effect-match":fa,"prefer-effect-path":ma,"prefer-effect-url":ga,"prefer-uninterruptible":va,"prefer-with-span":ya,"prefer-yield-now":xa,"preserve-caught-error":wa,"require-schema-class-brand":Ta,"require-try-promise-abort-signal":Da,"throw-in-effect-gen":Ma},mo=/* @__PURE__ */ new Set([`prefer-effect-filesystem`,`prefer-effect-path`]),ho=n.mapEntries(n.filter(po,(e,t)=>!mo.has(t)),(e,t)=>[`2digits/${t}`,`error`]),go=t({meta:{name:`@2digits/oxlint-plugin`},rules:po});export{go as default,ho as recommendedRules,po as rules};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@2digits/oxlint-plugin",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Custom Oxlint rules for 2digits projects.",
5
5
  "keywords": [
6
6
  "2digits",
@@ -28,20 +28,20 @@
28
28
  "access": "public"
29
29
  },
30
30
  "dependencies": {
31
- "@oxlint/plugins": "1.91.0",
31
+ "@oxlint/plugins": "1.92.0",
32
32
  "effect": "4.1.2",
33
33
  "effect-oxlint": "0.4.0"
34
34
  },
35
35
  "devDependencies": {
36
- "@2digits/tsconfig": "1.2.4",
36
+ "@2digits/tsconfig": "1.2.6",
37
37
  "@arethetypeswrong/core": "0.18.5",
38
38
  "@effect/platform-node": "4.1.2",
39
39
  "@effect/vitest": "4.1.2",
40
40
  "@typescript/native-preview": "7.0.0-dev.20260707.2",
41
41
  "dedent": "1.7.2",
42
- "oxlint": "1.91.0",
42
+ "oxlint": "1.92.0",
43
43
  "publint": "0.3.25",
44
- "tsrs": "0.21.0-ts7.1.0-beta",
44
+ "tsrs": "0.23.0-ts7.1.0-beta",
45
45
  "typescript": "7.1.0-beta",
46
46
  "vite-plus": "1.5.0",
47
47
  "vitest": "5.1.0"