@2digits/oxlint-plugin 0.0.0-tegami-trusted-publish-setup → 0.0.3

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 ADDED
@@ -0,0 +1,32 @@
1
+ @2digits/oxlint-plugin includes behavior adapted from these projects:
2
+
3
+ @systemfsoftware/oxlint-plugin
4
+ Copyright 2025 SystemF Software LLC
5
+ https://github.com/systemfsoftware/systemfsoftware
6
+ Licensed under the Apache License, Version 2.0.
7
+
8
+ oxlint-plugin-effect
9
+ Copyright 2025 Moritz Süßer and contributors
10
+ https://github.com/mpsuesser/oxlint-plugin-effect
11
+ Licensed under the MIT License.
12
+
13
+ Permission is hereby granted, free of charge, to any person obtaining a copy
14
+ of this software and associated documentation files (the "Software"), to deal
15
+ in the Software without restriction, including without limitation the rights
16
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
+ copies of the Software, and to permit persons to whom the Software is
18
+ furnished to do so, subject to the following conditions:
19
+
20
+ The above copyright notice and this permission notice shall be included in all
21
+ copies or substantial portions of the Software.
22
+
23
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
+ SOFTWARE.
30
+
31
+ The full Apache License 2.0 text is available at:
32
+ https://www.apache.org/licenses/LICENSE-2.0
package/README.md CHANGED
@@ -1,6 +1,62 @@
1
- # Placeholder package
2
-
3
- This empty package was published by [Tegami](https://tegami.fuma-nama.dev) to configure npm trusted publishing.
4
-
5
- The real package contents will be published via CI with OIDC.
6
-
1
+ # @2digits/oxlint-plugin
2
+
3
+ Custom [Oxlint JavaScript plugin](https://oxc.rs/docs/guide/usage/linter/writing-js-plugins.html) rules used by
4
+ `@2digits/oxlint-config`.
5
+
6
+ The recommended set is enabled by default by `@2digits/oxlint-config`. The opt-in `prefer-effect-filesystem` and
7
+ `prefer-effect-path` rules are excluded because the configured `@effect/tsgo/nodeBuiltinImport` diagnostic already
8
+ enforces those imports more broadly. To register the plugin directly:
9
+
10
+ ```ts
11
+ import { defineConfig } from 'oxlint';
12
+
13
+ import { recommendedRules } from '@2digits/oxlint-plugin';
14
+
15
+ export default defineConfig({
16
+ jsPlugins: [{ name: '2digits', specifier: import.meta.resolve('@2digits/oxlint-plugin') }],
17
+ rules: recommendedRules,
18
+ });
19
+ ```
20
+
21
+ ## Rules
22
+
23
+ The package exports all rules as `rules`, their names as `RuleName`, and the default error-level configuration as
24
+ `recommendedRules`.
25
+
26
+ - Copied and adapted Effect practices: `avoid-data-tagged-error`, `ban-error-string`,
27
+ `effect-promise-vs-trypromise`, `no-logging-in-catch`, and `throw-in-effect-gen`.
28
+ - Syntax-safe Effect diagnostics proposed in open `Effect-TS/tsgo` issues: the remaining `cors-*`, `dual-*`,
29
+ `no-*`, `prefer-*`, `preserve-*`, and `require-*` Effect rules.
30
+ - Effect v4 API guidance for Array, DateTime, Duration, Encoding, FileSystem, Filter, Headers, Match, Path, and Url,
31
+ plus interruptible `Effect.tryPromise` thunks.
32
+ - Effect and Alchemy import policy: namespace imports from PascalCase submodule entrypoints, canonical Effect aliases,
33
+ and no root-barrel module imports. `@effect/vitest` and lowercase unstable barrels are intentionally exempt.
34
+ - Alchemy v2 practices: every `alchemy-*` rule.
35
+
36
+ See each rule's `meta.docs.url` for its upstream rule, issue, or framework documentation. Copied-code attribution is in
37
+ [`NOTICE`](./NOTICE).
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
+
46
+ ## Adding a rule
47
+
48
+ Oxlint's JavaScript plugin API is currently alpha and does not expose type information. Keep rules syntax-safe and leave
49
+ semantic Effect checks to `@effect/tsgo` / `@effect/language-service`.
50
+
51
+ Oxfmt formats imports but does not enforce package-specific import architecture. The Effect language service's
52
+ `namespaceImportPackages` and `importAliases` settings guide generated auto-imports only, so the plugin enforces the same
53
+ policy for handwritten imports.
54
+
55
+ 1. Add one rule file under `src/rules/alchemy` or `src/rules/effect` with `defineRule` through `defineSyntaxRule` or
56
+ `defineEffectRule`.
57
+ 2. Register it in `src/rules/index.ts`. `src/index.ts` automatically includes it in `recommendedRules`.
58
+ 3. Add a matching test file under `test/rules` with valid and invalid `RuleTester` cases.
59
+ 4. Run `vp test`, `vp check`, and `vp run build`.
60
+
61
+ `defineEffectRule` resolves namespace and named imports from `effect`, `@effect/*`, and `alchemy/*` entrypoints, so rules
62
+ should match canonical API paths instead of hard-coding local import names.
@@ -0,0 +1,60 @@
1
+ import { Plugin } from "@oxlint/plugins";
2
+ //#region src/rules/index.d.ts
3
+ declare const rules: {
4
+ readonly 'alchemy-no-cloudflare-init-finalizer': import("@oxlint/plugins").Rule;
5
+ readonly 'alchemy-no-deprecated-docker-constraints': import("@oxlint/plugins").Rule;
6
+ readonly 'alchemy-no-deprecated-resource': import("@oxlint/plugins").Rule;
7
+ readonly 'alchemy-no-plaintext-github-secret': import("@oxlint/plugins").Rule;
8
+ readonly 'alchemy-no-removed-config-api': import("@oxlint/plugins").Rule;
9
+ readonly 'alchemy-no-reserved-eventbridge-default-name': import("@oxlint/plugins").Rule;
10
+ readonly 'alchemy-no-runtime-config': import("@oxlint/plugins").Rule;
11
+ readonly 'alchemy-no-v1-import': import("@oxlint/plugins").Rule;
12
+ readonly 'alchemy-no-v1-worker-properties': import("@oxlint/plugins").Rule;
13
+ readonly 'avoid-data-tagged-error': import("@oxlint/plugins").Rule;
14
+ readonly 'ban-error-string': import("@oxlint/plugins").Rule;
15
+ readonly 'cors-credentials-with-wildcard': import("@oxlint/plugins").Rule;
16
+ readonly 'dual-numeric-arity-with-optional-parameter': import("@oxlint/plugins").Rule;
17
+ readonly 'effect-promise-vs-trypromise': import("@oxlint/plugins").Rule;
18
+ readonly 'no-already-started-promise': import("@oxlint/plugins").Rule;
19
+ readonly 'no-async-effect-try': import("@oxlint/plugins").Rule;
20
+ readonly 'no-discarded-run-promise': import("@oxlint/plugins").Rule;
21
+ readonly 'no-discarded-schema-checks': import("@oxlint/plugins").Rule;
22
+ readonly 'no-empty-effect-callback': import("@oxlint/plugins").Rule;
23
+ readonly 'no-empty-schema-struct': import("@oxlint/plugins").Rule;
24
+ readonly 'no-effect-alchemy-barrel-imports': import("@oxlint/plugins").Rule;
25
+ readonly 'no-function-config-default': import("@oxlint/plugins").Rule;
26
+ readonly 'no-hash-as-identity': import("@oxlint/plugins").Rule;
27
+ readonly 'no-logging-in-catch': import("@oxlint/plugins").Rule;
28
+ readonly 'no-multi-shot-effect-callback': import("@oxlint/plugins").Rule;
29
+ readonly 'no-non-json-schema-annotation': import("@oxlint/plugins").Rule;
30
+ readonly 'no-option-of-service': import("@oxlint/plugins").Rule;
31
+ readonly 'no-overwritten-discriminant': import("@oxlint/plugins").Rule;
32
+ readonly 'no-service-option-get-or-throw': import("@oxlint/plugins").Rule;
33
+ readonly 'no-throw-in-effect-callback': import("@oxlint/plugins").Rule;
34
+ readonly 'no-zero-retry-times': import("@oxlint/plugins").Rule;
35
+ readonly 'prefer-effect-alchemy-namespace-imports': import("@oxlint/plugins").Rule;
36
+ readonly 'prefer-effect-array-sort': import("@oxlint/plugins").Rule;
37
+ readonly 'prefer-effect-datetime': import("@oxlint/plugins").Rule;
38
+ readonly 'prefer-effect-duration': import("@oxlint/plugins").Rule;
39
+ readonly 'prefer-effect-encoding': import("@oxlint/plugins").Rule;
40
+ readonly 'prefer-effect-filesystem': import("@oxlint/plugins").Rule;
41
+ readonly 'prefer-effect-filter': import("@oxlint/plugins").Rule;
42
+ readonly 'prefer-effect-headers': import("@oxlint/plugins").Rule;
43
+ readonly 'prefer-effect-match': import("@oxlint/plugins").Rule;
44
+ readonly 'prefer-effect-path': import("@oxlint/plugins").Rule;
45
+ readonly 'prefer-effect-url': import("@oxlint/plugins").Rule;
46
+ readonly 'prefer-uninterruptible': import("@oxlint/plugins").Rule;
47
+ readonly 'prefer-with-span': import("@oxlint/plugins").Rule;
48
+ readonly 'prefer-yield-now': import("@oxlint/plugins").Rule;
49
+ readonly 'preserve-caught-error': import("@oxlint/plugins").Rule;
50
+ readonly 'require-schema-class-brand': import("@oxlint/plugins").Rule;
51
+ readonly 'require-try-promise-abort-signal': import("@oxlint/plugins").Rule;
52
+ readonly 'throw-in-effect-gen': import("@oxlint/plugins").Rule;
53
+ };
54
+ //#endregion
55
+ //#region src/index.d.ts
56
+ type RuleName = keyof typeof rules;
57
+ declare const recommendedRules: Partial<Record<`2digits/${RuleName}`, 'error'>>;
58
+ declare const plugin: Plugin;
59
+ //#endregion
60
+ export { RuleName, plugin as default, recommendedRules, rules };
package/dist/index.mjs ADDED
@@ -0,0 +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 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,5 +1,48 @@
1
1
  {
2
2
  "name": "@2digits/oxlint-plugin",
3
- "version": "0.0.0-tegami-trusted-publish-setup",
4
- "description": "Placeholder published by Tegami for npm trusted publishing setup."
5
- }
3
+ "version": "0.0.3",
4
+ "description": "Custom Oxlint rules for 2digits projects.",
5
+ "keywords": [
6
+ "2digits",
7
+ "oxlint",
8
+ "oxlint-plugin"
9
+ ],
10
+ "license": "MIT",
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/2digits-agency/configs.git",
14
+ "directory": "packages/oxlint-plugin"
15
+ },
16
+ "files": [
17
+ "NOTICE",
18
+ "dist"
19
+ ],
20
+ "type": "module",
21
+ "sideEffects": false,
22
+ "types": "./dist/index.d.mts",
23
+ "exports": {
24
+ ".": "./dist/index.mjs",
25
+ "./package.json": "./package.json"
26
+ },
27
+ "publishConfig": {
28
+ "access": "public"
29
+ },
30
+ "dependencies": {
31
+ "@oxlint/plugins": "1.81.0"
32
+ },
33
+ "devDependencies": {
34
+ "@2digits/tsconfig": "0.8.8",
35
+ "@arethetypeswrong/core": "0.18.5",
36
+ "oxlint": "1.81.0",
37
+ "publint": "0.3.24",
38
+ "typescript": "7.0.2",
39
+ "vite-plus": "0.3.0"
40
+ },
41
+ "public": true,
42
+ "scripts": {
43
+ "build": "vp pack --minify",
44
+ "dev": "vp pack --watch",
45
+ "test": "vp test run",
46
+ "types": "tsc --noEmit"
47
+ }
48
+ }