@2digits/oxlint-plugin 0.0.1 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -0
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +2 -1
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -36,6 +36,13 @@ The package exports all rules as `rules`, their names as `RuleName`, and the def
|
|
|
36
36
|
See each rule's `meta.docs.url` for its upstream rule, issue, or framework documentation. Copied-code attribution is in
|
|
37
37
|
[`NOTICE`](./NOTICE).
|
|
38
38
|
|
|
39
|
+
## Automatic fixes
|
|
40
|
+
|
|
41
|
+
Run `vp lint --fix` to apply fixes from `prefer-effect-duration`, `no-empty-effect-callback`,
|
|
42
|
+
`no-effect-alchemy-barrel-imports`, `prefer-effect-alchemy-namespace-imports`,
|
|
43
|
+
`alchemy-no-v1-worker-properties`, and `alchemy-no-deprecated-docker-constraints`.
|
|
44
|
+
Fixes skip ambiguous bindings, conflicting properties, and unsupported import references.
|
|
45
|
+
|
|
39
46
|
## Adding a rule
|
|
40
47
|
|
|
41
48
|
Oxlint's JavaScript plugin API is currently alpha and does not expose type information. Keep rules syntax-safe and leave
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Plugin } from "@oxlint/plugins";
|
|
2
2
|
//#region src/rules/index.d.ts
|
|
3
|
-
declare const rules: {
|
|
3
|
+
export declare const rules: {
|
|
4
4
|
readonly 'alchemy-no-cloudflare-init-finalizer': import("@oxlint/plugins").Rule;
|
|
5
5
|
readonly 'alchemy-no-deprecated-docker-constraints': import("@oxlint/plugins").Rule;
|
|
6
6
|
readonly 'alchemy-no-deprecated-resource': import("@oxlint/plugins").Rule;
|
|
@@ -53,8 +53,8 @@ declare const rules: {
|
|
|
53
53
|
};
|
|
54
54
|
//#endregion
|
|
55
55
|
//#region src/index.d.ts
|
|
56
|
-
type RuleName = keyof typeof rules;
|
|
57
|
-
declare const recommendedRules: Partial<Record<`2digits/${RuleName}`, 'error'>>;
|
|
56
|
+
export type RuleName = keyof typeof rules;
|
|
57
|
+
export declare const recommendedRules: Partial<Record<`2digits/${RuleName}`, 'error'>>;
|
|
58
58
|
declare const plugin: Plugin;
|
|
59
59
|
//#endregion
|
|
60
|
-
export {
|
|
60
|
+
export { plugin as default };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import{defineRule as e,eslintCompatPlugin as t}from"@oxlint/plugins";const n={bindings:new Map,hasEffectImport:!1};function r(e){return e.imported.type===`Identifier`?e.imported.name:typeof e.imported.value==`string`?e.imported.value:void 0}function i(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 a(e){let t=new Map,n=!1;for(let a of e.body){if(a.type!==`ImportDeclaration`)continue;let e=a.source.value;(e===`effect`||e.startsWith(`effect/`)||e.startsWith(`@effect/`))&&(n=!0);let o=i(e);if(o!==void 0)for(let e of a.specifiers){if(e.type===`ImportNamespaceSpecifier`||e.type===`ImportDefaultSpecifier`){t.set(e.local.name,o);continue}let n=r(e);n!==void 0&&t.set(e.local.name,[...o,n])}}return{bindings:t,hasEffectImport:n}}function o(t,n){return e({meta:t,createOnce:n})}function s(t,r){return e({meta:t,createOnce(e){let t=n,{before:i,Program:o,...s}=r(e,()=>t);return{before(){t=n,i?.()},Program(e){t=a(e),o?.(e)},...s}}})}function c(e,t,n,r){return{type:e,docs:{description:t,recommended:!0,...r===void 0?{}:{url:r}},schema:[],messages:n}}function l(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 u(e){let t=[],n=e;for(;n.type===`ChainExpression`||n.type===`MemberExpression`;){if(n.type===`ChainExpression`){n=n.expression;continue}let e=l(n);if(e===void 0)return;t.unshift(e),n=n.object}return n.type===`Identifier`?[n.name,...t]:void 0}function d(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 f(e,t){let n=u(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 p(e,t,n,r){let i=f(e,t);return i?.length===2&&i[0]===n&&i[1]===r}function m(e,t,n){let r=f(e,t);return r?.length===n.length&&r.every((e,t)=>e===n[t])}function h(e){return e?.type===`ArrowFunctionExpression`||e?.type===`FunctionExpression`}function g(e,t){let n=e.arguments[t];return n===void 0||n.type===`SpreadElement`?void 0:n}function _(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 v(e,t){for(let n of e.properties)if(n.type===`Property`&&_(n)===t)return n}function y(e){return[`ParenthesizedExpression`,`TSAsExpression`,`TSNonNullExpression`,`TSSatisfiesExpression`,`TSTypeAssertion`].includes(e.type)}function b(e){let t=e;for(;y(t);)t=t.expression;return t}function x(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 S(e,t){let n=[e],r=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;x(e,n)}}return!1}function C(e,t){return S(e,e=>e.type===`Identifier`&&e.name===t)}function w(e){let t=e.params[0];return t?.type===`Identifier`?t:void 0}function T(e){let t=w(e);return t===void 0||!e.body||t.name.startsWith(`_`)?!1:C(e.body,t.name)}function E(e){let t=e.parent;for(;t;){if(h(t))return t;t=t.parent}}function D(e){let t=e.parent;if(t.type===`CallExpression`&&t.arguments.includes(e))return t}function O(e,t){return e.type===`Literal`&&e.value===t}function k(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 A(e){return u(e.callee)?.at(-1)?.endsWith(`Error`)===!0}const j=new Set([`alarm`,`fetch`,`queue`,`rpc`,`scheduled`,`tail`,`trace`,`webSocketClose`,`webSocketError`,`webSocketMessage`]);function M(e,t){return m(e,t,[`Cloudflare`,`Worker`])||m(e,t,[`Cloudflare`,`Workers`,`Worker`])}function N(e,t){let n=e.parent;for(;n;){if(n.type===`CallExpression`&&M(n.callee,t))return n;n=n.parent}}function P(e,t){let n=E(e),r=n===void 0?void 0:D(n);return r!==void 0&&p(r.callee,t,`Effect`,`gen`)?r:void 0}function F(e){let t=e.parent;for(;t;){if(h(t))return;if(t.type===`Property`){let e=_(t);if(e!==void 0&&j.has(e))return e}t=t.parent}}const ee=s(c(`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(!p(n.callee,r,`Effect`,`addFinalizer`))return;let i=P(n,r);i!==void 0&&N(i,r)?.arguments.includes(i)&&e.report({node:n,messageId:`finalizer`})}})),te=s(c(`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`),(e,t)=>({CallExpression(n){if(!p(n.callee,t(),`Docker`,`Service`))return;let r=g(n,1),i=r?.type===`ObjectExpression`?v(r,`constraints`):void 0;i!==void 0&&e.report({node:i,messageId:`constraints`})}})),ne=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`]]),re=s(c(`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=f(n.callee,t());if(r===void 0)return;let i=r.join(`.`),a=ne.get(i);a!==void 0&&e.report({node:n.callee,messageId:`deprecated`,data:{api:i,replacement:a}})}}));function ie(e,t){let n=b(e);if(n.type===`Literal`&&typeof n.value==`string`||n.type===`TemplateLiteral`)return!0;let r=u(n);return r?.[0]===`process`&&r[1]===`env`||n.type===`CallExpression`&&p(n.callee,t,`Config`,`string`)}const ae=s(c(`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(!p(n.callee,r,`GitHub`,`Secret`))return;let i=g(n,1),a=i?.type===`ObjectExpression`?v(i,`value`):void 0;a!==void 0&&ie(a.value,r)&&e.report({node:a.value,messageId:`plaintext`})}})),oe=s(c(`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=f(n.callee,t());r?.[0]===`Alchemy`&&(r[1]===`Secret`||r[1]===`Variable`)&&e.report({node:n.callee,messageId:`removed`,data:{api:r[1]}})}})),se=s(c(`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(!m(n.callee,t(),[`AWS`,`EventBridge`,`EventBus`]))return;let r=g(n,1),i=r?.type===`ObjectExpression`?v(r,`name`):void 0;i!==void 0&&O(i.value,`default`)&&e.report({node:i.value,messageId:`reserved`})}})),ce=s(c(`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`||f(i.callee,r)?.[0]!==`Config`)return;let a=P(n,r),o=a===void 0?void 0:F(a);a!==void 0&&o!==void 0&&N(a,r)!==void 0&&e.report({node:i,messageId:`runtime`,data:{handler:o}})}})),le=o(c(`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){let n=`alchemy/${r===`aws`?`AWS`:`Cloudflare`}`;e.report({node:t.source,messageId:`providerImport`,data:{replacement:n}})}}})),ue=s(c(`problem`,`Disallow Alchemy v1 Cloudflare Worker property names.`,{property:`Cloudflare.Worker {{old}} was replaced in v2. Use {{replacement}}.`},`https://alchemy.run/migrating-from-v1`),(e,t)=>({CallExpression(n){if(!M(n.callee,t()))return;let r=g(n,1);if(r?.type===`ObjectExpression`)for(let[t,n]of[[`entrypoint`,`main`],[`bindings`,`env`]]){let i=v(r,t);i!==void 0&&e.report({node:i,messageId:`property`,data:{old:t,replacement:n}})}}})),de=s(c(`suggestion`,`Prefer schema-based tagged errors so errors have a serializable contract.`,{taggedError:`Prefer Schema.TaggedErrorClass over Data.TaggedError.`}),(e,t)=>({CallExpression(n){p(n.callee,t(),`Data`,`TaggedError`)&&e.report({node:n.callee,messageId:`taggedError`})}})),fe=new Set([`error`,`err`,`e`,`cause`,`exception`,`ex`]);function I(e){return e?.type===`Identifier`&&fe.has(e.name)?e.name:void 0}function L(e){if(e.type!==`CallExpression`||e.arguments.length!==1)return!1;let t=u(e.callee);return t?.at(-1)===`String`&&t.length<=2}const R=o({...c(`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=g(t,0);if(n===void 0||!L(n)||!A(t))return;let r=g(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(L(t)){if(t.parent.type===`NewExpression`&&t.parent.arguments[0]===t&&A(t.parent))return;let n=I(t.arguments[0]);n!==void 0&&e.report({node:t,messageId:`errorString`,data:{name:n}});return}if(t.callee.type===`MemberExpression`&&u(t.callee)?.at(-1)===`toString`&&t.arguments.length===0){let n=I(t.callee.object);n!==void 0&&e.report({node:t,messageId:`errorString`,data:{name:n}})}},TemplateLiteral(t){let[n,r]=t.quasis,i=I(t.expressions[0]);i!==void 0&&t.quasis.length===2&&n?.value.raw===``&&r?.value.raw===``&&e.report({node:t,messageId:`errorString`,data:{name:i}})}}));function z(e){for(let t of e.arguments)if(t.type===`ObjectExpression`)return t}function B(e,t){let n=e.parent;if(n.type!==`Property`||_(n)!==t)return;let r=n.parent,i=r.parent;return r.type===`ObjectExpression`&&i?.type===`CallExpression`?i:void 0}function V(e,t){let n=D(e);return n===void 0?void 0:f(n.callee,t)}function H(e){let t=b(e);if(t.type===`NewExpression`)return u(t.callee)?.join(`.`)===`Promise`;if(t.type!==`CallExpression`)return!1;let n=u(t.callee);return n?.join(`.`)===`fetch`||n?.[0]===`Promise`&&n[1]!==`withResolvers`||[`catch`,`finally`,`then`].includes(n?.at(-1)??``)||h(t.callee)&&t.callee.async}function U(e){if(e.body){if(e.body.type!==`BlockStatement`)return b(e.body);if(!(e.body.body.length!==1||e.body.body[0]?.type!==`ReturnStatement`||!e.body.body[0].argument))return b(e.body.body[0].argument)}}function pe(e){let t=b(e);return O(t,`*`)?!0:t.type===`ArrayExpression`&&(t.elements.length===0||t.elements.some(e=>!e||e.type===`SpreadElement`?!1:O(e,`*`)))}const me=s(c(`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(!p(n.callee,r,`HttpMiddleware`,`cors`)&&!p(n.callee,r,`HttpRouter`,`cors`)&&!p(n.callee,r,`HttpApiBuilder`,`middlewareCors`))return;let i=z(n);if(i===void 0||!O(v(i,`credentials`)?.value??i,!0))return;let a=v(i,`allowedOrigins`);(a===void 0||pe(a.value))&&e.report({node:n,messageId:`wildcard`})}}));function he(e){return e.type===`AssignmentPattern`||e.type===`RestElement`||e.optional===!0}const ge=s(c(`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=g(n,0),i=g(n,1);i===void 0||!p(n.callee,t(),`Function`,`dual`)||r?.type!==`Literal`||typeof r.value!=`number`||!h(i)||i.params.some(e=>he(e))&&e.report({node:r,messageId:`unsafeArity`})}})),_e=s(c(`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){p(n.callee,t(),`Effect`,`promise`)&&e.report({node:n.callee,messageId:`tryPromise`})}}));function ve(e,t){if(!p(e.callee,t,`Effect`,`promise`)&&!p(e.callee,t,`Effect`,`tryPromise`))return;let n=g(e,0);if(n!==void 0&&h(n))return n;if(n?.type===`ObjectExpression`){let e=v(n,`try`);if(e!==void 0&&h(e.value))return e.value}}const ye=s(c(`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=new Set;return{before(){n=new Set},VariableDeclarator(e){e.id.type===`Identifier`&&e.init&&H(e.init)&&n.add(e.id.name)},CallExpression(r){let i=ve(r,t()),a=i===void 0?void 0:U(i);a?.type===`Identifier`&&n.has(a.name)&&e.report({node:a,messageId:`prestarted`})}}}),be=s(c(`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(!p(n.callee,t(),`Effect`,`try`))return;let r=g(n,0),i=r!==void 0&&h(r)?r:void 0;if(i===void 0&&r?.type===`ObjectExpression`){let e=v(r,`try`)?.value;e!==void 0&&h(e)&&(i=e)}let a=i===void 0?void 0:U(i);i!==void 0&&(i.async||a!==void 0&&H(a))&&e.report({node:i,messageId:`asyncTry`})}})),xe=s(c(`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=p(n.callee,r,`Effect`,`runPromise`),a=n.callee.type===`CallExpression`&&p(n.callee.callee,r,`Effect`,`runPromiseWith`);(i||a)&&k(n)&&e.report({node:n,messageId:`discarded`})}}));function Se(e,t){let n=b(e);if(n.type===`CallExpression`&&n.callee.type===`MemberExpression`&&l(n.callee)===t)return n}const Ce=s(c(`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=l(n.callee);if(r===void 0||![`mapElements`,`mapFields`,`mapMembers`].includes(r)||Se(n.callee.object,`check`)===void 0)return;let i=n.arguments.find(e=>e.type===`ObjectExpression`),a=i?.type===`ObjectExpression`?v(i,`unsafePreserveChecks`):void 0;a!==void 0&&O(a.value,!0)||e.report({node:n,messageId:`discarded`,data:{method:r}})}})),we={Array:`Arr`,Boolean:`Bool`,Equal:`Eq`,Function:`Fn`,Number:`Num`,Option:`Opt`,Predicate:`P`,Record:`R`,String:`Str`};function W(e){return e===`@effect/vitest`||e.startsWith(`@effect/vitest/`)}function G(e,t){return e.importKind===`type`||t?.importKind===`type`}function K(e){return we[e]??e}function Te(e,t){if(e===`effect`||e===`alchemy`||/^@effect\/[^/]+$/u.test(e)&&!W(e))return`${e}/${t}`}function Ee(e){if(W(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 De(e){return e?.imported.type===`Identifier`?e.imported.name:typeof e?.imported.value==`string`?e.imported.value:void 0}const Oe=o(c(`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`),e=>({ImportDeclaration(t){for(let n of t.specifiers){if(n.type!==`ImportSpecifier`||G(t,n))continue;let r=De(n),i=r===void 0||!/^\p{Lu}/u.test(r)?void 0:Te(t.source.value,r);r!==void 0&&i!==void 0&&e.report({node:n,messageId:`barrelImport`,data:{alias:K(r),source:i}})}}})),ke=s(c(`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`),(e,t)=>({CallExpression(n){if(!p(n.callee,t(),`Effect`,`callback`)&&!p(n.callee,t(),`Effect`,`async`))return;let r=g(n,0);r!==void 0&&h(r)&&r.body?.type===`BlockStatement`&&r.body.body.length===0&&e.report({node:n,messageId:`emptyCallback`})}})),Ae=s(c(`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=g(n,0);p(n.callee,t(),`Schema`,`Struct`)&&r?.type===`ObjectExpression`&&r.properties.length===0&&e.report({node:n,messageId:`emptyStruct`})}})),je=s(c(`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(!p(n.callee,t(),`Config`,`withDefault`))return;let r=g(n,n.arguments.length-1);r!==void 0&&h(r)&&r.params.length===0&&e.report({node:r,messageId:`functionDefault`})}}));function q(e,t){return e.type===`CallExpression`&&p(e.callee,t,`Hash`,`hash`)}const Me=s(c(`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=new Set;function r(e){return q(e,t())||e.type===`Identifier`&&n.has(e.name)}return{before(){n=new Set},VariableDeclarator(e){e.id.type===`Identifier`&&e.init&&q(e.init,t())&&n.add(e.id.name)},CallExpression(t){if(t.callee.type!==`MemberExpression`||![`delete`,`get`,`has`,`set`].includes(u(t.callee)?.at(-1)??``))return;let n=g(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`})}}}),Ne=new Set([`catch`,`catchAll`,`catchAllCause`,`catchIf`,`catchSome`,`catchSomeCause`,`catchTag`,`orElse`,`orElseFail`,`orElseSucceed`]),Pe=new Set([`log`,`logDebug`,`logError`,`logInfo`,`logTrace`,`logWarning`]);function Fe(e,t){let n=e.parent;for(;n;){if(h(n)){let e=D(n);if(e?.arguments.at(-1)===n){let n=f(e.callee,t),r=n?.[1];if(r!==void 0&&n?.[0]===`Effect`&&Ne.has(r))return{method:r}}}n=n.parent}}const Ie=s(c(`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=f(n.callee,r),a=i?.[1]!==void 0&&i[0]===`Effect`&&Pe.has(i[1])?i.join(`.`):void 0;if(a===void 0)return;let o=Fe(n,r);o!==void 0&&e.report({node:n,messageId:`logging`,data:{logger:a,catchMethod:o.method}})}}));function Le(e,t){let n=u(e.callee)?.at(-1);if(n===void 0||![`addEventListener`,`on`,`setInterval`].includes(n))return!1;if(n===`addEventListener`){let t=g(e,2);if(t?.type===`ObjectExpression`){let e=v(t,`once`);if(e!==void 0&&O(e.value,!0))return!1}}let r=g(e,n===`setInterval`?0:1);return r!==void 0&&C(r,t)}const Re=s(c(`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(!p(n.callee,t(),`Effect`,`callback`))return;let r=g(n,0);if(r===void 0||!h(r))return;let i=w(r)?.name,a=r.body;i!==void 0&&a&&S(a,e=>e.type===`CallExpression`&&Le(e,i))&&e.report({node:n,messageId:`multiShot`})}}));function ze(e){return e.type===`Literal`&&typeof e.value==`bigint`||e.type===`Identifier`&&[`NaN`,`Infinity`,`undefined`].includes(e.name)||h(e)||e.type===`CallExpression`&&u(e.callee)?.at(-1)===`Symbol`}function Be(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 Ve(e){let t=[e];for(;t.length>0;){let e=t.pop();if(e===void 0)continue;let n=b(e);if(ze(n))return n;Be(n,t)}}const He=s(c(`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=f(n.callee,r),a=n.callee.type===`MemberExpression`?l(n.callee):i?.[0]===`Schema`?i[1]:void 0;if(a===void 0||![`annotate`,`annotateEncoded`,`annotateKey`].includes(a))return;let o=z(n);if(o!==void 0&&v(o,`jsonSchema`)===void 0)for(let t of[`default`,`examples`]){let n=v(o,t);if(n===void 0)continue;let r=Ve(n.value);r!==void 0&&e.report({node:r,messageId:`nonJson`})}}})),Ue=s(c(`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=p(n.callee,r,`Effect`,`option`)||p(n.callee,r,`Effect`,`either`),a=g(n,0);if(i&&a?.type===`CallExpression`&&p(a.callee,r,`Effect`,`service`)){e.report({node:n,messageId:`mandatory`});return}if(n.callee.type!==`MemberExpression`||u(n.callee)?.at(-1)!==`pipe`)return;let o=b(n.callee.object),s=g(n,0);s!==void 0&&o.type===`CallExpression`&&p(o.callee,r,`Effect`,`service`)&&(p(s,r,`Effect`,`option`)||p(s,r,`Effect`,`either`))&&e.report({node:n,messageId:`mandatory`})}})),We=s(c(`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)===`_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`})}})),Ge=s(c(`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(p(n.callee,r,`Option`,`getOrThrow`)||p(n.callee,r,`Option`,`getOrThrowWith`)){let t=g(n,0),i=t?.type===`YieldExpression`?t.argument:t;i?.type===`CallExpression`&&p(i.callee,r,`Effect`,`serviceOption`)&&e.report({node:n,messageId:`getOrThrow`});return}if(n.callee.type!==`MemberExpression`||u(n.callee)?.at(-1)!==`pipe`)return;let i=b(n.callee.object),a=g(n,0);if(i.type!==`CallExpression`||!p(i.callee,r,`Effect`,`serviceOption`)||a?.type!==`CallExpression`||!p(a.callee,r,`Effect`,`map`))return;let o=g(a,0);o!==void 0&&(p(o,r,`Option`,`getOrThrow`)||p(o,r,`Option`,`getOrThrowWith`))&&e.report({node:n,messageId:`getOrThrow`})}})),Ke=new Set([`andThen`,`map`,`mapError`,`tap`,`tapError`,`tapErrorCause`]),qe=s(c(`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=E(n);if(r===void 0)return;let i=t(),a=V(r,i),o=B(r,`catch`);(a?.[0]===`Effect`&&a[1]!==void 0&&Ke.has(a[1])||o!==void 0&&(p(o.callee,i,`Effect`,`try`)||p(o.callee,i,`Effect`,`tryPromise`)))&&e.report({node:n,messageId:`callbackThrow`})}})),Je=s(c(`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(!p(n.callee,r,`Effect`,`retry`)&&!p(n.callee,r,`Effect`,`repeat`))return;let i=z(n);if(i===void 0)return;let a=v(i,`times`);a!==void 0&&O(a.value,0)&&e.report({node:a,messageId:`zeroTimes`})}})),Ye=o(c(`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`),e=>({ImportDeclaration(t){let n=Ee(t.source.value);if(n===void 0||t.importKind===`type`)return;let r=K(n);for(let n of t.specifiers)if(!(n.type===`ImportSpecifier`&&G(t,n))){if(n.type===`ImportNamespaceSpecifier`){n.local.name!==r&&e.report({node:n.local,messageId:`alias`,data:{alias:r,source:t.source.value}});continue}e.report({node:n,messageId:`namespace`,data:{alias:r,source:t.source.value}})}}})),Xe=s(c(`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`&&l(n.callee)===`sort`&&!p(n.callee,r,`Array`,`sort`)&&e.report({node:n,messageId:`effectArraySort`})}})),Ze=new Set([`toISOString`,`toLocaleDateString`,`toLocaleTimeString`]),Qe=s(c(`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`&&Ze.has(l(n.callee)??``)&&e.report({node:n,messageId:`effectDateTime`})}})),$e=new Set([`Effect.delay`,`Effect.sleep`,`Effect.timeout`,`Effect.timeoutOption`,`Effect.timeoutOrElse`,`Schedule.fixed`,`Schedule.spaced`,`Schedule.windowed`]),et=s(c(`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`),(e,t)=>({CallExpression(n){let r=f(n.callee,t());if(r===void 0||!$e.has(r.join(`.`)))return;let i=g(n,n.arguments.length-1);i?.type===`Literal`&&typeof i.value==`number`&&e.report({node:i,messageId:`effectDuration`})}})),tt=new Set([`base64`,`base64url`,`hex`]);function J(e){return e!==void 0&&[...tt].some(t=>O(e,t))}const nt=s(c(`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((d(n.callee,e,`atob`)||d(n.callee,e,`btoa`))&&n.arguments.length>0){e.report({node:n,messageId:`effectEncoding`});return}let r=u(n.callee),i=r?.join(`.`)===`Buffer.from`&&J(g(n,1)),a=r?.at(-1)===`toString`&&J(g(n,0));(i||a)&&e.report({node:n,messageId:`effectEncoding`})}})),rt=new Set([`fs`,`fs/promises`,`node:fs`,`node:fs/promises`]),it=s(c(`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&&rt.has(n.source.value)&&e.report({node:n.source,messageId:`effectFileSystem`,data:{source:n.source.value}})}}));function Y(e,t,n){return e.type===`CallExpression`&&p(e.callee,t,`Result`,n)?g(e,0):void 0}function X(e,t,n){let r=w(t),i=U(t);if(r===void 0||i?.type!==`ConditionalExpression`)return;let a=Y(i.consequent,n,`succeed`),o=Y(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 at=s(c(`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){X(e,n,t())},FunctionExpression(n){X(e,n,t())}})),ot=s(c(`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&&d(n.callee,e,`Headers`)&&e.report({node:n,messageId:`effectHeaders`})}})),st=s(c(`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.`},`https://www.effect.website/docs/v4/api/effect/Match`),(e,t)=>({SwitchStatement(n){t().hasEffectImport&&e.report({node:n,messageId:`effectMatch`})}})),ct=new Set([`node:path`,`path`]),lt=s(c(`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&&ct.has(n.source.value)&&e.report({node:n.source,messageId:`effectPath`,data:{source:n.source.value}})}})),ut=s(c(`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&&d(n.callee,e,`URL`)&&e.report({node:n,messageId:`effectUrl`})},CallExpression(n){let r=u(n.callee);t().hasEffectImport&&r?.[0]===`URL`&&[`canParse`,`parse`].includes(r[1]??``)&&n.callee.type===`MemberExpression`&&d(n.callee.object,e,`URL`)&&e.report({node:n,messageId:`effectUrl`})}})),dt=s(c(`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=p(n.callee,r,`Effect`,`uninterruptibleMask`)?`uninterruptible`:p(n.callee,r,`Effect`,`interruptibleMask`)?`interruptible`:void 0,a=g(n,0);i!==void 0&&a!==void 0&&h(a)&&!T(a)&&e.report({node:n,messageId:`unusedRestore`,data:{replacement:`Effect.${i}`}})}})),ft=s(c(`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(!p(n.callee,t(),`Effect`,`useSpan`))return;let r=g(n,n.arguments.length-1);r!==void 0&&h(r)&&!T(r)&&e.report({node:n,messageId:`unusedSpan`})}}));function pt(e,t){let n=b(e);if(O(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(p(n,t,`Duration`,`zero`))return!0;if(n.type===`CallExpression`){let e=f(n.callee,t),r=g(n,0);return r!==void 0&&e?.[0]===`Duration`&&O(r,0)}return!1}const mt=s(c(`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=g(n,0);i!==void 0&&p(n.callee,r,`Effect`,`sleep`)&&pt(i,r)&&e.report({node:n,messageId:`zeroSleep`})}})),Z=new Set([`catch`,`catchAll`,`mapError`]);function Q(e,t){let n=V(e,t),r=B(e,`catch`);if(!(n?.[0]===`Effect`&&n[1]!==void 0&&Z.has(n[1])||r!==void 0&&(p(r.callee,t,`Effect`,`try`)||p(r.callee,t,`Effect`,`tryPromise`)))||!e.body)return!1;let i=w(e);return S(e.body,e=>e.type===`NewExpression`&&A(e)&&(i===void 0||!C(e,i.name)))}const ht=s(c(`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){Q(n,t())&&e.report({node:n,messageId:`droppedCause`})},FunctionExpression(n){Q(n,t())&&e.report({node:n,messageId:`droppedCause`})}})),gt=s(c(`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){p(n.callee,t(),`Schema`,`Class`)&&(n.typeArguments?.params.length??0)<2&&e.report({node:n,messageId:`missingBrand`})}}));function _t(e,t){if(!p(e.callee,t,`Effect`,`tryPromise`))return;let n=g(e,0);if(n!==void 0&&h(n))return n;if(n?.type===`ObjectExpression`){let e=v(n,`try`);if(e!==void 0&&h(e.value))return e.value}}const vt=s(c(`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=_t(n,t());if(r===void 0)return;let i=w(r);i===void 0?e.report({node:r,messageId:`missingSignal`}):!i.name.startsWith(`_`)&&!T(r)&&e.report({node:i,messageId:`unusedSignal`})}}));function yt(e,t){let n=e.parent;if(n.type===`CallExpression`&&g(n,0)===e)return p(n.callee,t,`Effect`,`try`)||p(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`&&(p(r.parent.callee,t,`Effect`,`try`)||p(r.parent.callee,t,`Effect`,`tryPromise`))}const $={"alchemy-no-cloudflare-init-finalizer":ee,"alchemy-no-deprecated-docker-constraints":te,"alchemy-no-deprecated-resource":re,"alchemy-no-plaintext-github-secret":ae,"alchemy-no-removed-config-api":oe,"alchemy-no-reserved-eventbridge-default-name":se,"alchemy-no-runtime-config":ce,"alchemy-no-v1-import":le,"alchemy-no-v1-worker-properties":ue,"avoid-data-tagged-error":de,"ban-error-string":R,"cors-credentials-with-wildcard":me,"dual-numeric-arity-with-optional-parameter":ge,"effect-promise-vs-trypromise":_e,"no-already-started-promise":ye,"no-async-effect-try":be,"no-discarded-run-promise":xe,"no-discarded-schema-checks":Ce,"no-empty-effect-callback":ke,"no-empty-schema-struct":Ae,"no-effect-alchemy-barrel-imports":Oe,"no-function-config-default":je,"no-hash-as-identity":Me,"no-logging-in-catch":Ie,"no-multi-shot-effect-callback":Re,"no-non-json-schema-annotation":He,"no-option-of-service":Ue,"no-overwritten-discriminant":We,"no-service-option-get-or-throw":Ge,"no-throw-in-effect-callback":qe,"no-zero-retry-times":Je,"prefer-effect-alchemy-namespace-imports":Ye,"prefer-effect-array-sort":Xe,"prefer-effect-datetime":Qe,"prefer-effect-duration":et,"prefer-effect-encoding":nt,"prefer-effect-filesystem":it,"prefer-effect-filter":at,"prefer-effect-headers":ot,"prefer-effect-match":st,"prefer-effect-path":lt,"prefer-effect-url":ut,"prefer-uninterruptible":dt,"prefer-with-span":ft,"prefer-yield-now":mt,"preserve-caught-error":ht,"require-schema-class-brand":gt,"require-try-promise-abort-signal":vt,"throw-in-effect-gen":s(c(`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&&!h(i);)i=i.parent??void 0;if(i===void 0||yt(i,r))return;let a=D(i),o=a!==void 0&&[`fn`,`fnUntraced`,`gen`].some(e=>p(a.callee,r,`Effect`,e)),s=a?.callee,c=s?.type===`CallExpression`&&[`fn`,`fnUntraced`].some(e=>p(s.callee,r,`Effect`,e));(o||c)&&e.report({node:n,messageId:`throwInGen`})}}))},bt=new Set([`prefer-effect-filesystem`,`prefer-effect-path`]),xt=Object.fromEntries(Object.keys($).filter(e=>!bt.has(e)).map(e=>[`2digits/${e}`,`error`])),St=t({meta:{name:`@2digits/oxlint-plugin`},rules:$});export{St as default,xt as recommendedRules,$ as rules};
|
|
1
|
+
import{defineRule as e,eslintCompatPlugin as t}from"@oxlint/plugins";const n={bindings:new Map,hasEffectImport:!1};function r(e){return e.imported.type===`Identifier`?e.imported.name:typeof e.imported.value==`string`?e.imported.value:void 0}function i(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 a(e){let t=new Map,n=!1;for(let a of e.body){if(a.type!==`ImportDeclaration`)continue;let e=a.source.value;(e===`effect`||e.startsWith(`effect/`)||e.startsWith(`@effect/`))&&(n=!0);let o=i(e);if(o!==void 0)for(let e of a.specifiers){if(e.type===`ImportNamespaceSpecifier`||e.type===`ImportDefaultSpecifier`){t.set(e.local.name,o);continue}let n=r(e);n!==void 0&&t.set(e.local.name,[...o,n])}}return{bindings:t,hasEffectImport:n}}function o(t,n){return e({meta:t,createOnce:n})}function s(t,r){return e({meta:t,createOnce(e){let t=n,{before:i,Program:o,...s}=r(e,()=>t);return{before(){t=n,i?.()},Program(e){t=a(e),o?.(e)},...s}}})}function c(e,t,n,r){return{type:e,docs:{description:t,recommended:!0,...r===void 0?{}:{url:r}},schema:[],messages:n}}function l(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 u(e){let t=[],n=e;for(;n.type===`ChainExpression`||n.type===`MemberExpression`;){if(n.type===`ChainExpression`){n=n.expression;continue}let e=l(n);if(e===void 0)return;t.unshift(e),n=n.object}return n.type===`Identifier`?[n.name,...t]:void 0}function d(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 f(e,t){let n=u(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 p(e,t,n,r){let i=f(e,t);return i?.length===2&&i[0]===n&&i[1]===r}function m(e,t,n){let r=f(e,t);return r?.length===n.length&&r.every((e,t)=>e===n[t])}function h(e){return e?.type===`ArrowFunctionExpression`||e?.type===`FunctionExpression`}function g(e,t){let n=e.arguments[t];return n===void 0||n.type===`SpreadElement`?void 0:n}function _(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 v(e,t){for(let n of e.properties)if(n.type===`Property`&&_(n)===t)return n}function ee(e){return[`ParenthesizedExpression`,`TSAsExpression`,`TSNonNullExpression`,`TSSatisfiesExpression`,`TSTypeAssertion`].includes(e.type)}function y(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 b(e,t){let n=[e],r=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 x(e,t){return b(e,e=>e.type===`Identifier`&&e.name===t)}function S(e){let t=e.params[0];return t?.type===`Identifier`?t:void 0}function C(e){let t=S(e);return t===void 0||!e.body||t.name.startsWith(`_`)?!1:x(e.body,t.name)}function w(e){let t=e.parent;for(;t;){if(h(t))return t;t=t.parent}}function T(e){let t=e.parent;if(t.type===`CallExpression`&&t.arguments.includes(e))return t}function E(e,t){return e.type===`Literal`&&e.value===t}function ne(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 D(e){return u(e.callee)?.at(-1)?.endsWith(`Error`)===!0}const re=new Set([`alarm`,`fetch`,`queue`,`rpc`,`scheduled`,`tail`,`trace`,`webSocketClose`,`webSocketError`,`webSocketMessage`]);function ie(e,t){return m(e,t,[`Cloudflare`,`Worker`])||m(e,t,[`Cloudflare`,`Workers`,`Worker`])}function O(e,t){let n=e.parent;for(;n;){if(n.type===`CallExpression`&&ie(n.callee,t))return n;n=n.parent}}function k(e,t){let n=w(e),r=n===void 0?void 0:T(n);return r!==void 0&&p(r.callee,t,`Effect`,`gen`)?r:void 0}function ae(e){let t=e.parent;for(;t;){if(h(t))return;if(t.type===`Property`){let e=_(t);if(e!==void 0&&re.has(e))return e}t=t.parent}}const oe=s(c(`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(!p(n.callee,r,`Effect`,`addFinalizer`))return;let i=k(n,r);i!==void 0&&O(i,r)?.arguments.includes(i)&&e.report({node:n,messageId:`finalizer`})}}));function A(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 j(e,t){let n=u(t)?.[0];return(n===void 0?void 0:A(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 M(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`&&A(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 N(e,t){let n=new Set;return e.properties.every(e=>{if(e.type!==`Property`||e.computed||e.method||e.kind!==`init`)return!1;let r=e.key.type===`Identifier`?e.key.name:e.key.type===`Literal`?String(e.key.value):void 0;return r===void 0||r===t||n.has(r)?!1:(n.add(r),!0)})}const se=s({...c(`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(!p(n.callee,t(),`Docker`,`Service`))return;let r=g(n,1),i=r?.type===`ObjectExpression`?v(r,`constraints`):void 0;i!==void 0&&e.report({node:i,messageId:`constraints`,fix(t){if(j(e,n.callee)&&r?.type===`ObjectExpression`&&N(r,`placement`))return t.replaceText(i,`placement: { ${e.sourceCode.getText(i)} }`)}})}})),ce=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`]]),le=s(c(`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=f(n.callee,t());if(r===void 0)return;let i=r.join(`.`),a=ce.get(i);a!==void 0&&e.report({node:n.callee,messageId:`deprecated`,data:{api:i,replacement:a}})}}));function ue(e,t){let n=y(e);if(n.type===`Literal`&&typeof n.value==`string`||n.type===`TemplateLiteral`)return!0;let r=u(n);return r?.[0]===`process`&&r[1]===`env`||n.type===`CallExpression`&&p(n.callee,t,`Config`,`string`)}const de=s(c(`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(!p(n.callee,r,`GitHub`,`Secret`))return;let i=g(n,1),a=i?.type===`ObjectExpression`?v(i,`value`):void 0;a!==void 0&&ue(a.value,r)&&e.report({node:a.value,messageId:`plaintext`})}})),fe=s(c(`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=f(n.callee,t());r?.[0]===`Alchemy`&&(r[1]===`Secret`||r[1]===`Variable`)&&e.report({node:n.callee,messageId:`removed`,data:{api:r[1]}})}})),pe=s(c(`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(!m(n.callee,t(),[`AWS`,`EventBridge`,`EventBus`]))return;let r=g(n,1),i=r?.type===`ObjectExpression`?v(r,`name`):void 0;i!==void 0&&E(i.value,`default`)&&e.report({node:i.value,messageId:`reserved`})}})),me=s(c(`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`||f(i.callee,r)?.[0]!==`Config`)return;let a=k(n,r),o=a===void 0?void 0:ae(a);a!==void 0&&o!==void 0&&O(a,r)!==void 0&&e.report({node:i,messageId:`runtime`,data:{handler:o}})}})),he=o(c(`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){let n=`alchemy/${r===`aws`?`AWS`:`Cloudflare`}`;e.report({node:t.source,messageId:`providerImport`,data:{replacement:n}})}}})),ge=s({...c(`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(!ie(n.callee,t()))return;let r=g(n,1);if(r?.type===`ObjectExpression`)for(let[t,i]of[[`entrypoint`,`main`],[`bindings`,`env`]]){let a=v(r,t);a!==void 0&&e.report({node:a,messageId:`property`,data:{old:t,replacement:i},fix(o){if(j(e,n.callee)&&N(r,i))return o.replaceText(a.key,a.shorthand?`${i}: ${t}`:i)}})}}})),_e=s(c(`suggestion`,`Prefer schema-based tagged errors so errors have a serializable contract.`,{taggedError:`Prefer Schema.TaggedErrorClass over Data.TaggedError.`}),(e,t)=>({CallExpression(n){p(n.callee,t(),`Data`,`TaggedError`)&&e.report({node:n.callee,messageId:`taggedError`})}})),ve=new Set([`error`,`err`,`e`,`cause`,`exception`,`ex`]);function P(e){return e?.type===`Identifier`&&ve.has(e.name)?e.name:void 0}function F(e){if(e.type!==`CallExpression`||e.arguments.length!==1)return!1;let t=u(e.callee);return t?.at(-1)===`String`&&t.length<=2}const ye=o({...c(`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=g(t,0);if(n===void 0||!F(n)||!D(t))return;let r=g(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(F(t)){if(t.parent.type===`NewExpression`&&t.parent.arguments[0]===t&&D(t.parent))return;let n=P(t.arguments[0]);n!==void 0&&e.report({node:t,messageId:`errorString`,data:{name:n}});return}if(t.callee.type===`MemberExpression`&&u(t.callee)?.at(-1)===`toString`&&t.arguments.length===0){let n=P(t.callee.object);n!==void 0&&e.report({node:t,messageId:`errorString`,data:{name:n}})}},TemplateLiteral(t){let[n,r]=t.quasis,i=P(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 I(e){for(let t of e.arguments)if(t.type===`ObjectExpression`)return t}function L(e,t){let n=e.parent;if(n.type!==`Property`||_(n)!==t)return;let r=n.parent,i=r.parent;return r.type===`ObjectExpression`&&i?.type===`CallExpression`?i:void 0}function R(e,t){let n=T(e);return n===void 0?void 0:f(n.callee,t)}function z(e){let t=y(e);if(t.type===`NewExpression`)return u(t.callee)?.join(`.`)===`Promise`;if(t.type!==`CallExpression`)return!1;let n=u(t.callee);return n?.join(`.`)===`fetch`||n?.[0]===`Promise`&&n[1]!==`withResolvers`||[`catch`,`finally`,`then`].includes(n?.at(-1)??``)||h(t.callee)&&t.callee.async}function B(e){if(e.body){if(e.body.type!==`BlockStatement`)return y(e.body);if(e.body.body.length===1&&e.body.body[0]?.type===`ReturnStatement`&&e.body.body[0].argument)return y(e.body.body[0].argument)}}function be(e){let t=y(e);return E(t,`*`)?!0:t.type===`ArrayExpression`&&(t.elements.length===0||t.elements.some(e=>!e||e.type===`SpreadElement`?!1:E(e,`*`)))}const xe=s(c(`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(!p(n.callee,r,`HttpMiddleware`,`cors`)&&!p(n.callee,r,`HttpRouter`,`cors`)&&!p(n.callee,r,`HttpApiBuilder`,`middlewareCors`))return;let i=I(n);if(i===void 0||!E(v(i,`credentials`)?.value??i,!0))return;let a=v(i,`allowedOrigins`);(a===void 0||be(a.value))&&e.report({node:n,messageId:`wildcard`})}}));function Se(e){return e.type===`AssignmentPattern`||e.type===`RestElement`||e.optional===!0}const Ce=s(c(`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=g(n,0),i=g(n,1);i!==void 0&&p(n.callee,t(),`Function`,`dual`)&&r?.type===`Literal`&&typeof r.value==`number`&&h(i)&&i.params.some(e=>Se(e))&&e.report({node:r,messageId:`unsafeArity`})}})),we=s(c(`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){p(n.callee,t(),`Effect`,`promise`)&&e.report({node:n.callee,messageId:`tryPromise`})}}));function Te(e,t){if(!p(e.callee,t,`Effect`,`promise`)&&!p(e.callee,t,`Effect`,`tryPromise`))return;let n=g(e,0);if(n!==void 0&&h(n))return n;if(n?.type===`ObjectExpression`){let e=v(n,`try`);if(e!==void 0&&h(e.value))return e.value}}const Ee=s(c(`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=new Set;return{before(){n=new Set},VariableDeclarator(e){e.id.type===`Identifier`&&e.init&&z(e.init)&&n.add(e.id.name)},CallExpression(r){let i=Te(r,t()),a=i===void 0?void 0:B(i);a?.type===`Identifier`&&n.has(a.name)&&e.report({node:a,messageId:`prestarted`})}}}),De=s(c(`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(!p(n.callee,t(),`Effect`,`try`))return;let r=g(n,0),i=r!==void 0&&h(r)?r:void 0;if(i===void 0&&r?.type===`ObjectExpression`){let e=v(r,`try`)?.value;e!==void 0&&h(e)&&(i=e)}let a=i===void 0?void 0:B(i);i!==void 0&&(i.async||a!==void 0&&z(a))&&e.report({node:i,messageId:`asyncTry`})}})),Oe=s(c(`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=p(n.callee,r,`Effect`,`runPromise`),a=n.callee.type===`CallExpression`&&p(n.callee.callee,r,`Effect`,`runPromiseWith`);(i||a)&&ne(n)&&e.report({node:n,messageId:`discarded`})}}));function ke(e,t){let n=y(e);if(n.type===`CallExpression`&&n.callee.type===`MemberExpression`&&l(n.callee)===t)return n}const Ae=s(c(`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=l(n.callee);if(r===void 0||![`mapElements`,`mapFields`,`mapMembers`].includes(r)||ke(n.callee.object,`check`)===void 0)return;let i=n.arguments.find(e=>e.type===`ObjectExpression`),a=i?.type===`ObjectExpression`?v(i,`unsafePreserveChecks`):void 0;a!==void 0&&E(a.value,!0)||e.report({node:n,messageId:`discarded`,data:{method:r}})}})),je={Array:`Arr`,Boolean:`Bool`,Equal:`Eq`,Function:`Fn`,Number:`Num`,Option:`Opt`,Predicate:`P`,Record:`R`,String:`Str`};function V(e){return e===`@effect/vitest`||e.startsWith(`@effect/vitest/`)}function H(e,t){return e.importKind===`type`||t?.importKind===`type`}function U(e){return je[e]??e}function W(e,t){if(e===`effect`||e===`alchemy`||/^@effect\/[^/]+$/u.test(e)&&!V(e))return`${e}/${t}`}function G(e){if(V(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 Me(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)&&!H(t,n)?W(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 K(e,t,n){let r=G(t.source.value);if(r===void 0||t.attributes.length>0||e.sourceCode.getCommentsInside(t).length>0)return;let i=U(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`&&H(t,r)){if(r.local.name===i)return;c.push(e.sourceCode.getText(r));continue}let o=Ne(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 Ne(e,t,n,r){let i=t.find(t=>t.name===e.local.name);if(i!==void 0){if(e.type===`ImportNamespaceSpecifier`)return q(i,n,!1,r);if(e.imported.type===`Identifier`)return q(i,`${n}.${e.imported.name}`,!0,r)}}function q(e,t,n,r){let i=[],a=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 Pe(e){return e?.imported.type===`Identifier`?e.imported.name:typeof e?.imported.value==`string`?e.imported.value:void 0}const Fe=o({...c(`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`||H(t,n))continue;let r=Pe(n),i=r===void 0||!/^\p{Lu}/u.test(r)?void 0:W(t.source.value,r);r!==void 0&&i!==void 0&&e.report({node:n,messageId:`barrelImport`,data:{alias:U(r),source:i},fix:n=>Me(e,t,n)})}}})),Ie=s({...c(`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(!p(n.callee,t(),`Effect`,`callback`)&&!p(n.callee,t(),`Effect`,`async`))return;let r=g(n,0);r!==void 0&&h(r)&&r.body?.type===`BlockStatement`&&r.body.body.length===0&&e.report({node:n,messageId:`emptyCallback`,fix(t){if(!j(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=M(e,n,`effect/Effect`,`Effect`,t);return[...i.fixes,t.replaceText(n,`${i.name}.never`)]}})}})),Le=s(c(`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=g(n,0);p(n.callee,t(),`Schema`,`Struct`)&&r?.type===`ObjectExpression`&&r.properties.length===0&&e.report({node:n,messageId:`emptyStruct`})}})),Re=s(c(`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(!p(n.callee,t(),`Config`,`withDefault`))return;let r=g(n,n.arguments.length-1);r!==void 0&&h(r)&&r.params.length===0&&e.report({node:r,messageId:`functionDefault`})}}));function J(e,t){return e.type===`CallExpression`&&p(e.callee,t,`Hash`,`hash`)}const ze=s(c(`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=new Set;function r(e){return J(e,t())||e.type===`Identifier`&&n.has(e.name)}return{before(){n=new Set},VariableDeclarator(e){e.id.type===`Identifier`&&e.init&&J(e.init,t())&&n.add(e.id.name)},CallExpression(t){if(t.callee.type!==`MemberExpression`||![`delete`,`get`,`has`,`set`].includes(u(t.callee)?.at(-1)??``))return;let n=g(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`})}}}),Be=new Set([`catch`,`catchAll`,`catchAllCause`,`catchIf`,`catchSome`,`catchSomeCause`,`catchTag`,`orElse`,`orElseFail`,`orElseSucceed`]),Ve=new Set([`log`,`logDebug`,`logError`,`logInfo`,`logTrace`,`logWarning`]);function He(e,t){let n=e.parent;for(;n;){if(h(n)){let e=T(n);if(e?.arguments.at(-1)===n){let n=f(e.callee,t),r=n?.[1];if(r!==void 0&&n?.[0]===`Effect`&&Be.has(r))return{method:r}}}n=n.parent}}const Ue=s(c(`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=f(n.callee,r),a=i?.[1]!==void 0&&i[0]===`Effect`&&Ve.has(i[1])?i.join(`.`):void 0;if(a===void 0)return;let o=He(n,r);o!==void 0&&e.report({node:n,messageId:`logging`,data:{logger:a,catchMethod:o.method}})}}));function We(e,t){let n=u(e.callee)?.at(-1);if(n===void 0||![`addEventListener`,`on`,`setInterval`].includes(n))return!1;if(n===`addEventListener`){let t=g(e,2);if(t?.type===`ObjectExpression`){let e=v(t,`once`);if(e!==void 0&&E(e.value,!0))return!1}}let r=g(e,n===`setInterval`?0:1);return r!==void 0&&x(r,t)}const Ge=s(c(`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(!p(n.callee,t(),`Effect`,`callback`))return;let r=g(n,0);if(r===void 0||!h(r))return;let i=S(r)?.name,a=r.body;i!==void 0&&a&&b(a,e=>e.type===`CallExpression`&&We(e,i))&&e.report({node:n,messageId:`multiShot`})}}));function Ke(e){return e.type===`Literal`&&typeof e.value==`bigint`||e.type===`Identifier`&&[`NaN`,`Infinity`,`undefined`].includes(e.name)||h(e)||e.type===`CallExpression`&&u(e.callee)?.at(-1)===`Symbol`}function qe(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 Je(e){let t=[e];for(;t.length>0;){let e=t.pop();if(e===void 0)continue;let n=y(e);if(Ke(n))return n;qe(n,t)}}const Ye=s(c(`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=f(n.callee,r),a=n.callee.type===`MemberExpression`?l(n.callee):i?.[0]===`Schema`?i[1]:void 0;if(a===void 0||![`annotate`,`annotateEncoded`,`annotateKey`].includes(a))return;let o=I(n);if(o!==void 0&&v(o,`jsonSchema`)===void 0)for(let t of[`default`,`examples`]){let n=v(o,t);if(n===void 0)continue;let r=Je(n.value);r!==void 0&&e.report({node:r,messageId:`nonJson`})}}})),Xe=s(c(`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=p(n.callee,r,`Effect`,`option`)||p(n.callee,r,`Effect`,`either`),a=g(n,0);if(i&&a?.type===`CallExpression`&&p(a.callee,r,`Effect`,`service`)){e.report({node:n,messageId:`mandatory`});return}if(n.callee.type!==`MemberExpression`||u(n.callee)?.at(-1)!==`pipe`)return;let o=y(n.callee.object),s=g(n,0);s!==void 0&&o.type===`CallExpression`&&p(o.callee,r,`Effect`,`service`)&&(p(s,r,`Effect`,`option`)||p(s,r,`Effect`,`either`))&&e.report({node:n,messageId:`mandatory`})}})),Ze=s(c(`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)===`_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`})}})),Qe=s(c(`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(p(n.callee,r,`Option`,`getOrThrow`)||p(n.callee,r,`Option`,`getOrThrowWith`)){let t=g(n,0),i=t?.type===`YieldExpression`?t.argument:t;i?.type===`CallExpression`&&p(i.callee,r,`Effect`,`serviceOption`)&&e.report({node:n,messageId:`getOrThrow`});return}if(n.callee.type!==`MemberExpression`||u(n.callee)?.at(-1)!==`pipe`)return;let i=y(n.callee.object),a=g(n,0);if(i.type!==`CallExpression`||!p(i.callee,r,`Effect`,`serviceOption`)||a?.type!==`CallExpression`||!p(a.callee,r,`Effect`,`map`))return;let o=g(a,0);o!==void 0&&(p(o,r,`Option`,`getOrThrow`)||p(o,r,`Option`,`getOrThrowWith`))&&e.report({node:n,messageId:`getOrThrow`})}})),$e=new Set([`andThen`,`map`,`mapError`,`tap`,`tapError`,`tapErrorCause`]),et=s(c(`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=w(n);if(r===void 0)return;let i=t(),a=R(r,i),o=L(r,`catch`);(a?.[0]===`Effect`&&a[1]!==void 0&&$e.has(a[1])||o!==void 0&&(p(o.callee,i,`Effect`,`try`)||p(o.callee,i,`Effect`,`tryPromise`)))&&e.report({node:n,messageId:`callbackThrow`})}})),tt=s(c(`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(!p(n.callee,r,`Effect`,`retry`)&&!p(n.callee,r,`Effect`,`repeat`))return;let i=I(n);if(i===void 0)return;let a=v(i,`times`);a!==void 0&&E(a.value,0)&&e.report({node:a,messageId:`zeroTimes`})}})),nt=o({...c(`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=G(t.source.value);if(n===void 0||t.importKind===`type`)return;let r=U(n);for(let n of t.specifiers)if(!(n.type===`ImportSpecifier`&&H(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=>K(e,t,n)});continue}e.report({node:n,messageId:`namespace`,data:{alias:r,source:t.source.value},fix:n=>K(e,t,n)})}}})),rt=s(c(`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`&&l(n.callee)===`sort`&&!p(n.callee,r,`Array`,`sort`)&&e.report({node:n,messageId:`effectArraySort`})}})),it=new Set([`toISOString`,`toLocaleDateString`,`toLocaleTimeString`]),at=s(c(`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`&&it.has(l(n.callee)??``)&&e.report({node:n,messageId:`effectDateTime`})}})),ot=new Set([`Effect.delay`,`Effect.sleep`,`Effect.timeout`,`Effect.timeoutOption`,`Effect.timeoutOrElse`,`Schedule.fixed`,`Schedule.spaced`,`Schedule.windowed`]),st=s({...c(`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=f(n.callee,t());if(r===void 0||!ot.has(r.join(`.`)))return;let i=g(n,n.arguments.length-1);i?.type===`Literal`&&typeof i.value==`number`&&e.report({node:i,messageId:`effectDuration`,fix(t){if(!j(e,n.callee))return;let r=M(e,n,`effect/Duration`,`Duration`,t);return[...r.fixes,t.replaceText(i,`${r.name}.millis(${e.sourceCode.getText(i)})`)]}})}})),ct=new Set([`base64`,`base64url`,`hex`]);function Y(e){return e!==void 0&&[...ct].some(t=>E(e,t))}const lt=s(c(`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((d(n.callee,e,`atob`)||d(n.callee,e,`btoa`))&&n.arguments.length>0){e.report({node:n,messageId:`effectEncoding`});return}let r=u(n.callee),i=r?.join(`.`)===`Buffer.from`&&Y(g(n,1)),a=r?.at(-1)===`toString`&&Y(g(n,0));(i||a)&&e.report({node:n,messageId:`effectEncoding`})}})),ut=new Set([`fs`,`fs/promises`,`node:fs`,`node:fs/promises`]),dt=s(c(`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&&ut.has(n.source.value)&&e.report({node:n.source,messageId:`effectFileSystem`,data:{source:n.source.value}})}}));function X(e,t,n){return e.type===`CallExpression`&&p(e.callee,t,`Result`,n)?g(e,0):void 0}function Z(e,t,n){let r=S(t),i=B(t);if(r===void 0||i?.type!==`ConditionalExpression`)return;let a=X(i.consequent,n,`succeed`),o=X(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 ft=s(c(`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){Z(e,n,t())},FunctionExpression(n){Z(e,n,t())}})),pt=s(c(`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&&d(n.callee,e,`Headers`)&&e.report({node:n,messageId:`effectHeaders`})}})),mt=s(c(`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.`},`https://www.effect.website/docs/v4/api/effect/Match`),(e,t)=>({SwitchStatement(n){t().hasEffectImport&&e.report({node:n,messageId:`effectMatch`})}})),ht=new Set([`node:path`,`path`]),gt=s(c(`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&&ht.has(n.source.value)&&e.report({node:n.source,messageId:`effectPath`,data:{source:n.source.value}})}})),_t=s(c(`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&&d(n.callee,e,`URL`)&&e.report({node:n,messageId:`effectUrl`})},CallExpression(n){let r=u(n.callee);t().hasEffectImport&&r?.[0]===`URL`&&[`canParse`,`parse`].includes(r[1]??``)&&n.callee.type===`MemberExpression`&&d(n.callee.object,e,`URL`)&&e.report({node:n,messageId:`effectUrl`})}})),vt=s(c(`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=p(n.callee,r,`Effect`,`uninterruptibleMask`)?`uninterruptible`:p(n.callee,r,`Effect`,`interruptibleMask`)?`interruptible`:void 0,a=g(n,0);i!==void 0&&a!==void 0&&h(a)&&!C(a)&&e.report({node:n,messageId:`unusedRestore`,data:{replacement:`Effect.${i}`}})}})),yt=s(c(`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(!p(n.callee,t(),`Effect`,`useSpan`))return;let r=g(n,n.arguments.length-1);r!==void 0&&h(r)&&!C(r)&&e.report({node:n,messageId:`unusedSpan`})}}));function bt(e,t){let n=y(e);if(E(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(p(n,t,`Duration`,`zero`))return!0;if(n.type===`CallExpression`){let e=f(n.callee,t),r=g(n,0);return r!==void 0&&e?.[0]===`Duration`&&E(r,0)}return!1}const xt=s(c(`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=g(n,0);i!==void 0&&p(n.callee,r,`Effect`,`sleep`)&&bt(i,r)&&e.report({node:n,messageId:`zeroSleep`})}})),St=new Set([`catch`,`catchAll`,`mapError`]);function Q(e,t){let n=R(e,t),r=L(e,`catch`);if(!(n?.[0]===`Effect`&&n[1]!==void 0&&St.has(n[1])||r!==void 0&&(p(r.callee,t,`Effect`,`try`)||p(r.callee,t,`Effect`,`tryPromise`)))||!e.body)return!1;let i=S(e);return b(e.body,e=>e.type===`NewExpression`&&D(e)&&(i===void 0||!x(e,i.name)))}const Ct=s(c(`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){Q(n,t())&&e.report({node:n,messageId:`droppedCause`})},FunctionExpression(n){Q(n,t())&&e.report({node:n,messageId:`droppedCause`})}})),wt=s(c(`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){p(n.callee,t(),`Schema`,`Class`)&&(n.typeArguments?.params.length??0)<2&&e.report({node:n,messageId:`missingBrand`})}}));function Tt(e,t){if(!p(e.callee,t,`Effect`,`tryPromise`))return;let n=g(e,0);if(n!==void 0&&h(n))return n;if(n?.type===`ObjectExpression`){let e=v(n,`try`);if(e!==void 0&&h(e.value))return e.value}}const Et=s(c(`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=Tt(n,t());if(r===void 0)return;let i=S(r);i===void 0?e.report({node:r,messageId:`missingSignal`}):!i.name.startsWith(`_`)&&!C(r)&&e.report({node:i,messageId:`unusedSignal`})}}));function Dt(e,t){let n=e.parent;if(n.type===`CallExpression`&&g(n,0)===e)return p(n.callee,t,`Effect`,`try`)||p(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`&&(p(r.parent.callee,t,`Effect`,`try`)||p(r.parent.callee,t,`Effect`,`tryPromise`))}const $={"alchemy-no-cloudflare-init-finalizer":oe,"alchemy-no-deprecated-docker-constraints":se,"alchemy-no-deprecated-resource":le,"alchemy-no-plaintext-github-secret":de,"alchemy-no-removed-config-api":fe,"alchemy-no-reserved-eventbridge-default-name":pe,"alchemy-no-runtime-config":me,"alchemy-no-v1-import":he,"alchemy-no-v1-worker-properties":ge,"avoid-data-tagged-error":_e,"ban-error-string":ye,"cors-credentials-with-wildcard":xe,"dual-numeric-arity-with-optional-parameter":Ce,"effect-promise-vs-trypromise":we,"no-already-started-promise":Ee,"no-async-effect-try":De,"no-discarded-run-promise":Oe,"no-discarded-schema-checks":Ae,"no-empty-effect-callback":Ie,"no-empty-schema-struct":Le,"no-effect-alchemy-barrel-imports":Fe,"no-function-config-default":Re,"no-hash-as-identity":ze,"no-logging-in-catch":Ue,"no-multi-shot-effect-callback":Ge,"no-non-json-schema-annotation":Ye,"no-option-of-service":Xe,"no-overwritten-discriminant":Ze,"no-service-option-get-or-throw":Qe,"no-throw-in-effect-callback":et,"no-zero-retry-times":tt,"prefer-effect-alchemy-namespace-imports":nt,"prefer-effect-array-sort":rt,"prefer-effect-datetime":at,"prefer-effect-duration":st,"prefer-effect-encoding":lt,"prefer-effect-filesystem":dt,"prefer-effect-filter":ft,"prefer-effect-headers":pt,"prefer-effect-match":mt,"prefer-effect-path":gt,"prefer-effect-url":_t,"prefer-uninterruptible":vt,"prefer-with-span":yt,"prefer-yield-now":xt,"preserve-caught-error":Ct,"require-schema-class-brand":wt,"require-try-promise-abort-signal":Et,"throw-in-effect-gen":s(c(`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&&!h(i);)i=i.parent??void 0;if(i===void 0||Dt(i,r))return;let a=T(i),o=a!==void 0&&[`fn`,`fnUntraced`,`gen`].some(e=>p(a.callee,r,`Effect`,e)),s=a?.callee,c=s?.type===`CallExpression`&&[`fn`,`fnUntraced`].some(e=>p(s.callee,r,`Effect`,e));(o||c)&&e.report({node:n,messageId:`throwInGen`})}}))},Ot=new Set([`prefer-effect-filesystem`,`prefer-effect-path`]),kt=Object.fromEntries(Object.keys($).filter(e=>!Ot.has(e)).map(e=>[`2digits/${e}`,`error`])),At=t({meta:{name:`@2digits/oxlint-plugin`},rules:$});export{At as default,kt as recommendedRules,$ as rules};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@2digits/oxlint-plugin",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "Custom Oxlint rules for 2digits projects.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"2digits",
|
|
@@ -28,22 +28,22 @@
|
|
|
28
28
|
"access": "public"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@oxlint/plugins": "1.
|
|
31
|
+
"@oxlint/plugins": "1.83.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@2digits/tsconfig": "0.8.
|
|
34
|
+
"@2digits/tsconfig": "0.8.8",
|
|
35
35
|
"@arethetypeswrong/core": "0.18.5",
|
|
36
|
-
"
|
|
37
|
-
"oxlint": "1.81.0",
|
|
36
|
+
"oxlint": "1.83.0",
|
|
38
37
|
"publint": "0.3.24",
|
|
39
|
-
"typescript": "
|
|
40
|
-
"vite-plus": "0.3.
|
|
38
|
+
"typescript": "7.0.2",
|
|
39
|
+
"vite-plus": "0.3.2",
|
|
40
|
+
"vitest": "5.0.0"
|
|
41
41
|
},
|
|
42
42
|
"public": true,
|
|
43
43
|
"scripts": {
|
|
44
44
|
"build": "vp pack --minify",
|
|
45
45
|
"dev": "vp pack --watch",
|
|
46
|
-
"test": "
|
|
47
|
-
"types": "
|
|
46
|
+
"test": "vitest run",
|
|
47
|
+
"types": "tsc --noEmit"
|
|
48
48
|
}
|
|
49
49
|
}
|