@2digits/oxlint-plugin 0.4.2 → 0.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.mjs +1 -1
  2. package/package.json +4 -4
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
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/Effect";import*as a from"effect/Function";import*as o from"effect/Match";import*as s from"effect/Option";import*as c from"effect/Predicate";import*as l from"effect/Schema";import*as u from"effect/String";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 l.Class(`FileState`)({bindings:l.ReadonlyMap(l.String,l.Array(l.String)).pipe(l.withConstructorDefault(i.succeed(/* @__PURE__ */ new Map))),hasEffectImport:l.Boolean.pipe(l.withConstructorDefault(i.succeed(!1)))}){};const ne=te.make(),_=o.type().pipe(o.discriminatorsExhaustive(`type`)({Identifier:({name:e})=>e,Literal:({value:e})=>e}));function re(e){let t=r.lastNonEmpty(u.split(e,`/`));return/^\p{Ll}/u.test(t)?[]:[t]}const ie=o.type().pipe(o.withReturnType(),o.when(`alchemy`,a.constant([`Alchemy`])),o.when(o.is(`effect`,`@effect/platform`),a.constant([])),o.whenOr(u.startsWith(`effect/`),u.startsWith(`alchemy/`),u.startsWith(`@effect/`),re),o.orElse(a.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`||u.startsWith(`effect/`)(e)||u.startsWith(`@effect/`)(e))&&(n=!0);let i=ie(e);if(i!==void 0)for(let e of r.specifiers)e.type===`ImportNamespaceSpecifier`||e.type===`ImportDefaultSpecifier`?t.set(e.local.name,i):t.set(e.local.name,[...i,_(e.imported)])}return te.make({bindings:t,hasEffectImport:n})}function v(t,n){return e({meta:t,createOnce:n})}function y(t,n){return e({meta:t,createOnce(e){let t=ne,{before:r,Program:i,...a}=n(e,()=>t);return{before(){t=ne,r?.()},Program(e){t=ae(e),i?.(e)},...a}}})}function b(e,t,n,r){return{type:e,docs:{description:t,recommended:!0,...r===void 0?{}:{url:r}},schema:[],messages:n}}const x=o.type().pipe(o.when({computed:!1,property:{type:`Identifier`}},({property:e})=>e.name),o.when({computed:!0,property:{type:`Literal`,value:u.isString}},({property:e})=>e.value),o.orElse(a.constUndefined));function S(e){let t=[],n=e;for(;n.type===`ChainExpression`||n.type===`MemberExpression`;){if(n.type===`ChainExpression`){n=n.expression;continue}let e=x(n);if(e===void 0)return;t.unshift(e),n=n.object}return n.type===`Identifier`?[n.name,...t]:void 0}function C(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 oe(e){return e?.defs.length===1?e.defs[0]:void 0}function w(e,t,n){return e.type===`Identifier`&&e.name===n&&C(t,e,n)===void 0}function T(e,t){let n=S(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 E(e,t,n,r){let i=T(e,t);return i?.length===2&&i[0]===n&&i[1]===r}function D(e,t,n,i){let a=T(e,t);return a?.length===2&&a[0]===n&&r.contains(i,a[1])}function O(e,t,n){let i=T(e,t);return i?.length===n.length&&r.every(i,(e,t)=>e===n[t])}const se=o.type().pipe(o.when({type:o.is(`ArrowFunctionExpression`,`FunctionExpression`)},a.constTrue),o.orElse(a.constFalse));function k(e){return se(e)}function A(e,t){let n=e.arguments[t];return n===void 0||n.type===`SpreadElement`?void 0:n}const j=o.type().pipe(o.when({computed:!1,key:{type:`Identifier`}},({key:e})=>e.name),o.when({key:{type:`Literal`,value:u.isString}},({key:e})=>e.value),o.orElse(a.constUndefined));function M(e,t){return s.getOrUndefined(r.findFirst(e.properties,e=>e.type===`Property`&&j(e)===t))}const ce=/* @__PURE__ */ new Set([`ParenthesizedExpression`,`TSAsExpression`,`TSNonNullExpression`,`TSSatisfiesExpression`,`TSTypeAssertion`]);function le(e){return ce.has(e.type)}const ue=/* @__PURE__ */ new Set([`loc`,`parent`,`range`]);function N(e){let t=e;for(;le(t);)t=t.expression;return t}function de(e,t){if(r.isArray(e))for(let n of e)t.push(n);else for(let[r,i]of n.toEntries(e))ue.has(r)||t.push(i)}function P(e,t){let n=[e],r=/* @__PURE__ */ new WeakSet;for(;n.length>0;){let e=n.pop();if(c.isObjectOrArray(e)&&!r.has(e)){if(r.add(e),c.hasProperty(e,`type`)&&c.isString(e.type)&&t(e)===!0)return!0;de(e,n)}}return!1}function fe(e,t){return P(e,e=>e.type===`Identifier`&&e.name===t)}function F(e){let t=e.params[0];return t?.type===`Identifier`?t:void 0}function pe(e){let t=F(e);return t===void 0||!e.body||u.startsWith(`_`)(t.name)?!1:fe(e.body,t.name)}function me(e,t){for(let n=e.parent;n;n=n.parent)if(t(n))return n}function I(e){return me(e,k)}function L(e){let t=e.parent;if(t.type===`CallExpression`&&t.arguments.includes(e))return t}function he(e,t){return e.range[0]<=t.range[0]&&t.range[1]<=e.range[1]}function R(e){return e.type===`Literal`&&u.isString(e.value)}const ge=/* @__PURE__ */ new Set([`==`,`===`,`!=`,`!==`]);function _e(e){return ge.has(e)}function z(e,t){return e.type===`Literal`&&e.value===t}function ve(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 ye=c.mapInput(c.compose(c.isString,u.endsWith(`Error`)),e=>S(e.callee)?.at(-1)),be=/* @__PURE__ */ new Set([`alarm`,`fetch`,`queue`,`rpc`,`scheduled`,`tail`,`trace`,`webSocketClose`,`webSocketError`,`webSocketMessage`]),xe=[[`Cloudflare`,`Worker`],[`Cloudflare`,`Workers`,`Worker`]];function Se(e,t){return r.some(xe,n=>O(e,t,n))}function Ce(e,t){return me(e,e=>e.type===`CallExpression`&&Se(e.callee,t))}function we(e,t){let n=I(e),r=n===void 0?void 0:L(n);return r!==void 0&&E(r.callee,t,`Effect`,`gen`)?r:void 0}function Te(e){let t=e.parent;for(;t;){if(k(t))return;if(t.type===`Property`){let e=j(t);if(e!==void 0&&be.has(e))return e}t=t.parent}}const Ee=y(b(`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(!E(n.callee,r,`Effect`,`addFinalizer`))return;let i=we(n,r);i!==void 0&&Ce(i,r)?.arguments.includes(i)&&e.report({node:n,messageId:`finalizer`})}}));function B(e,t){let n=S(t)?.[0],i=n===void 0?void 0:C(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 De(e,t,n,i,a){let o=e.sourceCode.ast,c=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(C(e,t,n.local.name)?.defs??[],e=>e.node===n));if(s.isSome(c))return{name:c.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=s.getOrUndefined(r.findFirst(o.body,e=>e.type!==`ExpressionStatement`||!R(e.expression)));return{name:u,fixes:[p===void 0?a.insertTextAfter(o,`\n${f}`):a.insertTextBefore(p,f)]}}function Oe(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 ke=y({...b(`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(!E(n.callee,t(),`Docker`,`Service`))return;let r=A(n,1),i=r?.type===`ObjectExpression`?M(r,`constraints`):void 0;i!==void 0&&e.report({node:i,messageId:`constraints`,fix(t){if(B(e,n.callee)&&r?.type===`ObjectExpression`&&Oe(r,`placement`))return t.replaceText(i,`placement: { ${e.sourceCode.getText(i)} }`)}})}})),Ae=/* @__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`]]),je=y(b(`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=T(n.callee,t());if(i===void 0)return;let a=r.join(i,`.`),o=Ae.get(a);o!==void 0&&e.report({node:n.callee,messageId:`deprecated`,data:{api:a,replacement:o}})}}));function Me(e,t){let n=N(e);if(R(n)||n.type===`TemplateLiteral`)return!0;let r=S(n);return r?.[0]===`process`&&r[1]===`env`||n.type===`CallExpression`&&E(n.callee,t,`Config`,`string`)}const Ne=y(b(`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(!E(n.callee,r,`GitHub`,`Secret`))return;let i=A(n,1),a=i?.type===`ObjectExpression`?M(i,`value`):void 0;a!==void 0&&Me(a.value,r)&&e.report({node:a.value,messageId:`plaintext`})}})),Pe=y(b(`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=T(n.callee,t());r?.[0]===`Alchemy`&&(r[1]===`Secret`||r[1]===`Variable`)&&e.report({node:n.callee,messageId:`removed`,data:{api:r[1]}})}})),Fe=y(b(`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(!O(n.callee,t(),[`AWS`,`EventBridge`,`EventBus`]))return;let r=A(n,1),i=r?.type===`ObjectExpression`?M(r,`name`):void 0;i!==void 0&&z(i.value,`default`)&&e.report({node:i.value,messageId:`reserved`})}})),Ie=y(b(`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`||T(i.callee,r)?.[0]!==`Config`)return;let a=we(n,r);if(a===void 0)return;let o=Te(a);o!==void 0&&Ce(a,r)!==void 0&&e.report({node:i,messageId:`runtime`,data:{handler:o}})}})),Le=/* @__PURE__ */ new Map([[`alchemy/aws`,`alchemy/AWS`],[`alchemy/cloudflare`,`alchemy/Cloudflare`]]),Re=v(b(`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=s.getOrUndefined(r.findFirst(t.specifiers,e=>e.type===`ImportDefaultSpecifier`));n!==void 0&&e.report({node:n,messageId:`defaultImport`});return}let i=Le.get(n);i!==void 0&&e.report({node:t.source,messageId:`providerImport`,data:{replacement:i}})}})),ze=[[`entrypoint`,`main`],[`bindings`,`env`]],Be=y({...b(`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(!Se(n.callee,t()))return;let r=A(n,1);if(r?.type===`ObjectExpression`)for(let[t,i]of ze){let a=M(r,t);a!==void 0&&e.report({node:a,messageId:`property`,data:{old:t,replacement:i},fix(o){if(B(e,n.callee)&&Oe(r,i))return o.replaceText(a.key,a.shorthand?`${i}: ${t}`:i)}})}}})),Ve=y(b(`suggestion`,`Prefer schema-based tagged errors so errors have a serializable contract.`,{taggedError:`Prefer Schema.TaggedError over Data.TaggedError.`}),(e,t)=>({CallExpression(n){E(n.callee,t(),`Data`,`TaggedError`)&&e.report({node:n.callee,messageId:`taggedError`})}})),He=/* @__PURE__ */ new Set([`error`,`err`,`e`,`cause`,`exception`,`ex`]);function Ue(e){return e?.type===`Identifier`&&He.has(e.name)?e.name:void 0}function We(e){if(e.type!==`CallExpression`||e.arguments.length!==1)return!1;let t=S(e.callee);return t?.at(-1)===`String`&&t.length<=2}const Ge=v({...b(`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=A(t,0);if(n===void 0||!We(n)||!ye(t))return;let r=A(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(We(t)){if(t.parent.type===`NewExpression`&&t.parent.arguments[0]===t&&ye(t.parent))return;let n=Ue(t.arguments[0]);n!==void 0&&e.report({node:t,messageId:`errorString`,data:{name:n}});return}if(t.callee.type!==`MemberExpression`||S(t.callee)?.at(-1)!==`toString`||t.arguments.length>0)return;let n=Ue(t.callee.object);n!==void 0&&e.report({node:t,messageId:`errorString`,data:{name:n}})},TemplateLiteral(t){let[n,r]=t.quasis,i=Ue(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}})}})),Ke=/* @__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.toCodecIso.toCodecJson.toCodecStringTree.toEncoded.toType.UndefinedOr`.split(`.`)),qe=/* @__PURE__ */ new Set([`Array`,`ArrayEnsure`,`Chunk`,`HashSet`,`NonEmptyArray`,`Option`,`ReadonlySet`,`Redacted`,`Tree`,`UniqueArray`]),Je=/* @__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(`.`)),Ye=/* @__PURE__ */ new Set([`annotate`,`annotateKey`,`check`,`mapFields`]),Xe=/* @__PURE__ */ new Set([`CallExpression`,`Identifier`,`MemberExpression`,`ThisExpression`]),Ze=/^\p{Lu}/u;function V(e,t,n){let r=T(e,n);return S(e)?.length===2&&r?.length===2&&r[0]===`Schema`&&B(t,e)?r[1]:void 0}function Qe(e){return e!==void 0&&qe.has(e)}function $e(e){return e!==void 0&&(Ke.has(e)||qe.has(e))}const et=/* @__PURE__ */ new Set([`ArrowFunctionExpression`,`FunctionExpression`,`Identifier`,`Literal`,`ThisExpression`]);function tt(e,t,n){return r.every(e,e=>e===null||H(e,t,n))}function H(e,t,n){if(et.has(e.type))return!0;if(e.type===`MemberExpression`)return H(e.object,t,n)&&(!e.computed||H(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`?H(e.argument,t,n):(!e.computed||H(e.key,t,n))&&H(e.value,t,n));if(e.type!==`CallExpression`)return!1;let i=e.callee.type===`CallExpression`?e.callee.callee:e.callee;return V(i,t,n)!==void 0&&(e.callee===i||H(e.callee,t,n))&&tt(e.arguments,t,n)}function nt(e,t){if(e.type===`Identifier`)return t.bindings.get(e.name);if(e.type!==`TSQualifiedName`)return;let n=nt(e.left,t);return n===void 0?void 0:[...n,e.right.name]}function rt(e,t){for(let n=t.parent;n!==null;n=n.parent){let t=`typeParameters`in n&&n.typeParameters?.type===`TSTypeParameterDeclaration`?a.pipe(n.typeParameters.params,r.findFirst(t=>t.name.name===e),s.getOrUndefined):void 0;if(t!==void 0)return t}}function it(e,t,n){let r=/* @__PURE__ */ new Set,i=e,a=t;for(;i?.type===`TSTypeReference`;){let e=nt(i.typeName,n),t=e?.length===2&&e[0]===`Schema`?e[1]:void 0;if(t!==void 0)return!u.startsWith(`Constraint`)(t);let o=i.typeName.type===`Identifier`?rt(i.typeName.name,a):void 0;if(o===void 0||r.has(o))return r.size===0&&void 0;r.add(o),i=o.constraint,a=o}return r.size===0&&void 0}function at(e,t){let n=C(t,e,e.name)?.defs[0]?.name;return n!==void 0&&`typeAnnotation`in n?n.typeAnnotation??void 0:void 0}function ot(e,t,n){let r=e;for(;r.type===`TSSatisfiesExpression`||r.type===`TSNonNullExpression`;)r=r.expression;if(r.type===`TSAsExpression`)return it(r.typeAnnotation,r,n)===!1;let i=r.type===`Identifier`?at(r,t):void 0;return i!==void 0&&it(i.typeAnnotation,i,n)===!1}function st(e){return r.some(e.arguments,e=>e.type===`SpreadElement`)}function ct(e){let[t]=e.arguments;return e.arguments.length===1&&t?.type!==`SpreadElement`&&!e.typeArguments?t:void 0}function lt(e){return e.callee.type===`MemberExpression`&&!e.callee.optional&&x(e.callee)===`pipe`&&!e.typeArguments&&!st(e)}function ut(e,t,n){return(O(e.callee,n,[`pipe`])||O(e.callee,n,[`Function`,`pipe`]))&&B(t,e.callee)}function dt(e,t,n){return $e(V(e,t,n))?!0:e.type===`CallExpression`&&Je.has(V(e.callee,t,n)??``)}function ft(e,t,n){if(Ze.test(V(e,t,n)??``)||U(e,t,n)!==void 0)return!0;if(e.type!==`CallExpression`)return!1;let r=V(e.callee,t,n);return r===void 0?e.callee.type===`MemberExpression`&&Ye.has(x(e.callee)??``)&&ft(e.callee.object,t,n):Ze.test(r)||$e(r)}function pt(e,t,n){let[r,i]=e.arguments;if(!(r===void 0||i===void 0||r.type===`SpreadElement`||e.typeArguments||st(e)||!ft(r,t,n)&&!dt(i,t,n)))return[r,e.arguments.slice(1)]}function mt(e,t,n,r,i,a){let o=vt(e,i,a);return{head:o.head,steps:[...o.steps,t],violation:o.violation??n,reordersEffects:o.reordersEffects||r}}function ht(e,t,n){let r=ct(e);if(r===void 0)return;let i=V(e.callee,t,n);if($e(i)){let a=Qe(i);return mt(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`?V(e.callee.callee,t,n):void 0;if(a!==void 0&&Je.has(a))return mt(r,{text:t.sourceCode.getText(e.callee),wrapper:!1},{kind:`dataLastCall`,name:a},!H(e.callee,t,n)&&!H(r,t,n),t,n)}function gt(e,t,n){let i=ut(e,t,n),o=i?pt(e,t,n):lt(e)?[e.callee.object,e.arguments]:void 0;if(o===void 0)return;let[c,l]=o,u=r.map(l,e=>V(e,t,n)),d=a.pipe(u,r.findFirst(Qe),s.getOrUndefined),f=d!==void 0&&r.some(l.slice(u.indexOf(d)+1),e=>!H(e,t,n));return _t(c,r.map(l,(e,n)=>({text:t.sourceCode.getText(e),wrapper:Qe(u[n])})),i?{kind:`functionPipe`}:d===void 0?void 0:{kind:`wrapperPipe`,name:d},f,t,n)}function _t(e,t,n,r,i,a){let o=vt(e,i,a);return{head:o.head,steps:[...o.steps,...t],violation:o.violation??n,reordersEffects:o.reordersEffects||r}}function U(e,t,n){return e.type===`CallExpression`?ht(e,t,n)??gt(e,t,n):void 0}function vt(e,t,n){return U(e,t,n)??{head:e,steps:[],violation:void 0,reordersEffects:!1}}function yt(e,t,n){let r=e.parent;return r.type===`MemberExpression`&&r.object===e&&r.parent.type===`CallExpression`?r.parent.callee===r&&lt(r.parent):r.type===`CallExpression`&&r.arguments[0]===e&&(ut(r,t,n)||!lt(r))&&U(r,t,n)!==void 0}function bt(e,t,n){return r.isReadonlyArrayNonEmpty(t)?`${e===`\0`&&!Xe.has(n.type)?`(\0)`:e}.pipe(${r.join(t,`, `)})`:e}function xt(e,t){let n=`\0`,r=[];for(let i of t)if(i.wrapper){let t=bt(n,r,e),a=t===`\0`&&e.type===`SequenceExpression`?`(${t})`:t;n=`${i.text}(${a})`,r=[]}else r.push(i.text);return bt(n,r,e)}const St=y({...b(`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 i=t();if(!i.hasEffectImport)return;let a=U(n,e,i);if(a?.violation===void 0||yt(n,e,i))return;let{head:o}=a;if(a.steps[0]?.wrapper===!1&&ot(o,e,i))return;let s=r.some(e.sourceCode.getCommentsInside(n),e=>!he(o,e)),[c,l=``]=u.split(xt(o,a.steps),`\0`);e.report({node:n,messageId:a.violation.kind,data:{name:a.violation.name??``},fix:s||a.reordersEffects?void 0:e=>[e.replaceTextRange([n.range[0],o.range[0]],c),e.replaceTextRange([o.range[1],n.range[1]],l)]})}}));function Ct(e){return s.getOrUndefined(r.findFirst(e.arguments,e=>e.type===`ObjectExpression`))}function wt(e,t){let n=e.parent;if(n.type!==`Property`||j(n)!==t)return;let r=n.parent,i=r.parent;return r.type===`ObjectExpression`&&i?.type===`CallExpression`?i:void 0}function Tt(e,t){let n=L(e);return n===void 0?void 0:T(n.callee,t)}const Et=/* @__PURE__ */ new Set([`catch`,`finally`,`then`]);function Dt(e){let t=S(e.callee);return t!==void 0&&r.join(t,`.`)===`Promise`}function Ot(e){let t=S(e.callee);return t!==void 0&&r.join(t,`.`)===`fetch`||t?.[0]===`Promise`&&t[1]!==`withResolvers`||Et.has(t?.at(-1)??``)||k(e.callee)&&e.callee.async}const kt=o.type().pipe(o.discriminators(`type`)({CallExpression:Ot,NewExpression:Dt}),o.orElse(a.constFalse));function At(e){return kt(N(e))}function jt(e){if(e.body){if(e.body.type!==`BlockStatement`)return N(e.body);if(e.body.body.length===1&&e.body.body[0]?.type===`ReturnStatement`&&e.body.body[0].argument)return N(e.body.body[0].argument)}}function Mt(e){let t=e?.type===`ObjectExpression`?M(e,`try`)?.value:e;return k(t)?t:void 0}function Nt(e){let t=N(e);return z(t,`*`)?!0:t.type===`ArrayExpression`&&(t.elements.length===0||r.some(t.elements,e=>e!==null&&z(e,`*`)))}const Pt=y(b(`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(!E(n.callee,r,`HttpMiddleware`,`cors`)&&!E(n.callee,r,`HttpRouter`,`cors`)&&!E(n.callee,r,`HttpApiBuilder`,`middlewareCors`))return;let i=Ct(n);if(i===void 0||!z(M(i,`credentials`)?.value??i,!0))return;let a=M(i,`allowedOrigins`);(a===void 0||Nt(a.value))&&e.report({node:n,messageId:`wildcard`})}}));function Ft(e){return e.type===`AssignmentPattern`||e.type===`RestElement`||e.optional===!0}const It=y(b(`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=A(n,0),a=A(n,1);a!==void 0&&E(n.callee,t(),`Function`,`dual`)&&i?.type===`Literal`&&c.isNumber(i.value)&&k(a)&&r.some(a.params,Ft)&&e.report({node:i,messageId:`unsafeArity`})}})),Lt=y(b(`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){E(n.callee,t(),`Effect`,`promise`)&&e.report({node:n.callee,messageId:`tryPromise`})}}));function Rt(e,t){if(D(e.callee,t,`Effect`,[`promise`,`tryPromise`]))return Mt(A(e,0))}const zt=y(b(`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&&At(e.init)&&n.add(e.id.name)},CallExpression(r){let i=Rt(r,t()),a=i===void 0?void 0:jt(i);a?.type===`Identifier`&&n.has(a.name)&&e.report({node:a,messageId:`prestarted`})}}}),Bt=y(b(`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(!E(n.callee,t(),`Effect`,`try`))return;let r=A(n,0),i=r!==void 0&&k(r)?r:void 0;if(i===void 0&&r?.type===`ObjectExpression`){let e=M(r,`try`)?.value;e!==void 0&&k(e)&&(i=e)}let a=i===void 0?void 0:jt(i);i!==void 0&&(i.async||a!==void 0&&At(a))&&e.report({node:i,messageId:`asyncTry`})}})),Vt=y(b(`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=E(n.callee,r,`Effect`,`runPromise`),a=n.callee.type===`CallExpression`&&E(n.callee.callee,r,`Effect`,`runPromiseWith`);(i||a)&&ve(n)&&e.report({node:n,messageId:`discarded`})}})),Ht=/* @__PURE__ */ new Set([`mapElements`,`mapFields`,`mapMembers`]);function Ut(e,t){let n=N(e);if(n.type===`CallExpression`&&n.callee.type===`MemberExpression`&&x(n.callee)===t)return n}const Wt=y(b(`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=x(n.callee);i!==void 0&&Ht.has(i)&&Ut(n.callee.object,`check`)!==void 0&&(r.findFirst(n.arguments,e=>e.type===`ObjectExpression`).pipe(s.flatMapNullishOr(e=>M(e,`unsafePreserveChecks`)),s.exists(e=>z(e.value,!0)))||e.report({node:n,messageId:`discarded`,data:{method:i}}))}})),Gt={Array:`Arr`,Boolean:`Bool`,Equal:`Eq`,Function:`Fn`,Number:`Num`,Option:`Opt`,Predicate:`P`,Record:`R`,String:`Str`},Kt=/^\p{Lu}[^_]*$/u;function qt(e){return Kt.test(e)}function Jt(e){return e===`@effect/vitest`||u.startsWith(`@effect/vitest/`)(e)}function W(e,t){return e.importKind===`type`||t?.importKind===`type`}function Yt(e){return s.getOrElse(n.get(Gt,e),()=>e)}function Xt(e,t){if(e===`effect`||e===`alchemy`||/^@effect\/[^/]+$/u.test(e)&&!Jt(e))return`${e}/${t}`}function Zt(e){if(Jt(e)||!(u.startsWith(`effect/`)(e)||u.startsWith(`alchemy/`)(e)||/^@effect\/[^/]+\//u.test(e)))return;let t=r.lastNonEmpty(u.split(e,`/`));return qt(t)?t:void 0}function Qt(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=_(n.imported),i=qt(r)&&!W(t,n)?Xt(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,`
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/Effect";import*as a from"effect/Function";import*as o from"effect/Match";import*as s from"effect/Option";import*as c from"effect/Predicate";import*as l from"effect/Schema";import*as u from"effect/String";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 l.Class(`FileState`)({bindings:l.ReadonlyMap(l.String,l.Array(l.String)).pipe(l.withConstructorDefault(i.succeed(/* @__PURE__ */ new Map))),hasEffectImport:l.Boolean.pipe(l.withConstructorDefault(i.succeed(!1)))}){};const ne=te.make(),_=o.type().pipe(o.discriminatorsExhaustive(`type`)({Identifier:({name:e})=>e,Literal:({value:e})=>e}));function re(e){let t=r.lastNonEmpty(u.split(e,`/`));return/^\p{Ll}/u.test(t)?[]:[t]}const ie=o.type().pipe(o.withReturnType(),o.when(`alchemy`,a.constant([`Alchemy`])),o.when(o.is(`effect`,`@effect/platform`),a.constant([])),o.whenOr(u.startsWith(`effect/`),u.startsWith(`alchemy/`),u.startsWith(`@effect/`),re),o.orElse(a.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`||u.startsWith(`effect/`)(e)||u.startsWith(`@effect/`)(e))&&(n=!0);let i=ie(e);if(i!==void 0)for(let e of r.specifiers)e.type===`ImportNamespaceSpecifier`||e.type===`ImportDefaultSpecifier`?t.set(e.local.name,i):t.set(e.local.name,[...i,_(e.imported)])}return te.make({bindings:t,hasEffectImport:n})}function v(t,n){return e({meta:t,createOnce:n})}function y(t,n){return e({meta:t,createOnce(e){let t=ne,{before:r,Program:i,...a}=n(e,()=>t);return{before(){t=ne,r?.()},Program(e){t=ae(e),i?.(e)},...a}}})}function b(e,t,n,r){return{type:e,docs:{description:t,recommended:!0,...r===void 0?{}:{url:r}},schema:[],messages:n}}const x=o.type().pipe(o.when({computed:!1,property:{type:`Identifier`}},({property:e})=>e.name),o.when({computed:!0,property:{type:`Literal`,value:u.isString}},({property:e})=>e.value),o.orElse(a.constUndefined));function S(e){let t=[],n=e;for(;n.type===`ChainExpression`||n.type===`MemberExpression`;){if(n.type===`ChainExpression`){n=n.expression;continue}let e=x(n);if(e===void 0)return;t.unshift(e),n=n.object}return n.type===`Identifier`?[n.name,...t]:void 0}function C(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 oe(e){return e?.defs.length===1?e.defs[0]:void 0}function w(e,t,n){return e.type===`Identifier`&&e.name===n&&C(t,e,n)===void 0}function T(e,t){let n=S(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 E(e,t,n,r){let i=T(e,t);return i?.length===2&&i[0]===n&&i[1]===r}function D(e,t,n,i){let a=T(e,t);return a?.length===2&&a[0]===n&&r.contains(i,a[1])}function O(e,t,n){let i=T(e,t);return i?.length===n.length&&r.every(i,(e,t)=>e===n[t])}const se=o.type().pipe(o.when({type:o.is(`ArrowFunctionExpression`,`FunctionExpression`)},a.constTrue),o.orElse(a.constFalse));function k(e){return se(e)}function A(e,t){let n=e.arguments[t];return n===void 0||n.type===`SpreadElement`?void 0:n}const j=o.type().pipe(o.when({computed:!1,key:{type:`Identifier`}},({key:e})=>e.name),o.when({key:{type:`Literal`,value:u.isString}},({key:e})=>e.value),o.orElse(a.constUndefined));function M(e,t){return s.getOrUndefined(r.findFirst(e.properties,e=>e.type===`Property`&&j(e)===t))}const ce=/* @__PURE__ */ new Set([`ParenthesizedExpression`,`TSAsExpression`,`TSNonNullExpression`,`TSSatisfiesExpression`,`TSTypeAssertion`]);function le(e){return ce.has(e.type)}const ue=/* @__PURE__ */ new Set([`loc`,`parent`,`range`]);function N(e){let t=e;for(;le(t);)t=t.expression;return t}function de(e,t){if(r.isArray(e))for(let n of e)t.push(n);else for(let[r,i]of n.toEntries(e))ue.has(r)||t.push(i)}function P(e,t){let n=[e],r=/* @__PURE__ */ new WeakSet;for(;n.length>0;){let e=n.pop();if(c.isObjectOrArray(e)&&!r.has(e)){if(r.add(e),c.hasProperty(e,`type`)&&c.isString(e.type)&&t(e)===!0)return!0;de(e,n)}}return!1}function fe(e,t){return P(e,e=>e.type===`Identifier`&&e.name===t)}function F(e){let t=e.params[0];return t?.type===`Identifier`?t:void 0}function pe(e){let t=F(e);return t===void 0||!e.body||u.startsWith(`_`)(t.name)?!1:fe(e.body,t.name)}function me(e,t){for(let n=e.parent;n;n=n.parent)if(t(n))return n}function I(e){return me(e,k)}function L(e){let t=e.parent;if(t.type===`CallExpression`&&t.arguments.includes(e))return t}function he(e,t){return e.range[0]<=t.range[0]&&t.range[1]<=e.range[1]}function R(e){return e.type===`Literal`&&u.isString(e.value)}const ge=/* @__PURE__ */ new Set([`==`,`===`,`!=`,`!==`]);function _e(e){return ge.has(e)}function z(e,t){return e.type===`Literal`&&e.value===t}function ve(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 ye=c.mapInput(c.compose(c.isString,u.endsWith(`Error`)),e=>S(e.callee)?.at(-1)),be=/* @__PURE__ */ new Set([`alarm`,`fetch`,`queue`,`rpc`,`scheduled`,`tail`,`trace`,`webSocketClose`,`webSocketError`,`webSocketMessage`]),xe=[[`Cloudflare`,`Worker`],[`Cloudflare`,`Workers`,`Worker`]];function Se(e,t){return r.some(xe,n=>O(e,t,n))}function Ce(e,t){return me(e,e=>e.type===`CallExpression`&&Se(e.callee,t))}function we(e,t){let n=I(e),r=n===void 0?void 0:L(n);return r!==void 0&&E(r.callee,t,`Effect`,`gen`)?r:void 0}function Te(e){let t=e.parent;for(;t;){if(k(t))return;if(t.type===`Property`){let e=j(t);if(e!==void 0&&be.has(e))return e}t=t.parent}}const Ee=y(b(`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(!E(n.callee,r,`Effect`,`addFinalizer`))return;let i=we(n,r);i!==void 0&&Ce(i,r)?.arguments.includes(i)&&e.report({node:n,messageId:`finalizer`})}}));function B(e,t){let n=S(t)?.[0],i=n===void 0?void 0:C(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 De(e,t,n,i,a){let o=e.sourceCode.ast,c=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(C(e,t,n.local.name)?.defs??[],e=>e.node===n));if(s.isSome(c))return{name:c.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=s.getOrUndefined(r.findFirst(o.body,e=>e.type!==`ExpressionStatement`||!R(e.expression)));return{name:u,fixes:[p===void 0?a.insertTextAfter(o,`\n${f}`):a.insertTextBefore(p,f)]}}function Oe(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 ke=y({...b(`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(!E(n.callee,t(),`Docker`,`Service`))return;let r=A(n,1),i=r?.type===`ObjectExpression`?M(r,`constraints`):void 0;i!==void 0&&e.report({node:i,messageId:`constraints`,fix(t){if(B(e,n.callee)&&r?.type===`ObjectExpression`&&Oe(r,`placement`))return t.replaceText(i,`placement: { ${e.sourceCode.getText(i)} }`)}})}})),Ae=/* @__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`]]),je=y(b(`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=T(n.callee,t());if(i===void 0)return;let a=r.join(i,`.`),o=Ae.get(a);o!==void 0&&e.report({node:n.callee,messageId:`deprecated`,data:{api:a,replacement:o}})}}));function Me(e,t){let n=N(e);if(R(n)||n.type===`TemplateLiteral`)return!0;let r=S(n);return r?.[0]===`process`&&r[1]===`env`||n.type===`CallExpression`&&E(n.callee,t,`Config`,`string`)}const Ne=y(b(`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(!E(n.callee,r,`GitHub`,`Secret`))return;let i=A(n,1),a=i?.type===`ObjectExpression`?M(i,`value`):void 0;a!==void 0&&Me(a.value,r)&&e.report({node:a.value,messageId:`plaintext`})}})),Pe=y(b(`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=T(n.callee,t());r?.[0]===`Alchemy`&&(r[1]===`Secret`||r[1]===`Variable`)&&e.report({node:n.callee,messageId:`removed`,data:{api:r[1]}})}})),Fe=y(b(`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(!O(n.callee,t(),[`AWS`,`EventBridge`,`EventBus`]))return;let r=A(n,1),i=r?.type===`ObjectExpression`?M(r,`name`):void 0;i!==void 0&&z(i.value,`default`)&&e.report({node:i.value,messageId:`reserved`})}})),Ie=y(b(`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`||T(i.callee,r)?.[0]!==`Config`)return;let a=we(n,r);if(a===void 0)return;let o=Te(a);o!==void 0&&Ce(a,r)!==void 0&&e.report({node:i,messageId:`runtime`,data:{handler:o}})}})),Le=/* @__PURE__ */ new Map([[`alchemy/aws`,`alchemy/AWS`],[`alchemy/cloudflare`,`alchemy/Cloudflare`]]),Re=v(b(`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=s.getOrUndefined(r.findFirst(t.specifiers,e=>e.type===`ImportDefaultSpecifier`));n!==void 0&&e.report({node:n,messageId:`defaultImport`});return}let i=Le.get(n);i!==void 0&&e.report({node:t.source,messageId:`providerImport`,data:{replacement:i}})}})),ze=[[`entrypoint`,`main`],[`bindings`,`env`]],Be=y({...b(`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(!Se(n.callee,t()))return;let r=A(n,1);if(r?.type===`ObjectExpression`)for(let[t,i]of ze){let a=M(r,t);a!==void 0&&e.report({node:a,messageId:`property`,data:{old:t,replacement:i},fix(o){if(B(e,n.callee)&&Oe(r,i))return o.replaceText(a.key,a.shorthand?`${i}: ${t}`:i)}})}}})),Ve=y(b(`suggestion`,`Prefer schema-based tagged errors so errors have a serializable contract.`,{taggedError:`Prefer Schema.TaggedError over Data.TaggedError.`}),(e,t)=>({CallExpression(n){E(n.callee,t(),`Data`,`TaggedError`)&&e.report({node:n.callee,messageId:`taggedError`})}})),He=/* @__PURE__ */ new Set([`error`,`err`,`e`,`cause`,`exception`,`ex`]);function Ue(e){return e?.type===`Identifier`&&He.has(e.name)?e.name:void 0}function We(e){if(e.type!==`CallExpression`||e.arguments.length!==1)return!1;let t=S(e.callee);return t?.at(-1)===`String`&&t.length<=2}const Ge=v({...b(`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=A(t,0);if(n===void 0||!We(n)||!ye(t))return;let r=A(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(We(t)){if(t.parent.type===`NewExpression`&&t.parent.arguments[0]===t&&ye(t.parent))return;let n=Ue(t.arguments[0]);n!==void 0&&e.report({node:t,messageId:`errorString`,data:{name:n}});return}if(t.callee.type!==`MemberExpression`||S(t.callee)?.at(-1)!==`toString`||t.arguments.length>0)return;let n=Ue(t.callee.object);n!==void 0&&e.report({node:t,messageId:`errorString`,data:{name:n}})},TemplateLiteral(t){let[n,r]=t.quasis,i=Ue(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}})}})),Ke=/* @__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(`.`)),qe=/* @__PURE__ */ new Set([`Array`,`ArrayEnsure`,`Chunk`,`HashSet`,`NonEmptyArray`,`Option`,`ReadonlySet`,`Redacted`,`Tree`,`UniqueArray`]),Je=/* @__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(`.`)),Ye=/* @__PURE__ */ new Set([`annotate`,`annotateKey`,`check`,`mapFields`]),Xe=/* @__PURE__ */ new Set([`CallExpression`,`Identifier`,`MemberExpression`,`ThisExpression`]),Ze=/^\p{Lu}/u;function V(e,t,n){let r=T(e,n);return S(e)?.length===2&&r?.length===2&&r[0]===`Schema`&&B(t,e)?r[1]:void 0}function Qe(e){return e!==void 0&&qe.has(e)}function $e(e){return e!==void 0&&(Ke.has(e)||qe.has(e))}const et=/* @__PURE__ */ new Set([`ArrowFunctionExpression`,`FunctionExpression`,`Identifier`,`Literal`,`ThisExpression`]);function tt(e,t,n){return r.every(e,e=>e===null||H(e,t,n))}function H(e,t,n){if(et.has(e.type))return!0;if(e.type===`MemberExpression`)return H(e.object,t,n)&&(!e.computed||H(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`?H(e.argument,t,n):(!e.computed||H(e.key,t,n))&&H(e.value,t,n));if(e.type!==`CallExpression`)return!1;let i=e.callee.type===`CallExpression`?e.callee.callee:e.callee;return V(i,t,n)!==void 0&&(e.callee===i||H(e.callee,t,n))&&tt(e.arguments,t,n)}function nt(e,t){if(e.type===`Identifier`)return t.bindings.get(e.name);if(e.type!==`TSQualifiedName`)return;let n=nt(e.left,t);return n===void 0?void 0:[...n,e.right.name]}function rt(e,t){for(let n=t.parent;n!==null;n=n.parent){let t=`typeParameters`in n&&n.typeParameters?.type===`TSTypeParameterDeclaration`?a.pipe(n.typeParameters.params,r.findFirst(t=>t.name.name===e),s.getOrUndefined):void 0;if(t!==void 0)return t}}function it(e,t,n){let r=/* @__PURE__ */ new Set,i=e,a=t;for(;i?.type===`TSTypeReference`;){let e=nt(i.typeName,n),t=e?.length===2&&e[0]===`Schema`?e[1]:void 0;if(t!==void 0)return!u.startsWith(`Constraint`)(t);let o=i.typeName.type===`Identifier`?rt(i.typeName.name,a):void 0;if(o===void 0||r.has(o))return r.size===0&&void 0;r.add(o),i=o.constraint,a=o}return r.size===0&&void 0}function at(e,t){let n=C(t,e,e.name)?.defs[0]?.name;return n!==void 0&&`typeAnnotation`in n?n.typeAnnotation??void 0:void 0}function ot(e,t,n){let r=e;for(;r.type===`TSSatisfiesExpression`||r.type===`TSNonNullExpression`;)r=r.expression;if(r.type===`TSAsExpression`)return it(r.typeAnnotation,r,n)===!1;let i=r.type===`Identifier`?at(r,t):void 0;return i!==void 0&&it(i.typeAnnotation,i,n)===!1}function st(e){return r.some(e.arguments,e=>e.type===`SpreadElement`)}function ct(e){let[t]=e.arguments;return e.arguments.length===1&&t?.type!==`SpreadElement`&&!e.typeArguments?t:void 0}function lt(e){return e.callee.type===`MemberExpression`&&!e.callee.optional&&x(e.callee)===`pipe`&&!e.typeArguments&&!st(e)}function ut(e,t,n){return(O(e.callee,n,[`pipe`])||O(e.callee,n,[`Function`,`pipe`]))&&B(t,e.callee)}function dt(e,t,n){return $e(V(e,t,n))?!0:e.type===`CallExpression`&&Je.has(V(e.callee,t,n)??``)}function ft(e,t,n){if(Ze.test(V(e,t,n)??``)||U(e,t,n)!==void 0)return!0;if(e.type!==`CallExpression`)return!1;let r=V(e.callee,t,n);return r===void 0?e.callee.type===`MemberExpression`&&Ye.has(x(e.callee)??``)&&ft(e.callee.object,t,n):Ze.test(r)||$e(r)}function pt(e,t,n){let[r,i]=e.arguments;if(!(r===void 0||i===void 0||r.type===`SpreadElement`||e.typeArguments||st(e)||!ft(r,t,n)&&!dt(i,t,n)))return[r,e.arguments.slice(1)]}function mt(e,t,n,r,i,a){let o=vt(e,i,a);return{head:o.head,steps:[...o.steps,t],violation:o.violation??n,reordersEffects:o.reordersEffects||r}}function ht(e,t,n){let r=ct(e);if(r===void 0)return;let i=V(e.callee,t,n);if($e(i)){let a=Qe(i);return mt(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`?V(e.callee.callee,t,n):void 0;if(a!==void 0&&Je.has(a))return mt(r,{text:t.sourceCode.getText(e.callee),wrapper:!1},{kind:`dataLastCall`,name:a},!H(e.callee,t,n)&&!H(r,t,n),t,n)}function gt(e,t,n){let i=ut(e,t,n),o=i?pt(e,t,n):lt(e)?[e.callee.object,e.arguments]:void 0;if(o===void 0)return;let[c,l]=o,u=r.map(l,e=>V(e,t,n)),d=a.pipe(u,r.findFirst(Qe),s.getOrUndefined),f=d!==void 0&&r.some(l.slice(u.indexOf(d)+1),e=>!H(e,t,n));return _t(c,r.map(l,(e,n)=>({text:t.sourceCode.getText(e),wrapper:Qe(u[n])})),i?{kind:`functionPipe`}:d===void 0?void 0:{kind:`wrapperPipe`,name:d},f,t,n)}function _t(e,t,n,r,i,a){let o=vt(e,i,a);return{head:o.head,steps:[...o.steps,...t],violation:o.violation??n,reordersEffects:o.reordersEffects||r}}function U(e,t,n){return e.type===`CallExpression`?ht(e,t,n)??gt(e,t,n):void 0}function vt(e,t,n){return U(e,t,n)??{head:e,steps:[],violation:void 0,reordersEffects:!1}}function yt(e,t,n){let r=e.parent;return r.type===`MemberExpression`&&r.object===e&&r.parent.type===`CallExpression`?r.parent.callee===r&&lt(r.parent):r.type===`CallExpression`&&r.arguments[0]===e&&(ut(r,t,n)||!lt(r))&&U(r,t,n)!==void 0}function bt(e,t,n){return r.isReadonlyArrayNonEmpty(t)?`${e===`\0`&&!Xe.has(n.type)?`(\0)`:e}.pipe(${r.join(t,`, `)})`:e}function xt(e,t){let n=`\0`,r=[];for(let i of t)if(i.wrapper){let t=bt(n,r,e),a=t===`\0`&&e.type===`SequenceExpression`?`(${t})`:t;n=`${i.text}(${a})`,r=[]}else r.push(i.text);return bt(n,r,e)}const St=y({...b(`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 i=t();if(!i.hasEffectImport)return;let a=U(n,e,i);if(a?.violation===void 0||yt(n,e,i))return;let{head:o}=a;if(a.steps[0]?.wrapper===!1&&ot(o,e,i))return;let s=r.some(e.sourceCode.getCommentsInside(n),e=>!he(o,e)),[c,l=``]=u.split(xt(o,a.steps),`\0`);e.report({node:n,messageId:a.violation.kind,data:{name:a.violation.name??``},fix:s||a.reordersEffects?void 0:e=>[e.replaceTextRange([n.range[0],o.range[0]],c),e.replaceTextRange([o.range[1],n.range[1]],l)]})}}));function Ct(e){return s.getOrUndefined(r.findFirst(e.arguments,e=>e.type===`ObjectExpression`))}function wt(e,t){let n=e.parent;if(n.type!==`Property`||j(n)!==t)return;let r=n.parent,i=r.parent;return r.type===`ObjectExpression`&&i?.type===`CallExpression`?i:void 0}function Tt(e,t){let n=L(e);return n===void 0?void 0:T(n.callee,t)}const Et=/* @__PURE__ */ new Set([`catch`,`finally`,`then`]);function Dt(e){let t=S(e.callee);return t!==void 0&&r.join(t,`.`)===`Promise`}function Ot(e){let t=S(e.callee);return t!==void 0&&r.join(t,`.`)===`fetch`||t?.[0]===`Promise`&&t[1]!==`withResolvers`||Et.has(t?.at(-1)??``)||k(e.callee)&&e.callee.async}const kt=o.type().pipe(o.discriminators(`type`)({CallExpression:Ot,NewExpression:Dt}),o.orElse(a.constFalse));function At(e){return kt(N(e))}function jt(e){if(e.body){if(e.body.type!==`BlockStatement`)return N(e.body);if(e.body.body.length===1&&e.body.body[0]?.type===`ReturnStatement`&&e.body.body[0].argument)return N(e.body.body[0].argument)}}function Mt(e){let t=e?.type===`ObjectExpression`?M(e,`try`)?.value:e;return k(t)?t:void 0}function Nt(e){let t=N(e);return z(t,`*`)?!0:t.type===`ArrayExpression`&&(t.elements.length===0||r.some(t.elements,e=>e!==null&&z(e,`*`)))}const Pt=y(b(`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(!E(n.callee,r,`HttpMiddleware`,`cors`)&&!E(n.callee,r,`HttpRouter`,`cors`)&&!E(n.callee,r,`HttpApiBuilder`,`middlewareCors`))return;let i=Ct(n);if(i===void 0||!z(M(i,`credentials`)?.value??i,!0))return;let a=M(i,`allowedOrigins`);(a===void 0||Nt(a.value))&&e.report({node:n,messageId:`wildcard`})}}));function Ft(e){return e.type===`AssignmentPattern`||e.type===`RestElement`||e.optional===!0}const It=y(b(`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=A(n,0),a=A(n,1);a!==void 0&&E(n.callee,t(),`Function`,`dual`)&&i?.type===`Literal`&&c.isNumber(i.value)&&k(a)&&r.some(a.params,Ft)&&e.report({node:i,messageId:`unsafeArity`})}})),Lt=y(b(`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){E(n.callee,t(),`Effect`,`promise`)&&e.report({node:n.callee,messageId:`tryPromise`})}}));function Rt(e,t){if(D(e.callee,t,`Effect`,[`promise`,`tryPromise`]))return Mt(A(e,0))}const zt=y(b(`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&&At(e.init)&&n.add(e.id.name)},CallExpression(r){let i=Rt(r,t()),a=i===void 0?void 0:jt(i);a?.type===`Identifier`&&n.has(a.name)&&e.report({node:a,messageId:`prestarted`})}}}),Bt=y(b(`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(!E(n.callee,t(),`Effect`,`try`))return;let r=A(n,0),i=r!==void 0&&k(r)?r:void 0;if(i===void 0&&r?.type===`ObjectExpression`){let e=M(r,`try`)?.value;e!==void 0&&k(e)&&(i=e)}let a=i===void 0?void 0:jt(i);i!==void 0&&(i.async||a!==void 0&&At(a))&&e.report({node:i,messageId:`asyncTry`})}})),Vt=y(b(`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=E(n.callee,r,`Effect`,`runPromise`),a=n.callee.type===`CallExpression`&&E(n.callee.callee,r,`Effect`,`runPromiseWith`);(i||a)&&ve(n)&&e.report({node:n,messageId:`discarded`})}})),Ht=/* @__PURE__ */ new Set([`mapElements`,`mapFields`,`mapMembers`]);function Ut(e,t){let n=N(e);if(n.type===`CallExpression`&&n.callee.type===`MemberExpression`&&x(n.callee)===t)return n}const Wt=y(b(`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=x(n.callee);i!==void 0&&Ht.has(i)&&Ut(n.callee.object,`check`)!==void 0&&(r.findFirst(n.arguments,e=>e.type===`ObjectExpression`).pipe(s.flatMapNullishOr(e=>M(e,`unsafePreserveChecks`)),s.exists(e=>z(e.value,!0)))||e.report({node:n,messageId:`discarded`,data:{method:i}}))}})),Gt={Array:`Arr`,Boolean:`Bool`,Equal:`Eq`,Function:`Fn`,Number:`Num`,Option:`Opt`,Predicate:`P`,Record:`R`,String:`Str`},Kt=/^\p{Lu}[^_]*$/u;function qt(e){return Kt.test(e)}function Jt(e){return e===`@effect/vitest`||u.startsWith(`@effect/vitest/`)(e)}function W(e,t){return e.importKind===`type`||t?.importKind===`type`}function Yt(e){return s.getOrElse(n.get(Gt,e),()=>e)}function Xt(e,t){if(e===`effect`||e===`alchemy`||/^@effect\/[^/]+$/u.test(e)&&!Jt(e))return`${e}/${t}`}function Zt(e){if(Jt(e)||!(u.startsWith(`effect/`)(e)||u.startsWith(`alchemy/`)(e)||/^@effect\/[^/]+\//u.test(e)))return;let t=r.lastNonEmpty(u.split(e,`/`));return qt(t)?t:void 0}function Qt(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=_(n.imported),i=qt(r)&&!W(t,n)?Xt(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
2
  `))]}function $t(e,t,n){let i=Zt(t.source.value);if(i===void 0||t.attributes.length>0||e.sourceCode.getCommentsInside(t).length>0)return;let a=Yt(i),o=e.sourceCode.getDeclaredVariables(t),c=s.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!==c)||r.some(e.references,e=>e.identifier.name===a&&e.resolved!==c)))return;let l=[],u=[];for(let r of t.specifiers){if(r.type===`ImportDefaultSpecifier`)return;if(r.type===`ImportSpecifier`&&W(t,r)){if(r.local.name===a)return;u.push(e.sourceCode.getText(r));continue}let i=en(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 en(e,t,n,i){let a=s.getOrUndefined(r.findFirst(t,t=>t.name===e.local.name));if(a!==void 0){if(e.type===`ImportNamespaceSpecifier`)return tn(a,n,!1,i);if(e.imported.type===`Identifier`)return tn(a,`${n}.${e.imported.name}`,!0,i)}}function tn(e,t,n,r){let i=[],a=/* @__PURE__ */ new Set;for(let o of e.references){let e=o.identifier;if(a.has(e.range[0]))continue;a.add(e.range[0]);let s=e.parent;if(o.isWrite()||s.type===`ExportSpecifier`||u.startsWith(`JSX`)(s.type))return;let c=s.type===`Property`&&s.shorthand?`${e.name}: ${t}`:t;n&&(s.type===`CallExpression`&&s.callee===e||s.type===`TaggedTemplateExpression`&&s.tag===e)&&(c=`(0, ${t})`),i.push(r.replaceText(e,c))}return i}const nn=v({...b(`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`||W(t,n))continue;let r=_(n.imported),i=qt(r)?Xt(t.source.value,r):void 0;i!==void 0&&e.report({node:n,messageId:`barrelImport`,data:{alias:Yt(r),source:i},fix:n=>Qt(e,t,n)})}}})),rn=[`log`,`logDebug`,`logError`,`logFatal`,`logInfo`,`logTrace`,`logWarning`],an=[`debug`,`error`,`info`,`log`,`trace`,`warn`],on=[`as`,`asSome`,`asVoid`];function sn(e,t){let n=N(e);if(n.type!==`CallExpression`)return;let i=N(n.callee);if(i.type===`CallExpression`&&O(i.callee,t,[`Effect`,`logWithLevel`]))return`Effect.logWithLevel`;if(D(i,t,`Effect`,rn)||D(i,t,`Console`,an))return r.join(T(i,t)??[],`.`)}function cn(e,t){if(e===void 0)return;let n=N(e);return n.type===`CallExpression`&&n.arguments.length===1&&O(n.callee,t,[`Effect`,`as`])?`as`:D(n,t,`Effect`,[`asSome`,`asVoid`])?T(n,t)?.[1]:void 0}function ln(e,t){return O(e,t,[`pipe`])||O(e,t,[`Function`,`pipe`])}function un(e,t){let n=N(e.callee);if(n.type===`MemberExpression`&&x(n)===`pipe`){let r=A(e,0),i=sn(n.object,t),a=cn(r,t);return r===void 0||i===void 0||a===void 0?void 0:{logger:i,method:a,node:r}}if(ln(n,t)){let n=A(e,0),r=n===void 0?void 0:sn(n,t),i=A(e,1),a=cn(i,t);return i===void 0||r===void 0||a===void 0?void 0:{logger:r,method:a,node:i}}let r=D(n,t,`Effect`,on)?T(n,t)?.[1]:void 0,i=A(e,0);if(r===void 0||i===void 0||r===`as`&&e.arguments.length!==2)return;let a=sn(i,t);return a===void 0?void 0:{logger:a,method:r,node:e}}const dn=y(b(`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=un(n,t());r!==void 0&&e.report({node:r.node,messageId:r.method===`asVoid`?`asVoidOnLog`:`asOnLog`,data:{logger:r.logger,method:r.method}})}})),fn=y({...b(`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(!E(n.callee,t(),`Effect`,`callback`)&&!E(n.callee,t(),`Effect`,`async`))return;let i=A(n,0);i!==void 0&&k(i)&&i.body?.type===`BlockStatement`&&i.body.body.length===0&&e.report({node:n,messageId:`emptyCallback`,fix(t){if(!B(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=De(e,n,`effect/Effect`,`Effect`,t);return[...a.fixes,t.replaceText(n,`${a.name}.never`)]}})}})),pn=y(b(`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=A(n,0);E(n.callee,t(),`Schema`,`Struct`)&&r?.type===`ObjectExpression`&&r.properties.length===0&&e.report({node:n,messageId:`emptyStruct`})}}));function mn(e,t){let n=N(e),i=/* @__PURE__ */ new Set;for(;n.type===`Identifier`;){let e=C(t,n,n.name),a=oe(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=N(o.init)}return n}function hn(e){if(e.arguments.length===2)return A(e,0);let t=e.parent;if(e.arguments.length===1&&t.type===`CallExpression`&&t.arguments[0]===e&&t.callee.type===`MemberExpression`&&x(t.callee)===`pipe`)return t.callee.object}const gn=y(b(`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(!E(n.callee,t(),`Config`,`withDefault`)||!B(e,n.callee))return;let r=A(n,n.arguments.length-1),i=hn(n),a=i===void 0?void 0:mn(i,e);a?.type===`CallExpression`&&E(a.callee,t(),`Config`,`succeed`)&&B(e,a.callee)&&k(A(a,0))||k(r)&&r.params.length===0&&e.report({node:r,messageId:`functionDefault`})}})),_n=/* @__PURE__ */ new Set([`delete`,`get`,`has`,`set`]);function vn(e,t){return e.type===`CallExpression`&&E(e.callee,t,`Hash`,`hash`)}const yn=y(b(`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 vn(e,t())||e.type===`Identifier`&&n.has(e.name)}return{before(){n=/* @__PURE__ */ new Set},VariableDeclarator(e){e.id.type===`Identifier`&&e.init&&vn(e.init,t())&&n.add(e.id.name)},CallExpression(t){if(t.callee.type!==`MemberExpression`||!_n.has(S(t.callee)?.at(-1)??``))return;let n=A(t,0);n!==void 0&&r(n)&&e.report({node:n,messageId:`hashIdentity`})},BinaryExpression(t){_e(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`})}}}),bn=/* @__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(`.`)),xn=/* @__PURE__ */ new Set([`global`,`module`]),Sn=/* @__PURE__ */ new Set([`ArrowFunctionExpression`,`FunctionDeclaration`,`FunctionExpression`]),Cn=/* @__PURE__ */ new Set([`AssignmentExpression`,`AwaitExpression`,`ImportExpression`,`TaggedTemplateExpression`,`UpdateExpression`,`YieldExpression`]),wn=/* @__PURE__ */ new Set([`ParenthesizedExpression`,`TSAsExpression`,`TSNonNullExpression`]);function Tn(e,t,n){let i=T(e,t),a=i?.length===2&&i[0]===`Schema`?i[1]:void 0,o=S(e)?.[0];if(a===void 0||o===void 0||!bn.has(a))return;let s=C(n,e,o);return s!==void 0&&r.every(s.defs,e=>e.type===`ImportBinding`)?a:void 0}function En(e){let t=e.parent;for(;t;){if(Sn.has(t.type))return!0;t=t.parent}return!1}function Dn(e){let t=e,n=e.parent;for(;wn.has(n.type)&&n.parent!==null;)t=n,n=n.parent;return n.type===`CallExpression`&&n.callee===t}function On(e,t){return e.type===`CallExpression`&&T(e.callee,t)?.[0]===`Schema`}function kn(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 An(e){return r.every(e.references,e=>(!e.isWrite()||e.init)&&!kn(e.identifier))}function jn(e,t,n,r){let i=C(r,e,t);return i===void 0||he(n,i.scope.block)?!0:xn.has(i.scope.type)&&An(i)}function Mn(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 Nn(e,t){if(e===t)return!1;let n=e.parent;for(;n!==null&&n!==t;){if(Sn.has(n.type))return!0;n=n.parent}return!1}function Pn(e,t,n){return Nn(e,t)?!1:e.type===`CallExpression`||e.type===`NewExpression`?T(e.callee,n)===void 0:Cn.has(e.type)}function Fn(e,t,n){return!P(e,r=>r.type===`ThisExpression`||r.type===`Super`||r.type===`MetaProperty`&&r.meta.name===`new`||Pn(r,e,t)||r.type===`Identifier`&&!Mn(r)&&!jn(r,r.name,e,n))}const In=y(b(`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=Tn(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`)||!Dn(n)||!En(n))return;let s=N(o),c=On(s,i);(c||s.type===`Identifier`||s.type===`MemberExpression`)&&r.every(n.arguments,t=>Fn(t,i,e))&&e.report({node:n.callee,messageId:c?`inlineSchema`:`inlineCompile`,data:{method:a}})}})),Ln=/* @__PURE__ */ new Set([`catch`,`catchIf`,`catchTag`,`orElseSucceed`,`catchAll`,`catchAllCause`,`catchSome`,`catchSomeCause`,`orElse`,`orElseFail`]),Rn=/* @__PURE__ */ new Set([`log`,`logDebug`,`logError`,`logInfo`,`logTrace`,`logWarning`]);function zn(e,t){let n=e.parent;for(;n;){if(k(n)){let e=L(n);if(e?.arguments.at(-1)===n){let n=T(e.callee,t),r=n?.[1];if(r!==void 0&&n?.[0]===`Effect`&&Ln.has(r))return{method:r}}}n=n.parent}}const Bn=y(b(`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=T(n.callee,i),o=a?.[1]!==void 0&&a[0]===`Effect`&&Rn.has(a[1])?r.join(a,`.`):void 0;if(o===void 0)return;let s=zn(n,i);s!==void 0&&e.report({node:n,messageId:`logging`,data:{logger:o,catchMethod:s.method}})}})),Vn=o.type().pipe(o.when({type:`MemberExpression`,computed:!1,object:{type:`Identifier`,name:`Effect`},property:{type:`Identifier`,name:o.is(`catch`,`catchAll`,`catchIf`)}},a.constTrue),o.orElse(a.constFalse)),Hn=o.type().pipe(o.when({type:`MemberExpression`,computed:!1,object:{type:`Identifier`,name:`Match`},property:{type:`Identifier`,name:o.is(`when`,`not`)}},a.constTrue),o.orElse(a.constFalse)),G=o.type().pipe(o.when({type:`MemberExpression`,computed:!1,property:{type:`Identifier`,name:`_tag`}},a.constTrue),o.when({type:`MemberExpression`,computed:!0,property:{type:`Literal`,value:`_tag`}},a.constTrue),o.orElse(a.constFalse));function Un(e){if(_e(e.operator)){if(G(e.left)&&R(e.right))return e.left;if(G(e.right)&&R(e.left))return e.right}}function K(e){let t=I(e),n=t===void 0?void 0:L(t);return n!==void 0&&Vn(n.callee)}function Wn(e){return e.object.type===`MemberExpression`&&x(e.object)===`reason`}function Gn(e){let t=e.parent;return t.type===`CallExpression`&&t.arguments.includes(e)&&Hn(t.callee)}const Kn=v(b(`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=Un(t);n!==void 0&&K(t)&&e.report({node:t,messageId:Wn(n)?`reason`:`tag`})},SwitchStatement(t){G(t.discriminant)&&K(t)&&e.report({node:t,messageId:Wn(t.discriminant)?`reason`:`tag`})}})),qn=v(b(`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){Un(t)===void 0||K(t)||e.report({node:t,messageId:`manualComparison`})},SwitchStatement(t){G(t.discriminant)&&!K(t)&&e.report({node:t,messageId:`manualSwitch`})}})),Jn=v(b(`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(Gn(t))return;let n=s.getOrUndefined(r.findFirst(t.properties,e=>e.type===`Property`&&j(e)===`_tag`&&R(e.value)));n!==void 0&&e.report({node:n,messageId:`manualConstruction`})}})),Yn=/* @__PURE__ */ new Map([[`addEventListener`,1],[`on`,1],[`setInterval`,0]]);function Xn(e,t){let n=S(e.callee)?.at(-1),r=n===void 0?void 0:Yn.get(n);if(r===void 0)return!1;if(n===`addEventListener`){let t=A(e,2);if(t?.type===`ObjectExpression`){let e=M(t,`once`);if(e!==void 0&&z(e.value,!0))return!1}}let i=A(e,r);return i!==void 0&&fe(i,t)}const Zn=y(b(`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(!E(n.callee,t(),`Effect`,`callback`))return;let r=A(n,0);if(r===void 0||!k(r))return;let i=F(r)?.name,a=r.body;i!==void 0&&a&&P(a,e=>e.type===`CallExpression`&&Xn(e,i))&&e.report({node:n,messageId:`multiShot`})}})),Qn=/* @__PURE__ */ new Set([`NaN`,`Infinity`,`undefined`]),$n=/* @__PURE__ */ new Set([`annotate`,`annotateEncoded`,`annotateKey`]),er=[`default`,`examples`];function tr(e){return e.type===`Literal`&&c.isBigInt(e.value)||e.type===`Identifier`&&Qn.has(e.name)||k(e)||e.type===`CallExpression`&&S(e.callee)?.at(-1)===`Symbol`}function nr(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 rr(e){let t=[e];for(;t.length>0;){let e=t.pop();if(e===void 0)continue;let n=N(e);if(tr(n))return n;nr(n,t)}}const ir=y(b(`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=T(n.callee,r),a=n.callee.type===`MemberExpression`?x(n.callee):i?.[0]===`Schema`?i[1]:void 0;if(a===void 0||!$n.has(a))return;let o=Ct(n);if(o!==void 0&&M(o,`jsonSchema`)===void 0)for(let t of er){let n=M(o,t);if(n===void 0)continue;let r=rr(n.value);r!==void 0&&e.report({node:r,messageId:`nonJson`})}}})),ar=[`option`,`either`],or=y(b(`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=D(n.callee,r,`Effect`,ar),a=A(n,0);if(i&&a?.type===`CallExpression`&&E(a.callee,r,`Effect`,`service`)){e.report({node:n,messageId:`mandatory`});return}if(n.callee.type!==`MemberExpression`||S(n.callee)?.at(-1)!==`pipe`)return;let o=N(n.callee.object),s=A(n,0);s!==void 0&&o.type===`CallExpression`&&E(o.callee,r,`Effect`,`service`)&&D(s,r,`Effect`,ar)&&e.report({node:n,messageId:`mandatory`})}})),sr=y(b(`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`&&j(e)===`_tag`);if(s.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`})}})),cr=/^make[A-Z]/u,lr=/\.(?:test|spec)\.[cm]?[jt]sx?$/u,ur=v(b(`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(!lr.test(u.replaceAll(`\\`,`/`)(e.filename))&&(u.startsWith(`./`)(t.source.value)||u.startsWith(`../`)(t.source.value)))for(let n of t.specifiers){if(n.type!==`ImportSpecifier`)continue;let t=_(n.imported);cr.test(t)&&e.report({node:n,messageId:`serviceConstructorImport`,data:{name:t}})}}})),dr=[`getOrThrow`,`getOrThrowWith`],fr=y(b(`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(D(n.callee,r,`Option`,dr)){let t=A(n,0),i=t?.type===`YieldExpression`?t.argument:t;i?.type===`CallExpression`&&E(i.callee,r,`Effect`,`serviceOption`)&&e.report({node:n,messageId:`getOrThrow`});return}if(n.callee.type!==`MemberExpression`||S(n.callee)?.at(-1)!==`pipe`)return;let i=N(n.callee.object),a=A(n,0);if(i.type!==`CallExpression`||!E(i.callee,r,`Effect`,`serviceOption`)||a?.type!==`CallExpression`||!E(a.callee,r,`Effect`,`map`))return;let o=A(a,0);o!==void 0&&D(o,r,`Option`,dr)&&e.report({node:n,messageId:`getOrThrow`})}})),pr=/* @__PURE__ */ new Set([`andThen`,`map`,`mapError`,`tap`,`tapError`,`tapErrorCause`]),mr=y(b(`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=I(n);if(r===void 0)return;let i=t(),a=Tt(r,i),o=wt(r,`catch`);(a?.[0]===`Effect`&&a[1]!==void 0&&pr.has(a[1])||o!==void 0&&D(o.callee,i,`Effect`,[`try`,`tryPromise`]))&&e.report({node:n,messageId:`callbackThrow`})}})),hr=/* @__PURE__ */ new Set([`get`,`post`,`put`,`patch`,`delete`,`head`,`options`]);function gr(e,t){let n=e.parent,r=e.node;if(e.type!==`ImportBinding`||n?.type!==`ImportDeclaration`||W(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 _r(e,t){let n=S(e.callee),r=n?.[0],i=n?.at(-1);if(n===void 0||r===void 0||i===void 0||!hr.has(i))return!1;let a=oe(C(t,e,r));return a!==void 0&&gr(a,n)}function vr(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=j(r)??(r.key.type===`Literal`&&c.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 yr=v(b(`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`)||!_r(t,e))return;let n=vr(A(t,2)),i=vr(s.getOrUndefined(r.findFirst(n??[],e=>j(e)===`headers`))?.value);if(i!==void 0)for(let t of i){let n=j(t);n!==void 0&&/[A-Z]/u.test(n)&&e.report({node:t.key,messageId:`uppercase`,data:{name:n}})}}})),br=y(b(`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(!D(n.callee,r,`Effect`,[`retry`,`repeat`]))return;let i=Ct(n);if(i===void 0)return;let a=M(i,`times`);a!==void 0&&z(a.value,0)&&e.report({node:a,messageId:`zeroTimes`})}})),xr=v({...b(`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=Zt(t.source.value);if(n===void 0||t.importKind===`type`)return;let r=Yt(n);for(let n of t.specifiers)n.type===`ImportSpecifier`&&W(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=>$t(e,t,n)}):e.report({node:n,messageId:`namespace`,data:{alias:r,source:t.source.value},fix:n=>$t(e,t,n)}))}})),Sr=y(b(`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`&&x(n.callee)===`sort`&&!E(n.callee,r,`Array`,`sort`)&&e.report({node:n,messageId:`effectArraySort`})}})),Cr=/* @__PURE__ */ new Set([`toISOString`,`toLocaleDateString`,`toLocaleTimeString`]),wr=y(b(`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`&&Cr.has(x(n.callee)??``)&&e.report({node:n,messageId:`effectDateTime`})}})),Tr=/* @__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`]]),Er={first:e=>A(e,0),last:e=>A(e,e.arguments.length-1),"options.duration":e=>{let t=A(e,e.arguments.length-1);return t?.type===`ObjectExpression`?M(t,`duration`)?.value:void 0}};function Dr(e,t,n){let i=T(e.callee,n),a=i===void 0?void 0:Tr.get(r.join(i,`.`));return a!==void 0&&B(t,e.callee)?Er[a](e):void 0}function Or(e,t){return e**t}const kr=o.type().pipe(o.withReturnType(),o.when(`*`,()=>f.multiply),o.when(`+`,()=>f.sum),o.when(`-`,()=>f.subtract),o.when(`/`,()=>f.divideUnsafe),o.when(`%`,()=>f.remainder),o.when(`**`,()=>Or),o.orElse(a.constUndefined));function q(e){let t=N(e);if(t.type===`Literal`)return c.isNumber(t.value)?t.value:void 0;if(t.type===`UnaryExpression`&&(t.operator===`-`||t.operator===`+`)){let e=q(t.argument);return e===void 0||t.operator===`+`?e:-e}if(t.type!==`BinaryExpression`||t.left.type===`PrivateIdentifier`)return;let n=q(t.left),r=q(t.right);if(n!==void 0&&r!==void 0)return kr(t.operator)?.(n,r)}function Ar(e){let t=N(e);if(t.type===`Literal`)return c.isNumber(t.value)?[t.value]:void 0;if(t.type!==`BinaryExpression`||t.operator!==`*`)return;let n=Ar(t.left),i=Ar(t.right);return n===void 0||i===void 0?void 0:r.appendAll(n,i)}const jr=/* @__PURE__ */ new Set([6e4,36e5,864e5]),Mr=/* @__PURE__ */ new Set([60,3600,86400]),Nr=/* @__PURE__ */ new Set([7,24,60,1e3,3600,86400]);function Pr(e){let t=Ar(e);if(!(t===void 0||t.length<2)&&(r.some(t,e=>jr.has(e))||r.some(t,e=>Mr.has(e))&&r.filter(t,e=>Nr.has(e)).length>=2))return{millis:r.contains(t,1e3)||r.some(t,e=>e%6e4==0)}}const Fr=[[`weeks`,6048e5],[`days`,864e5],[`hours`,36e5],[`minutes`,6e4],[`seconds`,1e3],[`millis`,1]];function Ir(e){return!Number.isSafeInteger(e)||Math.abs(e)<1e4?String(e):u.replaceAll(/\B(?=(?:\d{3})+$)/gu,`_`)(String(e))}function Lr(e,t){let n=e*r.findFirst(Fr,([e])=>e===t).pipe(s.map(([,e])=>e),s.getOrElse(()=>1));return n===0?`Duration.zero`:r.findFirst(Fr,([,e])=>Number.isSafeInteger(n/e)).pipe(s.match({onNone:()=>`Duration.millis(${Ir(n)})`,onSome:([e,t])=>`Duration.${e}(${Ir(n/t)})`}))}const Rr=y({...b(`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=Dr(n,e,t());r!==void 0&&q(r)!==void 0&&e.report({node:r,messageId:`effectDuration`,fix(t){let i=De(e,n,`effect/Duration`,`Duration`,t);return[...i.fixes,t.replaceText(r,`${i.name}.millis(${e.sourceCode.getText(r)})`)]}})}})),zr=/* @__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`]]),Br=/* @__PURE__ */ new Set([`day`,`hour`,`minute`,`second`,`week`]),Vr=/* @__PURE__ */ new Set([`backoff`,`cooldown`,`day`,`debounce`,`delay`,`duration`,`expiration`,`expiry`,`hour`,`interval`,`lifetime`,`minute`,`second`,`throttle`,`timeout`,`ttl`,`week`]),Hr=a.flow(u.split(/[_$]+|(?<=[\da-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])/u),r.filter(u.isNonEmpty),r.map(u.toLowerCase)),Ur=/* @__PURE__ */ new Set([`at`,`epoch`,`per`,`timestamp`]);function Wr(e){return e!==void 0&&e!==`excluded`&&e!==`unknown`}function Gr(e){let t=Hr(e),n=t.indexOf(`in`),i=t[n-1]??``;if(n>0&&n<t.length-1&&(zr.has(i)||Br.has(i))||r.some(t,e=>Ur.has(e)))return`excluded`;let a=t.at(-1),o=t.at(-2);if(a===void 0)return;let s=zr.get(a);if(s!==void 0)return s;if(Vr.has(a)||a===`age`&&o===`max`||a===`in`&&o===`expires`)return`unknown`}function Kr(e,t,n){return r.some(C(n,e,t)?.defs??[],e=>e.type===`ImportBinding`)}const qr=o.type().pipe(o.withReturnType(),o.discriminators(`type`)({Identifier:a.flow(p.get(`name`),r.make),TSQualifiedName:({left:e,right:t})=>{let n=qr(e);return n===void 0?void 0:r.append(n,t.name)}}),o.orElse(a.constUndefined));function Jr(e,t,n){return P(e,e=>{if(e.type!==`TSTypeReference`)return!1;let[r,...i]=qr(e.typeName)??[],a=r===void 0||!Kr(e,r,t)?void 0:n.bindings.get(r);return a!==void 0&&[...a,...i][0]===`Duration`})}function Yr(e){return e.parent.type===`VariableDeclaration`&&e.parent.kind===`const`&&e.id.type===`Identifier`&&e.init!==null&&q(e.init)!==void 0}function Xr(e,t){let n=N(e);if(n.type!==`Identifier`)return;let r=oe(C(t,n,n.name))?.node;return r?.type===`VariableDeclarator`&&Yr(r)?r:void 0}const Zr=y(b(`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&&Jr(n.id.typeAnnotation,e,t()))return`none`;let i=Gr(n.id.name);if(r)return Wr(i)?i:`millis`;if(i===`excluded`||(q(n.init)??0)<=0)return`none`;if(Wr(i))return i;let a=Pr(n.init);return a?.millis===!0?`millis`:a!==void 0||i===`unknown`?void 0:`none`}return{before(){n.clear()},VariableDeclarator(e){t().hasEffectImport&&Yr(e)&&!n.has(e)&&n.set(e,!1)},CallExpression(r){let i=Dr(r,e,t()),a=i===void 0?void 0:Xr(i,e);a!==void 0&&n.set(a,!0)},"Program:exit":function(){for(let[t,i]of n){let n=r(t,i),a=q(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`:Lr(a,n)}})}}}}),Qr=/* @__PURE__ */ new Set([`base64`,`base64url`,`hex`]);function $r(e){return e!==void 0&&R(e)&&Qr.has(e.value)}const ei=y(b(`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((w(n.callee,e,`atob`)||w(n.callee,e,`btoa`))&&n.arguments.length>0){e.report({node:n,messageId:`effectEncoding`});return}let i=S(n.callee),a=i!==void 0&&r.join(i,`.`)===`Buffer.from`&&$r(A(n,1)),o=i?.at(-1)===`toString`&&$r(A(n,0));(a||o)&&e.report({node:n,messageId:`effectEncoding`})}})),ti=/* @__PURE__ */ new Set([`fs`,`fs/promises`,`node:fs`,`node:fs/promises`]),ni=y(b(`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 ri(e,t,n){return e.type===`CallExpression`&&E(e.callee,t,`Result`,n)?A(e,0):void 0}function ii(e,t,n){let r=F(t),i=jt(t);if(r===void 0||i?.type!==`ConditionalExpression`)return;let a=ri(i.consequent,n,`succeed`),o=ri(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 ai=y(b(`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){ii(e,n,t())},FunctionExpression(n){ii(e,n,t())}})),oi=y(b(`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&&w(n.callee,e,`Headers`)&&e.report({node:n,messageId:`effectHeaders`})}}));function si(e){return e.type===`Literal`||e.type===`TemplateLiteral`&&e.expressions.length===0}function ci(e,t){if(e.type===`BinaryExpression`&&_e(e.operator)){if(si(e.left))return t.sourceCode.getText(e.right);if(si(e.right))return t.sourceCode.getText(e.left)}}const li=y(b(`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=ci(t.test,e);if(n===void 0)return;let r=t.alternate,i=1;for(;r.type===`ConditionalExpression`;){if(ci(r.test,e)!==n)return;i+=1,r=r.alternate}i>1&&e.report({node:t,messageId:`preferMatch`})}})),ui=/* @__PURE__ */ new Set([`node:path`,`path`]),di=y(b(`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&&ui.has(n.source.value)&&e.report({node:n.source,messageId:`effectPath`,data:{source:n.source.value}})}})),fi=/* @__PURE__ */ new Set([`canParse`,`parse`]),pi=y(b(`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&&w(n.callee,e,`URL`)&&e.report({node:n,messageId:`effectUrl`})},CallExpression(n){let r=S(n.callee);t().hasEffectImport&&r?.[0]===`URL`&&fi.has(r[1]??``)&&n.callee.type===`MemberExpression`&&w(n.callee.object,e,`URL`)&&e.report({node:n,messageId:`effectUrl`})}})),mi=/* @__PURE__ */ new Map([[`interruptibleMask`,`interruptible`],[`uninterruptibleMask`,`uninterruptible`]]),hi=y(b(`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=T(n.callee,t()),i=r?.length===2&&r[0]===`Effect`?mi.get(r[1]??``):void 0,a=A(n,0);i!==void 0&&a!==void 0&&k(a)&&!pe(a)&&e.report({node:n,messageId:`unusedRestore`,data:{replacement:`Effect.${i}`}})}})),gi=y(b(`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(!E(n.callee,t(),`Effect`,`useSpan`))return;let r=A(n,n.arguments.length-1);r!==void 0&&k(r)&&!pe(r)&&e.report({node:n,messageId:`unusedSpan`})}}));function _i(e,t){let n=N(e);if(z(n,0))return!0;if(R(n))return/^0\s*(?:nanos?|micros?|millis?|seconds?|minutes?|hours?|days?|weeks?)$/i.test(n.value);if(E(n,t,`Duration`,`zero`))return!0;if(n.type===`CallExpression`){let e=T(n.callee,t),r=A(n,0);return r!==void 0&&e?.[0]===`Duration`&&z(r,0)}return!1}const vi=y(b(`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=A(n,0);i!==void 0&&E(n.callee,r,`Effect`,`sleep`)&&_i(i,r)&&e.report({node:n,messageId:`zeroSleep`})}})),yi=/* @__PURE__ */ new Set([`catch`,`mapError`,`catchAll`]);function bi(e,t){let n=Tt(e,t),r=wt(e,`catch`);if(!(n?.[0]===`Effect`&&n[1]!==void 0&&yi.has(n[1])||r!==void 0&&D(r.callee,t,`Effect`,[`try`,`tryPromise`]))||!e.body)return!1;let i=F(e);return P(e.body,e=>e.type===`NewExpression`&&ye(e)&&(i===void 0||!fe(e,i.name)))}const xi=y(b(`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){bi(n,t())&&e.report({node:n,messageId:`droppedCause`})},FunctionExpression(n){bi(n,t())&&e.report({node:n,messageId:`droppedCause`})}})),Si=y(b(`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){E(n.callee,t(),`Schema`,`Class`)&&(n.typeArguments?.params.length??0)<2&&e.report({node:n,messageId:`missingBrand`})}}));function Ci(e,t){if(E(e.callee,t,`Effect`,`tryPromise`))return Mt(A(e,0))}const wi=y(b(`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=Ci(n,t());if(r===void 0)return;let i=F(r);i===void 0?e.report({node:r,messageId:`missingSignal`}):!u.startsWith(`_`)(i.name)&&!pe(r)&&e.report({node:i,messageId:`unusedSignal`})}})),Ti=[`fn`,`fnUntraced`,`gen`],Ei=[`fn`,`fnUntraced`],Di=[`try`,`tryPromise`];function Oi(e,t){let n=e.parent;if(n.type===`CallExpression`&&A(n,0)===e)return D(n.callee,t,`Effect`,Di);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`&&D(r.parent.callee,t,`Effect`,Di)}const ki=y(b(`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=I(n);if(a===void 0||Oi(a,i))return;let o=L(a),s=o!==void 0&&r.some(Ti,e=>E(o.callee,i,`Effect`,e)),c=o?.callee,l=c?.type===`CallExpression`&&r.some(Ei,e=>E(c.callee,i,`Effect`,e));(s||l)&&e.report({node:n,messageId:`throwInGen`})}})),Ai=String.raw`(?:\r\n|\r(?!\n)|[\n\u2028\u2029])`,ji=String.raw`[^\S\r\n\u2028\u2029]*`,Mi=RegExp(`^(${ji}${Ai})(?:${ji}${Ai})+(${ji};?)$`,`u`),Ni=/^(?:module\s*\.\s*)?exports(?:\s*\.|\s*\[|$)/u,Pi=/* @__PURE__ */ new Set([`FunctionDeclaration`,`FunctionExpression`,`ArrowFunctionExpression`]),Fi=/* @__PURE__ */ new Set([`any`,`never`,`always`]),Ii=/* @__PURE__ */ new Set([`any`,`singleline`,`multiline`]),Li=/* @__PURE__ */ new Set([`blankLine`,`prev`,`next`]),Ri=/* @__PURE__ */ new Set([`selector`,`lineMode`]);function zi(e){return e.type===`Punctuator`&&e.value===`;`}function J(e,t){return e.loc.end.line===t.loc.start.line}function Y(e){return e.loc.start.line===e.loc.end.line}function Bi(e){return Pi.has(e.type)}function Vi(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)&&Y(n)===(t===`singleline`)}function Hi(e){if(e.type!==`ExpressionStatement`)return!1;let t=Vi(e.expression);if(t.type===`UnaryExpression`&&(t=Vi(t.argument)),t.type!==`CallExpression`)return!1;let n=t.callee;for(;n.type===`SequenceExpression`;)n=s.getOrThrowWith(r.last(n.expressions),()=>/* @__PURE__ */ Error(`Padding rule invariant: sequence expression is empty`));return Bi(n)}function Ui(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 Wi(e,t){if(e.type===`DoWhileStatement`&&e.body.type===`BlockStatement`||Hi(e))return!0;let n=t.getLastToken(e,e=>!zi(e)),r=n?.type===`Punctuator`&&n.value===`}`?t.getNodeByRangeIndex(n.range[0]):null;return r?.type===`BlockStatement`||r?.type===`SwitchStatement`}function Gi(e,t){return e.type===`ExpressionStatement`&&(e.parent.type===`Program`||e.parent.type===`BlockStatement`&&Bi(e.parent.parent))&&e.expression.type===`Literal`&&c.isString(e.expression.value)&&(t.getTokenBefore(e.expression)?.value!==`(`||t.getTokenAfter(e.expression)?.value!==`)`)}function Ki(e,t){if(!Gi(e,t)||!e.parent||!(`body`in e.parent)||!r.isArray(e.parent.body))return!1;let n=e.parent.body;return a.pipe(n,r.takeWhile(t=>t!==e),r.every(e=>Gi(e,t)))}function qi(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 Ji(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]&&zi(n)&&!J(r,n)&&J(n,i)?r:n}function Yi(e,t){if(Y(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":Wi,expression:(e,t)=>e.type===`ExpressionStatement`&&!Ki(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`)},Xi={"*":()=>!0,exports:qi,require:Ui,directive:Ki,iife:Hi,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`&&Ni.test(t.getText(e.expression.left)),"cjs-import":(e,t)=>e.type===`VariableDeclaration`&&e.declarations[0]?.init!=null&&u.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 Zi(e){return Ii.has(e)}function Qi(e){return Fi.has(e)}function $i(e){return c.isString(e)&&n.has(Xi,e)}function ea(e){return r.isArray(e)}function ta(e){if($i(e))return e;if(c.isObject(e)&&c.isString(e.selector)&&r.every(n.keys(e),e=>Ri.has(e))){if(!(`lineMode`in e))return{selector:e.selector};if(Zi(e.lineMode))return{selector:e.selector,lineMode:e.lineMode}}throw Error(`Invalid padding-line-between-statements statement matcher`)}function na(e){if(!r.isArray(e))return ta(e);let t=e;if(!r.isReadonlyArrayNonEmpty(t))throw Error(`Padding statement matcher arrays must not be empty`);return r.map(t,e=>ta(e))}function ra(e){return r.map(e,e=>{if(!c.isObject(e)||!(`blankLine`in e)||!(`prev`in e)||!(`next`in e)||r.some(n.keys(e),e=>!Li.has(e))||!Qi(e.blankLine))throw Error(`Invalid padding-line-between-statements configuration`);return{blankLine:e.blankLine,prev:na(e.prev),next:na(e.next)}})}function ia(e,t,n){let r=[],i=Ji(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 aa(e,t,n){return i.gen(function*(){if(n===`any`)return yield*i.void;let o=yield*h,s=o.sourceCode,c=ia(e,t,s);return n===`never`?r.isArrayNonEmpty(c)?yield*o.report({node:t,messageId:`unexpectedBlankLine`,loc:Yi(t,s),fix(e){if(c.length>=2)return null;let t=r.headNonEmpty(c),n=t[0].range[1],i=t[1].range[0];return e.replaceTextRange([n,i],a.pipe(s.text,u.slice(n,i),u.replace(Mi,`$1$2`)))}}):yield*i.void:r.isArrayNonEmpty(c)?yield*i.void:yield*o.report({node:t,messageId:`expectedBlankLine`,loc:Yi(t,s),fix(n){let r=Ji(e,s),i=s.getFirstTokenBetween(r,t,{includeComments:!0,filter(e){return!J(r,e)||(r=e,!1)}})??t;return n.insertTextAfter(r,J(r,i)?`
3
3
 
4
4
  `:`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@2digits/oxlint-plugin",
3
- "version": "0.4.2",
3
+ "version": "0.4.4",
4
4
  "description": "Custom Oxlint rules for 2digits projects.",
5
5
  "keywords": [
6
6
  "2digits",
@@ -29,14 +29,14 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "@oxlint/plugins": "1.90.0",
32
- "effect": "4.0.7",
32
+ "effect": "4.1.2",
33
33
  "effect-oxlint": "0.4.0"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@2digits/tsconfig": "1.2.1",
37
37
  "@arethetypeswrong/core": "0.18.5",
38
- "@effect/platform-node": "4.0.7",
39
- "@effect/vitest": "4.0.7",
38
+ "@effect/platform-node": "4.1.2",
39
+ "@effect/vitest": "4.1.2",
40
40
  "@typescript/native-preview": "7.0.0-dev.20260707.2",
41
41
  "dedent": "1.7.2",
42
42
  "oxlint": "1.90.0",