@2digits/oxlint-plugin 0.2.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/NOTICE CHANGED
@@ -13,7 +13,14 @@ Licensed under the MIT License.
13
13
  anti-slop
14
14
  Copyright (c) 2026 Dillon Mulroy
15
15
  https://github.com/dmmulroy/anti-slop
16
- Licensed under the MIT License. The permission notice below applies to this project too.
16
+ Licensed under the MIT License.
17
+
18
+ t3code (no-inline-schema-compile)
19
+ Copyright (c) 2026 T3 Tools Inc.
20
+ https://github.com/pingdotgg/t3code
21
+ Licensed under the MIT License.
22
+
23
+ The permission notice below applies to anti-slop and t3code.
17
24
 
18
25
  Permission is hereby granted, free of charge, to any person obtaining a copy
19
26
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -32,6 +32,12 @@ The package exports all rules as `rules`, their names as `RuleName`, and the def
32
32
  - Effect and Alchemy import policy: namespace imports from PascalCase submodule entrypoints, canonical Effect aliases,
33
33
  and no root-barrel module imports. `@effect/vitest` and lowercase unstable barrels are intentionally exempt.
34
34
  - Alchemy v2 practices: every `alchemy-*` rule.
35
+ - Schema compiler hoisting from t3code: `no-inline-schema-compile` reports `Schema.decode*`, `Schema.encode*`,
36
+ `Schema.is`, and `Schema.asserts` compilers that are built and invoked inside a function body when their schema
37
+ could be hoisted to module scope.
38
+ - Schema chain style: `consistent-schema-pipe` applies Schema modifiers and data-last steps with `.pipe(...)`
39
+ (`Schema.String.pipe(Schema.optionalKey)`) and calls Schema wrappers such as `Schema.Array(...)` directly. See
40
+ [ADR 0001](../../docs/adr/0001-schema-modifiers-pipe-wrappers-call.md).
35
41
 
36
42
  See each rule's `meta.docs.url` for its upstream rule, issue, or framework documentation. Copied-code attribution is in
37
43
  [`NOTICE`](./NOTICE).
@@ -173,7 +179,7 @@ The exported `PaddingLineOption` type describes each configuration entry. No opt
173
179
 
174
180
  ### Other fixes
175
181
 
176
- Run `vp lint --fix` to apply fixes from `prefer-effect-duration`, `no-empty-effect-callback`,
182
+ Run `vp lint --fix` to apply fixes from `consistent-schema-pipe`, `prefer-effect-duration`, `no-empty-effect-callback`,
177
183
  `no-effect-alchemy-barrel-imports`, `prefer-effect-alchemy-namespace-imports`,
178
184
  `alchemy-no-v1-worker-properties`, and `alchemy-no-deprecated-docker-constraints`.
179
185
  Fixes skip ambiguous bindings, conflicting properties, and unsupported import references.
package/dist/index.d.mts CHANGED
@@ -13,6 +13,7 @@ export declare const rules: {
13
13
  readonly 'alchemy-no-v1-worker-properties': import("effect-oxlint").OxlintRule;
14
14
  readonly 'avoid-data-tagged-error': import("effect-oxlint").OxlintRule;
15
15
  readonly 'ban-error-string': import("effect-oxlint").OxlintRule;
16
+ readonly 'consistent-schema-pipe': import("effect-oxlint").OxlintRule;
16
17
  readonly 'cors-credentials-with-wildcard': import("effect-oxlint").OxlintRule;
17
18
  readonly 'dual-numeric-arity-with-optional-parameter': import("effect-oxlint").OxlintRule;
18
19
  readonly 'effect-promise-vs-trypromise': import("effect-oxlint").OxlintRule;
@@ -25,6 +26,7 @@ export declare const rules: {
25
26
  readonly 'no-effect-alchemy-barrel-imports': import("effect-oxlint").OxlintRule;
26
27
  readonly 'no-function-config-default': import("effect-oxlint").OxlintRule;
27
28
  readonly 'no-hash-as-identity': import("effect-oxlint").OxlintRule;
29
+ readonly 'no-inline-schema-compile': import("effect-oxlint").OxlintRule;
28
30
  readonly 'no-logging-in-catch': import("effect-oxlint").OxlintRule;
29
31
  readonly 'no-manual-effect-error-tag': import("effect-oxlint").OxlintRule;
30
32
  readonly 'no-manual-tag-comparison': import("effect-oxlint").OxlintRule;
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import{defineRule as e,eslintCompatPlugin as t}from"@oxlint/plugins";import*as n from"effect/Array";import*as r from"effect/Function";import*as i from"effect/Record";import*as a from"effect/Option";import*as o from"effect/Match";import*as s from"effect/Number";import*as c from"effect/String";import{Rule as l,RuleContext as u,Visitor as d}from"effect-oxlint";import*as f from"effect/Effect";import*as p from"effect/Ref";const m={bindings:/* @__PURE__ */ new Map,hasEffectImport:!1};function h(e){return e.imported.type===`Identifier`?e.imported.name:typeof e.imported.value==`string`?e.imported.value:void 0}function g(e){if(e===`alchemy`)return[`Alchemy`];if(e===`effect`||e===`@effect/platform`)return[];if(e.startsWith(`effect/`)||e.startsWith(`@effect/platform/`)||e.startsWith(`alchemy/`)){let t=e.split(`/`).at(-1);return t===void 0?void 0:/^\p{Ll}/u.test(t)?[]:[t]}}function ee(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`||e.startsWith(`effect/`)||e.startsWith(`@effect/`))&&(n=!0);let i=g(e);if(i!==void 0)for(let e of r.specifiers){if(e.type===`ImportNamespaceSpecifier`||e.type===`ImportDefaultSpecifier`){t.set(e.local.name,i);continue}let n=h(e);n!==void 0&&t.set(e.local.name,[...i,n])}}return{bindings:t,hasEffectImport:n}}function _(t,n){return e({meta:t,createOnce:n})}function v(t,n){return e({meta:t,createOnce(e){let t=m,{before:r,Program:i,...a}=n(e,()=>t);return{before(){t=m,r?.()},Program(e){t=ee(e),i?.(e)},...a}}})}function y(e,t,n,r){return{type:e,docs:{description:t,recommended:!0,...r===void 0?{}:{url:r}},schema:[],messages:n}}function b(e){if(!e.computed&&e.property.type===`Identifier`)return e.property.name;if(e.computed&&e.property.type===`Literal`&&typeof e.property.value==`string`)return e.property.value}function x(e){let t=[],n=e;for(;n.type===`ChainExpression`||n.type===`MemberExpression`;){if(n.type===`ChainExpression`){n=n.expression;continue}let e=b(n);if(e===void 0)return;t.unshift(e),n=n.object}return n.type===`Identifier`?[n.name,...t]:void 0}function S(e,t,n){if(e.type!==`Identifier`||e.name!==n)return!1;let r=t.sourceCode.getScope(e);for(;r!==null;){if(r.set.has(n))return!1;r=r.upper}return!0}function C(e,t){let n=x(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 w(e,t,n,r){let i=C(e,t);return i?.length===2&&i[0]===n&&i[1]===r}function T(e,t,i){let a=C(e,t);return a?.length===i.length&&r.pipe(a,n.every((e,t)=>e===i[t]))}function E(e){return e?.type===`ArrowFunctionExpression`||e?.type===`FunctionExpression`}function D(e,t){let n=e.arguments[t];return n===void 0||n.type===`SpreadElement`?void 0:n}function O(e){if(!e.computed&&e.key.type===`Identifier`)return e.key.name;if(e.key.type===`Literal`&&typeof e.key.value==`string`)return e.key.value}function k(e,t){for(let n of e.properties)if(n.type===`Property`&&O(n)===t)return n}function te(e){return[`ParenthesizedExpression`,`TSAsExpression`,`TSNonNullExpression`,`TSSatisfiesExpression`,`TSTypeAssertion`].includes(e.type)}function A(e){let t=e;for(;te(t);)t=t.expression;return t}function ne(e,t){if(n.isArray(e))for(let n of e)t.push(n);else for(let[n,r]of i.toEntries(e))[`loc`,`parent`,`range`].includes(n)||t.push(r)}function j(e,t){let n=[e],r=/* @__PURE__ */ new WeakSet;for(;n.length>0;){let e=n.pop();if(e&&typeof e==`object`&&!r.has(e)){if(r.add(e),typeof e.type==`string`&&t(e)===!0)return!0;ne(e,n)}}return!1}function M(e,t){return j(e,e=>e.type===`Identifier`&&e.name===t)}function N(e){let t=e.params[0];return t?.type===`Identifier`?t:void 0}function P(e){let t=N(e);return t===void 0||!e.body||t.name.startsWith(`_`)?!1:M(e.body,t.name)}function re(e){let t=e.parent;for(;t;){if(E(t))return t;t=t.parent}}function F(e){let t=e.parent;if(t.type===`CallExpression`&&t.arguments.includes(e))return t}function I(e,t){return e.type===`Literal`&&e.value===t}function ie(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}function L(e){return x(e.callee)?.at(-1)?.endsWith(`Error`)===!0}const ae=/* @__PURE__ */ new Set([`alarm`,`fetch`,`queue`,`rpc`,`scheduled`,`tail`,`trace`,`webSocketClose`,`webSocketError`,`webSocketMessage`]);function oe(e,t){return T(e,t,[`Cloudflare`,`Worker`])||T(e,t,[`Cloudflare`,`Workers`,`Worker`])}function se(e,t){let n=e.parent;for(;n;){if(n.type===`CallExpression`&&oe(n.callee,t))return n;n=n.parent}}function ce(e,t){let n=re(e),r=n===void 0?void 0:F(n);return r!==void 0&&w(r.callee,t,`Effect`,`gen`)?r:void 0}function le(e){let t=e.parent;for(;t;){if(E(t))return;if(t.type===`Property`){let e=O(t);if(e!==void 0&&ae.has(e))return e}t=t.parent}}const ue=v(y(`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(!w(n.callee,r,`Effect`,`addFinalizer`))return;let i=ce(n,r);i!==void 0&&se(i,r)?.arguments.includes(i)&&e.report({node:n,messageId:`finalizer`})}}));function de(e,t,n){let r=e.sourceCode.getScope(t);for(;r!==null;){let e=r.set.get(n);if(e!==void 0)return e;r=r.upper}}function R(e,t){let i=x(t)?.[0],a=i===void 0?void 0:de(e,t,i);return r.pipe(a?.defs??[],n.some(e=>{let t=e.node;return e.type===`ImportBinding`&&t.parent?.type===`ImportDeclaration`&&t.parent.importKind!==`type`&&(t.type!==`ImportSpecifier`||t.importKind!==`type`)}))}function fe(e,t,i,o,s){let c=e.sourceCode.ast;for(let a of c.body)if(a.type===`ImportDeclaration`&&a.source.value===i&&a.importKind!==`type`){for(let i of a.specifiers)if(i.type===`ImportNamespaceSpecifier`&&r.pipe(de(e,t,i.local.name)?.defs??[],n.some(e=>e.node===i)))return{name:i.local.name,fixes:[]}}let l=new Set(r.pipe(e.sourceCode.scopeManager.scopes,n.flatMap(e=>[...r.pipe(e.variables,n.map(e=>e.name)),...r.pipe(e.references,n.map(e=>e.identifier.name))]))),u=o,d=2;for(;l.has(u);)u=`${o}${d++}`;let f=`import * as ${u} from '${i}';\n`,p=a.getOrUndefined(r.pipe(c.body,n.findFirst(e=>e.type!==`ExpressionStatement`||e.expression.type!==`Literal`||typeof e.expression.value!=`string`)));return{name:u,fixes:[p===void 0?s.insertTextAfter(c,`\n${f}`):s.insertTextBefore(p,f)]}}function pe(e,t){let i=/* @__PURE__ */ new Set;return r.pipe(e.properties,n.every(e=>{if(e.type!==`Property`||e.computed||e.method||e.kind!==`init`||e.key.type!==`Identifier`&&e.key.type!==`Literal`)return!1;let n=e.key.type===`Identifier`?e.key.name:String(e.key.value);return n===t||i.has(n)?!1:(i.add(n),!0)}))}const me=v({...y(`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(!w(n.callee,t(),`Docker`,`Service`))return;let r=D(n,1),i=r?.type===`ObjectExpression`?k(r,`constraints`):void 0;i!==void 0&&e.report({node:i,messageId:`constraints`,fix(t){if(R(e,n.callee)&&r?.type===`ObjectExpression`&&pe(r,`placement`))return t.replaceText(i,`placement: { ${e.sourceCode.getText(i)} }`)}})}})),he=/* @__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`]]),ge=v(y(`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(r){let i=C(r.callee,t());if(i===void 0)return;let a=n.join(i,`.`),o=he.get(a);o!==void 0&&e.report({node:r.callee,messageId:`deprecated`,data:{api:a,replacement:o}})}}));function _e(e,t){let n=A(e);if(n.type===`Literal`&&typeof n.value==`string`||n.type===`TemplateLiteral`)return!0;let r=x(n);return r?.[0]===`process`&&r[1]===`env`||n.type===`CallExpression`&&w(n.callee,t,`Config`,`string`)}const ve=v(y(`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(!w(n.callee,r,`GitHub`,`Secret`))return;let i=D(n,1),a=i?.type===`ObjectExpression`?k(i,`value`):void 0;a!==void 0&&_e(a.value,r)&&e.report({node:a.value,messageId:`plaintext`})}})),ye=v(y(`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=C(n.callee,t());r?.[0]===`Alchemy`&&(r[1]===`Secret`||r[1]===`Variable`)&&e.report({node:n.callee,messageId:`removed`,data:{api:r[1]}})}})),be=v(y(`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(!T(n.callee,t(),[`AWS`,`EventBridge`,`EventBus`]))return;let r=D(n,1),i=r?.type===`ObjectExpression`?k(r,`name`):void 0;i!==void 0&&I(i.value,`default`)&&e.report({node:i.value,messageId:`reserved`})}})),xe=v(y(`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`||C(i.callee,r)?.[0]!==`Config`)return;let a=ce(n,r),o=a===void 0?void 0:le(a);a!==void 0&&o!==void 0&&se(a,r)!==void 0&&e.report({node:i,messageId:`runtime`,data:{handler:o}})}})),Se=_(y(`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 i=t.source.value;if(i===`alchemy`){let i=a.getOrUndefined(r.pipe(t.specifiers,n.findFirst(e=>e.type===`ImportDefaultSpecifier`)));i!==void 0&&e.report({node:i,messageId:`defaultImport`});return}let o=/^alchemy\/(aws|cloudflare)$/.exec(i)?.[1];if(o===void 0)return;let s=`alchemy/${o===`aws`?`AWS`:`Cloudflare`}`;e.report({node:t.source,messageId:`providerImport`,data:{replacement:s}})}})),Ce=v({...y(`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(!oe(n.callee,t()))return;let r=D(n,1);if(r?.type===`ObjectExpression`)for(let[t,i]of[[`entrypoint`,`main`],[`bindings`,`env`]]){let a=k(r,t);a!==void 0&&e.report({node:a,messageId:`property`,data:{old:t,replacement:i},fix(o){if(R(e,n.callee)&&pe(r,i))return o.replaceText(a.key,a.shorthand?`${i}: ${t}`:i)}})}}})),we=v(y(`suggestion`,`Prefer schema-based tagged errors so errors have a serializable contract.`,{taggedError:`Prefer Schema.TaggedErrorClass over Data.TaggedError.`}),(e,t)=>({CallExpression(n){w(n.callee,t(),`Data`,`TaggedError`)&&e.report({node:n.callee,messageId:`taggedError`})}})),Te=/* @__PURE__ */ new Set([`error`,`err`,`e`,`cause`,`exception`,`ex`]);function Ee(e){return e?.type===`Identifier`&&Te.has(e.name)?e.name:void 0}function De(e){if(e.type!==`CallExpression`||e.arguments.length!==1)return!1;let t=x(e.callee);return t?.at(-1)===`String`&&t.length<=2}const Oe=_({...y(`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=D(t,0);if(n===void 0||!De(n)||!L(t))return;let r=D(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(De(t)){if(t.parent.type===`NewExpression`&&t.parent.arguments[0]===t&&L(t.parent))return;let n=Ee(t.arguments[0]);n!==void 0&&e.report({node:t,messageId:`errorString`,data:{name:n}});return}if(t.callee.type!==`MemberExpression`||x(t.callee)?.at(-1)!==`toString`||t.arguments.length>0)return;let n=Ee(t.callee.object);n!==void 0&&e.report({node:t,messageId:`errorString`,data:{name:n}})},TemplateLiteral(t){let[n,r]=t.quasis,i=Ee(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}})}}));function z(e){for(let t of e.arguments)if(t.type===`ObjectExpression`)return t}function ke(e,t){let n=e.parent;if(n.type!==`Property`||O(n)!==t)return;let r=n.parent,i=r.parent;return r.type===`ObjectExpression`&&i?.type===`CallExpression`?i:void 0}function Ae(e,t){let n=F(e);return n===void 0?void 0:C(n.callee,t)}function je(e){let t=A(e);if(t.type===`NewExpression`){let e=x(t.callee);return e!==void 0&&n.join(e,`.`)===`Promise`}if(t.type!==`CallExpression`)return!1;let r=x(t.callee);return r!==void 0&&n.join(r,`.`)===`fetch`||r?.[0]===`Promise`&&r[1]!==`withResolvers`||[`catch`,`finally`,`then`].includes(r?.at(-1)??``)||E(t.callee)&&t.callee.async}function B(e){if(e.body){if(e.body.type!==`BlockStatement`)return A(e.body);if(e.body.body.length===1&&e.body.body[0]?.type===`ReturnStatement`&&e.body.body[0].argument)return A(e.body.body[0].argument)}}function Me(e){let t=A(e);return I(t,`*`)?!0:t.type===`ArrayExpression`&&(t.elements.length===0||r.pipe(t.elements,n.some(e=>!e||e.type===`SpreadElement`?!1:I(e,`*`))))}const Ne=v(y(`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(!w(n.callee,r,`HttpMiddleware`,`cors`)&&!w(n.callee,r,`HttpRouter`,`cors`)&&!w(n.callee,r,`HttpApiBuilder`,`middlewareCors`))return;let i=z(n);if(i===void 0||!I(k(i,`credentials`)?.value??i,!0))return;let a=k(i,`allowedOrigins`);(a===void 0||Me(a.value))&&e.report({node:n,messageId:`wildcard`})}}));function Pe(e){return e.type===`AssignmentPattern`||e.type===`RestElement`||e.optional===!0}const Fe=v(y(`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(i){let a=D(i,0),o=D(i,1);o!==void 0&&w(i.callee,t(),`Function`,`dual`)&&a?.type===`Literal`&&typeof a.value==`number`&&E(o)&&r.pipe(o.params,n.some(e=>Pe(e)))&&e.report({node:a,messageId:`unsafeArity`})}})),Ie=v(y(`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){w(n.callee,t(),`Effect`,`promise`)&&e.report({node:n.callee,messageId:`tryPromise`})}}));function Le(e,t){if(!w(e.callee,t,`Effect`,`promise`)&&!w(e.callee,t,`Effect`,`tryPromise`))return;let n=D(e,0);if(n!==void 0&&E(n))return n;if(n?.type===`ObjectExpression`){let e=k(n,`try`);if(e!==void 0&&E(e.value))return e.value}}const Re=v(y(`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&&je(e.init)&&n.add(e.id.name)},CallExpression(r){let i=Le(r,t()),a=i===void 0?void 0:B(i);a?.type===`Identifier`&&n.has(a.name)&&e.report({node:a,messageId:`prestarted`})}}}),ze=v(y(`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(!w(n.callee,t(),`Effect`,`try`))return;let r=D(n,0),i=r!==void 0&&E(r)?r:void 0;if(i===void 0&&r?.type===`ObjectExpression`){let e=k(r,`try`)?.value;e!==void 0&&E(e)&&(i=e)}let a=i===void 0?void 0:B(i);i!==void 0&&(i.async||a!==void 0&&je(a))&&e.report({node:i,messageId:`asyncTry`})}})),Be=v(y(`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=w(n.callee,r,`Effect`,`runPromise`),a=n.callee.type===`CallExpression`&&w(n.callee.callee,r,`Effect`,`runPromiseWith`);(i||a)&&ie(n)&&e.report({node:n,messageId:`discarded`})}}));function Ve(e,t){let n=A(e);if(n.type===`CallExpression`&&n.callee.type===`MemberExpression`&&b(n.callee)===t)return n}const He=v(y(`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(i){if(!t().hasEffectImport||i.callee.type!==`MemberExpression`)return;let o=b(i.callee);if(o===void 0||![`mapElements`,`mapFields`,`mapMembers`].includes(o)||Ve(i.callee.object,`check`)===void 0)return;let s=a.getOrUndefined(r.pipe(i.arguments,n.findFirst(e=>e.type===`ObjectExpression`))),c=s?.type===`ObjectExpression`?k(s,`unsafePreserveChecks`):void 0;c!==void 0&&I(c.value,!0)||e.report({node:i,messageId:`discarded`,data:{method:o}})}})),Ue={Array:`Arr`,Boolean:`Bool`,Equal:`Eq`,Function:`Fn`,Number:`Num`,Option:`Opt`,Predicate:`P`,Record:`R`,String:`Str`};function We(e){return e===`@effect/vitest`||e.startsWith(`@effect/vitest/`)}function V(e,t){return e.importKind===`type`||t?.importKind===`type`}function H(e){return Ue[e]??e}function Ge(e,t){if(e===`effect`||e===`alchemy`||/^@effect\/[^/]+$/u.test(e)&&!We(e))return`${e}/${t}`}function Ke(e){if(We(e))return;let t=e.startsWith(`effect/`)||e.startsWith(`alchemy/`)||/^@effect\/[^/]+\//u.test(e)?e.split(`/`).at(-1):void 0;return t!==void 0&&/^\p{Lu}/u.test(t)?t:void 0}function qe(e,t,r){if(e.sourceCode.getCommentsInside(t).length>0||t.attributes.length>0)return;let i=[],a=[];for(let n of t.specifiers){if(n.type!==`ImportSpecifier`)return;let r=n.imported.type===`Identifier`?n.imported.name:n.imported.value,o=/^\p{Lu}/u.test(r)&&!V(t,n)?Ge(t.source.value,r):void 0;o===void 0?i.push(e.sourceCode.getText(n)):a.push(`import * as ${n.local.name} from '${o}';`)}return i.length>0&&a.unshift(`import { ${n.join(i,`, `)} } from ${e.sourceCode.getText(t.source)};`),[r.replaceText(t,n.join(a,`
2
- `))]}function Je(e,t,i){let o=Ke(t.source.value);if(o===void 0||t.attributes.length>0||e.sourceCode.getCommentsInside(t).length>0)return;let s=H(o),c=e.sourceCode.getDeclaredVariables(t),l=a.getOrUndefined(r.pipe(c,n.findFirst(e=>e.name===s)));if(r.pipe(e.sourceCode.scopeManager.scopes,n.some(e=>r.pipe(e.variables,n.some(e=>e.name===s&&e!==l))||r.pipe(e.references,n.some(e=>e.identifier.name===s&&e.resolved!==l)))))return;let u=[],d=[];for(let n of t.specifiers){if(n.type===`ImportDefaultSpecifier`)return;if(n.type===`ImportSpecifier`&&V(t,n)){if(n.local.name===s)return;d.push(e.sourceCode.getText(n));continue}let r=Ye(n,c,s,i);if(r===void 0)return;u.push(...r)}let f=e.sourceCode.getText(t.source),p=`import * as ${s} from ${f};${d.length===0?``:`\nimport { ${n.join(d,`, `)} } from ${f};`}`;return[i.replaceText(t,p),...u]}function Ye(e,t,i,o){let s=a.getOrUndefined(r.pipe(t,n.findFirst(t=>t.name===e.local.name)));if(s!==void 0){if(e.type===`ImportNamespaceSpecifier`)return Xe(s,i,!1,o);if(e.imported.type===`Identifier`)return Xe(s,`${i}.${e.imported.name}`,!0,o)}}function Xe(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`||s.type.startsWith(`JSX`))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}function Ze(e){return e?.imported.type===`Identifier`?e.imported.name:typeof e?.imported.value==`string`?e.imported.value:void 0}const Qe=_({...y(`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`||V(t,n))continue;let r=Ze(n),i=r===void 0||!/^\p{Lu}/u.test(r)?void 0:Ge(t.source.value,r);r!==void 0&&i!==void 0&&e.report({node:n,messageId:`barrelImport`,data:{alias:H(r),source:i},fix:n=>qe(e,t,n)})}}})),$e=v({...y(`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(i){if(!w(i.callee,t(),`Effect`,`callback`)&&!w(i.callee,t(),`Effect`,`async`))return;let a=D(i,0);a!==void 0&&E(a)&&a.body?.type===`BlockStatement`&&a.body.body.length===0&&e.report({node:i,messageId:`emptyCallback`,fix(t){if(!R(e,i.callee)||i.arguments.length!==1||a.async||a.generator||r.pipe(a.params,n.some(e=>e.type!==`Identifier`))||e.sourceCode.getCommentsInside(i).length>0)return;let o=fe(e,i,`effect/Effect`,`Effect`,t);return[...o.fixes,t.replaceText(i,`${o.name}.never`)]}})}})),et=v(y(`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=D(n,0);w(n.callee,t(),`Schema`,`Struct`)&&r?.type===`ObjectExpression`&&r.properties.length===0&&e.report({node:n,messageId:`emptyStruct`})}}));function tt(e,t){let i=A(e),a=/* @__PURE__ */ new Set;for(;i.type===`Identifier`;){let e=t.sourceCode.getScope(i);for(;e!==null&&!e.set.has(i.name);)e=e.upper;let o=e?.set.get(i.name),s=o?.defs.length===1?o.defs[0]:void 0,c=s?.node;if(o===void 0||a.has(o)||c?.type!==`VariableDeclarator`||c.id.type!==`Identifier`||s?.parent?.type!==`VariableDeclaration`||s.parent.kind!==`const`||!c.init||r.pipe(o.references,n.some(e=>e.isWrite()&&!e.init)))return;a.add(o),i=A(c.init)}return i}function nt(e){if(e.arguments.length===2)return D(e,0);let t=e.parent;if(e.arguments.length===1&&t.type===`CallExpression`&&t.arguments[0]===e&&t.callee.type===`MemberExpression`&&b(t.callee)===`pipe`)return t.callee.object}const rt=v(y(`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(!w(n.callee,t(),`Config`,`withDefault`)||!R(e,n.callee))return;let r=D(n,n.arguments.length-1),i=nt(n),a=i===void 0?void 0:tt(i,e);a?.type===`CallExpression`&&w(a.callee,t(),`Config`,`succeed`)&&R(e,a.callee)&&E(D(a,0))||r!==void 0&&E(r)&&r.params.length===0&&e.report({node:r,messageId:`functionDefault`})}}));function it(e,t){return e.type===`CallExpression`&&w(e.callee,t,`Hash`,`hash`)}const at=v(y(`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 it(e,t())||e.type===`Identifier`&&n.has(e.name)}return{before(){n=/* @__PURE__ */ new Set},VariableDeclarator(e){e.id.type===`Identifier`&&e.init&&it(e.init,t())&&n.add(e.id.name)},CallExpression(t){if(t.callee.type!==`MemberExpression`||![`delete`,`get`,`has`,`set`].includes(x(t.callee)?.at(-1)??``))return;let n=D(t,0);n!==void 0&&r(n)&&e.report({node:n,messageId:`hashIdentity`})},BinaryExpression(t){[`===`,`!==`,`==`,`!=`].includes(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`})}}}),ot=/* @__PURE__ */ new Set([`catch`,`catchAll`,`catchAllCause`,`catchIf`,`catchSome`,`catchSomeCause`,`catchTag`,`orElse`,`orElseFail`,`orElseSucceed`]),st=/* @__PURE__ */ new Set([`log`,`logDebug`,`logError`,`logInfo`,`logTrace`,`logWarning`]);function ct(e,t){let n=e.parent;for(;n;){if(E(n)){let e=F(n);if(e?.arguments.at(-1)===n){let n=C(e.callee,t),r=n?.[1];if(r!==void 0&&n?.[0]===`Effect`&&ot.has(r))return{method:r}}}n=n.parent}}const lt=v(y(`suggestion`,`Keep logging separate from Effect recovery handlers.`,{logging:`Move {{logger}} out of Effect.{{catchMethod}} and use Effect.tapError before recovery.`}),(e,t)=>({CallExpression(r){let i=t(),a=C(r.callee,i),o=a?.[1]!==void 0&&a[0]===`Effect`&&st.has(a[1])?n.join(a,`.`):void 0;if(o===void 0)return;let s=ct(r,i);s!==void 0&&e.report({node:r,messageId:`logging`,data:{logger:o,catchMethod:s.method}})}})),ut=/* @__PURE__ */ new Set([`==`,`===`,`!=`,`!==`]),dt=/* @__PURE__ */ new Set([`catch`,`catchAll`,`catchIf`]);function U(e){return e.type===`Literal`&&typeof e.value==`string`}function W(e){return e.type===`MemberExpression`&&b(e)===`_tag`}function ft(e){if(ut.has(e.operator)){if(W(e.left)&&U(e.right))return e.left;if(W(e.right)&&U(e.left))return e.right}}function G(e){let t=e.parent;for(;t;){if(t.type===`ArrowFunctionExpression`||t.type===`FunctionExpression`){let e=t.parent;return e.type===`CallExpression`&&e.arguments.includes(t)&&e.callee.type===`MemberExpression`&&e.callee.object.type===`Identifier`&&e.callee.object.name===`Effect`&&!e.callee.computed&&e.callee.property.type===`Identifier`&&dt.has(e.callee.property.name)}t=t.parent}return!1}function pt(e){return e.object.type===`MemberExpression`&&b(e.object)===`reason`}function mt(e){let t=e.parent;return t.type===`CallExpression`&&t.arguments.includes(e)&&t.callee.type===`MemberExpression`&&t.callee.object.type===`Identifier`&&t.callee.object.name===`Match`&&!t.callee.computed&&t.callee.property.type===`Identifier`&&(t.callee.property.name===`when`||t.callee.property.name===`not`)}const ht=_(y(`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=ft(t);n!==void 0&&G(t)&&e.report({node:t,messageId:pt(n)?`reason`:`tag`})},SwitchStatement(t){W(t.discriminant)&&G(t)&&e.report({node:t,messageId:pt(t.discriminant)?`reason`:`tag`})}})),gt=_(y(`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){ft(t)===void 0||G(t)||e.report({node:t,messageId:`manualComparison`})},SwitchStatement(t){W(t.discriminant)&&!G(t)&&e.report({node:t,messageId:`manualSwitch`})}})),_t=_(y(`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(mt(t))return;let i=a.getOrUndefined(r.pipe(t.properties,n.findFirst(e=>e.type===`Property`&&O(e)===`_tag`&&U(e.value))));i!==void 0&&e.report({node:i,messageId:`manualConstruction`})}}));function vt(e,t){let n=x(e.callee)?.at(-1);if(n===void 0||![`addEventListener`,`on`,`setInterval`].includes(n))return!1;if(n===`addEventListener`){let t=D(e,2);if(t?.type===`ObjectExpression`){let e=k(t,`once`);if(e!==void 0&&I(e.value,!0))return!1}}let r=D(e,n===`setInterval`?0:1);return r!==void 0&&M(r,t)}const yt=v(y(`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(!w(n.callee,t(),`Effect`,`callback`))return;let r=D(n,0);if(r===void 0||!E(r))return;let i=N(r)?.name,a=r.body;i!==void 0&&a&&j(a,e=>e.type===`CallExpression`&&vt(e,i))&&e.report({node:n,messageId:`multiShot`})}}));function bt(e){return e.type===`Literal`&&typeof e.value==`bigint`||e.type===`Identifier`&&[`NaN`,`Infinity`,`undefined`].includes(e.name)||E(e)||e.type===`CallExpression`&&x(e.callee)?.at(-1)===`Symbol`}function xt(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 St(e){let t=[e];for(;t.length>0;){let e=t.pop();if(e===void 0)continue;let n=A(e);if(bt(n))return n;xt(n,t)}}const Ct=v(y(`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=C(n.callee,r),a=n.callee.type===`MemberExpression`?b(n.callee):i?.[0]===`Schema`?i[1]:void 0;if(a===void 0||![`annotate`,`annotateEncoded`,`annotateKey`].includes(a))return;let o=z(n);if(o!==void 0&&k(o,`jsonSchema`)===void 0)for(let t of[`default`,`examples`]){let n=k(o,t);if(n===void 0)continue;let r=St(n.value);r!==void 0&&e.report({node:r,messageId:`nonJson`})}}})),wt=v(y(`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=w(n.callee,r,`Effect`,`option`)||w(n.callee,r,`Effect`,`either`),a=D(n,0);if(i&&a?.type===`CallExpression`&&w(a.callee,r,`Effect`,`service`)){e.report({node:n,messageId:`mandatory`});return}if(n.callee.type!==`MemberExpression`||x(n.callee)?.at(-1)!==`pipe`)return;let o=A(n.callee.object),s=D(n,0);s!==void 0&&o.type===`CallExpression`&&w(o.callee,r,`Effect`,`service`)&&(w(s,r,`Effect`,`option`)||w(s,r,`Effect`,`either`))&&e.report({node:n,messageId:`mandatory`})}})),Tt=v(y(`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 i=a.getOrElse(r.pipe(t.properties,n.findFirstIndex(e=>e.type===`Property`&&O(e)===`_tag`)),()=>-1);if(i===-1)return;let o=r.pipe(t.properties.slice(i+1),n.some(e=>e.type===`SpreadElement`)),s=t.properties[i];o&&s?.type===`Property`&&e.report({node:s,messageId:`overwritten`})}})),Et=/^make[A-Z]/u,Dt=/\.(?:test|spec)\.[cm]?[jt]sx?$/u,Ot=_(y(`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(!Dt.test(e.filename.replaceAll(`\\`,`/`))&&(t.source.value.startsWith(`./`)||t.source.value.startsWith(`../`)))for(let n of t.specifiers){if(n.type!==`ImportSpecifier`)continue;let t=n.imported.type===`Identifier`?n.imported.name:n.imported.value;Et.test(t)&&e.report({node:n,messageId:`serviceConstructorImport`,data:{name:t}})}}})),kt=v(y(`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(w(n.callee,r,`Option`,`getOrThrow`)||w(n.callee,r,`Option`,`getOrThrowWith`)){let t=D(n,0),i=t?.type===`YieldExpression`?t.argument:t;i?.type===`CallExpression`&&w(i.callee,r,`Effect`,`serviceOption`)&&e.report({node:n,messageId:`getOrThrow`});return}if(n.callee.type!==`MemberExpression`||x(n.callee)?.at(-1)!==`pipe`)return;let i=A(n.callee.object),a=D(n,0);if(i.type!==`CallExpression`||!w(i.callee,r,`Effect`,`serviceOption`)||a?.type!==`CallExpression`||!w(a.callee,r,`Effect`,`map`))return;let o=D(a,0);o!==void 0&&(w(o,r,`Option`,`getOrThrow`)||w(o,r,`Option`,`getOrThrowWith`))&&e.report({node:n,messageId:`getOrThrow`})}})),At=/* @__PURE__ */ new Set([`andThen`,`map`,`mapError`,`tap`,`tapError`,`tapErrorCause`]),jt=v(y(`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=re(n);if(r===void 0)return;let i=t(),a=Ae(r,i),o=ke(r,`catch`);(a?.[0]===`Effect`&&a[1]!==void 0&&At.has(a[1])||o!==void 0&&(w(o.callee,i,`Effect`,`try`)||w(o.callee,i,`Effect`,`tryPromise`)))&&e.report({node:n,messageId:`callbackThrow`})}})),Mt=/* @__PURE__ */ new Set([`get`,`post`,`put`,`patch`,`delete`,`head`,`options`]);function Nt(e,t){let n=e.parent,r=e.node;if(e.type!==`ImportBinding`||n?.type!==`ImportDeclaration`||V(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 Pt(e,t){let n=x(e.callee),r=n?.[0],i=n?.at(-1);if(n===void 0||r===void 0||i===void 0||!Mt.has(i))return!1;let a=t.sourceCode.getScope(e);for(;a;){let e=a.set.get(r);if(e!==void 0){let t=e.defs.length===1?e.defs[0]:void 0;return t!==void 0&&Nt(t,n)}a=a.upper}return!1}function Ft(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=O(r)??(r.key.type===`Literal`&&typeof r.key.value==`number`?String(r.key.value):void 0);if(e===void 0||t.has(e))return;t.add(e),n.push(r)}return n}const It=_(y(`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.pipe(t.arguments,n.some(e=>e.type===`SpreadElement`))||!Pt(t,e))return;let i=Ft(D(t,2)),o=Ft(a.getOrUndefined(r.pipe(i??[],n.findFirst(e=>O(e)===`headers`)))?.value);if(o!==void 0)for(let t of o){let n=O(t);n!==void 0&&/[A-Z]/u.test(n)&&e.report({node:t.key,messageId:`uppercase`,data:{name:n}})}}})),Lt=v(y(`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(!w(n.callee,r,`Effect`,`retry`)&&!w(n.callee,r,`Effect`,`repeat`))return;let i=z(n);if(i===void 0)return;let a=k(i,`times`);a!==void 0&&I(a.value,0)&&e.report({node:a,messageId:`zeroTimes`})}})),Rt=_({...y(`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=Ke(t.source.value);if(n===void 0||t.importKind===`type`)return;let r=H(n);for(let n of t.specifiers)n.type===`ImportSpecifier`&&V(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=>Je(e,t,n)}):e.report({node:n,messageId:`namespace`,data:{alias:r,source:t.source.value},fix:n=>Je(e,t,n)}))}})),zt=v(y(`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`&&b(n.callee)===`sort`&&!w(n.callee,r,`Array`,`sort`)&&e.report({node:n,messageId:`effectArraySort`})}})),Bt=/* @__PURE__ */ new Set([`toISOString`,`toLocaleDateString`,`toLocaleTimeString`]),Vt=v(y(`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`&&Bt.has(b(n.callee)??``)&&e.report({node:n,messageId:`effectDateTime`})}})),Ht=/* @__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`]]);function Ut(e,t,r){let i=C(e.callee,r),a=i===void 0?void 0:Ht.get(n.join(i,`.`)),o=a!==void 0&&R(t,e.callee)?a:void 0;if(o===`first`)return D(e,0);if(o===`last`)return D(e,e.arguments.length-1);if(o===`options.duration`){let t=D(e,e.arguments.length-1);return(t?.type===`ObjectExpression`?k(t,`duration`):void 0)?.value}}function K(e){let t=A(e);if(t.type===`Literal`)return typeof t.value==`number`?t.value:void 0;if(t.type===`UnaryExpression`&&(t.operator===`-`||t.operator===`+`)){let e=K(t.argument);return e===void 0||t.operator===`+`?e:-e}if(t.type!==`BinaryExpression`||t.left.type===`PrivateIdentifier`)return;let n=K(t.left),i=K(t.right);if(n!==void 0&&i!==void 0)return r.pipe(o.value(t.operator),o.when(`*`,()=>s.multiply(n,i)),o.when(`+`,()=>s.sum(n,i)),o.when(`-`,()=>s.subtract(n,i)),o.when(`/`,()=>s.divideUnsafe(n,i)),o.when(`%`,()=>s.remainder(n,i)),o.when(`**`,()=>n**i),o.orElse(r.constUndefined))}function Wt(e){let t=A(e);if(t.type===`Literal`)return typeof t.value==`number`?[t.value]:void 0;if(t.type!==`BinaryExpression`||t.operator!==`*`)return;let n=Wt(t.left),r=Wt(t.right);return n===void 0||r===void 0?void 0:[...n,...r]}const Gt=/* @__PURE__ */ new Set([6e4,36e5,864e5]),Kt=/* @__PURE__ */ new Set([60,3600,86400]),qt=/* @__PURE__ */ new Set([7,24,60,1e3,3600,86400]);function Jt(e){let t=Wt(e);if(!(t===void 0||t.length<2)&&(r.pipe(t,n.some(e=>Gt.has(e)))||r.pipe(t,n.some(e=>Kt.has(e)))&&r.pipe(t,n.filter(e=>qt.has(e))).length>=2))return{millis:t.includes(1e3)||r.pipe(t,n.some(e=>e%6e4==0))}}const Yt=[[`weeks`,6048e5],[`days`,864e5],[`hours`,36e5],[`minutes`,6e4],[`seconds`,1e3],[`millis`,1]];function Xt(e){return!Number.isSafeInteger(e)||Math.abs(e)<1e4?String(e):String(e).replaceAll(/\B(?=(?:\d{3})+$)/gu,`_`)}function Zt(e,t){let i=e*(a.getOrUndefined(r.pipe(Yt,n.findFirst(([e])=>e===t)))?.[1]??1);if(i===0)return`Duration.zero`;for(let[e,t]of Yt)if(Number.isSafeInteger(i/t))return`Duration.${e}(${Xt(i/t)})`;return`Duration.millis(${Xt(i)})`}const Qt=v({...y(`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=Ut(n,e,t());r!==void 0&&K(r)!==void 0&&e.report({node:r,messageId:`effectDuration`,fix(t){let i=fe(e,n,`effect/Duration`,`Duration`,t);return[...i.fixes,t.replaceText(r,`${i.name}.millis(${e.sourceCode.getText(r)})`)]}})}})),$t=/* @__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`]]),en=/* @__PURE__ */ new Set([`day`,`hour`,`minute`,`second`,`week`]),tn=/* @__PURE__ */ new Set([`backoff`,`cooldown`,`day`,`debounce`,`delay`,`duration`,`expiration`,`expiry`,`hour`,`interval`,`lifetime`,`minute`,`second`,`throttle`,`timeout`,`ttl`,`week`]),nn=r.flow(c.split(/[_$]+|(?<=[\da-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])/u),n.filter(c.isNonEmpty),n.map(c.toLowerCase)),rn=/* @__PURE__ */ new Set([`at`,`epoch`,`per`,`timestamp`]);function an(e){return e!==void 0&&e!==`excluded`&&e!==`unknown`}function on(e){let t=nn(e),i=t.indexOf(`in`),a=t[i-1]??``;if(i>0&&i<t.length-1&&($t.has(a)||en.has(a))||r.pipe(t,n.some(e=>rn.has(e))))return`excluded`;let o=t.at(-1),s=t.at(-2);if(o===void 0)return;let c=$t.get(o);if(c!==void 0)return c;if(tn.has(o)||o===`age`&&s===`max`||o===`in`&&s===`expires`)return`unknown`}function sn(e,t,i){let a=i.sourceCode.getScope(e);for(;a!==null&&!a.set.has(t);)a=a.upper;return r.pipe(a?.set.get(t)?.defs??[],n.some(e=>e.type===`ImportBinding`))}function cn(e){if(e.type===`Identifier`)return[e.name];if(e.type===`TSQualifiedName`){let t=cn(e.left);return t===void 0?void 0:[...t,e.right.name]}}function ln(e,t,n){return j(e,e=>{if(e.type!==`TSTypeReference`)return!1;let[r,...i]=cn(e.typeName)??[],a=r===void 0||!sn(e,r,t)?void 0:n.bindings.get(r);return a!==void 0&&[...a,...i][0]===`Duration`})}function un(e){return e.parent.type===`VariableDeclaration`&&e.parent.kind===`const`&&e.id.type===`Identifier`&&e.init!==null&&K(e.init)!==void 0}function dn(e,t){let n=A(e);if(n.type!==`Identifier`)return;let r=t.sourceCode.getScope(n);for(;r!==null&&!r.set.has(n.name);)r=r.upper;let i=r?.set.get(n.name)?.defs,a=i?.length===1?i[0]?.node:void 0;return a?.type===`VariableDeclarator`&&un(a)?a:void 0}const fn=v(y(`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&&ln(n.id.typeAnnotation,e,t()))return`none`;let i=on(n.id.name);if(r)return an(i)?i:`millis`;if(i===`excluded`||(K(n.init)??0)<=0)return`none`;if(an(i))return i;let a=Jt(n.init);return a?.millis===!0?`millis`:a!==void 0||i===`unknown`?void 0:`none`}return{before(){n=/* @__PURE__ */ new Map},VariableDeclarator(e){t().hasEffectImport&&un(e)&&!n.has(e)&&n.set(e,!1)},CallExpression(r){let i=Ut(r,e,t()),a=i===void 0?void 0:dn(i,e);a!==void 0&&n.set(a,!0)},"Program:exit":function(){for(let[t,i]of n){let n=r(t,i),a=K(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`:Zt(a,n)}})}}}}),pn=/* @__PURE__ */ new Set([`base64`,`base64url`,`hex`]);function mn(e){return e!==void 0&&r.pipe([...pn],n.some(t=>I(e,t)))}const hn=v(y(`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(r){if(!t().hasEffectImport)return;if((S(r.callee,e,`atob`)||S(r.callee,e,`btoa`))&&r.arguments.length>0){e.report({node:r,messageId:`effectEncoding`});return}let i=x(r.callee),a=i!==void 0&&n.join(i,`.`)===`Buffer.from`&&mn(D(r,1)),o=i?.at(-1)===`toString`&&mn(D(r,0));(a||o)&&e.report({node:r,messageId:`effectEncoding`})}})),gn=/* @__PURE__ */ new Set([`fs`,`fs/promises`,`node:fs`,`node:fs/promises`]),_n=v(y(`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&&gn.has(n.source.value)&&e.report({node:n.source,messageId:`effectFileSystem`,data:{source:n.source.value}})}}));function vn(e,t,n){return e.type===`CallExpression`&&w(e.callee,t,`Result`,n)?D(e,0):void 0}function yn(e,t,n){let r=N(t),i=B(t);if(r===void 0||i?.type!==`ConditionalExpression`)return;let a=vn(i.consequent,n,`succeed`),o=vn(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 bn=v(y(`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){yn(e,n,t())},FunctionExpression(n){yn(e,n,t())}})),xn=v(y(`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&&S(n.callee,e,`Headers`)&&e.report({node:n,messageId:`effectHeaders`})}})),Sn=/* @__PURE__ */ new Set([`==`,`===`,`!=`,`!==`]);function Cn(e){return e.type===`Literal`||e.type===`TemplateLiteral`&&e.expressions.length===0}function wn(e,t){if(e.type===`BinaryExpression`&&Sn.has(e.operator)){if(Cn(e.left))return t.sourceCode.getText(e.right);if(Cn(e.right))return t.sourceCode.getText(e.left)}}const Tn=v(y(`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=wn(t.test,e);if(n===void 0)return;let r=t.alternate,i=1;for(;r.type===`ConditionalExpression`;){if(wn(r.test,e)!==n)return;i+=1,r=r.alternate}i>1&&e.report({node:t,messageId:`preferMatch`})}})),En=/* @__PURE__ */ new Set([`node:path`,`path`]),Dn=v(y(`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&&En.has(n.source.value)&&e.report({node:n.source,messageId:`effectPath`,data:{source:n.source.value}})}})),On=v(y(`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&&S(n.callee,e,`URL`)&&e.report({node:n,messageId:`effectUrl`})},CallExpression(n){let r=x(n.callee);t().hasEffectImport&&r?.[0]===`URL`&&[`canParse`,`parse`].includes(r[1]??``)&&n.callee.type===`MemberExpression`&&S(n.callee.object,e,`URL`)&&e.report({node:n,messageId:`effectUrl`})}})),kn=v(y(`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(),i=w(n.callee,r,`Effect`,`uninterruptibleMask`)?`uninterruptible`:w(n.callee,r,`Effect`,`interruptibleMask`)?`interruptible`:void 0,a=D(n,0);i!==void 0&&a!==void 0&&E(a)&&!P(a)&&e.report({node:n,messageId:`unusedRestore`,data:{replacement:`Effect.${i}`}})}})),An=v(y(`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(!w(n.callee,t(),`Effect`,`useSpan`))return;let r=D(n,n.arguments.length-1);r!==void 0&&E(r)&&!P(r)&&e.report({node:n,messageId:`unusedSpan`})}}));function jn(e,t){let n=A(e);if(I(n,0))return!0;if(n.type===`Literal`&&typeof n.value==`string`)return/^0\s*(?:nanos?|micros?|millis?|seconds?|minutes?|hours?|days?|weeks?)$/i.test(n.value);if(w(n,t,`Duration`,`zero`))return!0;if(n.type===`CallExpression`){let e=C(n.callee,t),r=D(n,0);return r!==void 0&&e?.[0]===`Duration`&&I(r,0)}return!1}const Mn=v(y(`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=D(n,0);i!==void 0&&w(n.callee,r,`Effect`,`sleep`)&&jn(i,r)&&e.report({node:n,messageId:`zeroSleep`})}})),Nn=/* @__PURE__ */ new Set([`catch`,`catchAll`,`mapError`]);function Pn(e,t){let n=Ae(e,t),r=ke(e,`catch`);if(!(n?.[0]===`Effect`&&n[1]!==void 0&&Nn.has(n[1])||r!==void 0&&(w(r.callee,t,`Effect`,`try`)||w(r.callee,t,`Effect`,`tryPromise`)))||!e.body)return!1;let i=N(e);return j(e.body,e=>e.type===`NewExpression`&&L(e)&&(i===void 0||!M(e,i.name)))}const Fn=v(y(`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){Pn(n,t())&&e.report({node:n,messageId:`droppedCause`})},FunctionExpression(n){Pn(n,t())&&e.report({node:n,messageId:`droppedCause`})}})),In=v(y(`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){w(n.callee,t(),`Schema`,`Class`)&&(n.typeArguments?.params.length??0)<2&&e.report({node:n,messageId:`missingBrand`})}}));function Ln(e,t){if(!w(e.callee,t,`Effect`,`tryPromise`))return;let n=D(e,0);if(n!==void 0&&E(n))return n;if(n?.type===`ObjectExpression`){let e=k(n,`try`);if(e!==void 0&&E(e.value))return e.value}}const Rn=v(y(`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=Ln(n,t());if(r===void 0)return;let i=N(r);i===void 0?e.report({node:r,messageId:`missingSignal`}):!i.name.startsWith(`_`)&&!P(r)&&e.report({node:i,messageId:`unusedSignal`})}}));function zn(e,t){let n=e.parent;if(n.type===`CallExpression`&&D(n,0)===e)return w(n.callee,t,`Effect`,`try`)||w(n.callee,t,`Effect`,`tryPromise`);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`&&(w(r.parent.callee,t,`Effect`,`try`)||w(r.parent.callee,t,`Effect`,`tryPromise`))}const Bn=v(y(`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(i){let a=t(),o=i.parent;for(;o&&!E(o);)o=o.parent??void 0;if(o===void 0||zn(o,a))return;let s=F(o),c=s!==void 0&&r.pipe([`fn`,`fnUntraced`,`gen`],n.some(e=>w(s.callee,a,`Effect`,e))),l=s?.callee,u=l?.type===`CallExpression`&&r.pipe([`fn`,`fnUntraced`],n.some(e=>w(l.callee,a,`Effect`,e)));(c||u)&&e.report({node:i,messageId:`throwInGen`})}})),Vn=String.raw`(?:\r\n|\r(?!\n)|[\n\u2028\u2029])`,Hn=String.raw`[^\S\r\n\u2028\u2029]*`,Un=RegExp(`^(${Hn}${Vn})(?:${Hn}${Vn})+(${Hn};?)$`,`u`),Wn=/^(?:module\s*\.\s*)?exports(?:\s*\.|\s*\[|$)/u;function Gn(e){return e.type===`Punctuator`&&e.value===`;`}function q(e,t){return e.loc.end.line===t.loc.start.line}function J(e){return e.loc.start.line===e.loc.end.line}function Kn(e){return[`FunctionDeclaration`,`FunctionExpression`,`ArrowFunctionExpression`].includes(e.type)}function qn(e){return e.type===`ChainExpression`?e.expression:e}function Y(e,t){return(r,i)=>i.getFirstToken(r)?.value===t&&(n.isArray(e)?e.includes(r.type):e===r.type)}function X(e){return t=>t.type===e}function Z(e,t){return(n,r)=>e(n,r)&&J(n)===(t===`singleline`)}function Jn(e){if(e.type!==`ExpressionStatement`)return!1;let t=qn(e.expression);if(t.type===`UnaryExpression`&&(t=qn(t.argument)),t.type!==`CallExpression`)return!1;let n=t.callee;for(;n.type===`SequenceExpression`;){let e=n.expressions.at(-1);if(e===void 0)throw Error(`Padding rule invariant: sequence expression is empty`);n=e}return Kn(n)}function Yn(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 Xn(e,t){if(e.type===`DoWhileStatement`&&e.body.type===`BlockStatement`||Jn(e))return!0;let n=t.getLastToken(e,e=>!Gn(e)),r=n?.type===`Punctuator`&&n.value===`}`?t.getNodeByRangeIndex(n.range[0]):null;return r?.type===`BlockStatement`||r?.type===`SwitchStatement`}function Zn(e,t){return e.type===`ExpressionStatement`&&(e.parent.type===`Program`||e.parent.type===`BlockStatement`&&Kn(e.parent.parent))&&e.expression.type===`Literal`&&typeof e.expression.value==`string`&&(t.getTokenBefore(e.expression)?.value!==`(`||t.getTokenAfter(e.expression)?.value!==`)`)}function Qn(e,t){if(!Zn(e,t)||!e.parent||!(`body`in e.parent)||!n.isArray(e.parent.body))return!1;for(let n of e.parent.body){if(n===e)break;if(!Zn(n,t))return!1}return!0}function $n(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 er(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]&&Gn(n)&&!q(r,n)&&q(n,i)?r:n}function tr(e,t){if(J(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 Q={"block-like":Xn,expression:(e,t)=>e.type===`ExpressionStatement`&&!Qn(e,t),return:Y(`ReturnStatement`,`return`),export:Y([`ExportAllDeclaration`,`ExportDefaultDeclaration`,`ExportNamedDeclaration`],`export`),var:Y(`VariableDeclaration`,`var`),let:Y(`VariableDeclaration`,`let`),const:Y(`VariableDeclaration`,`const`),using:e=>e.type===`VariableDeclaration`&&(e.kind===`using`||e.kind===`await using`),type:Y(`TSTypeAliasDeclaration`,`type`)},nr={"*":()=>!0,exports:$n,require:Yn,directive:Qn,iife:Jn,block:X(`BlockStatement`),empty:X(`EmptyStatement`),function:X(`FunctionDeclaration`),"ts-method":X(`TSMethodSignature`),break:Y(`BreakStatement`,`break`),case:Y(`SwitchCase`,`case`),class:Y(`ClassDeclaration`,`class`),continue:Y(`ContinueStatement`,`continue`),debugger:Y(`DebuggerStatement`,`debugger`),default:Y([`SwitchCase`,`ExportDefaultDeclaration`],`default`),do:Y(`DoWhileStatement`,`do`),for:Y([`ForStatement`,`ForInStatement`,`ForOfStatement`],`for`),if:Y(`IfStatement`,`if`),import:Y(`ImportDeclaration`,`import`),switch:Y(`SwitchStatement`,`switch`),throw:Y(`ThrowStatement`,`throw`),try:Y(`TryStatement`,`try`),while:Y([`WhileStatement`,`DoWhileStatement`],`while`),with:Y(`WithStatement`,`with`),"cjs-export":(e,t)=>e.type===`ExpressionStatement`&&e.expression.type===`AssignmentExpression`&&Wn.test(t.getText(e.expression.left)),"cjs-import":(e,t)=>e.type===`VariableDeclaration`&&e.declarations[0]?.init!=null&&t.getText(e.declarations[0].init).startsWith(`require(`),enum:Y(`TSEnumDeclaration`,`enum`),interface:Y(`TSInterfaceDeclaration`,`interface`),"function-overload":X(`TSDeclareFunction`),...Q,"singleline-block-like":Z(Q[`block-like`],`singleline`),"multiline-block-like":Z(Q[`block-like`],`multiline`),"singleline-expression":Z(Q.expression,`singleline`),"multiline-expression":Z(Q.expression,`multiline`),"singleline-return":Z(Q.return,`singleline`),"multiline-return":Z(Q.return,`multiline`),"singleline-export":Z(Q.export,`singleline`),"multiline-export":Z(Q.export,`multiline`),"singleline-var":Z(Q.var,`singleline`),"multiline-var":Z(Q.var,`multiline`),"singleline-let":Z(Q.let,`singleline`),"multiline-let":Z(Q.let,`multiline`),"singleline-const":Z(Q.const,`singleline`),"multiline-const":Z(Q.const,`multiline`),"singleline-using":Z(Q.using,`singleline`),"multiline-using":Z(Q.using,`multiline`),"singleline-type":Z(Q.type,`singleline`),"multiline-type":Z(Q.type,`multiline`)};function rr(e){return typeof e==`string`&&i.has(nr,e)}function ir(e){return n.isArray(e)}function ar(e){if(rr(e))return e;if(typeof e==`object`&&e&&`selector`in e&&typeof e.selector==`string`&&r.pipe(i.keys(e),n.every(e=>e===`selector`||e===`lineMode`))){if(!(`lineMode`in e))return{selector:e.selector};if(e.lineMode===`any`||e.lineMode===`singleline`||e.lineMode===`multiline`)return{selector:e.selector,lineMode:e.lineMode}}throw Error(`Invalid padding-line-between-statements statement matcher`)}function or(e){if(!n.isArray(e))return ar(e);let t=e,i=t[0];if(i===void 0)throw Error(`Padding statement matcher arrays must not be empty`);return[ar(i),...r.pipe(t.slice(1),n.map(e=>ar(e)))]}function sr(e){return r.pipe(e,n.map(e=>{if(typeof e!=`object`||!e||!(`blankLine`in e)||!(`prev`in e)||!(`next`in e)||r.pipe(i.keys(e),n.some(e=>![`blankLine`,`prev`,`next`].includes(e)))||e.blankLine!==`any`&&e.blankLine!==`never`&&e.blankLine!==`always`)throw Error(`Invalid padding-line-between-statements configuration`);return{blankLine:e.blankLine,prev:or(e.prev),next:or(e.next)}}))}function cr(e,t,n){let r=[],i=er(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 lr(e,t,n){return f.gen(function*(){if(n===`any`)return yield*f.void;let r=yield*u,i=r.sourceCode,a=cr(e,t,i);return n===`never`?a.length===0?yield*f.void:yield*r.report({node:t,messageId:`unexpectedBlankLine`,loc:tr(t,i),fix(e){if(a.length>=2)return null;let t=a[0];if(t===void 0)throw Error(`Padding rule invariant: reported padding pair is missing`);let n=t[0].range[1],r=t[1].range[0];return e.replaceTextRange([n,r],i.text.slice(n,r).replace(Un,`$1$2`))}}):a.length>0?yield*f.void:yield*r.report({node:t,messageId:`expectedBlankLine`,loc:tr(t,i),fix(n){let r=er(e,i),a=i.getFirstTokenBetween(r,t,{includeComments:!0,filter(e){return!q(r,e)||(r=e,!1)}})??t;return n.insertTextAfter(r,q(r,a)?`
1
+ import{defineRule as e,eslintCompatPlugin as t}from"@oxlint/plugins";import*as n from"effect/Array";import*as r from"effect/Function";import*as i from"effect/Record";import*as a from"effect/Match";import*as o from"effect/Option";import*as s from"effect/Predicate";import*as c from"effect/String";import*as l from"effect/Result";import*as u from"effect/Number";import{Rule as d,RuleContext as f,Visitor as ee}from"effect-oxlint";import*as p from"effect/Effect";import*as m from"effect/Ref";const h={bindings:/* @__PURE__ */ new Map,hasEffectImport:!1},g=a.type().pipe(a.discriminatorsExhaustive(`type`)({Identifier:({name:e})=>e,Literal:({value:e})=>e})),te=/^(?:effect|@effect\/platform|alchemy)\//u;function ne(e){let t=n.lastNonEmpty(c.split(e,`/`));return/^\p{Ll}/u.test(t)?[]:[t]}const _=a.type().pipe(a.withReturnType(),a.when(`alchemy`,()=>[`Alchemy`]),a.when(a.is(`effect`,`@effect/platform`),()=>[]),a.when(e=>te.test(e),ne),a.orElse(r.constUndefined));function re(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`||e.startsWith(`effect/`)||e.startsWith(`@effect/`))&&(n=!0);let i=_(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,g(e.imported)])}return{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=h,{before:r,Program:i,...a}=n(e,()=>t);return{before(){t=h,r?.()},Program(e){t=re(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=a.type().pipe(a.when({computed:!1,property:{type:`Identifier`}},({property:e})=>e.name),a.when({computed:!0,property:{type:`Literal`,value:c.isString}},({property:e})=>e.value),a.orElse(r.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 ie(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,r,i){let a=T(e,t);return a?.length===2&&a[0]===r&&n.contains(i,a[1])}function O(e,t,r){let i=T(e,t);return i?.length===r.length&&n.every(i,(e,t)=>e===r[t])}const ae=a.type().pipe(a.when({type:a.is(`ArrowFunctionExpression`,`FunctionExpression`)},r.constTrue),a.orElse(r.constFalse));function k(e){return ae(e)}function A(e,t){let n=e.arguments[t];return n===void 0||n.type===`SpreadElement`?void 0:n}const j=a.type().pipe(a.when({computed:!1,key:{type:`Identifier`}},({key:e})=>e.name),a.when({key:{type:`Literal`,value:c.isString}},({key:e})=>e.value),a.orElse(r.constUndefined));function M(e,t){return o.getOrUndefined(n.findFirst(e.properties,e=>e.type===`Property`&&j(e)===t))}const oe=/* @__PURE__ */ new Set([`ParenthesizedExpression`,`TSAsExpression`,`TSNonNullExpression`,`TSSatisfiesExpression`,`TSTypeAssertion`]);function se(e){return oe.has(e.type)}const ce=/* @__PURE__ */ new Set([`loc`,`parent`,`range`]);function N(e){let t=e;for(;se(t);)t=t.expression;return t}function le(e,t){if(n.isArray(e))for(let n of e)t.push(n);else for(let[n,r]of i.toEntries(e))ce.has(n)||t.push(r)}function P(e,t){let n=[e],r=/* @__PURE__ */ new WeakSet;for(;n.length>0;){let e=n.pop();if(s.isObjectOrArray(e)&&!r.has(e)){if(r.add(e),s.hasProperty(e,`type`)&&s.isString(e.type)&&t(e)===!0)return!0;le(e,n)}}return!1}function ue(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 de(e){let t=F(e);return t===void 0||!e.body||t.name.startsWith(`_`)?!1:ue(e.body,t.name)}function fe(e,t){for(let n=e.parent;n;n=n.parent)if(t(n))return n}function I(e){return fe(e,k)}function L(e){let t=e.parent;if(t.type===`CallExpression`&&t.arguments.includes(e))return t}function pe(e,t){return e.range[0]<=t.range[0]&&t.range[1]<=e.range[1]}function R(e){return e.type===`Literal`&&c.isString(e.value)}const me=/* @__PURE__ */ new Set([`==`,`===`,`!=`,`!==`]);function he(e){return me.has(e)}function z(e,t){return e.type===`Literal`&&e.value===t}function ge(e){let t=e.parent;return t?t.type===`ExpressionStatement`||t.type===`UnaryExpression`&&t.operator===`void`||t.type===`SequenceExpression`&&t.expressions.at(-1)!==e:!1}const _e=s.mapInput(s.compose(s.isString,c.endsWith(`Error`)),e=>S(e.callee)?.at(-1)),ve=/* @__PURE__ */ new Set([`alarm`,`fetch`,`queue`,`rpc`,`scheduled`,`tail`,`trace`,`webSocketClose`,`webSocketError`,`webSocketMessage`]),ye=[[`Cloudflare`,`Worker`],[`Cloudflare`,`Workers`,`Worker`]];function be(e,t){return n.some(ye,n=>O(e,t,n))}function xe(e,t){return fe(e,e=>e.type===`CallExpression`&&be(e.callee,t))}function Se(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 Ce(e){let t=e.parent;for(;t;){if(k(t))return;if(t.type===`Property`){let e=j(t);if(e!==void 0&&ve.has(e))return e}t=t.parent}}const we=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=Se(n,r);i!==void 0&&xe(i,r)?.arguments.includes(i)&&e.report({node:n,messageId:`finalizer`})}}));function B(e,t){let r=S(t)?.[0],i=r===void 0?void 0:C(e,t,r);return n.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 Te(e,t,r,i,a){let s=e.sourceCode.ast,c=n.findFirst(n.flatMap(s.body,e=>e.type===`ImportDeclaration`&&e.source.value===r&&e.importKind!==`type`?e.specifiers:[]),r=>r.type===`ImportNamespaceSpecifier`&&n.some(C(e,t,r.local.name)?.defs??[],e=>e.node===r));if(o.isSome(c))return{name:c.value.local.name,fixes:[]};let l=new Set(n.flatMap(e.sourceCode.scopeManager.scopes,e=>[...n.map(e.variables,e=>e.name),...n.map(e.references,e=>e.identifier.name)])),u=i,d=2;for(;l.has(u);)u=`${i}${d++}`;let f=`import * as ${u} from '${r}';\n`,ee=o.getOrUndefined(n.findFirst(s.body,e=>e.type!==`ExpressionStatement`||!R(e.expression)));return{name:u,fixes:[ee===void 0?a.insertTextAfter(s,`\n${f}`):a.insertTextBefore(ee,f)]}}function Ee(e,t){let r=/* @__PURE__ */ new Set;return n.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 n=e.key.type===`Identifier`?e.key.name:String(e.key.value);return n===t||r.has(n)?!1:(r.add(n),!0)})}const De=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`&&Ee(r,`placement`))return t.replaceText(i,`placement: { ${e.sourceCode.getText(i)} }`)}})}})),Oe=/* @__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`]]),ke=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(r){let i=T(r.callee,t());if(i===void 0)return;let a=n.join(i,`.`),o=Oe.get(a);o!==void 0&&e.report({node:r.callee,messageId:`deprecated`,data:{api:a,replacement:o}})}}));function Ae(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 je=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&&Ae(a.value,r)&&e.report({node:a.value,messageId:`plaintext`})}})),Me=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]}})}})),Ne=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`})}})),Pe=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=Se(n,r);if(a===void 0)return;let o=Ce(a);o!==void 0&&xe(a,r)!==void 0&&e.report({node:i,messageId:`runtime`,data:{handler:o}})}})),Fe=/* @__PURE__ */ new Map([[`alchemy/aws`,`alchemy/AWS`],[`alchemy/cloudflare`,`alchemy/Cloudflare`]]),Ie=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 r=t.source.value;if(r===`alchemy`){let r=o.getOrUndefined(n.findFirst(t.specifiers,e=>e.type===`ImportDefaultSpecifier`));r!==void 0&&e.report({node:r,messageId:`defaultImport`});return}let i=Fe.get(r);i!==void 0&&e.report({node:t.source,messageId:`providerImport`,data:{replacement:i}})}})),Le=[[`entrypoint`,`main`],[`bindings`,`env`]],Re=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(!be(n.callee,t()))return;let r=A(n,1);if(r?.type===`ObjectExpression`)for(let[t,i]of Le){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)&&Ee(r,i))return o.replaceText(a.key,a.shorthand?`${i}: ${t}`:i)}})}}})),ze=y(b(`suggestion`,`Prefer schema-based tagged errors so errors have a serializable contract.`,{taggedError:`Prefer Schema.TaggedErrorClass over Data.TaggedError.`}),(e,t)=>({CallExpression(n){E(n.callee,t(),`Data`,`TaggedError`)&&e.report({node:n.callee,messageId:`taggedError`})}})),Be=/* @__PURE__ */ new Set([`error`,`err`,`e`,`cause`,`exception`,`ex`]);function Ve(e){return e?.type===`Identifier`&&Be.has(e.name)?e.name:void 0}function He(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 Ue=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||!He(n)||!_e(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(He(t)){if(t.parent.type===`NewExpression`&&t.parent.arguments[0]===t&&_e(t.parent))return;let n=Ve(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=Ve(t.callee.object);n!==void 0&&e.report({node:t,messageId:`errorString`,data:{name:n}})},TemplateLiteral(t){let[n,r]=t.quasis,i=Ve(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}})}})),We=/* @__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(`.`)),Ge=/* @__PURE__ */ new Set([`Array`,`ArrayEnsure`,`Chunk`,`HashSet`,`NonEmptyArray`,`Option`,`ReadonlySet`,`Redacted`,`Tree`,`UniqueArray`]),Ke=/* @__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(`.`)),qe=/* @__PURE__ */ new Set([`annotate`,`annotateKey`,`check`,`mapFields`]),Je=/* @__PURE__ */ new Set([`CallExpression`,`Identifier`,`MemberExpression`,`ThisExpression`]),Ye=/^\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 Xe(e){return e!==void 0&&Ge.has(e)}function Ze(e){return e!==void 0&&(We.has(e)||Ge.has(e))}const Qe=/* @__PURE__ */ new Set([`ArrowFunctionExpression`,`FunctionExpression`,`Identifier`,`Literal`,`ThisExpression`]);function $e(e,t,r){return n.every(e,e=>e===null||H(e,t,r))}function H(e,t,r){if(Qe.has(e.type))return!0;if(e.type===`MemberExpression`)return H(e.object,t,r)&&(!e.computed||H(e.property,t,r));if(e.type===`TemplateLiteral`)return $e(e.expressions,t,r);if(e.type===`ArrayExpression`)return $e(e.elements,t,r);if(e.type===`ObjectExpression`)return n.every(e.properties,e=>e.type===`SpreadElement`?H(e.argument,t,r):(!e.computed||H(e.key,t,r))&&H(e.value,t,r));if(e.type!==`CallExpression`)return!1;let i=e.callee.type===`CallExpression`?e.callee.callee:e.callee;return V(i,t,r)!==void 0&&(e.callee===i||H(e.callee,t,r))&&$e(e.arguments,t,r)}function et(e,t){if(e.type===`Identifier`)return t.bindings.get(e.name);if(e.type!==`TSQualifiedName`)return;let n=et(e.left,t);return n===void 0?void 0:[...n,e.right.name]}function tt(e,t){for(let i=t.parent;i!==null;i=i.parent){let t=`typeParameters`in i&&i.typeParameters?.type===`TSTypeParameterDeclaration`?r.pipe(i.typeParameters.params,n.findFirst(t=>t.name.name===e),o.getOrUndefined):void 0;if(t!==void 0)return t}}function nt(e,t,n){let r=/* @__PURE__ */ new Set,i=e,a=t;for(;i?.type===`TSTypeReference`;){let e=et(i.typeName,n),t=e?.length===2&&e[0]===`Schema`?e[1]:void 0;if(t!==void 0)return!t.startsWith(`Constraint`);let o=i.typeName.type===`Identifier`?tt(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 rt(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 it(e,t,n){let r=e;for(;r.type===`TSSatisfiesExpression`||r.type===`TSNonNullExpression`;)r=r.expression;if(r.type===`TSAsExpression`)return nt(r.typeAnnotation,r,n)===!1;let i=r.type===`Identifier`?rt(r,t):void 0;return i!==void 0&&nt(i.typeAnnotation,i,n)===!1}function at(e){return n.some(e.arguments,e=>e.type===`SpreadElement`)}function ot(e){let[t]=e.arguments;return e.arguments.length===1&&t?.type!==`SpreadElement`&&!e.typeArguments?t:void 0}function st(e){return e.callee.type===`MemberExpression`&&!e.callee.optional&&x(e.callee)===`pipe`&&!e.typeArguments&&!at(e)}function ct(e,t,n){return(O(e.callee,n,[`pipe`])||O(e.callee,n,[`Function`,`pipe`]))&&B(t,e.callee)}function lt(e,t,n){return Ze(V(e,t,n))?!0:e.type===`CallExpression`&&Ke.has(V(e.callee,t,n)??``)}function ut(e,t,n){if(Ye.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`&&qe.has(x(e.callee)??``)&&ut(e.callee.object,t,n):Ye.test(r)||Ze(r)}function dt(e,t,n){let[r,i]=e.arguments;if(!(r===void 0||i===void 0||r.type===`SpreadElement`||e.typeArguments||at(e)||!ut(r,t,n)&&!lt(i,t,n)))return[r,e.arguments.slice(1)]}function ft(e,t,n,r,i,a){let o=gt(e,i,a);return{head:o.head,steps:[...o.steps,t],violation:o.violation??n,reordersEffects:o.reordersEffects||r}}function pt(e,t,n){let r=ot(e);if(r===void 0)return;let i=V(e.callee,t,n);if(Ze(i)){let a=Xe(i);return ft(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&&Ke.has(a))return ft(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 mt(e,t,i){let a=ct(e,t,i),s=a?dt(e,t,i):st(e)?[e.callee.object,e.arguments]:void 0;if(s===void 0)return;let[c,l]=s,u=n.map(l,e=>V(e,t,i)),d=r.pipe(u,n.findFirst(Xe),o.getOrUndefined),f=d!==void 0&&n.some(l.slice(u.indexOf(d)+1),e=>!H(e,t,i));return ht(c,n.map(l,(e,n)=>({text:t.sourceCode.getText(e),wrapper:Xe(u[n])})),a?{kind:`functionPipe`}:d===void 0?void 0:{kind:`wrapperPipe`,name:d},f,t,i)}function ht(e,t,n,r,i,a){let o=gt(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`?pt(e,t,n)??mt(e,t,n):void 0}function gt(e,t,n){return U(e,t,n)??{head:e,steps:[],violation:void 0,reordersEffects:!1}}function _t(e,t,n){let r=e.parent;return r.type===`MemberExpression`&&r.object===e&&r.parent.type===`CallExpression`?r.parent.callee===r&&st(r.parent):r.type===`CallExpression`&&r.arguments[0]===e&&(ct(r,t,n)||!st(r))&&U(r,t,n)!==void 0}function vt(e,t,r){return n.isReadonlyArrayNonEmpty(t)?`${e===`\0`&&!Je.has(r.type)?`(\0)`:e}.pipe(${n.join(t,`, `)})`:e}function yt(e,t){let n=`\0`,r=[];for(let i of t)if(i.wrapper){let t=vt(n,r,e),a=t===`\0`&&e.type===`SequenceExpression`?`(${t})`:t;n=`${i.text}(${a})`,r=[]}else r.push(i.text);return vt(n,r,e)}const bt=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(r){let i=t();if(!i.hasEffectImport)return;let a=U(r,e,i);if(a?.violation===void 0||_t(r,e,i))return;let{head:o}=a;if(a.steps[0]?.wrapper===!1&&it(o,e,i))return;let s=n.some(e.sourceCode.getCommentsInside(r),e=>!pe(o,e)),[c=``,l=``]=yt(o,a.steps).split(`\0`);e.report({node:r,messageId:a.violation.kind,data:{name:a.violation.name??``},fix:s||a.reordersEffects?void 0:e=>[e.replaceTextRange([r.range[0],o.range[0]],c),e.replaceTextRange([o.range[1],r.range[1]],l)]})}}));function xt(e){return o.getOrUndefined(n.findFirst(e.arguments,e=>e.type===`ObjectExpression`))}function St(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 Ct(e,t){let n=L(e);return n===void 0?void 0:T(n.callee,t)}const wt=/* @__PURE__ */ new Set([`catch`,`finally`,`then`]);function Tt(e){let t=S(e.callee);return t!==void 0&&n.join(t,`.`)===`Promise`}function Et(e){let t=S(e.callee);return t!==void 0&&n.join(t,`.`)===`fetch`||t?.[0]===`Promise`&&t[1]!==`withResolvers`||wt.has(t?.at(-1)??``)||k(e.callee)&&e.callee.async}const Dt=a.type().pipe(a.discriminators(`type`)({CallExpression:Et,NewExpression:Tt}),a.orElse(r.constFalse));function Ot(e){return Dt(N(e))}function kt(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 At(e){let t=e?.type===`ObjectExpression`?M(e,`try`)?.value:e;return k(t)?t:void 0}function jt(e){let t=N(e);return z(t,`*`)?!0:t.type===`ArrayExpression`&&(t.elements.length===0||n.some(t.elements,e=>e!==null&&z(e,`*`)))}const Mt=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=xt(n);if(i===void 0||!z(M(i,`credentials`)?.value??i,!0))return;let a=M(i,`allowedOrigins`);(a===void 0||jt(a.value))&&e.report({node:n,messageId:`wildcard`})}}));function Nt(e){return e.type===`AssignmentPattern`||e.type===`RestElement`||e.optional===!0}const Pt=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(r){let i=A(r,0),a=A(r,1);a!==void 0&&E(r.callee,t(),`Function`,`dual`)&&i?.type===`Literal`&&s.isNumber(i.value)&&k(a)&&n.some(a.params,Nt)&&e.report({node:i,messageId:`unsafeArity`})}})),Ft=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 It(e,t){if(D(e.callee,t,`Effect`,[`promise`,`tryPromise`]))return At(A(e,0))}const Lt=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&&Ot(e.init)&&n.add(e.id.name)},CallExpression(r){let i=It(r,t()),a=i===void 0?void 0:kt(i);a?.type===`Identifier`&&n.has(a.name)&&e.report({node:a,messageId:`prestarted`})}}}),Rt=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:kt(i);i!==void 0&&(i.async||a!==void 0&&Ot(a))&&e.report({node:i,messageId:`asyncTry`})}})),zt=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)&&ge(n)&&e.report({node:n,messageId:`discarded`})}})),Bt=/* @__PURE__ */ new Set([`mapElements`,`mapFields`,`mapMembers`]);function Vt(e,t){let n=N(e);if(n.type===`CallExpression`&&n.callee.type===`MemberExpression`&&x(n.callee)===t)return n}const Ht=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(r){if(!t().hasEffectImport||r.callee.type!==`MemberExpression`)return;let i=x(r.callee);i!==void 0&&Bt.has(i)&&Vt(r.callee.object,`check`)!==void 0&&(n.findFirst(r.arguments,e=>e.type===`ObjectExpression`).pipe(o.flatMapNullishOr(e=>M(e,`unsafePreserveChecks`)),o.exists(e=>z(e.value,!0)))||e.report({node:r,messageId:`discarded`,data:{method:i}}))}})),Ut={Array:`Arr`,Boolean:`Bool`,Equal:`Eq`,Function:`Fn`,Number:`Num`,Option:`Opt`,Predicate:`P`,Record:`R`,String:`Str`},Wt=/^\p{Lu}/u;function Gt(e){return Wt.test(e)}function Kt(e){return e===`@effect/vitest`||e.startsWith(`@effect/vitest/`)}function W(e,t){return e.importKind===`type`||t?.importKind===`type`}function qt(e){return o.getOrElse(i.get(Ut,e),()=>e)}function Jt(e,t){if(e===`effect`||e===`alchemy`||/^@effect\/[^/]+$/u.test(e)&&!Kt(e))return`${e}/${t}`}function Yt(e){if(Kt(e)||!(e.startsWith(`effect/`)||e.startsWith(`alchemy/`)||/^@effect\/[^/]+\//u.test(e)))return;let t=n.lastNonEmpty(c.split(e,`/`));return Gt(t)?t:void 0}function Xt(e,t,r){let i=t.specifiers;if(e.sourceCode.getCommentsInside(t).length>0||t.attributes.length>0||!n.every(i,e=>e.type===`ImportSpecifier`))return;let[a,o]=n.partition(i,n=>{let r=g(n.imported),i=Gt(r)&&!W(t,n)?Jt(t.source.value,r):void 0;return i===void 0?l.fail(e.sourceCode.getText(n)):l.succeed(`import * as ${n.local.name} from '${i}';`)}),s=n.isReadonlyArrayNonEmpty(o)?n.prepend(a,`import { ${n.join(o,`, `)} } from ${e.sourceCode.getText(t.source)};`):a;return[r.replaceText(t,n.join(s,`
2
+ `))]}function Zt(e,t,r){let i=Yt(t.source.value);if(i===void 0||t.attributes.length>0||e.sourceCode.getCommentsInside(t).length>0)return;let a=qt(i),s=e.sourceCode.getDeclaredVariables(t),c=o.getOrUndefined(n.findFirst(s,e=>e.name===a));if(n.some(e.sourceCode.scopeManager.scopes,e=>n.some(e.variables,e=>e.name===a&&e!==c)||n.some(e.references,e=>e.identifier.name===a&&e.resolved!==c)))return;let l=[],u=[];for(let n of t.specifiers){if(n.type===`ImportDefaultSpecifier`)return;if(n.type===`ImportSpecifier`&&W(t,n)){if(n.local.name===a)return;u.push(e.sourceCode.getText(n));continue}let i=Qt(n,s,a,r);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 { ${n.join(u,`, `)} } from ${d};`}`;return[r.replaceText(t,f),...l]}function Qt(e,t,r,i){let a=o.getOrUndefined(n.findFirst(t,t=>t.name===e.local.name));if(a!==void 0){if(e.type===`ImportNamespaceSpecifier`)return $t(a,r,!1,i);if(e.imported.type===`Identifier`)return $t(a,`${r}.${e.imported.name}`,!0,i)}}function $t(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`||s.type.startsWith(`JSX`))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 en=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=g(n.imported),i=Gt(r)?Jt(t.source.value,r):void 0;i!==void 0&&e.report({node:n,messageId:`barrelImport`,data:{alias:qt(r),source:i},fix:n=>Xt(e,t,n)})}}})),tn=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(r){if(!E(r.callee,t(),`Effect`,`callback`)&&!E(r.callee,t(),`Effect`,`async`))return;let i=A(r,0);i!==void 0&&k(i)&&i.body?.type===`BlockStatement`&&i.body.body.length===0&&e.report({node:r,messageId:`emptyCallback`,fix(t){if(!B(e,r.callee)||r.arguments.length!==1||i.async||i.generator||n.some(i.params,e=>e.type!==`Identifier`)||e.sourceCode.getCommentsInside(r).length>0)return;let a=Te(e,r,`effect/Effect`,`Effect`,t);return[...a.fixes,t.replaceText(r,`${a.name}.never`)]}})}})),nn=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 rn(e,t){let r=N(e),i=/* @__PURE__ */ new Set;for(;r.type===`Identifier`;){let e=C(t,r,r.name),a=ie(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||n.some(e.references,e=>e.isWrite()&&!e.init))return;i.add(e),r=N(o.init)}return r}function an(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 on=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=an(n),a=i===void 0?void 0:rn(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`})}})),sn=/* @__PURE__ */ new Set([`delete`,`get`,`has`,`set`]);function cn(e,t){return e.type===`CallExpression`&&E(e.callee,t,`Hash`,`hash`)}const ln=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 cn(e,t())||e.type===`Identifier`&&n.has(e.name)}return{before(){n=/* @__PURE__ */ new Set},VariableDeclarator(e){e.id.type===`Identifier`&&e.init&&cn(e.init,t())&&n.add(e.id.name)},CallExpression(t){if(t.callee.type!==`MemberExpression`||!sn.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){he(t.operator)&&r(t.left)&&r(t.right)&&e.report({node:t,messageId:`hashIdentity`})},MemberExpression(t){t.computed&&r(t.property)&&e.report({node:t.property,messageId:`hashIdentity`})}}}),un=/* @__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(`.`)),dn=/* @__PURE__ */ new Set([`global`,`module`]),fn=/* @__PURE__ */ new Set([`ArrowFunctionExpression`,`FunctionDeclaration`,`FunctionExpression`]),pn=/* @__PURE__ */ new Set([`AssignmentExpression`,`AwaitExpression`,`ImportExpression`,`TaggedTemplateExpression`,`UpdateExpression`,`YieldExpression`]),mn=/* @__PURE__ */ new Set([`ParenthesizedExpression`,`TSAsExpression`,`TSNonNullExpression`]);function hn(e,t,r){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||!un.has(a))return;let s=C(r,e,o);return s!==void 0&&n.every(s.defs,e=>e.type===`ImportBinding`)?a:void 0}function gn(e){let t=e.parent;for(;t;){if(fn.has(t.type))return!0;t=t.parent}return!1}function _n(e){let t=e,n=e.parent;for(;mn.has(n.type)&&n.parent!==null;)t=n,n=n.parent;return n.type===`CallExpression`&&n.callee===t}function vn(e,t){return e.type===`CallExpression`&&T(e.callee,t)?.[0]===`Schema`}function yn(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 bn(e){return n.every(e.references,e=>(!e.isWrite()||e.init)&&!yn(e.identifier))}function xn(e,t,n,r){let i=C(r,e,t);return i===void 0||pe(n,i.scope.block)?!0:dn.has(i.scope.type)&&bn(i)}function Sn(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 Cn(e,t){if(e===t)return!1;let n=e.parent;for(;n!==null&&n!==t;){if(fn.has(n.type))return!0;n=n.parent}return!1}function wn(e,t,n){return Cn(e,t)?!1:e.type===`CallExpression`||e.type===`NewExpression`?T(e.callee,n)===void 0:pn.has(e.type)}function Tn(e,t,n){return!P(e,r=>r.type===`ThisExpression`||r.type===`Super`||r.type===`MetaProperty`&&r.meta.name===`new`||wn(r,e,t)||r.type===`Identifier`&&!Sn(r)&&!xn(r,r.name,e,n))}const En=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(r){let i=t();if(!i.hasEffectImport)return;let a=hn(r.callee,i,e),[o]=r.arguments;if(a===void 0||o===void 0||o.type===`SpreadElement`||n.some(r.arguments,e=>e.type===`SpreadElement`)||!_n(r)||!gn(r))return;let s=N(o),c=vn(s,i);(c||s.type===`Identifier`||s.type===`MemberExpression`)&&n.every(r.arguments,t=>Tn(t,i,e))&&e.report({node:r.callee,messageId:c?`inlineSchema`:`inlineCompile`,data:{method:a}})}})),Dn=/* @__PURE__ */ new Set([`catch`,`catchAll`,`catchAllCause`,`catchIf`,`catchSome`,`catchSomeCause`,`catchTag`,`orElse`,`orElseFail`,`orElseSucceed`]),On=/* @__PURE__ */ new Set([`log`,`logDebug`,`logError`,`logInfo`,`logTrace`,`logWarning`]);function kn(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`&&Dn.has(r))return{method:r}}}n=n.parent}}const An=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(r){let i=t(),a=T(r.callee,i),o=a?.[1]!==void 0&&a[0]===`Effect`&&On.has(a[1])?n.join(a,`.`):void 0;if(o===void 0)return;let s=kn(r,i);s!==void 0&&e.report({node:r,messageId:`logging`,data:{logger:o,catchMethod:s.method}})}})),jn=a.type().pipe(a.when({type:`MemberExpression`,computed:!1,object:{type:`Identifier`,name:`Effect`},property:{type:`Identifier`,name:a.is(`catch`,`catchAll`,`catchIf`)}},r.constTrue),a.orElse(r.constFalse)),Mn=a.type().pipe(a.when({type:`MemberExpression`,computed:!1,object:{type:`Identifier`,name:`Match`},property:{type:`Identifier`,name:a.is(`when`,`not`)}},r.constTrue),a.orElse(r.constFalse)),G=a.type().pipe(a.when({type:`MemberExpression`,computed:!1,property:{type:`Identifier`,name:`_tag`}},r.constTrue),a.when({type:`MemberExpression`,computed:!0,property:{type:`Literal`,value:`_tag`}},r.constTrue),a.orElse(r.constFalse));function Nn(e){if(he(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&&jn(n.callee)}function Pn(e){return e.object.type===`MemberExpression`&&x(e.object)===`reason`}function Fn(e){let t=e.parent;return t.type===`CallExpression`&&t.arguments.includes(e)&&Mn(t.callee)}const In=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=Nn(t);n!==void 0&&K(t)&&e.report({node:t,messageId:Pn(n)?`reason`:`tag`})},SwitchStatement(t){G(t.discriminant)&&K(t)&&e.report({node:t,messageId:Pn(t.discriminant)?`reason`:`tag`})}})),Ln=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){Nn(t)===void 0||K(t)||e.report({node:t,messageId:`manualComparison`})},SwitchStatement(t){G(t.discriminant)&&!K(t)&&e.report({node:t,messageId:`manualSwitch`})}})),Rn=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(Fn(t))return;let r=o.getOrUndefined(n.findFirst(t.properties,e=>e.type===`Property`&&j(e)===`_tag`&&R(e.value)));r!==void 0&&e.report({node:r,messageId:`manualConstruction`})}})),zn=/* @__PURE__ */ new Map([[`addEventListener`,1],[`on`,1],[`setInterval`,0]]);function Bn(e,t){let n=S(e.callee)?.at(-1),r=n===void 0?void 0:zn.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&&ue(i,t)}const Vn=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`&&Bn(e,i))&&e.report({node:n,messageId:`multiShot`})}})),Hn=/* @__PURE__ */ new Set([`NaN`,`Infinity`,`undefined`]),Un=/* @__PURE__ */ new Set([`annotate`,`annotateEncoded`,`annotateKey`]),Wn=[`default`,`examples`];function Gn(e){return e.type===`Literal`&&s.isBigInt(e.value)||e.type===`Identifier`&&Hn.has(e.name)||k(e)||e.type===`CallExpression`&&S(e.callee)?.at(-1)===`Symbol`}function Kn(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 qn(e){let t=[e];for(;t.length>0;){let e=t.pop();if(e===void 0)continue;let n=N(e);if(Gn(n))return n;Kn(n,t)}}const Jn=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||!Un.has(a))return;let o=xt(n);if(o!==void 0&&M(o,`jsonSchema`)===void 0)for(let t of Wn){let n=M(o,t);if(n===void 0)continue;let r=qn(n.value);r!==void 0&&e.report({node:r,messageId:`nonJson`})}}})),Yn=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`,[`option`,`either`]),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`,[`option`,`either`])&&e.report({node:n,messageId:`mandatory`})}})),Xn=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 r=n.findFirstWithIndex(t.properties,e=>e.type===`Property`&&j(e)===`_tag`);if(o.isNone(r))return;let[i,a]=r.value;n.some(n.drop(t.properties,a+1),e=>e.type===`SpreadElement`)&&e.report({node:i,messageId:`overwritten`})}})),Zn=/^make[A-Z]/u,Qn=/\.(?:test|spec)\.[cm]?[jt]sx?$/u,$n=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(!Qn.test(e.filename.replaceAll(`\\`,`/`))&&(t.source.value.startsWith(`./`)||t.source.value.startsWith(`../`)))for(let n of t.specifiers){if(n.type!==`ImportSpecifier`)continue;let t=g(n.imported);Zn.test(t)&&e.report({node:n,messageId:`serviceConstructorImport`,data:{name:t}})}}})),er=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`,[`getOrThrow`,`getOrThrowWith`])){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`,[`getOrThrow`,`getOrThrowWith`])&&e.report({node:n,messageId:`getOrThrow`})}})),tr=/* @__PURE__ */ new Set([`andThen`,`map`,`mapError`,`tap`,`tapError`,`tapErrorCause`]),nr=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=Ct(r,i),o=St(r,`catch`);(a?.[0]===`Effect`&&a[1]!==void 0&&tr.has(a[1])||o!==void 0&&D(o.callee,i,`Effect`,[`try`,`tryPromise`]))&&e.report({node:n,messageId:`callbackThrow`})}})),rr=/* @__PURE__ */ new Set([`get`,`post`,`put`,`patch`,`delete`,`head`,`options`]);function ir(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 ar(e,t){let n=S(e.callee),r=n?.[0],i=n?.at(-1);if(n===void 0||r===void 0||i===void 0||!rr.has(i))return!1;let a=ie(C(t,e,r));return a!==void 0&&ir(a,n)}function or(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`&&s.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 sr=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(n.some(t.arguments,e=>e.type===`SpreadElement`)||!ar(t,e))return;let r=or(A(t,2)),i=or(o.getOrUndefined(n.findFirst(r??[],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}})}}})),cr=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=xt(n);if(i===void 0)return;let a=M(i,`times`);a!==void 0&&z(a.value,0)&&e.report({node:a,messageId:`zeroTimes`})}})),lr=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=Yt(t.source.value);if(n===void 0||t.importKind===`type`)return;let r=qt(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=>Zt(e,t,n)}):e.report({node:n,messageId:`namespace`,data:{alias:r,source:t.source.value},fix:n=>Zt(e,t,n)}))}})),ur=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`})}})),dr=/* @__PURE__ */ new Set([`toISOString`,`toLocaleDateString`,`toLocaleTimeString`]),fr=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`&&dr.has(x(n.callee)??``)&&e.report({node:n,messageId:`effectDateTime`})}})),pr=/* @__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`]]),mr={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 hr(e,t,r){let i=T(e.callee,r),a=i===void 0?void 0:pr.get(n.join(i,`.`));return a!==void 0&&B(t,e.callee)?mr[a](e):void 0}function gr(e,t){return e**t}const _r=a.type().pipe(a.withReturnType(),a.when(`*`,()=>u.multiply),a.when(`+`,()=>u.sum),a.when(`-`,()=>u.subtract),a.when(`/`,()=>u.divideUnsafe),a.when(`%`,()=>u.remainder),a.when(`**`,()=>gr),a.orElse(r.constUndefined));function q(e){let t=N(e);if(t.type===`Literal`)return s.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 _r(t.operator)?.(n,r)}function vr(e){let t=N(e);if(t.type===`Literal`)return s.isNumber(t.value)?[t.value]:void 0;if(t.type!==`BinaryExpression`||t.operator!==`*`)return;let r=vr(t.left),i=vr(t.right);return r===void 0||i===void 0?void 0:n.appendAll(r,i)}const yr=/* @__PURE__ */ new Set([6e4,36e5,864e5]),br=/* @__PURE__ */ new Set([60,3600,86400]),xr=/* @__PURE__ */ new Set([7,24,60,1e3,3600,86400]);function Sr(e){let t=vr(e);if(!(t===void 0||t.length<2)&&(n.some(t,e=>yr.has(e))||n.some(t,e=>br.has(e))&&n.filter(t,e=>xr.has(e)).length>=2))return{millis:n.contains(t,1e3)||n.some(t,e=>e%6e4==0)}}const Cr=[[`weeks`,6048e5],[`days`,864e5],[`hours`,36e5],[`minutes`,6e4],[`seconds`,1e3],[`millis`,1]];function wr(e){return!Number.isSafeInteger(e)||Math.abs(e)<1e4?String(e):String(e).replaceAll(/\B(?=(?:\d{3})+$)/gu,`_`)}function Tr(e,t){let r=e*n.findFirst(Cr,([e])=>e===t).pipe(o.map(([,e])=>e),o.getOrElse(()=>1));return r===0?`Duration.zero`:n.findFirst(Cr,([,e])=>Number.isSafeInteger(r/e)).pipe(o.match({onNone:()=>`Duration.millis(${wr(r)})`,onSome:([e,t])=>`Duration.${e}(${wr(r/t)})`}))}const Er=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=hr(n,e,t());r!==void 0&&q(r)!==void 0&&e.report({node:r,messageId:`effectDuration`,fix(t){let i=Te(e,n,`effect/Duration`,`Duration`,t);return[...i.fixes,t.replaceText(r,`${i.name}.millis(${e.sourceCode.getText(r)})`)]}})}})),Dr=/* @__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`]]),Or=/* @__PURE__ */ new Set([`day`,`hour`,`minute`,`second`,`week`]),kr=/* @__PURE__ */ new Set([`backoff`,`cooldown`,`day`,`debounce`,`delay`,`duration`,`expiration`,`expiry`,`hour`,`interval`,`lifetime`,`minute`,`second`,`throttle`,`timeout`,`ttl`,`week`]),Ar=r.flow(c.split(/[_$]+|(?<=[\da-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])/u),n.filter(c.isNonEmpty),n.map(c.toLowerCase)),jr=/* @__PURE__ */ new Set([`at`,`epoch`,`per`,`timestamp`]);function Mr(e){return e!==void 0&&e!==`excluded`&&e!==`unknown`}function Nr(e){let t=Ar(e),r=t.indexOf(`in`),i=t[r-1]??``;if(r>0&&r<t.length-1&&(Dr.has(i)||Or.has(i))||n.some(t,e=>jr.has(e)))return`excluded`;let a=t.at(-1),o=t.at(-2);if(a===void 0)return;let s=Dr.get(a);if(s!==void 0)return s;if(kr.has(a)||a===`age`&&o===`max`||a===`in`&&o===`expires`)return`unknown`}function Pr(e,t,r){return n.some(C(r,e,t)?.defs??[],e=>e.type===`ImportBinding`)}const Fr=a.type().pipe(a.discriminators(`type`)({Identifier:({name:e})=>[e],TSQualifiedName:({left:e,right:t})=>{let r=Fr(e);return r===void 0?void 0:n.append(r,t.name)}}),a.orElse(r.constUndefined));function Ir(e,t,n){return P(e,e=>{if(e.type!==`TSTypeReference`)return!1;let[r,...i]=Fr(e.typeName)??[],a=r===void 0||!Pr(e,r,t)?void 0:n.bindings.get(r);return a!==void 0&&[...a,...i][0]===`Duration`})}function Lr(e){return e.parent.type===`VariableDeclaration`&&e.parent.kind===`const`&&e.id.type===`Identifier`&&e.init!==null&&q(e.init)!==void 0}function Rr(e,t){let n=N(e);if(n.type!==`Identifier`)return;let r=ie(C(t,n,n.name))?.node;return r?.type===`VariableDeclarator`&&Lr(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&&Ir(n.id.typeAnnotation,e,t()))return`none`;let i=Nr(n.id.name);if(r)return Mr(i)?i:`millis`;if(i===`excluded`||(q(n.init)??0)<=0)return`none`;if(Mr(i))return i;let a=Sr(n.init);return a?.millis===!0?`millis`:a!==void 0||i===`unknown`?void 0:`none`}return{before(){n=/* @__PURE__ */ new Map},VariableDeclarator(e){t().hasEffectImport&&Lr(e)&&!n.has(e)&&n.set(e,!1)},CallExpression(r){let i=hr(r,e,t()),a=i===void 0?void 0:Rr(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`:Tr(a,n)}})}}}}),Br=/* @__PURE__ */ new Set([`base64`,`base64url`,`hex`]);function Vr(e){return e!==void 0&&R(e)&&Br.has(e.value)}const Hr=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(r){if(!t().hasEffectImport)return;if((w(r.callee,e,`atob`)||w(r.callee,e,`btoa`))&&r.arguments.length>0){e.report({node:r,messageId:`effectEncoding`});return}let i=S(r.callee),a=i!==void 0&&n.join(i,`.`)===`Buffer.from`&&Vr(A(r,1)),o=i?.at(-1)===`toString`&&Vr(A(r,0));(a||o)&&e.report({node:r,messageId:`effectEncoding`})}})),Ur=/* @__PURE__ */ new Set([`fs`,`fs/promises`,`node:fs`,`node:fs/promises`]),Wr=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&&Ur.has(n.source.value)&&e.report({node:n.source,messageId:`effectFileSystem`,data:{source:n.source.value}})}}));function Gr(e,t,n){return e.type===`CallExpression`&&E(e.callee,t,`Result`,n)?A(e,0):void 0}function Kr(e,t,n){let r=F(t),i=kt(t);if(r===void 0||i?.type!==`ConditionalExpression`)return;let a=Gr(i.consequent,n,`succeed`),o=Gr(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 qr=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){Kr(e,n,t())},FunctionExpression(n){Kr(e,n,t())}})),Jr=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 Yr(e){return e.type===`Literal`||e.type===`TemplateLiteral`&&e.expressions.length===0}function Xr(e,t){if(e.type===`BinaryExpression`&&he(e.operator)){if(Yr(e.left))return t.sourceCode.getText(e.right);if(Yr(e.right))return t.sourceCode.getText(e.left)}}const Zr=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=Xr(t.test,e);if(n===void 0)return;let r=t.alternate,i=1;for(;r.type===`ConditionalExpression`;){if(Xr(r.test,e)!==n)return;i+=1,r=r.alternate}i>1&&e.report({node:t,messageId:`preferMatch`})}})),Qr=/* @__PURE__ */ new Set([`node:path`,`path`]),$r=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&&Qr.has(n.source.value)&&e.report({node:n.source,messageId:`effectPath`,data:{source:n.source.value}})}})),ei=/* @__PURE__ */ new Set([`canParse`,`parse`]),ti=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`&&ei.has(r[1]??``)&&n.callee.type===`MemberExpression`&&w(n.callee.object,e,`URL`)&&e.report({node:n,messageId:`effectUrl`})}})),ni=/* @__PURE__ */ new Map([[`interruptibleMask`,`interruptible`],[`uninterruptibleMask`,`uninterruptible`]]),ri=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`?ni.get(r[1]??``):void 0,a=A(n,0);i!==void 0&&a!==void 0&&k(a)&&!de(a)&&e.report({node:n,messageId:`unusedRestore`,data:{replacement:`Effect.${i}`}})}})),ii=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)&&!de(r)&&e.report({node:n,messageId:`unusedSpan`})}}));function ai(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 oi=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`)&&ai(i,r)&&e.report({node:n,messageId:`zeroSleep`})}})),si=/* @__PURE__ */ new Set([`catch`,`catchAll`,`mapError`]);function ci(e,t){let n=Ct(e,t),r=St(e,`catch`);if(!(n?.[0]===`Effect`&&n[1]!==void 0&&si.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`&&_e(e)&&(i===void 0||!ue(e,i.name)))}const li=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){ci(n,t())&&e.report({node:n,messageId:`droppedCause`})},FunctionExpression(n){ci(n,t())&&e.report({node:n,messageId:`droppedCause`})}})),ui=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 di(e,t){if(E(e.callee,t,`Effect`,`tryPromise`))return At(A(e,0))}const fi=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=di(n,t());if(r===void 0)return;let i=F(r);i===void 0?e.report({node:r,messageId:`missingSignal`}):!i.name.startsWith(`_`)&&!de(r)&&e.report({node:i,messageId:`unusedSignal`})}})),pi=[`fn`,`fnUntraced`,`gen`],mi=[`fn`,`fnUntraced`];function hi(e,t){let n=e.parent;if(n.type===`CallExpression`&&A(n,0)===e)return D(n.callee,t,`Effect`,[`try`,`tryPromise`]);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`,[`try`,`tryPromise`])}const gi=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(r){let i=t(),a=I(r);if(a===void 0||hi(a,i))return;let o=L(a),s=o!==void 0&&n.some(pi,e=>E(o.callee,i,`Effect`,e)),c=o?.callee,l=c?.type===`CallExpression`&&n.some(mi,e=>E(c.callee,i,`Effect`,e));(s||l)&&e.report({node:r,messageId:`throwInGen`})}})),_i=String.raw`(?:\r\n|\r(?!\n)|[\n\u2028\u2029])`,vi=String.raw`[^\S\r\n\u2028\u2029]*`,yi=RegExp(`^(${vi}${_i})(?:${vi}${_i})+(${vi};?)$`,`u`),bi=/^(?:module\s*\.\s*)?exports(?:\s*\.|\s*\[|$)/u,xi=/* @__PURE__ */ new Set([`FunctionDeclaration`,`FunctionExpression`,`ArrowFunctionExpression`]),Si=/* @__PURE__ */ new Set([`any`,`never`,`always`]),Ci=/* @__PURE__ */ new Set([`any`,`singleline`,`multiline`]),wi=/* @__PURE__ */ new Set([`blankLine`,`prev`,`next`]),Ti=/* @__PURE__ */ new Set([`selector`,`lineMode`]);function Ei(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 Di(e){return xi.has(e.type)}function Oi(e){return e.type===`ChainExpression`?e.expression:e}function X(e,t){let r=new Set(n.ensure(e));return(e,n)=>n.getFirstToken(e)?.value===t&&r.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 ki(e){if(e.type!==`ExpressionStatement`)return!1;let t=Oi(e.expression);if(t.type===`UnaryExpression`&&(t=Oi(t.argument)),t.type!==`CallExpression`)return!1;let r=t.callee;for(;r.type===`SequenceExpression`;)r=o.getOrThrowWith(n.last(r.expressions),()=>/* @__PURE__ */ Error(`Padding rule invariant: sequence expression is empty`));return Di(r)}function Ai(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 ji(e,t){if(e.type===`DoWhileStatement`&&e.body.type===`BlockStatement`||ki(e))return!0;let n=t.getLastToken(e,e=>!Ei(e)),r=n?.type===`Punctuator`&&n.value===`}`?t.getNodeByRangeIndex(n.range[0]):null;return r?.type===`BlockStatement`||r?.type===`SwitchStatement`}function Mi(e,t){return e.type===`ExpressionStatement`&&(e.parent.type===`Program`||e.parent.type===`BlockStatement`&&Di(e.parent.parent))&&e.expression.type===`Literal`&&s.isString(e.expression.value)&&(t.getTokenBefore(e.expression)?.value!==`(`||t.getTokenAfter(e.expression)?.value!==`)`)}function Ni(e,t){if(!Mi(e,t)||!e.parent||!(`body`in e.parent)||!n.isArray(e.parent.body))return!1;let i=e.parent.body;return r.pipe(i,n.takeWhile(t=>t!==e),n.every(e=>Mi(e,t)))}function Pi(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 Fi(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]&&Ei(n)&&!J(r,n)&&J(n,i)?r:n}function Ii(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":ji,expression:(e,t)=>e.type===`ExpressionStatement`&&!Ni(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`)},Li={"*":()=>!0,exports:Pi,require:Ai,directive:Ni,iife:ki,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`&&bi.test(t.getText(e.expression.left)),"cjs-import":(e,t)=>e.type===`VariableDeclaration`&&e.declarations[0]?.init!=null&&t.getText(e.declarations[0].init).startsWith(`require(`),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 Ri(e){return Ci.has(e)}function zi(e){return Si.has(e)}function Bi(e){return s.isString(e)&&i.has(Li,e)}function Vi(e){return n.isArray(e)}function Hi(e){if(Bi(e))return e;if(s.isObject(e)&&s.isString(e.selector)&&n.every(i.keys(e),e=>Ti.has(e))){if(!(`lineMode`in e))return{selector:e.selector};if(Ri(e.lineMode))return{selector:e.selector,lineMode:e.lineMode}}throw Error(`Invalid padding-line-between-statements statement matcher`)}function Ui(e){if(!n.isArray(e))return Hi(e);let t=e;if(!n.isReadonlyArrayNonEmpty(t))throw Error(`Padding statement matcher arrays must not be empty`);return n.map(t,e=>Hi(e))}function Wi(e){return n.map(e,e=>{if(!s.isObject(e)||!(`blankLine`in e)||!(`prev`in e)||!(`next`in e)||n.some(i.keys(e),e=>!wi.has(e))||!zi(e.blankLine))throw Error(`Invalid padding-line-between-statements configuration`);return{blankLine:e.blankLine,prev:Ui(e.prev),next:Ui(e.next)}})}function Gi(e,t,n){let r=[],i=Fi(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 Ki(e,t,r){return p.gen(function*(){if(r===`any`)return yield*p.void;let i=yield*f,a=i.sourceCode,o=Gi(e,t,a);return r===`never`?n.isArrayNonEmpty(o)?yield*i.report({node:t,messageId:`unexpectedBlankLine`,loc:Ii(t,a),fix(e){if(o.length>=2)return null;let t=n.headNonEmpty(o),r=t[0].range[1],i=t[1].range[0];return e.replaceTextRange([r,i],a.text.slice(r,i).replace(yi,`$1$2`))}}):yield*p.void:n.isArrayNonEmpty(o)?yield*p.void:yield*i.report({node:t,messageId:`expectedBlankLine`,loc:Ii(t,a),fix(n){let r=Fi(e,a),i=a.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
  `:`
5
- `)}})})}function*ur(e,t){let i=e.sourceCode,s=new Set(r.pipe(t,n.flatMap(e=>r.pipe([e.prev,e.next].flat(),n.flatMap(e=>typeof e==`string`?[]:[e.selector]))))),c=yield*p.make(new Map(Array.from(s,e=>[e,/* @__PURE__ */ new Set]))),l=yield*p.make(n.empty()),u=yield*p.make(a.none());function m(){return p.update(u,e=>a.some({upper:e,prevNode:a.none()}))}function h(){return p.update(u,a.flatMap(e=>e.upper))}function g(e,t,a){let o=e;for(;o.type===`LabeledStatement`;)o=o.body;return ir(t)?r.pipe(t,n.some(e=>g(o,e,a))):typeof t==`string`?nr[t](o,i):a.get(t.selector)?.has(o)===!0&&(t.lineMode===`singleline`?J(o):t.lineMode!==`multiline`||!J(o))}let ee=n.reverse(t);function _(e,t,n){for(let r of ee)if(g(e,r.prev,n)&&g(t,r.next,n))return r.blankLine;return`any`}let v=o.type().pipe(o.when({parent:o.null},r.constant(f.void)),o.not({parent:{type:o.is(`BlockStatement`,`Program`,`StaticBlock`,`SwitchCase`,`SwitchStatement`,`TSInterfaceBody`,`TSModuleBlock`,`TSTypeLiteral`)}},r.constant(f.void)),o.orElse(e=>f.gen(function*(){let t=yield*p.get(u);if(a.isNone(t))return yield*f.die(/* @__PURE__ */ Error(`Padding rule invariant: statement scope is missing`));if(a.isSome(t.value.prevNode)){let n=t.value.prevNode.value;yield*p.update(l,t=>(t.push({prevNode:n,nextNode:e}),t))}yield*p.set(u,a.some({upper:t.value.upper,prevNode:a.some(e)}))})));function y(e){return f.andThen(v(e),m())}let b={Program:m,"Program:exit":f.fn(`'Program:exit'`)(function*(){let e=yield*p.get(c);yield*p.get(l).pipe(f.flatMap(t=>f.all(r.pipe(t,n.map(({prevNode:t,nextNode:n})=>lr(t,n,_(t,n,e))))))),yield*h()}),BlockStatement:m,"BlockStatement:exit":h,SwitchStatement:m,"SwitchStatement:exit":h,SwitchCase:y,"SwitchCase:exit":h,StaticBlock:m,"StaticBlock:exit":h,TSInterfaceBody:m,"TSInterfaceBody:exit":h,TSModuleBlock:m,"TSModuleBlock:exit":h,TSTypeLiteral:m,"TSTypeLiteral:exit":h,TSDeclareFunction:y,"TSDeclareFunction:exit":h,TSMethodSignature:y,"TSMethodSignature:exit":h,":statement":v};return d.merge(b,...Array.from(s,e=>d.on(e,t=>p.update(c,n=>(n.get(e)?.add(t),n)))))}const $={"alchemy-no-cloudflare-init-finalizer":ue,"alchemy-no-deprecated-docker-constraints":me,"alchemy-no-deprecated-resource":ge,"alchemy-no-plaintext-github-secret":ve,"alchemy-no-removed-config-api":ye,"alchemy-no-reserved-eventbridge-default-name":be,"alchemy-no-runtime-config":xe,"alchemy-no-v1-import":Se,"alchemy-no-v1-worker-properties":Ce,"avoid-data-tagged-error":we,"ban-error-string":Oe,"cors-credentials-with-wildcard":Ne,"dual-numeric-arity-with-optional-parameter":Fe,"effect-promise-vs-trypromise":Ie,"no-already-started-promise":Re,"no-async-effect-try":ze,"no-discarded-run-promise":Be,"no-discarded-schema-checks":He,"no-empty-effect-callback":$e,"no-empty-schema-struct":et,"no-effect-alchemy-barrel-imports":Qe,"no-function-config-default":rt,"no-hash-as-identity":at,"no-logging-in-catch":lt,"no-manual-effect-error-tag":ht,"no-manual-tag-comparison":gt,"no-manual-tagged-construction":_t,"no-multi-shot-effect-callback":yt,"no-non-json-schema-annotation":Ct,"no-option-of-service":wt,"no-overwritten-discriminant":Tt,"no-service-option-get-or-throw":kt,"no-service-constructor-imports":Ot,"no-throw-in-effect-callback":jt,"no-uppercase-http-api-header":It,"no-zero-retry-times":Lt,"padding-line-between-statements":l.define({name:`padding-line-between-statements`,meta:{type:`layout`,docs:{description:`Require or disallow padding lines between statements`,url:`https://eslint.style/rules/padding-line-between-statements`,recommended:!0},fixable:`whitespace`,schema:{type:`array`,items:{type:`object`,properties:{blankLine:{enum:[`any`,`never`,`always`]},prev:{$ref:`#/$defs/statementOption`},next:{$ref:`#/$defs/statementOption`}},required:[`blankLine`,`prev`,`next`],additionalProperties:!1},$defs:{statementMatcher:{anyOf:[{type:`string`,enum:i.keys(nr)},{type:`object`,properties:{selector:{type:`string`},lineMode:{enum:[`any`,`singleline`,`multiline`]}},required:[`selector`],additionalProperties:!1}]},statementOption:{anyOf:[{$ref:`#/$defs/statementMatcher`},{type:`array`,items:{$ref:`#/$defs/statementMatcher`},minItems:1,uniqueItems:!0}]}}},messages:{unexpectedBlankLine:`Unexpected blank line before this statement.`,expectedBlankLine:`Expected blank line before this statement.`}},*create(){let e=yield*u;return yield*ur(e,sr(e.options))}}),"prefer-effect-alchemy-namespace-imports":Rt,"prefer-effect-array-sort":zt,"prefer-effect-datetime":Vt,"prefer-effect-duration":Qt,"prefer-effect-duration-constants":fn,"prefer-effect-encoding":hn,"prefer-effect-filesystem":_n,"prefer-effect-filter":bn,"prefer-effect-headers":xn,"prefer-effect-match":Tn,"prefer-effect-path":Dn,"prefer-effect-url":On,"prefer-uninterruptible":kn,"prefer-with-span":An,"prefer-yield-now":Mn,"preserve-caught-error":Fn,"require-schema-class-brand":In,"require-try-promise-abort-signal":Rn,"throw-in-effect-gen":Bn},dr=/* @__PURE__ */ new Set([`prefer-effect-filesystem`,`prefer-effect-path`]),fr=i.fromEntries(r.pipe(i.keys($),n.filter(e=>!dr.has(e)),n.map(e=>[`2digits/${e}`,`error`]))),pr=t({meta:{name:`@2digits/oxlint-plugin`},rules:$});export{pr as default,fr as recommendedRules,$ as rules};
5
+ `)}})})}function*qi(e,t){let i=e.sourceCode,c=n.fromIterable(new Set(r.pipe(t,n.flatMap(e=>[...n.ensure(e.prev),...n.ensure(e.next)]),n.flatMap(e=>s.isString(e)?[]:[e.selector])))),l=yield*m.make(new Map(n.map(c,e=>[e,/* @__PURE__ */ new Set]))),u=yield*m.make(n.empty()),d=yield*m.make(o.none());function f(){return m.update(d,e=>o.some({upper:e,prevNode:o.none()}))}function h(){return m.update(d,o.flatMap(e=>e.upper))}function g(e,t,r){let a=e;for(;a.type===`LabeledStatement`;)a=a.body;return Vi(t)?n.some(t,e=>g(a,e,r)):s.isString(t)?Li[t](a,i):r.get(t.selector)?.has(a)===!0&&(t.lineMode===`singleline`?Y(a):t.lineMode!==`multiline`||!Y(a))}function te(e,i,a){return r.pipe(n.findLast(t,t=>g(e,t.prev,a)&&g(i,t.next,a)),o.match({onNone:()=>`any`,onSome:e=>e.blankLine}))}let ne=a.type().pipe(a.when({parent:a.null},r.constant(p.void)),a.not({parent:{type:a.is(`BlockStatement`,`Program`,`StaticBlock`,`SwitchCase`,`SwitchStatement`,`TSInterfaceBody`,`TSModuleBlock`,`TSTypeLiteral`)}},r.constant(p.void)),a.orElse(e=>p.gen(function*(){let t=yield*m.get(d);if(o.isNone(t))return yield*p.die(/* @__PURE__ */ Error(`Padding rule invariant: statement scope is missing`));if(o.isSome(t.value.prevNode)){let n=t.value.prevNode.value;yield*m.update(u,t=>(t.push({prevNode:n,nextNode:e}),t))}yield*m.set(d,o.some({upper:t.value.upper,prevNode:o.some(e)}))})));function _(e){return p.andThen(ne(e),f())}let re={Program:f,"Program:exit":p.fn(`'Program:exit'`)(function*(){let e=yield*m.get(l);yield*m.get(u).pipe(p.flatMap(t=>p.all(n.map(t,({prevNode:t,nextNode:n})=>Ki(t,n,te(t,n,e)))))),yield*h()}),BlockStatement:f,"BlockStatement:exit":h,SwitchStatement:f,"SwitchStatement:exit":h,SwitchCase:_,"SwitchCase:exit":h,StaticBlock:f,"StaticBlock:exit":h,TSInterfaceBody:f,"TSInterfaceBody:exit":h,TSModuleBlock:f,"TSModuleBlock:exit":h,TSTypeLiteral:f,"TSTypeLiteral:exit":h,TSDeclareFunction:_,"TSDeclareFunction:exit":h,TSMethodSignature:_,"TSMethodSignature:exit":h,":statement":ne};return ee.merge(re,...n.map(c,e=>ee.on(e,t=>m.update(l,n=>(n.get(e)?.add(t),n)))))}const Ji={"alchemy-no-cloudflare-init-finalizer":we,"alchemy-no-deprecated-docker-constraints":De,"alchemy-no-deprecated-resource":ke,"alchemy-no-plaintext-github-secret":je,"alchemy-no-removed-config-api":Me,"alchemy-no-reserved-eventbridge-default-name":Ne,"alchemy-no-runtime-config":Pe,"alchemy-no-v1-import":Ie,"alchemy-no-v1-worker-properties":Re,"avoid-data-tagged-error":ze,"ban-error-string":Ue,"consistent-schema-pipe":bt,"cors-credentials-with-wildcard":Mt,"dual-numeric-arity-with-optional-parameter":Pt,"effect-promise-vs-trypromise":Ft,"no-already-started-promise":Lt,"no-async-effect-try":Rt,"no-discarded-run-promise":zt,"no-discarded-schema-checks":Ht,"no-empty-effect-callback":tn,"no-empty-schema-struct":nn,"no-effect-alchemy-barrel-imports":en,"no-function-config-default":on,"no-hash-as-identity":ln,"no-inline-schema-compile":En,"no-logging-in-catch":An,"no-manual-effect-error-tag":In,"no-manual-tag-comparison":Ln,"no-manual-tagged-construction":Rn,"no-multi-shot-effect-callback":Vn,"no-non-json-schema-annotation":Jn,"no-option-of-service":Yn,"no-overwritten-discriminant":Xn,"no-service-option-get-or-throw":er,"no-service-constructor-imports":$n,"no-throw-in-effect-callback":nr,"no-uppercase-http-api-header":sr,"no-zero-retry-times":cr,"padding-line-between-statements":d.define({name:`padding-line-between-statements`,meta:{type:`layout`,docs:{description:`Require or disallow padding lines between statements`,url:`https://eslint.style/rules/padding-line-between-statements`,recommended:!0},fixable:`whitespace`,schema:{type:`array`,items:{type:`object`,properties:{blankLine:{enum:[`any`,`never`,`always`]},prev:{$ref:`#/$defs/statementOption`},next:{$ref:`#/$defs/statementOption`}},required:[`blankLine`,`prev`,`next`],additionalProperties:!1},$defs:{statementMatcher:{anyOf:[{type:`string`,enum:i.keys(Li)},{type:`object`,properties:{selector:{type:`string`},lineMode:{enum:[`any`,`singleline`,`multiline`]}},required:[`selector`],additionalProperties:!1}]},statementOption:{anyOf:[{$ref:`#/$defs/statementMatcher`},{type:`array`,items:{$ref:`#/$defs/statementMatcher`},minItems:1,uniqueItems:!0}]}}},messages:{unexpectedBlankLine:`Unexpected blank line before this statement.`,expectedBlankLine:`Expected blank line before this statement.`}},*create(){let e=yield*f;return yield*qi(e,Wi(e.options))}}),"prefer-effect-alchemy-namespace-imports":lr,"prefer-effect-array-sort":ur,"prefer-effect-datetime":fr,"prefer-effect-duration":Er,"prefer-effect-duration-constants":zr,"prefer-effect-encoding":Hr,"prefer-effect-filesystem":Wr,"prefer-effect-filter":qr,"prefer-effect-headers":Jr,"prefer-effect-match":Zr,"prefer-effect-path":$r,"prefer-effect-url":ti,"prefer-uninterruptible":ri,"prefer-with-span":ii,"prefer-yield-now":oi,"preserve-caught-error":li,"require-schema-class-brand":ui,"require-try-promise-abort-signal":fi,"throw-in-effect-gen":gi},Yi=/* @__PURE__ */ new Set([`prefer-effect-filesystem`,`prefer-effect-path`]),Xi=i.fromEntries(r.pipe(i.keys(Ji),n.filter(e=>!Yi.has(e)),n.map(e=>[`2digits/${e}`,`error`]))),Zi=t({meta:{name:`@2digits/oxlint-plugin`},rules:Ji});export{Zi as default,Xi as recommendedRules,Ji as rules};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@2digits/oxlint-plugin",
3
- "version": "0.2.0",
3
+ "version": "0.3.1",
4
4
  "description": "Custom Oxlint rules for 2digits projects.",
5
5
  "keywords": [
6
6
  "2digits",
@@ -33,8 +33,9 @@
33
33
  "effect-oxlint": "0.4.0"
34
34
  },
35
35
  "devDependencies": {
36
- "@2digits/tsconfig": "1.0.0",
36
+ "@2digits/tsconfig": "1.0.1",
37
37
  "@arethetypeswrong/core": "0.18.5",
38
+ "@effect/platform-node": "4.0.5",
38
39
  "@effect/vitest": "4.0.5",
39
40
  "dedent": "1.7.2",
40
41
  "oxlint": "1.88.0",