@milkenjoyer/toolchain 0.7.1 → 0.7.2

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.
@@ -3497,6 +3497,12 @@ const isOsBinding = (source, node) => {
3497
3497
  };
3498
3498
  return lookup(source.getScope(node));
3499
3499
  };
3500
+ const isManagedAcquire = (node) => {
3501
+ const parent = node.parent;
3502
+ if (parent === null) return false;
3503
+ if (parent.type === "CallExpression" && parent.arguments[0] === node && parent.callee.type === "MemberExpression" && parent.callee.object.type === "Identifier" && parent.callee.object.name === "Effect" && Option.exists(memberPropertyName(parent.callee), (name) => name === "acquireRelease" || name === "acquireUseRelease")) return true;
3504
+ return isManagedAcquire(parent);
3505
+ };
3500
3506
  const useTempFileScopedRule = Rule.define({
3501
3507
  name: "use-temp-file-scoped",
3502
3508
  meta: Rule.meta({
@@ -3522,7 +3528,7 @@ const useTempFileScopedRule = Rule.define({
3522
3528
  messageId: "tmpdir"
3523
3529
  })) : Effect.void,
3524
3530
  CallExpression: (node) => {
3525
- if (node.type !== "CallExpression" || node.callee.type !== "MemberExpression") return Effect.void;
3531
+ if (node.type !== "CallExpression" || node.callee.type !== "MemberExpression" || isManagedAcquire(node)) return Effect.void;
3526
3532
  return Option.match(Option.filter(memberPropertyName(node.callee), (name) => name === "makeTempFile" || name === "makeTempDirectory"), {
3527
3533
  onNone: () => Effect.void,
3528
3534
  onSome: (api) => context.report(Diagnostic.fromId({
@@ -3539,7 +3545,6 @@ const useTempFileScopedRule = Rule.define({
3539
3545
  const kept = [
3540
3546
  "avoid-mutable-state",
3541
3547
  "avoid-option-getorthrow",
3542
- "effect-run-in-body",
3543
3548
  "no-chained-type-assertions",
3544
3549
  "no-module-mocking",
3545
3550
  "prefer-redacted-config",
@@ -3952,7 +3952,7 @@ interface RuleReplacedByExternalSpecifier {
3952
3952
  */
3953
3953
  url?: string;
3954
3954
  }
3955
- interface CreateRule {
3955
+ interface CreateRule$1 {
3956
3956
  meta?: RuleMeta;
3957
3957
  create: (context: Context) => VisitorObject;
3958
3958
  }
@@ -3962,6 +3962,6 @@ interface CreateRule {
3962
3962
  *
3963
3963
  * @since 0.2.2
3964
3964
  */
3965
- declare const plugin$1: Plugin.DefinedPlugin<Record<string, CreateRule>>;
3965
+ declare const plugin$1: Plugin.DefinedPlugin<Record<string, CreateRule$1>>;
3966
3966
  declare const plugin: Pick<typeof plugin$1, "meta" | "rules">;
3967
3967
  export { plugin as default };
@@ -1 +1 @@
1
- export { t as default } from "./effect-plugin-Cee5222q.mjs";
1
+ export { t as default } from "./effect-plugin-kYxB-5LJ.mjs";
@@ -7,7 +7,6 @@ import * as Struct from "effect/Struct";
7
7
  const patchCommand = "effect-tsgo patch --oxlint";
8
8
  const effectTsgoPlugin = "effecttsgo";
9
9
  const beyondRecommended = [
10
- "effecttsgo/any-unknown-in-error-context",
11
10
  "effecttsgo/crypto-random-uuid-in-effect",
12
11
  "effecttsgo/effect-try-without-catch",
13
12
  "effecttsgo/global-date-in-effect",
@@ -18,7 +17,11 @@ const beyondRecommended = [
18
17
  "effecttsgo/missing-effect-service-dependency",
19
18
  "effecttsgo/unsafe-effect-type-assertion"
20
19
  ];
21
- const disabledRecommendedTsgoRules = ["effecttsgo/return-effect-in-gen", "effecttsgo/layer-merge-all-with-dependencies"];
20
+ const disabledRecommendedTsgoRules = [
21
+ "effecttsgo/schema-number",
22
+ "effecttsgo/return-effect-in-gen",
23
+ "effecttsgo/layer-merge-all-with-dependencies"
24
+ ];
22
25
  const enforcedTsgoRules = Arr.sort(Arr.dedupe([...Arr.filter(Struct.keys(presets.recommended.rules ?? {}), (rule) => !disabledRecommendedTsgoRules.includes(rule)), ...beyondRecommended]), Order.String);
23
26
  const effectTsgoRules = R.fromEntries([...Arr.map(enforcedTsgoRules, (rule) => [rule, "error"]), ...Arr.map(disabledRecommendedTsgoRules, (rule) => [rule, "off"])]);
24
27
  export { disabledRecommendedTsgoRules, effectTsgoPlugin, effectTsgoRules, enforcedTsgoRules, patchCommand };
@@ -0,0 +1,7 @@
1
+ import { CreateRule } from "effect-oxlint";
2
+ import upstream from "@foldkit/oxlint-plugin";
3
+ declare const plugin: {
4
+ readonly meta: typeof upstream.meta;
5
+ readonly rules: Record<string, CreateRule>;
6
+ };
7
+ export { plugin as default };
@@ -0,0 +1,32 @@
1
+ import * as Arr from "effect/Array";
2
+ import * as R from "effect/Record";
3
+ import * as Schema from "effect/Schema";
4
+ import * as Effect from "effect/Effect";
5
+ import { existsSync, readFileSync } from "node:fs";
6
+ import { dirname, join } from "node:path";
7
+ import upstream from "@foldkit/oxlint-plugin";
8
+ // src/foldkit-plugin.ts
9
+ const Dependencies = Schema.Record(Schema.String, Schema.Unknown).pipe(Schema.withDecodingDefaultKey(Effect.succeed({})));
10
+ const Manifest = Schema.fromJsonString(Schema.Struct({
11
+ dependencies: Dependencies,
12
+ devDependencies: Dependencies,
13
+ peerDependencies: Dependencies
14
+ }));
15
+ const packages = /* @__PURE__ */ new Map();
16
+ const usesFoldkit = (directory) => {
17
+ const cached = packages.get(directory);
18
+ if (cached !== void 0) return cached;
19
+ const file = join(directory, "package.json");
20
+ const parent = dirname(directory);
21
+ const enabled = existsSync(file) ? Arr.some(R.values(Schema.decodeSync(Manifest)(readFileSync(file, "utf8"))), (dependencies) => R.has(dependencies, "foldkit")) : parent !== directory && usesFoldkit(parent);
22
+ packages.set(directory, enabled);
23
+ return enabled;
24
+ };
25
+ const plugin = {
26
+ meta: upstream.meta,
27
+ rules: R.map(upstream.rules, (rule) => ({
28
+ ...rule,
29
+ create: (context) => usesFoldkit(dirname(context.filename)) ? rule.create(context) : {}
30
+ }))
31
+ };
32
+ export { plugin as default };
package/dist/lint.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import { t as plugin } from "./effect-plugin-Cee5222q.mjs";
1
+ import { t as plugin } from "./effect-plugin-kYxB-5LJ.mjs";
2
2
  import { effectTsgoPlugin, effectTsgoRules } from "./effect-tsgo.mjs";
3
3
  import { exceptions } from "./exceptions.mjs";
4
- import { t as plugin$1 } from "./plugin-DpJJbtFQ.mjs";
4
+ import { t as plugin$1 } from "./plugin-BoBRGtGf.mjs";
5
5
  import { staticRules } from "./rules.mjs";
6
6
  import * as Arr from "effect/Array";
7
7
  import * as Option from "effect/Option";
@@ -51,6 +51,8 @@ const testFiles = [
51
51
  "**/*.test.tsx",
52
52
  "**/*.spec.ts",
53
53
  "**/*.spec.tsx",
54
+ "**/*.fake.ts",
55
+ "**/*.fake.tsx",
54
56
  "**/tests/**",
55
57
  "**/test/**"
56
58
  ];
@@ -65,7 +67,23 @@ const toolchainScopes = [
65
67
  })),
66
68
  {
67
69
  files: testFiles,
68
- rules: { "effecttsgo/any-unknown-in-error-context": "off" }
70
+ rules: {
71
+ "effecttsgo/lazy-effect": "off",
72
+ "eslint/no-extend-native": "off",
73
+ "typescript/unbound-method": "off",
74
+ "typescript/no-deprecated": "off",
75
+ "effect/use-temp-file-scoped": "off",
76
+ "birbprophet/no-process-env": "off"
77
+ }
78
+ },
79
+ {
80
+ files: [
81
+ "**/*.config.ts",
82
+ "**/*.config.mts",
83
+ "**/*.config.js",
84
+ "**/*.config.mjs"
85
+ ],
86
+ rules: { "birbprophet/no-process-env": "off" }
69
87
  }
70
88
  ];
71
89
  const atError = (prefix, rules) => R.fromEntries(Arr.map(rules, (rule) => [`${prefix}/${rule}`, "error"]));
@@ -87,10 +105,10 @@ const lint = ({ ignores = [] } = {}) => ({
87
105
  name: "vite-plus",
88
106
  specifier: resolved("vite-plus/oxlint-plugin")
89
107
  },
90
- ...Arr.map(foldkitPreset.jsPlugins, ({ name, specifier }) => ({
91
- name,
92
- specifier: resolved(specifier)
93
- })),
108
+ {
109
+ name: "foldkit",
110
+ specifier: sibling("foldkit-plugin")
111
+ },
94
112
  {
95
113
  name: plugin.meta.name,
96
114
  specifier: sibling("effect-plugin")
@@ -26,6 +26,34 @@ const noCommentsRule = Rule.define({
26
26
  }),
27
27
  name: "no-comments"
28
28
  });
29
+ // src/rules/no-process-env.ts
30
+ const passesEnvironment = (node) => {
31
+ const parent = node.parent;
32
+ return parent.type === "SpreadElement" || (parent.type === "CallExpression" || parent.type === "NewExpression") && parent.arguments.includes(node) || parent.type === "VariableDeclarator" && parent.init === node && parent.id.type === "ObjectPattern" && Arr.some(parent.id.properties, (property) => property.type === "RestElement");
33
+ };
34
+ const isGlobalProcess = (source, node) => {
35
+ const lookup = (scope) => {
36
+ const variable = scope.set.get(node.name);
37
+ if (variable !== void 0 && variable.defs.length > 0) return false;
38
+ return scope.upper === null ? true : lookup(scope.upper);
39
+ };
40
+ return lookup(source.getScope(node));
41
+ };
42
+ const noProcessEnvRule = Rule.define({
43
+ name: "no-process-env",
44
+ meta: Rule.meta({
45
+ type: "suggestion",
46
+ description: "Read configuration through Effect Config",
47
+ messages: { config: "Read configuration through Effect Config. Passing the whole environment through is allowed." }
48
+ }),
49
+ *create() {
50
+ const context = yield* RuleContext;
51
+ return { MemberExpression: (node) => node.type === "MemberExpression" && node.object.type === "Identifier" && node.object.name === "process" && isGlobalProcess(context.sourceCode, node.object) && Option.contains(memberPropertyName(node), "env") && !passesEnvironment(node) ? context.report(Diagnostic.fromId({
52
+ node,
53
+ messageId: "config"
54
+ })) : Effect.void };
55
+ }
56
+ });
29
57
  // src/shared/member-path.ts
30
58
  const resolveBinding = (sourceCode, node) => {
31
59
  const findBinding = (scope) => Option.flatMap(scope, (current) => Option.orElse(Option.fromUndefinedOr(current.set.get(node.name)), () => findBinding(Option.fromNullishOr(current.upper))));
@@ -255,6 +283,7 @@ const plugin = Plugin.define({
255
283
  name: "birbprophet",
256
284
  rules: {
257
285
  "no-comments": noCommentsRule,
286
+ "no-process-env": noProcessEnvRule,
258
287
  "prefer-accessible-scene-locators": preferAccessibleSceneLocatorsRule,
259
288
  "require-command-answer-names": requireCommandAnswerNamesRule,
260
289
  "require-past-tense-messages": requirePastTenseMessagesRule
package/dist/plugin.d.mts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { Plugin } from "effect-oxlint";
2
2
  declare const plugin: Plugin.DefinedPlugin<{
3
3
  readonly "no-comments": import("effect-oxlint").CreateRule;
4
+ readonly "no-process-env": import("effect-oxlint").CreateRule;
4
5
  readonly "prefer-accessible-scene-locators": import("effect-oxlint").CreateRule;
5
6
  readonly "require-command-answer-names": import("effect-oxlint").CreateRule;
6
7
  readonly "require-past-tense-messages": import("effect-oxlint").CreateRule;
package/dist/plugin.mjs CHANGED
@@ -1 +1 @@
1
- export { t as default } from "./plugin-DpJJbtFQ.mjs";
1
+ export { t as default } from "./plugin-BoBRGtGf.mjs";
package/dist/rules.d.mts CHANGED
@@ -1,4 +1,5 @@
1
1
  export declare const staticRules: {
2
+ "effecttsgo/any-unknown-in-error-context": "off";
2
3
  "effecttsgo/strict-effect-provide": "off";
3
4
  "eslint/array-callback-return": "error";
4
5
  "eslint/constructor-super": "off";
@@ -53,7 +54,7 @@ export declare const staticRules: {
53
54
  "import/no-cycle": "error";
54
55
  "import/no-mutable-exports": "error";
55
56
  "import/no-unassigned-import": "off";
56
- "node/no-process-env": "error";
57
+ "node/no-process-env": "off";
57
58
  "oxc/bad-bitwise-operator": "error";
58
59
  "oxc/no-accumulating-spread": "error";
59
60
  "promise/always-return": "off";
@@ -93,17 +94,21 @@ export declare const staticRules: {
93
94
  "unicorn/consistent-function-scoping": "off";
94
95
  "unicorn/new-for-builtins": "error";
95
96
  "unicorn/no-abusive-eslint-disable": "error";
96
- "unicorn/no-document-cookie": "error";
97
+ "unicorn/no-document-cookie": "off";
97
98
  "unicorn/no-negation-in-equality-check": "error";
98
99
  "unicorn/no-new-buffer": "error";
99
100
  "unicorn/no-object-as-default-parameter": "error";
100
101
  "unicorn/no-unnecessary-await": "off";
102
+ "unicorn/require-post-message-target-origin": "off";
101
103
  "unicorn/prefer-module": "error";
102
104
  "unicorn/prefer-number-properties": "error";
103
105
  "vitest/expect-expect": "off";
104
106
  "vitest/no-identical-title": "error";
105
107
  "vitest/no-import-node-test": "error";
106
108
  "vitest/no-standalone-expect": "off";
109
+ "vitest/valid-expect": ["error", {
110
+ maxArgs: number;
111
+ }];
107
112
  "vitest/valid-title": ["error", {
108
113
  allowArguments: boolean;
109
114
  }];
package/dist/rules.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  const staticRules = {
2
+ "effecttsgo/any-unknown-in-error-context": "off",
2
3
  "effecttsgo/strict-effect-provide": "off",
3
4
  "eslint/array-callback-return": "error",
4
5
  "eslint/constructor-super": "off",
@@ -58,7 +59,7 @@ const staticRules = {
58
59
  "import/no-cycle": "error",
59
60
  "import/no-mutable-exports": "error",
60
61
  "import/no-unassigned-import": "off",
61
- "node/no-process-env": "error",
62
+ "node/no-process-env": "off",
62
63
  "oxc/bad-bitwise-operator": "error",
63
64
  "oxc/no-accumulating-spread": "error",
64
65
  "promise/always-return": "off",
@@ -98,17 +99,19 @@ const staticRules = {
98
99
  "unicorn/consistent-function-scoping": "off",
99
100
  "unicorn/new-for-builtins": "error",
100
101
  "unicorn/no-abusive-eslint-disable": "error",
101
- "unicorn/no-document-cookie": "error",
102
+ "unicorn/no-document-cookie": "off",
102
103
  "unicorn/no-negation-in-equality-check": "error",
103
104
  "unicorn/no-new-buffer": "error",
104
105
  "unicorn/no-object-as-default-parameter": "error",
105
106
  "unicorn/no-unnecessary-await": "off",
107
+ "unicorn/require-post-message-target-origin": "off",
106
108
  "unicorn/prefer-module": "error",
107
109
  "unicorn/prefer-number-properties": "error",
108
110
  "vitest/expect-expect": "off",
109
111
  "vitest/no-identical-title": "error",
110
112
  "vitest/no-import-node-test": "error",
111
113
  "vitest/no-standalone-expect": "off",
114
+ "vitest/valid-expect": ["error", { maxArgs: 2 }],
112
115
  "vitest/valid-title": ["error", { allowArguments: true }]
113
116
  };
114
117
  export { staticRules };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@milkenjoyer/toolchain",
3
- "version": "0.7.1",
3
+ "version": "0.7.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/birbprophet/agent-kit.git",
@@ -33,6 +33,10 @@
33
33
  "types": "./dist/effect-plugin.d.mts",
34
34
  "default": "./dist/effect-plugin.mjs"
35
35
  },
36
+ "./foldkit-plugin": {
37
+ "types": "./dist/foldkit-plugin.d.mts",
38
+ "default": "./dist/foldkit-plugin.mjs"
39
+ },
36
40
  "./exceptions": {
37
41
  "types": "./dist/exceptions.d.mts",
38
42
  "default": "./dist/exceptions.mjs"