@2digits/oxlint-plugin 0.1.4 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE +8 -1
- package/README.md +39 -1
- package/dist/index.d.mts +3 -0
- package/dist/index.mjs +3 -3
- package/package.json +8 -8
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.
|
|
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).
|
|
@@ -68,6 +74,38 @@ not seven defects or a runtime outage.
|
|
|
68
74
|
Use `@effect/vitest` for tests exercising Effect code. Run effects with `it.effect` (or `it.live` when live runtime
|
|
69
75
|
services are required), not manual `Effect.run*` calls. RuleTester and synchronous CLI tests use regular `it`.
|
|
70
76
|
|
|
77
|
+
### Duration constants
|
|
78
|
+
|
|
79
|
+
`prefer-effect-duration` wraps number literals and literal arithmetic passed as `Duration.Input` to Effect v4 APIs
|
|
80
|
+
(`Effect.sleep`, `Effect.timeout`, `Schedule.spaced`, `Schedule.exponential`, `Stream.debounce`, `TestClock.adjust`, the
|
|
81
|
+
`duration` option of `Effect.timeoutOrElse`, and others) with `Duration.millis`.
|
|
82
|
+
|
|
83
|
+
`prefer-effect-duration-constants` reports `const` declarations that hold a duration as a plain number, in files that
|
|
84
|
+
import Effect:
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
import * as Effect from 'effect/Effect';
|
|
88
|
+
|
|
89
|
+
const TIMEOUT_MS = 30_000; // Declare it as Duration.seconds(30)
|
|
90
|
+
const CACHE_TTL_SECONDS = 3600; // Declare it as Duration.hours(1)
|
|
91
|
+
const ONE_DAY = 24 * 60 * 60 * 1000; // Declare it as Duration.days(1)
|
|
92
|
+
const wait = 250; // Declare it as Duration.millis(250)
|
|
93
|
+
|
|
94
|
+
Effect.sleep(wait);
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
A constant is reported when its name ends in a plural or abbreviated unit (`_MS`, `Seconds`, `_MINS`, `_DAYS`) or a
|
|
98
|
+
duration word (`TIMEOUT`, `DELAY`, `INTERVAL`, `TTL`, `ONE_DAY`, `maxAge`, `expiresIn`), when it is hand-written time
|
|
99
|
+
arithmetic, or when it is passed to an Effect duration API. Only the last word of the name counts, so
|
|
100
|
+
`RETRY_DELAY_FACTOR` is not a duration. Names containing `per`, `at`, `epoch`, or `timestamp` (`MS_PER_SECOND`,
|
|
101
|
+
`REQUESTS_PER_SECOND`, `CREATED_AT_MS`), zero or negative sentinels, and constants annotated with a `Duration` type are
|
|
102
|
+
skipped unless they are passed to a duration API. The suggested constructor uses the unit from the name; Effect's millisecond
|
|
103
|
+
interpretation applies only to constants passed to duration APIs. Without a known unit, the message stays generic.
|
|
104
|
+
|
|
105
|
+
There is **no autofix**: the constant changes from `number` to `Duration`. Convert at non-Effect boundaries with
|
|
106
|
+
`Duration.toMillis` or `Duration.toSeconds`, read configurable durations with `Config.Duration`, and use
|
|
107
|
+
`Schema.DurationFromMillis` for schema fields.
|
|
108
|
+
|
|
71
109
|
### Function-valued Config defaults
|
|
72
110
|
|
|
73
111
|
`no-function-config-default` reports inline zero-parameter functions passed to Effect's eager `Config.withDefault` API,
|
|
@@ -141,7 +179,7 @@ The exported `PaddingLineOption` type describes each configuration entry. No opt
|
|
|
141
179
|
|
|
142
180
|
### Other fixes
|
|
143
181
|
|
|
144
|
-
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`,
|
|
145
183
|
`no-effect-alchemy-barrel-imports`, `prefer-effect-alchemy-namespace-imports`,
|
|
146
184
|
`alchemy-no-v1-worker-properties`, and `alchemy-no-deprecated-docker-constraints`.
|
|
147
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;
|
|
@@ -43,6 +45,7 @@ export declare const rules: {
|
|
|
43
45
|
readonly 'prefer-effect-array-sort': import("effect-oxlint").OxlintRule;
|
|
44
46
|
readonly 'prefer-effect-datetime': import("effect-oxlint").OxlintRule;
|
|
45
47
|
readonly 'prefer-effect-duration': import("effect-oxlint").OxlintRule;
|
|
48
|
+
readonly 'prefer-effect-duration-constants': import("effect-oxlint").OxlintRule;
|
|
46
49
|
readonly 'prefer-effect-encoding': import("effect-oxlint").OxlintRule;
|
|
47
50
|
readonly 'prefer-effect-filesystem': import("effect-oxlint").OxlintRule;
|
|
48
51
|
readonly 'prefer-effect-filter': import("effect-oxlint").OxlintRule;
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{defineRule as e,eslintCompatPlugin as t}from"@oxlint/plugins";import{Rule as n,RuleContext as r,Visitor as i}from"effect-oxlint";import*as a from"effect/Array";import*as o from"effect/Effect";import*as s from"effect/Function";import*as c from"effect/Match";import*as l from"effect/Option";import*as u from"effect/Ref";const d={bindings:/* @__PURE__ */ new Map,hasEffectImport:!1};function f(e){return e.imported.type===`Identifier`?e.imported.name:typeof e.imported.value==`string`?e.imported.value:void 0}function p(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 m(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=p(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=f(e);n!==void 0&&t.set(e.local.name,[...i,n])}}return{bindings:t,hasEffectImport:n}}function h(t,n){return e({meta:t,createOnce:n})}function g(t,n){return e({meta:t,createOnce(e){let t=d,{before:r,Program:i,...a}=n(e,()=>t);return{before(){t=d,r?.()},Program(e){t=m(e),i?.(e)},...a}}})}function _(e,t,n,r){return{type:e,docs:{description:t,recommended:!0,...r===void 0?{}:{url:r}},schema:[],messages:n}}function v(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 y(e){let t=[],n=e;for(;n.type===`ChainExpression`||n.type===`MemberExpression`;){if(n.type===`ChainExpression`){n=n.expression;continue}let e=v(n);if(e===void 0)return;t.unshift(e),n=n.object}return n.type===`Identifier`?[n.name,...t]:void 0}function b(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 x(e,t){let n=y(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 S(e,t,n,r){let i=x(e,t);return i?.length===2&&i[0]===n&&i[1]===r}function C(e,t,n){let r=x(e,t);return r?.length===n.length&&r.every((e,t)=>e===n[t])}function w(e){return e?.type===`ArrowFunctionExpression`||e?.type===`FunctionExpression`}function T(e,t){let n=e.arguments[t];return n===void 0||n.type===`SpreadElement`?void 0:n}function E(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 D(e,t){for(let n of e.properties)if(n.type===`Property`&&E(n)===t)return n}function ee(e){return[`ParenthesizedExpression`,`TSAsExpression`,`TSNonNullExpression`,`TSSatisfiesExpression`,`TSTypeAssertion`].includes(e.type)}function O(e){let t=e;for(;ee(t);)t=t.expression;return t}function te(e,t){if(Array.isArray(e)){for(let n of e)t.push(n);return}for(let[n,r]of Object.entries(e))[`loc`,`parent`,`range`].includes(n)||t.push(r)}function k(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;te(e,n)}}return!1}function A(e,t){return k(e,e=>e.type===`Identifier`&&e.name===t)}function j(e){let t=e.params[0];return t?.type===`Identifier`?t:void 0}function M(e){let t=j(e);return t===void 0||!e.body||t.name.startsWith(`_`)?!1:A(e.body,t.name)}function ne(e){let t=e.parent;for(;t;){if(w(t))return t;t=t.parent}}function N(e){let t=e.parent;if(t.type===`CallExpression`&&t.arguments.includes(e))return t}function P(e,t){return e.type===`Literal`&&e.value===t}function re(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 F(e){return y(e.callee)?.at(-1)?.endsWith(`Error`)===!0}const ie=/* @__PURE__ */ new Set([`alarm`,`fetch`,`queue`,`rpc`,`scheduled`,`tail`,`trace`,`webSocketClose`,`webSocketError`,`webSocketMessage`]);function ae(e,t){return C(e,t,[`Cloudflare`,`Worker`])||C(e,t,[`Cloudflare`,`Workers`,`Worker`])}function oe(e,t){let n=e.parent;for(;n;){if(n.type===`CallExpression`&&ae(n.callee,t))return n;n=n.parent}}function se(e,t){let n=ne(e),r=n===void 0?void 0:N(n);return r!==void 0&&S(r.callee,t,`Effect`,`gen`)?r:void 0}function ce(e){let t=e.parent;for(;t;){if(w(t))return;if(t.type===`Property`){let e=E(t);if(e!==void 0&&ie.has(e))return e}t=t.parent}}const le=g(_(`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(!S(n.callee,r,`Effect`,`addFinalizer`))return;let i=se(n,r);i!==void 0&&oe(i,r)?.arguments.includes(i)&&e.report({node:n,messageId:`finalizer`})}}));function ue(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 I(e,t){let n=y(t)?.[0];return(n===void 0?void 0:ue(e,t,n))?.defs.some(e=>{let t=e.node;return e.type===`ImportBinding`&&t.parent?.type===`ImportDeclaration`&&t.parent.importKind!==`type`&&(t.type!==`ImportSpecifier`||t.importKind!==`type`)})===!0}function de(e,t,n,r,i){let a=e.sourceCode.ast;for(let r of a.body)if(r.type===`ImportDeclaration`&&r.source.value===n&&r.importKind!==`type`){for(let n of r.specifiers)if(n.type===`ImportNamespaceSpecifier`&&ue(e,t,n.local.name)?.defs.some(e=>e.node===n))return{name:n.local.name,fixes:[]}}let o=new Set(e.sourceCode.scopeManager.scopes.flatMap(e=>[...e.variables.map(e=>e.name),...e.references.map(e=>e.identifier.name)])),s=r,c=2;for(;o.has(s);)s=`${r}${c++}`;let l=`import * as ${s} from '${n}';\n`,u=a.body.find(e=>e.type!==`ExpressionStatement`||e.expression.type!==`Literal`||typeof e.expression.value!=`string`);return{name:s,fixes:[u===void 0?i.insertTextAfter(a,`\n${l}`):i.insertTextBefore(u,l)]}}function fe(e,t){let n=/* @__PURE__ */ new Set;return e.properties.every(e=>{if(e.type!==`Property`||e.computed||e.method||e.kind!==`init`||e.key.type!==`Identifier`&&e.key.type!==`Literal`)return!1;let r=e.key.type===`Identifier`?e.key.name:String(e.key.value);return r===t||n.has(r)?!1:(n.add(r),!0)})}const pe=g({..._(`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(!S(n.callee,t(),`Docker`,`Service`))return;let r=T(n,1),i=r?.type===`ObjectExpression`?D(r,`constraints`):void 0;i!==void 0&&e.report({node:i,messageId:`constraints`,fix(t){if(I(e,n.callee)&&r?.type===`ObjectExpression`&&fe(r,`placement`))return t.replaceText(i,`placement: { ${e.sourceCode.getText(i)} }`)}})}})),me=/* @__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`]]),he=g(_(`problem`,`Disallow deprecated Alchemy resource APIs that have supported replacements.`,{deprecated:`{{api}} is deprecated. Use {{replacement}}.`},`https://alchemy.run/llms-full.txt`),(e,t)=>({CallExpression(n){let r=x(n.callee,t());if(r===void 0)return;let i=r.join(`.`),a=me.get(i);a!==void 0&&e.report({node:n.callee,messageId:`deprecated`,data:{api:i,replacement:a}})}}));function ge(e,t){let n=O(e);if(n.type===`Literal`&&typeof n.value==`string`||n.type===`TemplateLiteral`)return!0;let r=y(n);return r?.[0]===`process`&&r[1]===`env`||n.type===`CallExpression`&&S(n.callee,t,`Config`,`string`)}const _e=g(_(`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(!S(n.callee,r,`GitHub`,`Secret`))return;let i=T(n,1),a=i?.type===`ObjectExpression`?D(i,`value`):void 0;a!==void 0&&ge(a.value,r)&&e.report({node:a.value,messageId:`plaintext`})}})),ve=g(_(`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=x(n.callee,t());r?.[0]===`Alchemy`&&(r[1]===`Secret`||r[1]===`Variable`)&&e.report({node:n.callee,messageId:`removed`,data:{api:r[1]}})}})),ye=g(_(`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(!C(n.callee,t(),[`AWS`,`EventBridge`,`EventBus`]))return;let r=T(n,1),i=r?.type===`ObjectExpression`?D(r,`name`):void 0;i!==void 0&&P(i.value,`default`)&&e.report({node:i.value,messageId:`reserved`})}})),be=g(_(`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`||x(i.callee,r)?.[0]!==`Config`)return;let a=se(n,r),o=a===void 0?void 0:ce(a);a!==void 0&&o!==void 0&&oe(a,r)!==void 0&&e.report({node:i,messageId:`runtime`,data:{handler:o}})}})),xe=h(_(`problem`,`Disallow Alchemy v1 imports that bypass the Effect-based Stack API.`,{defaultImport:`The default alchemy() API is from v1. Use import * as Alchemy and Alchemy.Stack.`,providerImport:`Use the v2 provider entrypoint {{replacement}} (capitalization is significant).`},`https://alchemy.run/migrating-from-v1`),e=>({ImportDeclaration(t){let n=t.source.value;if(n===`alchemy`){let n=t.specifiers.find(e=>e.type===`ImportDefaultSpecifier`);n!==void 0&&e.report({node:n,messageId:`defaultImport`});return}let r=/^alchemy\/(aws|cloudflare)$/.exec(n)?.[1];if(r===void 0)return;let i=`alchemy/${r===`aws`?`AWS`:`Cloudflare`}`;e.report({node:t.source,messageId:`providerImport`,data:{replacement:i}})}})),Se=g({..._(`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(!ae(n.callee,t()))return;let r=T(n,1);if(r?.type===`ObjectExpression`)for(let[t,i]of[[`entrypoint`,`main`],[`bindings`,`env`]]){let a=D(r,t);a!==void 0&&e.report({node:a,messageId:`property`,data:{old:t,replacement:i},fix(o){if(I(e,n.callee)&&fe(r,i))return o.replaceText(a.key,a.shorthand?`${i}: ${t}`:i)}})}}})),Ce=g(_(`suggestion`,`Prefer schema-based tagged errors so errors have a serializable contract.`,{taggedError:`Prefer Schema.TaggedErrorClass over Data.TaggedError.`}),(e,t)=>({CallExpression(n){S(n.callee,t(),`Data`,`TaggedError`)&&e.report({node:n.callee,messageId:`taggedError`})}})),we=/* @__PURE__ */ new Set([`error`,`err`,`e`,`cause`,`exception`,`ex`]);function L(e){return e?.type===`Identifier`&&we.has(e.name)?e.name:void 0}function Te(e){if(e.type!==`CallExpression`||e.arguments.length!==1)return!1;let t=y(e.callee);return t?.at(-1)===`String`&&t.length<=2}const Ee=h({..._(`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=T(t,0);if(n===void 0||!Te(n)||!F(t))return;let r=T(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(Te(t)){if(t.parent.type===`NewExpression`&&t.parent.arguments[0]===t&&F(t.parent))return;let n=L(t.arguments[0]);n!==void 0&&e.report({node:t,messageId:`errorString`,data:{name:n}});return}if(t.callee.type!==`MemberExpression`||y(t.callee)?.at(-1)!==`toString`||t.arguments.length>0)return;let n=L(t.callee.object);n!==void 0&&e.report({node:t,messageId:`errorString`,data:{name:n}})},TemplateLiteral(t){let[n,r]=t.quasis,i=L(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 R(e){for(let t of e.arguments)if(t.type===`ObjectExpression`)return t}function De(e,t){let n=e.parent;if(n.type!==`Property`||E(n)!==t)return;let r=n.parent,i=r.parent;return r.type===`ObjectExpression`&&i?.type===`CallExpression`?i:void 0}function Oe(e,t){let n=N(e);return n===void 0?void 0:x(n.callee,t)}function ke(e){let t=O(e);if(t.type===`NewExpression`)return y(t.callee)?.join(`.`)===`Promise`;if(t.type!==`CallExpression`)return!1;let n=y(t.callee);return n?.join(`.`)===`fetch`||n?.[0]===`Promise`&&n[1]!==`withResolvers`||[`catch`,`finally`,`then`].includes(n?.at(-1)??``)||w(t.callee)&&t.callee.async}function z(e){if(e.body){if(e.body.type!==`BlockStatement`)return O(e.body);if(e.body.body.length===1&&e.body.body[0]?.type===`ReturnStatement`&&e.body.body[0].argument)return O(e.body.body[0].argument)}}function Ae(e){let t=O(e);return P(t,`*`)?!0:t.type===`ArrayExpression`&&(t.elements.length===0||t.elements.some(e=>!e||e.type===`SpreadElement`?!1:P(e,`*`)))}const je=g(_(`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(!S(n.callee,r,`HttpMiddleware`,`cors`)&&!S(n.callee,r,`HttpRouter`,`cors`)&&!S(n.callee,r,`HttpApiBuilder`,`middlewareCors`))return;let i=R(n);if(i===void 0||!P(D(i,`credentials`)?.value??i,!0))return;let a=D(i,`allowedOrigins`);(a===void 0||Ae(a.value))&&e.report({node:n,messageId:`wildcard`})}}));function Me(e){return e.type===`AssignmentPattern`||e.type===`RestElement`||e.optional===!0}const Ne=g(_(`problem`,`Disallow numeric dual arity with optional or rest parameters because dispatch becomes ambiguous.`,{unsafeArity:`Function.dual with numeric arity misdispatches an implementation with optional/default/rest parameters. Use predicate dispatch.`},`https://github.com/Effect-TS/tsgo/issues/401`),(e,t)=>({CallExpression(n){let r=T(n,0),i=T(n,1);i!==void 0&&S(n.callee,t(),`Function`,`dual`)&&r?.type===`Literal`&&typeof r.value==`number`&&w(i)&&i.params.some(e=>Me(e))&&e.report({node:r,messageId:`unsafeArity`})}})),Pe=g(_(`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){S(n.callee,t(),`Effect`,`promise`)&&e.report({node:n.callee,messageId:`tryPromise`})}}));function Fe(e,t){if(!S(e.callee,t,`Effect`,`promise`)&&!S(e.callee,t,`Effect`,`tryPromise`))return;let n=T(e,0);if(n!==void 0&&w(n))return n;if(n?.type===`ObjectExpression`){let e=D(n,`try`);if(e!==void 0&&w(e.value))return e.value}}const Ie=g(_(`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&&ke(e.init)&&n.add(e.id.name)},CallExpression(r){let i=Fe(r,t()),a=i===void 0?void 0:z(i);a?.type===`Identifier`&&n.has(a.name)&&e.report({node:a,messageId:`prestarted`})}}}),Le=g(_(`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(!S(n.callee,t(),`Effect`,`try`))return;let r=T(n,0),i=r!==void 0&&w(r)?r:void 0;if(i===void 0&&r?.type===`ObjectExpression`){let e=D(r,`try`)?.value;e!==void 0&&w(e)&&(i=e)}let a=i===void 0?void 0:z(i);i!==void 0&&(i.async||a!==void 0&&ke(a))&&e.report({node:i,messageId:`asyncTry`})}})),Re=g(_(`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=S(n.callee,r,`Effect`,`runPromise`),a=n.callee.type===`CallExpression`&&S(n.callee.callee,r,`Effect`,`runPromiseWith`);(i||a)&&re(n)&&e.report({node:n,messageId:`discarded`})}}));function ze(e,t){let n=O(e);if(n.type===`CallExpression`&&n.callee.type===`MemberExpression`&&v(n.callee)===t)return n}const Be=g(_(`problem`,`Disallow schema mapping that silently drops checks attached to the receiver.`,{discarded:`{{method}} creates a new schema and drops the preceding check. Re-attach the check after mapping or explicitly preserve it.`},`https://github.com/Effect-TS/tsgo/issues/435`),(e,t)=>({CallExpression(n){if(!t().hasEffectImport||n.callee.type!==`MemberExpression`)return;let r=v(n.callee);if(r===void 0||![`mapElements`,`mapFields`,`mapMembers`].includes(r)||ze(n.callee.object,`check`)===void 0)return;let i=n.arguments.find(e=>e.type===`ObjectExpression`),a=i?.type===`ObjectExpression`?D(i,`unsafePreserveChecks`):void 0;a!==void 0&&P(a.value,!0)||e.report({node:n,messageId:`discarded`,data:{method:r}})}})),Ve={Array:`Arr`,Boolean:`Bool`,Equal:`Eq`,Function:`Fn`,Number:`Num`,Option:`Opt`,Predicate:`P`,Record:`R`,String:`Str`};function He(e){return e===`@effect/vitest`||e.startsWith(`@effect/vitest/`)}function B(e,t){return e.importKind===`type`||t?.importKind===`type`}function V(e){return Ve[e]??e}function Ue(e,t){if(e===`effect`||e===`alchemy`||/^@effect\/[^/]+$/u.test(e)&&!He(e))return`${e}/${t}`}function We(e){if(He(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 Ge(e,t,n){if(e.sourceCode.getCommentsInside(t).length>0||t.attributes.length>0)return;let r=[],i=[];for(let n of t.specifiers){if(n.type!==`ImportSpecifier`)return;let a=n.imported.type===`Identifier`?n.imported.name:n.imported.value,o=/^\p{Lu}/u.test(a)&&!B(t,n)?Ue(t.source.value,a):void 0;o===void 0?r.push(e.sourceCode.getText(n)):i.push(`import * as ${n.local.name} from '${o}';`)}return r.length>0&&i.unshift(`import { ${r.join(`, `)} } from ${e.sourceCode.getText(t.source)};`),[n.replaceText(t,i.join(`
|
|
2
|
-
`))]}function Ke(e,t,n){let r=We(t.source.value);if(r===void 0||t.attributes.length>0||e.sourceCode.getCommentsInside(t).length>0)return;let i=V(r),a=e.sourceCode.getDeclaredVariables(t),o=a.find(e=>e.name===i);if(e.sourceCode.scopeManager.scopes.some(e=>e.variables.some(e=>e.name===i&&e!==o)||e.references.some(e=>e.identifier.name===i&&e.resolved!==o)))return;let s=[],c=[];for(let r of t.specifiers){if(r.type===`ImportDefaultSpecifier`)return;if(r.type===`ImportSpecifier`&&B(t,r)){if(r.local.name===i)return;c.push(e.sourceCode.getText(r));continue}let o=qe(r,a,i,n);if(o===void 0)return;s.push(...o)}let l=e.sourceCode.getText(t.source),u=`import * as ${i} from ${l};${c.length===0?``:`\nimport { ${c.join(`, `)} } from ${l};`}`;return[n.replaceText(t,u),...s]}function qe(e,t,n,r){let i=t.find(t=>t.name===e.local.name);if(i!==void 0){if(e.type===`ImportNamespaceSpecifier`)return Je(i,n,!1,r);if(e.imported.type===`Identifier`)return Je(i,`${n}.${e.imported.name}`,!0,r)}}function Je(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 Ye(e){return e?.imported.type===`Identifier`?e.imported.name:typeof e?.imported.value==`string`?e.imported.value:void 0}const Xe=h({..._(`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`||B(t,n))continue;let r=Ye(n),i=r===void 0||!/^\p{Lu}/u.test(r)?void 0:Ue(t.source.value,r);r!==void 0&&i!==void 0&&e.report({node:n,messageId:`barrelImport`,data:{alias:V(r),source:i},fix:n=>Ge(e,t,n)})}}})),Ze=g({..._(`suggestion`,`Prefer Effect.never to an empty Effect.callback registration.`,{emptyCallback:`An empty Effect.callback registration is Effect.never. Use the explicit primitive.`},`https://github.com/Effect-TS/tsgo/issues/636`),fixable:`code`},(e,t)=>({CallExpression(n){if(!S(n.callee,t(),`Effect`,`callback`)&&!S(n.callee,t(),`Effect`,`async`))return;let r=T(n,0);r!==void 0&&w(r)&&r.body?.type===`BlockStatement`&&r.body.body.length===0&&e.report({node:n,messageId:`emptyCallback`,fix(t){if(!I(e,n.callee)||n.arguments.length!==1||r.async||r.generator||r.params.some(e=>e.type!==`Identifier`)||e.sourceCode.getCommentsInside(n).length>0)return;let i=de(e,n,`effect/Effect`,`Effect`,t);return[...i.fixes,t.replaceText(n,`${i.name}.never`)]}})}})),Qe=g(_(`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=T(n,0);S(n.callee,t(),`Schema`,`Struct`)&&r?.type===`ObjectExpression`&&r.properties.length===0&&e.report({node:n,messageId:`emptyStruct`})}}));function $e(e,t){let n=O(e),r=/* @__PURE__ */ new Set;for(;n.type===`Identifier`;){let e=t.sourceCode.getScope(n);for(;e!==null&&!e.set.has(n.name);)e=e.upper;let i=e?.set.get(n.name),a=i?.defs.length===1?i.defs[0]:void 0,o=a?.node;if(i===void 0||r.has(i)||o?.type!==`VariableDeclarator`||o.id.type!==`Identifier`||a?.parent?.type!==`VariableDeclaration`||a.parent.kind!==`const`||!o.init||i.references.some(e=>e.isWrite()&&!e.init))return;r.add(i),n=O(o.init)}return n}function et(e){if(e.arguments.length===2)return T(e,0);let t=e.parent;if(e.arguments.length===1&&t.type===`CallExpression`&&t.arguments[0]===e&&t.callee.type===`MemberExpression`&&v(t.callee)===`pipe`)return t.callee.object}const tt=g(_(`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(!S(n.callee,t(),`Config`,`withDefault`)||!I(e,n.callee))return;let r=T(n,n.arguments.length-1),i=et(n),a=i===void 0?void 0:$e(i,e);a?.type===`CallExpression`&&S(a.callee,t(),`Config`,`succeed`)&&I(e,a.callee)&&w(T(a,0))||r!==void 0&&w(r)&&r.params.length===0&&e.report({node:r,messageId:`functionDefault`})}}));function nt(e,t){return e.type===`CallExpression`&&S(e.callee,t,`Hash`,`hash`)}const rt=g(_(`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 nt(e,t())||e.type===`Identifier`&&n.has(e.name)}return{before(){n=/* @__PURE__ */ new Set},VariableDeclarator(e){e.id.type===`Identifier`&&e.init&&nt(e.init,t())&&n.add(e.id.name)},CallExpression(t){if(t.callee.type!==`MemberExpression`||![`delete`,`get`,`has`,`set`].includes(y(t.callee)?.at(-1)??``))return;let n=T(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`})}}}),it=/* @__PURE__ */ new Set([`catch`,`catchAll`,`catchAllCause`,`catchIf`,`catchSome`,`catchSomeCause`,`catchTag`,`orElse`,`orElseFail`,`orElseSucceed`]),at=/* @__PURE__ */ new Set([`log`,`logDebug`,`logError`,`logInfo`,`logTrace`,`logWarning`]);function ot(e,t){let n=e.parent;for(;n;){if(w(n)){let e=N(n);if(e?.arguments.at(-1)===n){let n=x(e.callee,t),r=n?.[1];if(r!==void 0&&n?.[0]===`Effect`&&it.has(r))return{method:r}}}n=n.parent}}const st=g(_(`suggestion`,`Keep logging separate from Effect recovery handlers.`,{logging:`Move {{logger}} out of Effect.{{catchMethod}} and use Effect.tapError before recovery.`}),(e,t)=>({CallExpression(n){let r=t(),i=x(n.callee,r),a=i?.[1]!==void 0&&i[0]===`Effect`&&at.has(i[1])?i.join(`.`):void 0;if(a===void 0)return;let o=ot(n,r);o!==void 0&&e.report({node:n,messageId:`logging`,data:{logger:a,catchMethod:o.method}})}})),ct=/* @__PURE__ */ new Set([`==`,`===`,`!=`,`!==`]),lt=/* @__PURE__ */ new Set([`catch`,`catchAll`,`catchIf`]);function H(e){return e.type===`Literal`&&typeof e.value==`string`}function U(e){return e.type===`MemberExpression`&&v(e)===`_tag`}function ut(e){if(ct.has(e.operator)){if(U(e.left)&&H(e.right))return e.left;if(U(e.right)&&H(e.left))return e.right}}function W(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`&<.has(e.callee.property.name)}t=t.parent}return!1}function dt(e){return e.object.type===`MemberExpression`&&v(e.object)===`reason`}function ft(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 pt=h(_(`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=ut(t);n!==void 0&&W(t)&&e.report({node:t,messageId:dt(n)?`reason`:`tag`})},SwitchStatement(t){U(t.discriminant)&&W(t)&&e.report({node:t,messageId:dt(t.discriminant)?`reason`:`tag`})}})),mt=h(_(`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){ut(t)===void 0||W(t)||e.report({node:t,messageId:`manualComparison`})},SwitchStatement(t){U(t.discriminant)&&!W(t)&&e.report({node:t,messageId:`manualSwitch`})}})),ht=h(_(`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(ft(t))return;let n=t.properties.find(e=>e.type===`Property`&&E(e)===`_tag`&&H(e.value));n!==void 0&&e.report({node:n,messageId:`manualConstruction`})}}));function gt(e,t){let n=y(e.callee)?.at(-1);if(n===void 0||![`addEventListener`,`on`,`setInterval`].includes(n))return!1;if(n===`addEventListener`){let t=T(e,2);if(t?.type===`ObjectExpression`){let e=D(t,`once`);if(e!==void 0&&P(e.value,!0))return!1}}let r=T(e,n===`setInterval`?0:1);return r!==void 0&&A(r,t)}const _t=g(_(`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(!S(n.callee,t(),`Effect`,`callback`))return;let r=T(n,0);if(r===void 0||!w(r))return;let i=j(r)?.name,a=r.body;i!==void 0&&a&&k(a,e=>e.type===`CallExpression`&>(e,i))&&e.report({node:n,messageId:`multiShot`})}}));function vt(e){return e.type===`Literal`&&typeof e.value==`bigint`||e.type===`Identifier`&&[`NaN`,`Infinity`,`undefined`].includes(e.name)||w(e)||e.type===`CallExpression`&&y(e.callee)?.at(-1)===`Symbol`}function yt(e,t){if(e.type===`ArrayExpression`){for(let n of e.elements)n&&n.type!==`SpreadElement`&&t.push(n);return}if(e.type===`ObjectExpression`)for(let n of e.properties)n.type===`Property`&&t.push(n.value)}function bt(e){let t=[e];for(;t.length>0;){let e=t.pop();if(e===void 0)continue;let n=O(e);if(vt(n))return n;yt(n,t)}}const xt=g(_(`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=x(n.callee,r),a=n.callee.type===`MemberExpression`?v(n.callee):i?.[0]===`Schema`?i[1]:void 0;if(a===void 0||![`annotate`,`annotateEncoded`,`annotateKey`].includes(a))return;let o=R(n);if(o!==void 0&&D(o,`jsonSchema`)===void 0)for(let t of[`default`,`examples`]){let n=D(o,t);if(n===void 0)continue;let r=bt(n.value);r!==void 0&&e.report({node:r,messageId:`nonJson`})}}})),St=g(_(`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=S(n.callee,r,`Effect`,`option`)||S(n.callee,r,`Effect`,`either`),a=T(n,0);if(i&&a?.type===`CallExpression`&&S(a.callee,r,`Effect`,`service`)){e.report({node:n,messageId:`mandatory`});return}if(n.callee.type!==`MemberExpression`||y(n.callee)?.at(-1)!==`pipe`)return;let o=O(n.callee.object),s=T(n,0);s!==void 0&&o.type===`CallExpression`&&S(o.callee,r,`Effect`,`service`)&&(S(s,r,`Effect`,`option`)||S(s,r,`Effect`,`either`))&&e.report({node:n,messageId:`mandatory`})}})),Ct=g(_(`problem`,`Ensure a later object spread cannot overwrite an explicitly assigned _tag.`,{overwritten:`A later spread can overwrite _tag at runtime. Move _tag after all spreads.`},`https://github.com/Effect-TS/tsgo/issues/426`),e=>({ObjectExpression(t){let n=t.properties.findIndex(e=>e.type===`Property`&&E(e)===`_tag`);if(n===-1)return;let r=t.properties.slice(n+1).some(e=>e.type===`SpreadElement`),i=t.properties[n];r&&i?.type===`Property`&&e.report({node:i,messageId:`overwritten`})}})),wt=/^make[A-Z]/u,Tt=/\.(?:test|spec)\.[cm]?[jt]sx?$/u,Et=h(_(`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(!Tt.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;wt.test(t)&&e.report({node:n,messageId:`serviceConstructorImport`,data:{name:t}})}}})),Dt=g(_(`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(S(n.callee,r,`Option`,`getOrThrow`)||S(n.callee,r,`Option`,`getOrThrowWith`)){let t=T(n,0),i=t?.type===`YieldExpression`?t.argument:t;i?.type===`CallExpression`&&S(i.callee,r,`Effect`,`serviceOption`)&&e.report({node:n,messageId:`getOrThrow`});return}if(n.callee.type!==`MemberExpression`||y(n.callee)?.at(-1)!==`pipe`)return;let i=O(n.callee.object),a=T(n,0);if(i.type!==`CallExpression`||!S(i.callee,r,`Effect`,`serviceOption`)||a?.type!==`CallExpression`||!S(a.callee,r,`Effect`,`map`))return;let o=T(a,0);o!==void 0&&(S(o,r,`Option`,`getOrThrow`)||S(o,r,`Option`,`getOrThrowWith`))&&e.report({node:n,messageId:`getOrThrow`})}})),Ot=/* @__PURE__ */ new Set([`andThen`,`map`,`mapError`,`tap`,`tapError`,`tapErrorCause`]),kt=g(_(`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=ne(n);if(r===void 0)return;let i=t(),a=Oe(r,i),o=De(r,`catch`);(a?.[0]===`Effect`&&a[1]!==void 0&&Ot.has(a[1])||o!==void 0&&(S(o.callee,i,`Effect`,`try`)||S(o.callee,i,`Effect`,`tryPromise`)))&&e.report({node:n,messageId:`callbackThrow`})}})),At=/* @__PURE__ */ new Set([`get`,`post`,`put`,`patch`,`delete`,`head`,`options`]);function jt(e,t){let n=e.parent,r=e.node;if(e.type!==`ImportBinding`||n?.type!==`ImportDeclaration`||B(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 Mt(e,t){let n=y(e.callee),r=n?.[0],i=n?.at(-1);if(n===void 0||r===void 0||i===void 0||!At.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&&jt(t,n)}a=a.upper}return!1}function Nt(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=E(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 Pt=h(_(`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(t.arguments.some(e=>e.type===`SpreadElement`)||!Mt(t,e))return;let n=Nt(Nt(T(t,2))?.find(e=>E(e)===`headers`)?.value);if(n!==void 0)for(let t of n){let n=E(t);n!==void 0&&/[A-Z]/u.test(n)&&e.report({node:t.key,messageId:`uppercase`,data:{name:n}})}}})),Ft=g(_(`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(!S(n.callee,r,`Effect`,`retry`)&&!S(n.callee,r,`Effect`,`repeat`))return;let i=R(n);if(i===void 0)return;let a=D(i,`times`);a!==void 0&&P(a.value,0)&&e.report({node:a,messageId:`zeroTimes`})}})),It=h({..._(`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=We(t.source.value);if(n===void 0||t.importKind===`type`)return;let r=V(n);for(let n of t.specifiers)if(!(n.type===`ImportSpecifier`&&B(t,n))){if(n.type===`ImportNamespaceSpecifier`){n.local.name!==r&&e.report({node:n.local,messageId:`alias`,data:{alias:r,source:t.source.value},fix:n=>Ke(e,t,n)});continue}e.report({node:n,messageId:`namespace`,data:{alias:r,source:t.source.value},fix:n=>Ke(e,t,n)})}}})),Lt=g(_(`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`&&v(n.callee)===`sort`&&!S(n.callee,r,`Array`,`sort`)&&e.report({node:n,messageId:`effectArraySort`})}})),Rt=/* @__PURE__ */ new Set([`toISOString`,`toLocaleDateString`,`toLocaleTimeString`]),zt=g(_(`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`&&Rt.has(v(n.callee)??``)&&e.report({node:n,messageId:`effectDateTime`})}})),Bt=/* @__PURE__ */ new Set([`Effect.delay`,`Effect.sleep`,`Effect.timeout`,`Effect.timeoutOption`,`Effect.timeoutOrElse`,`Schedule.fixed`,`Schedule.spaced`,`Schedule.windowed`]),Vt=g({..._(`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=x(n.callee,t());if(r===void 0||!Bt.has(r.join(`.`)))return;let i=T(n,n.arguments.length-1);i?.type===`Literal`&&typeof i.value==`number`&&e.report({node:i,messageId:`effectDuration`,fix(t){if(!I(e,n.callee))return;let r=de(e,n,`effect/Duration`,`Duration`,t);return[...r.fixes,t.replaceText(i,`${r.name}.millis(${e.sourceCode.getText(i)})`)]}})}})),Ht=/* @__PURE__ */ new Set([`base64`,`base64url`,`hex`]);function Ut(e){return e!==void 0&&[...Ht].some(t=>P(e,t))}const Wt=g(_(`suggestion`,`Prefer Effect Encoding for portable Base64, Base64Url, and hexadecimal encoding.`,{effectEncoding:`Use Encoding encode/decode helpers; decoders return Result instead of throwing.`},`https://www.effect.website/docs/v4/api/effect/Encoding`),(e,t)=>({CallExpression(n){if(!t().hasEffectImport)return;if((b(n.callee,e,`atob`)||b(n.callee,e,`btoa`))&&n.arguments.length>0){e.report({node:n,messageId:`effectEncoding`});return}let r=y(n.callee),i=r?.join(`.`)===`Buffer.from`&&Ut(T(n,1)),a=r?.at(-1)===`toString`&&Ut(T(n,0));(i||a)&&e.report({node:n,messageId:`effectEncoding`})}})),Gt=/* @__PURE__ */ new Set([`fs`,`fs/promises`,`node:fs`,`node:fs/promises`]),Kt=g(_(`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&&Gt.has(n.source.value)&&e.report({node:n.source,messageId:`effectFileSystem`,data:{source:n.source.value}})}}));function qt(e,t,n){return e.type===`CallExpression`&&S(e.callee,t,`Result`,n)?T(e,0):void 0}function Jt(e,t,n){let r=j(t),i=z(t);if(r===void 0||i?.type!==`ConditionalExpression`)return;let a=qt(i.consequent,n,`succeed`),o=qt(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 Yt=g(_(`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){Jt(e,n,t())},FunctionExpression(n){Jt(e,n,t())}})),Xt=g(_(`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&&b(n.callee,e,`Headers`)&&e.report({node:n,messageId:`effectHeaders`})}})),Zt=/* @__PURE__ */ new Set([`==`,`===`,`!=`,`!==`]);function Qt(e){return e.type===`Literal`||e.type===`TemplateLiteral`&&e.expressions.length===0}function $t(e,t){if(e.type===`BinaryExpression`&&Zt.has(e.operator)){if(Qt(e.left))return t.sourceCode.getText(e.right);if(Qt(e.right))return t.sourceCode.getText(e.left)}}const en=g(_(`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=$t(t.test,e);if(n===void 0)return;let r=t.alternate,i=1;for(;r.type===`ConditionalExpression`;){if($t(r.test,e)!==n)return;i+=1,r=r.alternate}i>1&&e.report({node:t,messageId:`preferMatch`})}})),tn=/* @__PURE__ */ new Set([`node:path`,`path`]),nn=g(_(`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&&tn.has(n.source.value)&&e.report({node:n.source,messageId:`effectPath`,data:{source:n.source.value}})}})),rn=g(_(`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&&b(n.callee,e,`URL`)&&e.report({node:n,messageId:`effectUrl`})},CallExpression(n){let r=y(n.callee);t().hasEffectImport&&r?.[0]===`URL`&&[`canParse`,`parse`].includes(r[1]??``)&&n.callee.type===`MemberExpression`&&b(n.callee.object,e,`URL`)&&e.report({node:n,messageId:`effectUrl`})}})),an=g(_(`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=S(n.callee,r,`Effect`,`uninterruptibleMask`)?`uninterruptible`:S(n.callee,r,`Effect`,`interruptibleMask`)?`interruptible`:void 0,a=T(n,0);i!==void 0&&a!==void 0&&w(a)&&!M(a)&&e.report({node:n,messageId:`unusedRestore`,data:{replacement:`Effect.${i}`}})}})),on=g(_(`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(!S(n.callee,t(),`Effect`,`useSpan`))return;let r=T(n,n.arguments.length-1);r!==void 0&&w(r)&&!M(r)&&e.report({node:n,messageId:`unusedSpan`})}}));function sn(e,t){let n=O(e);if(P(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(S(n,t,`Duration`,`zero`))return!0;if(n.type===`CallExpression`){let e=x(n.callee,t),r=T(n,0);return r!==void 0&&e?.[0]===`Duration`&&P(r,0)}return!1}const cn=g(_(`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=T(n,0);i!==void 0&&S(n.callee,r,`Effect`,`sleep`)&&sn(i,r)&&e.report({node:n,messageId:`zeroSleep`})}})),ln=/* @__PURE__ */ new Set([`catch`,`catchAll`,`mapError`]);function un(e,t){let n=Oe(e,t),r=De(e,`catch`);if(!(n?.[0]===`Effect`&&n[1]!==void 0&&ln.has(n[1])||r!==void 0&&(S(r.callee,t,`Effect`,`try`)||S(r.callee,t,`Effect`,`tryPromise`)))||!e.body)return!1;let i=j(e);return k(e.body,e=>e.type===`NewExpression`&&F(e)&&(i===void 0||!A(e,i.name)))}const dn=g(_(`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){un(n,t())&&e.report({node:n,messageId:`droppedCause`})},FunctionExpression(n){un(n,t())&&e.report({node:n,messageId:`droppedCause`})}})),fn=g(_(`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){S(n.callee,t(),`Schema`,`Class`)&&(n.typeArguments?.params.length??0)<2&&e.report({node:n,messageId:`missingBrand`})}}));function pn(e,t){if(!S(e.callee,t,`Effect`,`tryPromise`))return;let n=T(e,0);if(n!==void 0&&w(n))return n;if(n?.type===`ObjectExpression`){let e=D(n,`try`);if(e!==void 0&&w(e.value))return e.value}}const mn=g(_(`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=pn(n,t());if(r===void 0)return;let i=j(r);i===void 0?e.report({node:r,messageId:`missingSignal`}):!i.name.startsWith(`_`)&&!M(r)&&e.report({node:i,messageId:`unusedSignal`})}}));function hn(e,t){let n=e.parent;if(n.type===`CallExpression`&&T(n,0)===e)return S(n.callee,t,`Effect`,`try`)||S(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`&&(S(r.parent.callee,t,`Effect`,`try`)||S(r.parent.callee,t,`Effect`,`tryPromise`))}const gn=g(_(`problem`,`Disallow throw in Effect generator APIs because it creates an untyped defect.`,{throwInGen:`Use yield* Effect.fail(...) instead of throw so the failure stays in the typed error channel.`}),(e,t)=>({ThrowStatement(n){let r=t(),i=n.parent;for(;i&&!w(i);)i=i.parent??void 0;if(i===void 0||hn(i,r))return;let a=N(i),o=a!==void 0&&[`fn`,`fnUntraced`,`gen`].some(e=>S(a.callee,r,`Effect`,e)),s=a?.callee,c=s?.type===`CallExpression`&&[`fn`,`fnUntraced`].some(e=>S(s.callee,r,`Effect`,e));(o||c)&&e.report({node:n,messageId:`throwInGen`})}})),_n=String.raw`(?:\r\n|\r(?!\n)|[\n\u2028\u2029])`,G=String.raw`[^\S\r\n\u2028\u2029]*`,vn=RegExp(`^(${G}${_n})(?:${G}${_n})+(${G};?)$`,`u`),yn=/^(?:module\s*\.\s*)?exports(?:\s*\.|\s*\[|$)/u;function bn(e){return e.type===`Punctuator`&&e.value===`;`}function K(e,t){return e.loc.end.line===t.loc.start.line}function q(e){return e.loc.start.line===e.loc.end.line}function xn(e){return[`FunctionDeclaration`,`FunctionExpression`,`ArrowFunctionExpression`].includes(e.type)}function Sn(e){return e.type===`ChainExpression`?e.expression:e}function J(e,t){return(n,r)=>r.getFirstToken(n)?.value===t&&(a.isArray(e)?e.includes(n.type):e===n.type)}function Y(e){return t=>t.type===e}function X(e,t){return(n,r)=>e(n,r)&&q(n)===(t===`singleline`)}function Cn(e){if(e.type!==`ExpressionStatement`)return!1;let t=Sn(e.expression);if(t.type===`UnaryExpression`&&(t=Sn(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 xn(n)}function wn(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 Tn(e,t){if(e.type===`DoWhileStatement`&&e.body.type===`BlockStatement`||Cn(e))return!0;let n=t.getLastToken(e,e=>!bn(e)),r=n?.type===`Punctuator`&&n.value===`}`?t.getNodeByRangeIndex(n.range[0]):null;return r?.type===`BlockStatement`||r?.type===`SwitchStatement`}function En(e,t){return e.type===`ExpressionStatement`&&(e.parent.type===`Program`||e.parent.type===`BlockStatement`&&xn(e.parent.parent))&&e.expression.type===`Literal`&&typeof e.expression.value==`string`&&(t.getTokenBefore(e.expression)?.value!==`(`||t.getTokenAfter(e.expression)?.value!==`)`)}function Dn(e,t){if(!En(e,t)||!e.parent||!(`body`in e.parent)||!Array.isArray(e.parent.body))return!1;for(let n of e.parent.body){if(n===e)break;if(!En(n,t))return!1}return!0}function On(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 kn(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]&&bn(n)&&!K(r,n)&&K(n,i)?r:n}function An(e,t){if(q(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 Z={"block-like":Tn,expression:(e,t)=>e.type===`ExpressionStatement`&&!Dn(e,t),return:J(`ReturnStatement`,`return`),export:J([`ExportAllDeclaration`,`ExportDefaultDeclaration`,`ExportNamedDeclaration`],`export`),var:J(`VariableDeclaration`,`var`),let:J(`VariableDeclaration`,`let`),const:J(`VariableDeclaration`,`const`),using:e=>e.type===`VariableDeclaration`&&(e.kind===`using`||e.kind===`await using`),type:J(`TSTypeAliasDeclaration`,`type`)},Q={"*":()=>!0,exports:On,require:wn,directive:Dn,iife:Cn,block:Y(`BlockStatement`),empty:Y(`EmptyStatement`),function:Y(`FunctionDeclaration`),"ts-method":Y(`TSMethodSignature`),break:J(`BreakStatement`,`break`),case:J(`SwitchCase`,`case`),class:J(`ClassDeclaration`,`class`),continue:J(`ContinueStatement`,`continue`),debugger:J(`DebuggerStatement`,`debugger`),default:J([`SwitchCase`,`ExportDefaultDeclaration`],`default`),do:J(`DoWhileStatement`,`do`),for:J([`ForStatement`,`ForInStatement`,`ForOfStatement`],`for`),if:J(`IfStatement`,`if`),import:J(`ImportDeclaration`,`import`),switch:J(`SwitchStatement`,`switch`),throw:J(`ThrowStatement`,`throw`),try:J(`TryStatement`,`try`),while:J([`WhileStatement`,`DoWhileStatement`],`while`),with:J(`WithStatement`,`with`),"cjs-export":(e,t)=>e.type===`ExpressionStatement`&&e.expression.type===`AssignmentExpression`&&yn.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:J(`TSEnumDeclaration`,`enum`),interface:J(`TSInterfaceDeclaration`,`interface`),"function-overload":Y(`TSDeclareFunction`),...Z,"singleline-block-like":X(Z[`block-like`],`singleline`),"multiline-block-like":X(Z[`block-like`],`multiline`),"singleline-expression":X(Z.expression,`singleline`),"multiline-expression":X(Z.expression,`multiline`),"singleline-return":X(Z.return,`singleline`),"multiline-return":X(Z.return,`multiline`),"singleline-export":X(Z.export,`singleline`),"multiline-export":X(Z.export,`multiline`),"singleline-var":X(Z.var,`singleline`),"multiline-var":X(Z.var,`multiline`),"singleline-let":X(Z.let,`singleline`),"multiline-let":X(Z.let,`multiline`),"singleline-const":X(Z.const,`singleline`),"multiline-const":X(Z.const,`multiline`),"singleline-using":X(Z.using,`singleline`),"multiline-using":X(Z.using,`multiline`),"singleline-type":X(Z.type,`singleline`),"multiline-type":X(Z.type,`multiline`)};function jn(e){return typeof e==`string`&&Object.hasOwn(Q,e)}function Mn(e){return Array.isArray(e)}function $(e){if(jn(e))return e;if(typeof e==`object`&&e&&`selector`in e&&typeof e.selector==`string`&&Object.keys(e).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 Nn(e){if(!Array.isArray(e))return $(e);let t=e,n=t[0];if(n===void 0)throw Error(`Padding statement matcher arrays must not be empty`);return[$(n),...t.slice(1).map(e=>$(e))]}function Pn(e){return e.map(e=>{if(typeof e!=`object`||!e||!(`blankLine`in e)||!(`prev`in e)||!(`next`in e)||Object.keys(e).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:Nn(e.prev),next:Nn(e.next)}})}function Fn(e,t,n){let r=[],i=kn(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 In(e,t,n){return o.gen(function*(){if(n===`any`)return yield*o.void;let i=yield*r,a=i.sourceCode,s=Fn(e,t,a);return n===`never`?s.length===0?yield*o.void:yield*i.report({node:t,messageId:`unexpectedBlankLine`,loc:An(t,a),fix(e){if(s.length>=2)return null;let t=s[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],a.text.slice(n,r).replace(vn,`$1$2`))}}):s.length>0?yield*o.void:yield*i.report({node:t,messageId:`expectedBlankLine`,loc:An(t,a),fix(n){let r=kn(e,a),i=a.getFirstTokenBetween(r,t,{includeComments:!0,filter(e){return!K(r,e)||(r=e,!1)}})??t;return n.insertTextAfter(r,K(r,i)?`
|
|
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 re(e){let t=N(e);return t===void 0||!e.body||t.name.startsWith(`_`)?!1:M(e.body,t.name)}function ie(e){let t=e.parent;for(;t;){if(E(t))return t;t=t.parent}}function P(e){let t=e.parent;if(t.type===`CallExpression`&&t.arguments.includes(e))return t}function F(e,t){return e.type===`Literal`&&e.value===t}function ae(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 oe(e){return x(e.callee)?.at(-1)?.endsWith(`Error`)===!0}const se=/* @__PURE__ */ new Set([`alarm`,`fetch`,`queue`,`rpc`,`scheduled`,`tail`,`trace`,`webSocketClose`,`webSocketError`,`webSocketMessage`]);function ce(e,t){return T(e,t,[`Cloudflare`,`Worker`])||T(e,t,[`Cloudflare`,`Workers`,`Worker`])}function le(e,t){let n=e.parent;for(;n;){if(n.type===`CallExpression`&&ce(n.callee,t))return n;n=n.parent}}function ue(e,t){let n=ie(e),r=n===void 0?void 0:P(n);return r!==void 0&&w(r.callee,t,`Effect`,`gen`)?r:void 0}function de(e){let t=e.parent;for(;t;){if(E(t))return;if(t.type===`Property`){let e=O(t);if(e!==void 0&&se.has(e))return e}t=t.parent}}const fe=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=ue(n,r);i!==void 0&&le(i,r)?.arguments.includes(i)&&e.report({node:n,messageId:`finalizer`})}}));function pe(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 I(e,t){let i=x(t)?.[0],a=i===void 0?void 0:pe(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 me(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(pe(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 he(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 ge=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(I(e,n.callee)&&r?.type===`ObjectExpression`&&he(r,`placement`))return t.replaceText(i,`placement: { ${e.sourceCode.getText(i)} }`)}})}})),_e=/* @__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`]]),ve=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=_e.get(a);o!==void 0&&e.report({node:r.callee,messageId:`deprecated`,data:{api:a,replacement:o}})}}));function ye(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 be=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&&ye(a.value,r)&&e.report({node:a.value,messageId:`plaintext`})}})),xe=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]}})}})),Se=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&&F(i.value,`default`)&&e.report({node:i.value,messageId:`reserved`})}})),Ce=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=ue(n,r),o=a===void 0?void 0:de(a);a!==void 0&&o!==void 0&&le(a,r)!==void 0&&e.report({node:i,messageId:`runtime`,data:{handler:o}})}})),we=_(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}})}})),Te=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(!ce(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(I(e,n.callee)&&he(r,i))return o.replaceText(a.key,a.shorthand?`${i}: ${t}`:i)}})}}})),Ee=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`})}})),De=/* @__PURE__ */ new Set([`error`,`err`,`e`,`cause`,`exception`,`ex`]);function Oe(e){return e?.type===`Identifier`&&De.has(e.name)?e.name:void 0}function ke(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 Ae=_({...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||!ke(n)||!oe(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(ke(t)){if(t.parent.type===`NewExpression`&&t.parent.arguments[0]===t&&oe(t.parent))return;let n=Oe(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=Oe(t.callee.object);n!==void 0&&e.report({node:t,messageId:`errorString`,data:{name:n}})},TemplateLiteral(t){let[n,r]=t.quasis,i=Oe(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}})}})),je=/* @__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(`.`)),Me=/* @__PURE__ */ new Set([`Array`,`ArrayEnsure`,`Chunk`,`HashSet`,`NonEmptyArray`,`Option`,`ReadonlySet`,`Redacted`,`Tree`,`UniqueArray`]),Ne=/* @__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(`.`)),Pe=/* @__PURE__ */ new Set([`annotate`,`annotateKey`,`check`,`mapFields`]),Fe=/* @__PURE__ */ new Set([`CallExpression`,`Identifier`,`MemberExpression`,`ThisExpression`]),Ie=/^\p{Lu}/u;function L(e,t,n){let r=C(e,n);return x(e)?.length===2&&r?.length===2&&r[0]===`Schema`&&I(t,e)?r[1]:void 0}function Le(e){return e!==void 0&&Me.has(e)}function Re(e){return e!==void 0&&(je.has(e)||Me.has(e))}const ze=/* @__PURE__ */ new Set([`ArrowFunctionExpression`,`FunctionExpression`,`Identifier`,`Literal`,`ThisExpression`]);function Be(e,t,i){return r.pipe(e,n.every(e=>e===null||R(e,t,i)))}function R(e,t,i){if(ze.has(e.type))return!0;if(e.type===`MemberExpression`)return R(e.object,t,i)&&(!e.computed||R(e.property,t,i));if(e.type===`TemplateLiteral`)return Be(e.expressions,t,i);if(e.type===`ArrayExpression`)return Be(e.elements,t,i);if(e.type===`ObjectExpression`)return r.pipe(e.properties,n.every(e=>e.type===`SpreadElement`?R(e.argument,t,i):(!e.computed||R(e.key,t,i))&&R(e.value,t,i)));if(e.type!==`CallExpression`)return!1;let a=e.callee.type===`CallExpression`?e.callee.callee:e.callee;return L(a,t,i)!==void 0&&(e.callee===a||R(e.callee,t,i))&&Be(e.arguments,t,i)}function Ve(e){return r.pipe(e.arguments,n.some(e=>e.type===`SpreadElement`))}function He(e){let[t]=e.arguments;return e.arguments.length===1&&t?.type!==`SpreadElement`&&!e.typeArguments?t:void 0}function z(e){return e.callee.type===`MemberExpression`&&!e.callee.optional&&b(e.callee)===`pipe`&&!e.typeArguments&&!Ve(e)}function Ue(e,t,n){return(T(e.callee,n,[`pipe`])||T(e.callee,n,[`Function`,`pipe`]))&&I(t,e.callee)}function We(e,t,n){return Re(L(e,t,n))?!0:e.type===`CallExpression`&&Ne.has(L(e.callee,t,n)??``)}function Ge(e,t,n){if(Ie.test(L(e,t,n)??``)||B(e,t,n)!==void 0)return!0;if(e.type!==`CallExpression`)return!1;let r=L(e.callee,t,n);return r===void 0?e.callee.type===`MemberExpression`&&Pe.has(b(e.callee)??``)&&Ge(e.callee.object,t,n):Ie.test(r)||Re(r)}function Ke(e,t,n){let[r,i]=e.arguments;if(!(r===void 0||i===void 0||r.type===`SpreadElement`||e.typeArguments||Ve(e)||!Ge(r,t,n)&&!We(i,t,n)))return[r,e.arguments.slice(1)]}function qe(e,t,n,r,i,a){let o=Ze(e,i,a);return{head:o.head,steps:[...o.steps,t],violation:o.violation??n,reordersEffects:o.reordersEffects||r}}function Je(e,t,n){let r=He(e);if(r===void 0)return;let i=L(e.callee,t,n);if(Re(i)){let a=Le(i);return qe(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`?L(e.callee.callee,t,n):void 0;if(a!==void 0&&Ne.has(a))return qe(r,{text:t.sourceCode.getText(e.callee),wrapper:!1},{kind:`dataLastCall`,name:a},!R(e.callee,t,n)&&!R(r,t,n),t,n)}function Ye(e,t,i){let o=Ue(e,t,i),s=o?Ke(e,t,i):z(e)?[e.callee.object,e.arguments]:void 0;if(s===void 0)return;let[c,l]=s,u=r.pipe(l,n.map(e=>L(e,t,i))),d=r.pipe(u,n.findFirst(Le),a.getOrUndefined),f=d!==void 0&&r.pipe(l.slice(u.indexOf(d)+1),n.some(e=>!R(e,t,i)));return Xe(c,r.pipe(l,n.map((e,n)=>({text:t.sourceCode.getText(e),wrapper:Le(u[n])}))),o?{kind:`functionPipe`}:d===void 0?void 0:{kind:`wrapperPipe`,name:d},f,t,i)}function Xe(e,t,n,r,i,a){let o=Ze(e,i,a);return{head:o.head,steps:[...o.steps,...t],violation:o.violation??n,reordersEffects:o.reordersEffects||r}}function B(e,t,n){return e.type===`CallExpression`?Je(e,t,n)??Ye(e,t,n):void 0}function Ze(e,t,n){return B(e,t,n)??{head:e,steps:[],violation:void 0,reordersEffects:!1}}function Qe(e,t,n){let r=e.parent;return r.type===`MemberExpression`&&r.object===e&&r.parent.type===`CallExpression`?r.parent.callee===r&&z(r.parent):r.type===`CallExpression`&&r.arguments[0]===e&&(Ue(r,t,n)||!z(r))&&B(r,t,n)!==void 0}function $e(e,t,r){return n.isReadonlyArrayNonEmpty(t)?`${e===`\0`&&!Fe.has(r.type)?`(\0)`:e}.pipe(${n.join(t,`, `)})`:e}function et(e,t){let n=`\0`,r=[];for(let i of t)if(i.wrapper){let t=$e(n,r,e),a=t===`\0`&&e.type===`SequenceExpression`?`(${t})`:t;n=`${i.text}(${a})`,r=[]}else r.push(i.text);return $e(n,r,e)}function tt(e,t){return e.range[0]<=t.range[0]&&t.range[1]<=e.range[1]}const nt=v({...y(`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(i){let a=t();if(!a.hasEffectImport)return;let o=B(i,e,a);if(o?.violation===void 0||Qe(i,e,a))return;let{head:s}=o,c=r.pipe(e.sourceCode.getCommentsInside(i),n.some(e=>!tt(s,e))),[l=``,u=``]=et(s,o.steps).split(`\0`);e.report({node:i,messageId:o.violation.kind,data:{name:o.violation.name??``},fix:c||o.reordersEffects?void 0:e=>[e.replaceTextRange([i.range[0],s.range[0]],l),e.replaceTextRange([s.range[1],i.range[1]],u)]})}}));function V(e){for(let t of e.arguments)if(t.type===`ObjectExpression`)return t}function rt(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 it(e,t){let n=P(e);return n===void 0?void 0:C(n.callee,t)}function at(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 H(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 ot(e){let t=A(e);return F(t,`*`)?!0:t.type===`ArrayExpression`&&(t.elements.length===0||r.pipe(t.elements,n.some(e=>!e||e.type===`SpreadElement`?!1:F(e,`*`))))}const st=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=V(n);if(i===void 0||!F(k(i,`credentials`)?.value??i,!0))return;let a=k(i,`allowedOrigins`);(a===void 0||ot(a.value))&&e.report({node:n,messageId:`wildcard`})}}));function ct(e){return e.type===`AssignmentPattern`||e.type===`RestElement`||e.optional===!0}const lt=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=>ct(e)))&&e.report({node:a,messageId:`unsafeArity`})}})),ut=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 dt(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 ft=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&&at(e.init)&&n.add(e.id.name)},CallExpression(r){let i=dt(r,t()),a=i===void 0?void 0:H(i);a?.type===`Identifier`&&n.has(a.name)&&e.report({node:a,messageId:`prestarted`})}}}),pt=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:H(i);i!==void 0&&(i.async||a!==void 0&&at(a))&&e.report({node:i,messageId:`asyncTry`})}})),mt=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)&&ae(n)&&e.report({node:n,messageId:`discarded`})}}));function ht(e,t){let n=A(e);if(n.type===`CallExpression`&&n.callee.type===`MemberExpression`&&b(n.callee)===t)return n}const gt=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)||ht(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&&F(c.value,!0)||e.report({node:i,messageId:`discarded`,data:{method:o}})}})),_t={Array:`Arr`,Boolean:`Bool`,Equal:`Eq`,Function:`Fn`,Number:`Num`,Option:`Opt`,Predicate:`P`,Record:`R`,String:`Str`};function vt(e){return e===`@effect/vitest`||e.startsWith(`@effect/vitest/`)}function U(e,t){return e.importKind===`type`||t?.importKind===`type`}function W(e){return _t[e]??e}function yt(e,t){if(e===`effect`||e===`alchemy`||/^@effect\/[^/]+$/u.test(e)&&!vt(e))return`${e}/${t}`}function bt(e){if(vt(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 xt(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)&&!U(t,n)?yt(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 St(e,t,i){let o=bt(t.source.value);if(o===void 0||t.attributes.length>0||e.sourceCode.getCommentsInside(t).length>0)return;let s=W(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`&&U(t,n)){if(n.local.name===s)return;d.push(e.sourceCode.getText(n));continue}let r=Ct(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 Ct(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 wt(s,i,!1,o);if(e.imported.type===`Identifier`)return wt(s,`${i}.${e.imported.name}`,!0,o)}}function wt(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 Tt(e){return e?.imported.type===`Identifier`?e.imported.name:typeof e?.imported.value==`string`?e.imported.value:void 0}const Et=_({...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`||U(t,n))continue;let r=Tt(n),i=r===void 0||!/^\p{Lu}/u.test(r)?void 0:yt(t.source.value,r);r!==void 0&&i!==void 0&&e.report({node:n,messageId:`barrelImport`,data:{alias:W(r),source:i},fix:n=>xt(e,t,n)})}}})),Dt=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(!I(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=me(e,i,`effect/Effect`,`Effect`,t);return[...o.fixes,t.replaceText(i,`${o.name}.never`)]}})}})),Ot=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 kt(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 At(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 jt=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`)||!I(e,n.callee))return;let r=D(n,n.arguments.length-1),i=At(n),a=i===void 0?void 0:kt(i,e);a?.type===`CallExpression`&&w(a.callee,t(),`Config`,`succeed`)&&I(e,a.callee)&&E(D(a,0))||r!==void 0&&E(r)&&r.params.length===0&&e.report({node:r,messageId:`functionDefault`})}}));function Mt(e,t){return e.type===`CallExpression`&&w(e.callee,t,`Hash`,`hash`)}const Nt=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 Mt(e,t())||e.type===`Identifier`&&n.has(e.name)}return{before(){n=/* @__PURE__ */ new Set},VariableDeclarator(e){e.id.type===`Identifier`&&e.init&&Mt(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`})}}}),Pt=/* @__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(`.`)),Ft=/* @__PURE__ */ new Set([`global`,`module`]),It=/* @__PURE__ */ new Set([`ArrowFunctionExpression`,`FunctionDeclaration`,`FunctionExpression`]),Lt=/* @__PURE__ */ new Set([`AssignmentExpression`,`AwaitExpression`,`ImportExpression`,`TaggedTemplateExpression`,`UpdateExpression`,`YieldExpression`]),Rt=/* @__PURE__ */ new Set([`ParenthesizedExpression`,`TSAsExpression`,`TSNonNullExpression`]);function zt(e,t,n){let r=n.sourceCode.getScope(e);for(;r!==null;){let e=r.set.get(t);if(e!==void 0)return e;r=r.upper}}function Bt(e,t,i){let a=C(e,t),o=a?.length===2&&a[0]===`Schema`?a[1]:void 0,s=x(e)?.[0];if(o===void 0||s===void 0||!Pt.has(o))return;let c=zt(e,s,i);return c!==void 0&&r.pipe(c.defs,n.every(e=>e.type===`ImportBinding`))?o:void 0}function Vt(e){let t=e.parent;for(;t;){if(It.has(t.type))return!0;t=t.parent}return!1}function Ht(e){let t=e,n=e.parent;for(;Rt.has(n.type)&&n.parent!==null;)t=n,n=n.parent;return n.type===`CallExpression`&&n.callee===t}function Ut(e,t){return e.type===`CallExpression`&&C(e.callee,t)?.[0]===`Schema`}function Wt(e,t){return e.range[0]<=t.range[0]&&t.range[1]<=e.range[1]}function Gt(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 Kt(e){return r.pipe(e.references,n.every(e=>(!e.isWrite()||e.init)&&!Gt(e.identifier)))}function qt(e,t,n,r){let i=zt(e,t,r);return i===void 0||Wt(n,i.scope.block)?!0:Ft.has(i.scope.type)&&Kt(i)}function Jt(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 Yt(e,t){if(e===t)return!1;let n=e.parent;for(;n!==null&&n!==t;){if(It.has(n.type))return!0;n=n.parent}return!1}function Xt(e,t,n){return Yt(e,t)?!1:e.type===`CallExpression`||e.type===`NewExpression`?C(e.callee,n)===void 0:Lt.has(e.type)}function Zt(e,t,n){return!j(e,r=>r.type===`ThisExpression`||r.type===`Super`||r.type===`MetaProperty`&&r.meta.name===`new`||Xt(r,e,t)||r.type===`Identifier`&&!Jt(r)&&!qt(r,r.name,e,n))}const Qt=v(y(`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(i){let a=t();if(!a.hasEffectImport)return;let o=Bt(i.callee,a,e),[s]=i.arguments;if(o===void 0||s===void 0||s.type===`SpreadElement`||r.pipe(i.arguments,n.some(e=>e.type===`SpreadElement`))||!Ht(i)||!Vt(i))return;let c=A(s),l=Ut(c,a);(l||c.type===`Identifier`||c.type===`MemberExpression`)&&r.pipe(i.arguments,n.every(t=>Zt(t,a,e)))&&e.report({node:i.callee,messageId:l?`inlineSchema`:`inlineCompile`,data:{method:o}})}})),$t=/* @__PURE__ */ new Set([`catch`,`catchAll`,`catchAllCause`,`catchIf`,`catchSome`,`catchSomeCause`,`catchTag`,`orElse`,`orElseFail`,`orElseSucceed`]),en=/* @__PURE__ */ new Set([`log`,`logDebug`,`logError`,`logInfo`,`logTrace`,`logWarning`]);function tn(e,t){let n=e.parent;for(;n;){if(E(n)){let e=P(n);if(e?.arguments.at(-1)===n){let n=C(e.callee,t),r=n?.[1];if(r!==void 0&&n?.[0]===`Effect`&&$t.has(r))return{method:r}}}n=n.parent}}const nn=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`&&en.has(a[1])?n.join(a,`.`):void 0;if(o===void 0)return;let s=tn(r,i);s!==void 0&&e.report({node:r,messageId:`logging`,data:{logger:o,catchMethod:s.method}})}})),rn=/* @__PURE__ */ new Set([`==`,`===`,`!=`,`!==`]),an=/* @__PURE__ */ new Set([`catch`,`catchAll`,`catchIf`]);function on(e){return e.type===`Literal`&&typeof e.value==`string`}function G(e){return e.type===`MemberExpression`&&b(e)===`_tag`}function sn(e){if(rn.has(e.operator)){if(G(e.left)&&on(e.right))return e.left;if(G(e.right)&&on(e.left))return e.right}}function K(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`&&an.has(e.callee.property.name)}t=t.parent}return!1}function cn(e){return e.object.type===`MemberExpression`&&b(e.object)===`reason`}function ln(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 un=_(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=sn(t);n!==void 0&&K(t)&&e.report({node:t,messageId:cn(n)?`reason`:`tag`})},SwitchStatement(t){G(t.discriminant)&&K(t)&&e.report({node:t,messageId:cn(t.discriminant)?`reason`:`tag`})}})),dn=_(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){sn(t)===void 0||K(t)||e.report({node:t,messageId:`manualComparison`})},SwitchStatement(t){G(t.discriminant)&&!K(t)&&e.report({node:t,messageId:`manualSwitch`})}})),fn=_(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(ln(t))return;let i=a.getOrUndefined(r.pipe(t.properties,n.findFirst(e=>e.type===`Property`&&O(e)===`_tag`&&on(e.value))));i!==void 0&&e.report({node:i,messageId:`manualConstruction`})}}));function pn(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&&F(e.value,!0))return!1}}let r=D(e,n===`setInterval`?0:1);return r!==void 0&&M(r,t)}const mn=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`&&pn(e,i))&&e.report({node:n,messageId:`multiShot`})}}));function hn(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 gn(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 _n(e){let t=[e];for(;t.length>0;){let e=t.pop();if(e===void 0)continue;let n=A(e);if(hn(n))return n;gn(n,t)}}const vn=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=V(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=_n(n.value);r!==void 0&&e.report({node:r,messageId:`nonJson`})}}})),yn=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`})}})),bn=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`})}})),xn=/^make[A-Z]/u,Sn=/\.(?:test|spec)\.[cm]?[jt]sx?$/u,Cn=_(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(!Sn.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;xn.test(t)&&e.report({node:n,messageId:`serviceConstructorImport`,data:{name:t}})}}})),wn=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`})}})),Tn=/* @__PURE__ */ new Set([`andThen`,`map`,`mapError`,`tap`,`tapError`,`tapErrorCause`]),En=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=ie(n);if(r===void 0)return;let i=t(),a=it(r,i),o=rt(r,`catch`);(a?.[0]===`Effect`&&a[1]!==void 0&&Tn.has(a[1])||o!==void 0&&(w(o.callee,i,`Effect`,`try`)||w(o.callee,i,`Effect`,`tryPromise`)))&&e.report({node:n,messageId:`callbackThrow`})}})),Dn=/* @__PURE__ */ new Set([`get`,`post`,`put`,`patch`,`delete`,`head`,`options`]);function On(e,t){let n=e.parent,r=e.node;if(e.type!==`ImportBinding`||n?.type!==`ImportDeclaration`||U(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 kn(e,t){let n=x(e.callee),r=n?.[0],i=n?.at(-1);if(n===void 0||r===void 0||i===void 0||!Dn.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&&On(t,n)}a=a.upper}return!1}function An(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 jn=_(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`))||!kn(t,e))return;let i=An(D(t,2)),o=An(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}})}}})),Mn=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=V(n);if(i===void 0)return;let a=k(i,`times`);a!==void 0&&F(a.value,0)&&e.report({node:a,messageId:`zeroTimes`})}})),Nn=_({...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=bt(t.source.value);if(n===void 0||t.importKind===`type`)return;let r=W(n);for(let n of t.specifiers)n.type===`ImportSpecifier`&&U(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=>St(e,t,n)}):e.report({node:n,messageId:`namespace`,data:{alias:r,source:t.source.value},fix:n=>St(e,t,n)}))}})),Pn=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`})}})),Fn=/* @__PURE__ */ new Set([`toISOString`,`toLocaleDateString`,`toLocaleTimeString`]),In=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`&&Fn.has(b(n.callee)??``)&&e.report({node:n,messageId:`effectDateTime`})}})),Ln=/* @__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 Rn(e,t,r){let i=C(e.callee,r),a=i===void 0?void 0:Ln.get(n.join(i,`.`)),o=a!==void 0&&I(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 q(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=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),i=q(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 zn(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=zn(t.left),r=zn(t.right);return n===void 0||r===void 0?void 0:[...n,...r]}const Bn=/* @__PURE__ */ new Set([6e4,36e5,864e5]),Vn=/* @__PURE__ */ new Set([60,3600,86400]),Hn=/* @__PURE__ */ new Set([7,24,60,1e3,3600,86400]);function Un(e){let t=zn(e);if(!(t===void 0||t.length<2)&&(r.pipe(t,n.some(e=>Bn.has(e)))||r.pipe(t,n.some(e=>Vn.has(e)))&&r.pipe(t,n.filter(e=>Hn.has(e))).length>=2))return{millis:t.includes(1e3)||r.pipe(t,n.some(e=>e%6e4==0))}}const Wn=[[`weeks`,6048e5],[`days`,864e5],[`hours`,36e5],[`minutes`,6e4],[`seconds`,1e3],[`millis`,1]];function Gn(e){return!Number.isSafeInteger(e)||Math.abs(e)<1e4?String(e):String(e).replaceAll(/\B(?=(?:\d{3})+$)/gu,`_`)}function Kn(e,t){let i=e*(a.getOrUndefined(r.pipe(Wn,n.findFirst(([e])=>e===t)))?.[1]??1);if(i===0)return`Duration.zero`;for(let[e,t]of Wn)if(Number.isSafeInteger(i/t))return`Duration.${e}(${Gn(i/t)})`;return`Duration.millis(${Gn(i)})`}const qn=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=Rn(n,e,t());r!==void 0&&q(r)!==void 0&&e.report({node:r,messageId:`effectDuration`,fix(t){let i=me(e,n,`effect/Duration`,`Duration`,t);return[...i.fixes,t.replaceText(r,`${i.name}.millis(${e.sourceCode.getText(r)})`)]}})}})),Jn=/* @__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`]]),Yn=/* @__PURE__ */ new Set([`day`,`hour`,`minute`,`second`,`week`]),Xn=/* @__PURE__ */ new Set([`backoff`,`cooldown`,`day`,`debounce`,`delay`,`duration`,`expiration`,`expiry`,`hour`,`interval`,`lifetime`,`minute`,`second`,`throttle`,`timeout`,`ttl`,`week`]),Zn=r.flow(c.split(/[_$]+|(?<=[\da-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])/u),n.filter(c.isNonEmpty),n.map(c.toLowerCase)),Qn=/* @__PURE__ */ new Set([`at`,`epoch`,`per`,`timestamp`]);function $n(e){return e!==void 0&&e!==`excluded`&&e!==`unknown`}function er(e){let t=Zn(e),i=t.indexOf(`in`),a=t[i-1]??``;if(i>0&&i<t.length-1&&(Jn.has(a)||Yn.has(a))||r.pipe(t,n.some(e=>Qn.has(e))))return`excluded`;let o=t.at(-1),s=t.at(-2);if(o===void 0)return;let c=Jn.get(o);if(c!==void 0)return c;if(Xn.has(o)||o===`age`&&s===`max`||o===`in`&&s===`expires`)return`unknown`}function tr(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 nr(e){if(e.type===`Identifier`)return[e.name];if(e.type===`TSQualifiedName`){let t=nr(e.left);return t===void 0?void 0:[...t,e.right.name]}}function rr(e,t,n){return j(e,e=>{if(e.type!==`TSTypeReference`)return!1;let[r,...i]=nr(e.typeName)??[],a=r===void 0||!tr(e,r,t)?void 0:n.bindings.get(r);return a!==void 0&&[...a,...i][0]===`Duration`})}function ir(e){return e.parent.type===`VariableDeclaration`&&e.parent.kind===`const`&&e.id.type===`Identifier`&&e.init!==null&&q(e.init)!==void 0}function ar(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`&&ir(a)?a:void 0}const or=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&&rr(n.id.typeAnnotation,e,t()))return`none`;let i=er(n.id.name);if(r)return $n(i)?i:`millis`;if(i===`excluded`||(q(n.init)??0)<=0)return`none`;if($n(i))return i;let a=Un(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&&ir(e)&&!n.has(e)&&n.set(e,!1)},CallExpression(r){let i=Rn(r,e,t()),a=i===void 0?void 0:ar(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`:Kn(a,n)}})}}}}),sr=/* @__PURE__ */ new Set([`base64`,`base64url`,`hex`]);function cr(e){return e!==void 0&&r.pipe([...sr],n.some(t=>F(e,t)))}const lr=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`&&cr(D(r,1)),o=i?.at(-1)===`toString`&&cr(D(r,0));(a||o)&&e.report({node:r,messageId:`effectEncoding`})}})),ur=/* @__PURE__ */ new Set([`fs`,`fs/promises`,`node:fs`,`node:fs/promises`]),dr=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&&ur.has(n.source.value)&&e.report({node:n.source,messageId:`effectFileSystem`,data:{source:n.source.value}})}}));function fr(e,t,n){return e.type===`CallExpression`&&w(e.callee,t,`Result`,n)?D(e,0):void 0}function pr(e,t,n){let r=N(t),i=H(t);if(r===void 0||i?.type!==`ConditionalExpression`)return;let a=fr(i.consequent,n,`succeed`),o=fr(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 mr=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){pr(e,n,t())},FunctionExpression(n){pr(e,n,t())}})),hr=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`})}})),gr=/* @__PURE__ */ new Set([`==`,`===`,`!=`,`!==`]);function _r(e){return e.type===`Literal`||e.type===`TemplateLiteral`&&e.expressions.length===0}function vr(e,t){if(e.type===`BinaryExpression`&&gr.has(e.operator)){if(_r(e.left))return t.sourceCode.getText(e.right);if(_r(e.right))return t.sourceCode.getText(e.left)}}const yr=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=vr(t.test,e);if(n===void 0)return;let r=t.alternate,i=1;for(;r.type===`ConditionalExpression`;){if(vr(r.test,e)!==n)return;i+=1,r=r.alternate}i>1&&e.report({node:t,messageId:`preferMatch`})}})),br=/* @__PURE__ */ new Set([`node:path`,`path`]),xr=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&&br.has(n.source.value)&&e.report({node:n.source,messageId:`effectPath`,data:{source:n.source.value}})}})),Sr=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`})}})),Cr=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)&&!re(a)&&e.report({node:n,messageId:`unusedRestore`,data:{replacement:`Effect.${i}`}})}})),wr=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)&&!re(r)&&e.report({node:n,messageId:`unusedSpan`})}}));function Tr(e,t){let n=A(e);if(F(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`&&F(r,0)}return!1}const Er=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`)&&Tr(i,r)&&e.report({node:n,messageId:`zeroSleep`})}})),Dr=/* @__PURE__ */ new Set([`catch`,`catchAll`,`mapError`]);function Or(e,t){let n=it(e,t),r=rt(e,`catch`);if(!(n?.[0]===`Effect`&&n[1]!==void 0&&Dr.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`&&oe(e)&&(i===void 0||!M(e,i.name)))}const kr=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){Or(n,t())&&e.report({node:n,messageId:`droppedCause`})},FunctionExpression(n){Or(n,t())&&e.report({node:n,messageId:`droppedCause`})}})),Ar=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 jr(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 Mr=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=jr(n,t());if(r===void 0)return;let i=N(r);i===void 0?e.report({node:r,messageId:`missingSignal`}):!i.name.startsWith(`_`)&&!re(r)&&e.report({node:i,messageId:`unusedSignal`})}}));function Nr(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 Pr=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||Nr(o,a))return;let s=P(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`})}})),Fr=String.raw`(?:\r\n|\r(?!\n)|[\n\u2028\u2029])`,Ir=String.raw`[^\S\r\n\u2028\u2029]*`,Lr=RegExp(`^(${Ir}${Fr})(?:${Ir}${Fr})+(${Ir};?)$`,`u`),Rr=/^(?:module\s*\.\s*)?exports(?:\s*\.|\s*\[|$)/u;function zr(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 Br(e){return[`FunctionDeclaration`,`FunctionExpression`,`ArrowFunctionExpression`].includes(e.type)}function Vr(e){return e.type===`ChainExpression`?e.expression:e}function X(e,t){return(r,i)=>i.getFirstToken(r)?.value===t&&(n.isArray(e)?e.includes(r.type):e===r.type)}function Z(e){return t=>t.type===e}function Q(e,t){return(n,r)=>e(n,r)&&Y(n)===(t===`singleline`)}function Hr(e){if(e.type!==`ExpressionStatement`)return!1;let t=Vr(e.expression);if(t.type===`UnaryExpression`&&(t=Vr(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 Br(n)}function Ur(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 Wr(e,t){if(e.type===`DoWhileStatement`&&e.body.type===`BlockStatement`||Hr(e))return!0;let n=t.getLastToken(e,e=>!zr(e)),r=n?.type===`Punctuator`&&n.value===`}`?t.getNodeByRangeIndex(n.range[0]):null;return r?.type===`BlockStatement`||r?.type===`SwitchStatement`}function Gr(e,t){return e.type===`ExpressionStatement`&&(e.parent.type===`Program`||e.parent.type===`BlockStatement`&&Br(e.parent.parent))&&e.expression.type===`Literal`&&typeof e.expression.value==`string`&&(t.getTokenBefore(e.expression)?.value!==`(`||t.getTokenAfter(e.expression)?.value!==`)`)}function Kr(e,t){if(!Gr(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(!Gr(n,t))return!1}return!0}function qr(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 Jr(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]&&zr(n)&&!J(r,n)&&J(n,i)?r:n}function Yr(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":Wr,expression:(e,t)=>e.type===`ExpressionStatement`&&!Kr(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`)},Xr={"*":()=>!0,exports:qr,require:Ur,directive:Kr,iife:Hr,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`&&Rr.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 Zr(e){return typeof e==`string`&&i.has(Xr,e)}function Qr(e){return n.isArray(e)}function $r(e){if(Zr(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 ei(e){if(!n.isArray(e))return $r(e);let t=e,i=t[0];if(i===void 0)throw Error(`Padding statement matcher arrays must not be empty`);return[$r(i),...r.pipe(t.slice(1),n.map(e=>$r(e)))]}function ti(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:ei(e.prev),next:ei(e.next)}}))}function ni(e,t,n){let r=[],i=Jr(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 ri(e,t,n){return f.gen(function*(){if(n===`any`)return yield*f.void;let r=yield*u,i=r.sourceCode,a=ni(e,t,i);return n===`never`?a.length===0?yield*f.void:yield*r.report({node:t,messageId:`unexpectedBlankLine`,loc:Yr(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(Lr,`$1$2`))}}):a.length>0?yield*f.void:yield*r.report({node:t,messageId:`expectedBlankLine`,loc:Yr(t,i),fix(n){let r=Jr(e,i),a=i.getFirstTokenBetween(r,t,{includeComments:!0,filter(e){return!J(r,e)||(r=e,!1)}})??t;return n.insertTextAfter(r,J(r,a)?`
|
|
3
3
|
|
|
4
4
|
`:`
|
|
5
|
-
`)}})})}function*
|
|
5
|
+
`)}})})}function*ii(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 Qr(t)?r.pipe(t,n.some(e=>g(o,e,a))):typeof t==`string`?Xr[t](o,i):a.get(t.selector)?.has(o)===!0&&(t.lineMode===`singleline`?Y(o):t.lineMode!==`multiline`||!Y(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})=>ri(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 ai={"alchemy-no-cloudflare-init-finalizer":fe,"alchemy-no-deprecated-docker-constraints":ge,"alchemy-no-deprecated-resource":ve,"alchemy-no-plaintext-github-secret":be,"alchemy-no-removed-config-api":xe,"alchemy-no-reserved-eventbridge-default-name":Se,"alchemy-no-runtime-config":Ce,"alchemy-no-v1-import":we,"alchemy-no-v1-worker-properties":Te,"avoid-data-tagged-error":Ee,"ban-error-string":Ae,"consistent-schema-pipe":nt,"cors-credentials-with-wildcard":st,"dual-numeric-arity-with-optional-parameter":lt,"effect-promise-vs-trypromise":ut,"no-already-started-promise":ft,"no-async-effect-try":pt,"no-discarded-run-promise":mt,"no-discarded-schema-checks":gt,"no-empty-effect-callback":Dt,"no-empty-schema-struct":Ot,"no-effect-alchemy-barrel-imports":Et,"no-function-config-default":jt,"no-hash-as-identity":Nt,"no-inline-schema-compile":Qt,"no-logging-in-catch":nn,"no-manual-effect-error-tag":un,"no-manual-tag-comparison":dn,"no-manual-tagged-construction":fn,"no-multi-shot-effect-callback":mn,"no-non-json-schema-annotation":vn,"no-option-of-service":yn,"no-overwritten-discriminant":bn,"no-service-option-get-or-throw":wn,"no-service-constructor-imports":Cn,"no-throw-in-effect-callback":En,"no-uppercase-http-api-header":jn,"no-zero-retry-times":Mn,"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(Xr)},{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*ii(e,ti(e.options))}}),"prefer-effect-alchemy-namespace-imports":Nn,"prefer-effect-array-sort":Pn,"prefer-effect-datetime":In,"prefer-effect-duration":qn,"prefer-effect-duration-constants":or,"prefer-effect-encoding":lr,"prefer-effect-filesystem":dr,"prefer-effect-filter":mr,"prefer-effect-headers":hr,"prefer-effect-match":yr,"prefer-effect-path":xr,"prefer-effect-url":Sr,"prefer-uninterruptible":Cr,"prefer-with-span":wr,"prefer-yield-now":Er,"preserve-caught-error":kr,"require-schema-class-brand":Ar,"require-try-promise-abort-signal":Mr,"throw-in-effect-gen":Pr},oi=/* @__PURE__ */ new Set([`prefer-effect-filesystem`,`prefer-effect-path`]),si=i.fromEntries(r.pipe(i.keys(ai),n.filter(e=>!oi.has(e)),n.map(e=>[`2digits/${e}`,`error`]))),ci=t({meta:{name:`@2digits/oxlint-plugin`},rules:ai});export{ci as default,si as recommendedRules,ai as rules};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@2digits/oxlint-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Custom Oxlint rules for 2digits projects.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"2digits",
|
|
@@ -28,20 +28,20 @@
|
|
|
28
28
|
"access": "public"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@oxlint/plugins": "1.
|
|
32
|
-
"effect": "4.0.
|
|
31
|
+
"@oxlint/plugins": "1.88.0",
|
|
32
|
+
"effect": "4.0.5",
|
|
33
33
|
"effect-oxlint": "0.4.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@2digits/tsconfig": "0.
|
|
36
|
+
"@2digits/tsconfig": "1.0.0",
|
|
37
37
|
"@arethetypeswrong/core": "0.18.5",
|
|
38
|
-
"@effect/vitest": "4.0.
|
|
38
|
+
"@effect/vitest": "4.0.5",
|
|
39
39
|
"dedent": "1.7.2",
|
|
40
|
-
"oxlint": "1.
|
|
40
|
+
"oxlint": "1.88.0",
|
|
41
41
|
"publint": "0.3.25",
|
|
42
42
|
"typescript": "7.0.2",
|
|
43
|
-
"vite-plus": "1.
|
|
44
|
-
"vitest": "5.0.
|
|
43
|
+
"vite-plus": "1.3.0",
|
|
44
|
+
"vitest": "5.0.5"
|
|
45
45
|
},
|
|
46
46
|
"public": true,
|
|
47
47
|
"scripts": {
|