@milkenjoyer/toolchain 0.21.0 → 0.22.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/README.md +2 -0
  2. package/TESTING.md +26 -0
  3. package/dist/{effect-plugin-BiskbKO9.mjs → effect-plugin-roghk4W1.mjs} +0 -1
  4. package/dist/effect-plugin.mjs +1 -1
  5. package/dist/exceptions-D0yZUk8P.mjs +145 -0
  6. package/dist/exceptions.mjs +1 -1
  7. package/dist/{guard-CAm90ZGy.mjs → guard-n0LC_buo.mjs} +2 -2
  8. package/dist/guard.mjs +1 -1
  9. package/dist/{lint-CiO5Etue.mjs → lint-Bx4NP_kA.mjs} +4 -4
  10. package/dist/lint.mjs +1 -1
  11. package/dist/{plugin-DwQM07Ih.mjs → plugin-DUUAfi92.mjs} +324 -28
  12. package/dist/plugin.d.mts +5 -0
  13. package/dist/plugin.mjs +1 -1
  14. package/dist/{renovate-ci-BdVmECgm.mjs → renovate-ci-_6NQAucj.mjs} +7 -3
  15. package/dist/renovate-ci.d.mts +2 -1
  16. package/dist/renovate-ci.mjs +1 -1
  17. package/dist/{rules-vHmNoAU0.mjs → rules-5qwzfDWJ.mjs} +3 -1
  18. package/dist/rules.d.mts +2 -0
  19. package/dist/rules.mjs +1 -1
  20. package/dist/standard.mjs +1 -1
  21. package/dist/starts.mjs +1 -1
  22. package/package.json +2 -1
  23. package/src/effect-plugin.ts +0 -1
  24. package/src/exceptions.ts +132 -0
  25. package/src/plugin.ts +10 -0
  26. package/src/renovate-ci.ts +5 -2
  27. package/src/rules/no-mock-call-mirrors.ts +121 -0
  28. package/src/rules/no-test-internal-imports.ts +102 -0
  29. package/src/rules/no-test-timeouts.ts +83 -0
  30. package/src/rules/no-test-waits.ts +113 -0
  31. package/src/rules/require-test-quarantine.ts +36 -0
  32. package/src/rules/test-api.ts +57 -0
  33. package/src/rules/test-hygiene.test.ts +241 -0
  34. package/src/rules/test-package.ts +32 -0
  35. package/src/rules.ts +2 -0
  36. package/src/shared/member-path.ts +7 -0
  37. package/dist/exceptions-Dybl9xpc.mjs +0 -11
@@ -4,9 +4,10 @@ import { parse } from "yaml";
4
4
  const headRequest = "github.event.action == 'labeled' && github.event.label.name == format('ready:{0}', github.event.pull_request.head.sha)";
5
5
  const renovateRequest = "github.event.action != 'labeled' && github.event.pull_request.user.login == 'renovate[bot]' && github.event.pull_request.head.repo.full_name == github.repository";
6
6
  const readyRequest = `github.event_name == 'push' || (github.event.pull_request.draft == false && !startsWith(github.head_ref, 'probe/') && ((${headRequest}) || (${renovateRequest})))`;
7
- const budgetRequest = `github.event_name == 'pull_request' && github.event.pull_request.draft == false && (${renovateRequest})`;
7
+ const budgetRequest = `github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.draft == false && (${renovateRequest}))`;
8
8
  const checksRequest = `always() && (${readyRequest}) && (needs.budget.result == 'success' || needs.budget.result == 'skipped')`;
9
9
  const resultRequest = `always() && (${readyRequest})`;
10
+ const mainOnlyRequest = "always() && github.event_name == 'push' && needs.budget.result == 'success'";
10
11
  const readyGroup = `\${{ github.workflow }}-\${{ github.event_name == 'pull_request' && !((${headRequest}) || (${renovateRequest})) && format('label-{0}-{1}', github.event.pull_request.number, github.event.label.name) || github.event.pull_request.number || github.ref }}`;
11
12
  const readyCancellation = `\${{ github.event_name == 'pull_request' && ((${headRequest}) || (${renovateRequest})) }}`;
12
13
  const readyRunName = `\${{ github.event_name == 'push' && format('ready {0} at {1}', github.ref_name, github.sha) || ((${headRequest}) || (${renovateRequest})) && format('ready #{0} at {1}', github.event.pull_request.number, github.event.pull_request.head.sha) || format('label {0} on #{1}', github.event.label.name, github.event.pull_request.number) }}`;
@@ -56,7 +57,10 @@ const Layout = Schema.Struct({
56
57
  on: Schema.Record(Schema.String, Schema.Unknown),
57
58
  jobs: Schema.Record(Schema.String, Schema.Unknown)
58
59
  });
59
- const MainOnlyJob = Schema.Struct({ if: Schema.Literal("github.event_name == 'push'") });
60
+ const MainOnlyJob = Schema.Struct({
61
+ needs: Schema.Literal("budget"),
62
+ if: Schema.Literal(mainOnlyRequest)
63
+ });
60
64
  const isRenovateCi = (text) => {
61
65
  const parsed = parse(text);
62
66
  const decoded = Schema.decodeUnknownOption(Workflow)(parsed);
@@ -70,4 +74,4 @@ const isRenovateCi = (text) => {
70
74
  "ready"
71
75
  ].includes(name) || Schema.is(MainOnlyJob)(job)) && workflow.on.pull_request.types.join(",") === "labeled,opened,synchronize,reopened,ready_for_review" && workflow.jobs.ready.needs.join(",") === "budget,checks" && workflow.jobs.budget.steps.some(Schema.is(BudgetStep)) && workflow.jobs.ready.steps.some(Schema.is(ResultStep));
72
76
  };
73
- export { readyCancellation as a, readyRunName as c, isRenovateCi as i, renovateRequest as l, checksRequest as n, readyGroup as o, headRequest as r, readyRequest as s, budgetRequest as t, resultRequest as u };
77
+ export { mainOnlyRequest as a, readyRequest as c, resultRequest as d, isRenovateCi as i, readyRunName as l, checksRequest as n, readyCancellation as o, headRequest as r, readyGroup as s, budgetRequest as t, renovateRequest as u };
@@ -1,9 +1,10 @@
1
1
  export declare const headRequest = "github.event.action == 'labeled' && github.event.label.name == format('ready:{0}', github.event.pull_request.head.sha)";
2
2
  export declare const renovateRequest = "github.event.action != 'labeled' && github.event.pull_request.user.login == 'renovate[bot]' && github.event.pull_request.head.repo.full_name == github.repository";
3
3
  export declare const readyRequest = "github.event_name == 'push' || (github.event.pull_request.draft == false && !startsWith(github.head_ref, 'probe/') && ((github.event.action == 'labeled' && github.event.label.name == format('ready:{0}', github.event.pull_request.head.sha)) || (github.event.action != 'labeled' && github.event.pull_request.user.login == 'renovate[bot]' && github.event.pull_request.head.repo.full_name == github.repository)))";
4
- export declare const budgetRequest = "github.event_name == 'pull_request' && github.event.pull_request.draft == false && (github.event.action != 'labeled' && github.event.pull_request.user.login == 'renovate[bot]' && github.event.pull_request.head.repo.full_name == github.repository)";
4
+ export declare const budgetRequest = "github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.draft == false && (github.event.action != 'labeled' && github.event.pull_request.user.login == 'renovate[bot]' && github.event.pull_request.head.repo.full_name == github.repository))";
5
5
  export declare const checksRequest = "always() && (github.event_name == 'push' || (github.event.pull_request.draft == false && !startsWith(github.head_ref, 'probe/') && ((github.event.action == 'labeled' && github.event.label.name == format('ready:{0}', github.event.pull_request.head.sha)) || (github.event.action != 'labeled' && github.event.pull_request.user.login == 'renovate[bot]' && github.event.pull_request.head.repo.full_name == github.repository)))) && (needs.budget.result == 'success' || needs.budget.result == 'skipped')";
6
6
  export declare const resultRequest = "always() && (github.event_name == 'push' || (github.event.pull_request.draft == false && !startsWith(github.head_ref, 'probe/') && ((github.event.action == 'labeled' && github.event.label.name == format('ready:{0}', github.event.pull_request.head.sha)) || (github.event.action != 'labeled' && github.event.pull_request.user.login == 'renovate[bot]' && github.event.pull_request.head.repo.full_name == github.repository))))";
7
+ export declare const mainOnlyRequest = "always() && github.event_name == 'push' && needs.budget.result == 'success'";
7
8
  export declare const readyGroup = "${{ github.workflow }}-${{ github.event_name == 'pull_request' && !((github.event.action == 'labeled' && github.event.label.name == format('ready:{0}', github.event.pull_request.head.sha)) || (github.event.action != 'labeled' && github.event.pull_request.user.login == 'renovate[bot]' && github.event.pull_request.head.repo.full_name == github.repository)) && format('label-{0}-{1}', github.event.pull_request.number, github.event.label.name) || github.event.pull_request.number || github.ref }}";
8
9
  export declare const readyCancellation = "${{ github.event_name == 'pull_request' && ((github.event.action == 'labeled' && github.event.label.name == format('ready:{0}', github.event.pull_request.head.sha)) || (github.event.action != 'labeled' && github.event.pull_request.user.login == 'renovate[bot]' && github.event.pull_request.head.repo.full_name == github.repository)) }}";
9
10
  export declare const readyRunName = "${{ github.event_name == 'push' && format('ready {0} at {1}', github.ref_name, github.sha) || ((github.event.action == 'labeled' && github.event.label.name == format('ready:{0}', github.event.pull_request.head.sha)) || (github.event.action != 'labeled' && github.event.pull_request.user.login == 'renovate[bot]' && github.event.pull_request.head.repo.full_name == github.repository)) && format('ready #{0} at {1}', github.event.pull_request.number, github.event.pull_request.head.sha) || format('label {0} on #{1}', github.event.label.name, github.event.pull_request.number) }}";
@@ -1 +1 @@
1
- export { t as budgetRequest, n as checksRequest, r as headRequest, i as isRenovateCi, a as readyCancellation, o as readyGroup, s as readyRequest, c as readyRunName, l as renovateRequest, u as resultRequest } from "./renovate-ci-BdVmECgm.mjs";
1
+ export { t as budgetRequest, n as checksRequest, r as headRequest, i as isRenovateCi, a as mainOnlyRequest, o as readyCancellation, s as readyGroup, c as readyRequest, l as readyRunName, u as renovateRequest, d as resultRequest } from "./renovate-ci-_6NQAucj.mjs";
@@ -108,10 +108,12 @@ const staticRules = {
108
108
  "unicorn/prefer-module": "error",
109
109
  "unicorn/prefer-number-properties": "error",
110
110
  "vitest/expect-expect": "off",
111
+ "vitest/no-disabled-tests": "off",
111
112
  "vitest/no-identical-title": "error",
112
113
  "vitest/no-import-node-test": "error",
113
114
  "vitest/no-standalone-expect": "off",
114
115
  "vitest/valid-expect": ["error", { maxArgs: 2 }],
115
- "vitest/valid-title": ["error", { allowArguments: true }]
116
+ "vitest/valid-title": ["error", { allowArguments: true }],
117
+ "vitest/warn-todo": "off"
116
118
  };
117
119
  export { staticRules as t };
package/dist/rules.d.mts CHANGED
@@ -103,6 +103,7 @@ export declare const staticRules: {
103
103
  "unicorn/prefer-module": "error";
104
104
  "unicorn/prefer-number-properties": "error";
105
105
  "vitest/expect-expect": "off";
106
+ "vitest/no-disabled-tests": "off";
106
107
  "vitest/no-identical-title": "error";
107
108
  "vitest/no-import-node-test": "error";
108
109
  "vitest/no-standalone-expect": "off";
@@ -112,4 +113,5 @@ export declare const staticRules: {
112
113
  "vitest/valid-title": ["error", {
113
114
  allowArguments: boolean;
114
115
  }];
116
+ "vitest/warn-todo": "off";
115
117
  };
package/dist/rules.mjs CHANGED
@@ -1 +1 @@
1
- export { t as staticRules } from "./rules-vHmNoAU0.mjs";
1
+ export { t as staticRules } from "./rules-5qwzfDWJ.mjs";
package/dist/standard.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env bun
2
2
  import { f as versionOf } from "./versions-KbYa8kbF.mjs";
3
- import { a as ruleFindings, c as exactFindings, l as manifestRanges, s as PLAIN, u as resolveCatalog } from "./guard-CAm90ZGy.mjs";
3
+ import { a as ruleFindings, c as exactFindings, l as manifestRanges, s as PLAIN, u as resolveCatalog } from "./guard-n0LC_buo.mjs";
4
4
  import { t as fmt } from "./fmt-C6autuPP.mjs";
5
5
  import { n as criticalFindings, t as decode } from "./specs-file-Ck9ZOt46.mjs";
6
6
  import * as Console from "effect/Console";
package/dist/starts.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { i as isRenovateCi } from "./renovate-ci-BdVmECgm.mjs";
1
+ import { i as isRenovateCi } from "./renovate-ci-_6NQAucj.mjs";
2
2
  import * as Schema from "effect/Schema";
3
3
  import { parse } from "yaml";
4
4
  // src/starts/policy.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@milkenjoyer/toolchain",
3
- "version": "0.21.0",
3
+ "version": "0.22.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/birbprophet/agent-kit.git",
@@ -18,6 +18,7 @@
18
18
  "files": [
19
19
  "dist",
20
20
  "STARTS.md",
21
+ "TESTING.md",
21
22
  "formal-tools/tla2tools-1.8.0.jar",
22
23
  "licenses",
23
24
  "node-version",
@@ -7,7 +7,6 @@ const kept: ReadonlyArray<string> = [
7
7
  "avoid-mutable-state",
8
8
  "avoid-option-getorthrow",
9
9
  "no-chained-type-assertions",
10
- "no-module-mocking",
11
10
  "prefer-redacted-config",
12
11
  "require-effect-concurrency",
13
12
  "throw-in-effect-gen",
package/src/exceptions.ts CHANGED
@@ -5,6 +5,138 @@ export type Exception = {
5
5
  };
6
6
 
7
7
  export const exceptions: ReadonlyArray<Exception> = [
8
+ {
9
+ files: [
10
+ "packages/toolchain/tests/renovate-ci.test.ts",
11
+ "packages/toolchain/tests/standard-fixture.ts",
12
+ "plugins/agent-kit/tests/board.test.ts",
13
+ "plugins/agent-kit/tests/codex-usage.test.ts",
14
+ "plugins/agent-kit/tests/kept-clock.test.ts",
15
+ "plugins/agent-kit/tests/kept-clock.ts",
16
+ "plugins/agent-kit/tests/kept-fake.ts",
17
+ "plugins/agent-kit/tests/kept-fixes.test.ts",
18
+ "plugins/agent-kit/tests/kept-plan.test.ts",
19
+ "plugins/agent-kit/tests/kept-relocation.test.ts",
20
+ "plugins/agent-kit/tests/kept-runner.test.ts",
21
+ "plugins/agent-kit/tests/kept.test.ts",
22
+ "plugins/agent-kit/tests/pool-quota.test.ts",
23
+ "plugins/agent-kit/tests/request-ready.test.ts",
24
+ "plugins/agent-kit/tests/wait-ready.test.ts",
25
+ "tests/ready-request.test.ts",
26
+ "tests/repo-guard/check.test.ts",
27
+ ],
28
+ rules: ["birbprophet/no-test-waits"],
29
+ issue: "https://github.com/birbprophet/agent-kit/issues/532",
30
+ },
31
+ {
32
+ files: [
33
+ "packages/toolchain/tests/bins-packed.test.ts",
34
+ "packages/toolchain/tests/build.test.ts",
35
+ "packages/toolchain/tests/false-positives.test.ts",
36
+ "packages/toolchain/tests/formal-arithmetic.test.ts",
37
+ "packages/toolchain/tests/formal-proofs.test.ts",
38
+ "packages/toolchain/tests/formal.test.ts",
39
+ "packages/toolchain/tests/hooks.test.ts",
40
+ "packages/toolchain/tests/knip.test.ts",
41
+ "packages/toolchain/tests/rules.test.ts",
42
+ "packages/toolchain/tests/standard-aggregate-ids.test.ts",
43
+ "packages/toolchain/tests/standard-config.test.ts",
44
+ "packages/toolchain/tests/standard-domain-layout.test.ts",
45
+ "packages/toolchain/tests/standard-domain.test.ts",
46
+ "packages/toolchain/tests/standard-infra.test.ts",
47
+ "packages/toolchain/tests/standard-pins.test.ts",
48
+ "packages/toolchain/tests/standard-rules.test.ts",
49
+ "plugins/agent-kit/tests/codex-launch.test.ts",
50
+ "plugins/agent-kit/tests/kept-admission.test.ts",
51
+ "plugins/agent-kit/tests/kept-fixes.test.ts",
52
+ "plugins/agent-kit/tests/kept-relocation.test.ts",
53
+ "plugins/agent-kit/tests/kept-runner.test.ts",
54
+ "plugins/agent-kit/tests/kept.test.ts",
55
+ "tests/no-comments.test.ts",
56
+ "tests/repo-guard/check.test.ts",
57
+ "tests/spawned-commands.test.ts",
58
+ ],
59
+ rules: ["birbprophet/no-test-timeouts"],
60
+ issue: "https://github.com/birbprophet/agent-kit/issues/532",
61
+ },
62
+ {
63
+ files: [
64
+ "packages/toolchain/tests/catalog.test.ts",
65
+ "packages/toolchain/tests/ci-budget.test.ts",
66
+ "packages/toolchain/tests/fixtures/formal/formal/counter.conformance.ts",
67
+ "packages/toolchain/tests/fixtures/proofs/formal/add32.proof.ts",
68
+ "packages/toolchain/tests/fixtures/proofs/formal/credits.proof.ts",
69
+ "packages/toolchain/tests/fixtures/proofs/formal/next-below.proof.ts",
70
+ "packages/toolchain/tests/fixtures/proofs/formal/used-percent.proof.ts",
71
+ "packages/toolchain/tests/foldkit-vite.test.ts",
72
+ "packages/toolchain/tests/formal-traces.test.ts",
73
+ "packages/toolchain/tests/hooks-fixture.ts",
74
+ "packages/toolchain/tests/hooks.test.ts",
75
+ "packages/toolchain/tests/renovate-ci.test.ts",
76
+ "packages/toolchain/tests/renovate.test.ts",
77
+ "packages/toolchain/tests/rules.test.ts",
78
+ "packages/toolchain/tests/rules/no-comments.test.ts",
79
+ "packages/toolchain/tests/rules/no-process-env.test.ts",
80
+ "packages/toolchain/tests/rules/prefer-accessible-scene-locators.test.ts",
81
+ "packages/toolchain/tests/rules/require-command-answer-names.test.ts",
82
+ "packages/toolchain/tests/rules/require-past-tense-messages.test.ts",
83
+ "packages/toolchain/tests/rules/use-temp-file-scoped.test.ts",
84
+ "packages/toolchain/tests/solver.test.ts",
85
+ "packages/toolchain/tests/standard-domain.test.ts",
86
+ "packages/toolchain/tests/standard-infra.test.ts",
87
+ "packages/toolchain/tests/standard-pins.test.ts",
88
+ "packages/toolchain/tests/standard.test.ts",
89
+ "packages/toolchain/tests/starts-policy.test.ts",
90
+ "packages/toolchain/tests/verdict.test.ts",
91
+ "packages/toolchain/tests/verification.test.ts",
92
+ "plugins/agent-kit/tests/board.test.ts",
93
+ "plugins/agent-kit/tests/boat-cost.test.ts",
94
+ "plugins/agent-kit/tests/boat-paid.test.ts",
95
+ "plugins/agent-kit/tests/cleanup.test.ts",
96
+ "plugins/agent-kit/tests/codex-launch.test.ts",
97
+ "plugins/agent-kit/tests/codex-usage.test.ts",
98
+ "plugins/agent-kit/tests/disk-policy.test.ts",
99
+ "plugins/agent-kit/tests/fixed-model-quota.test.ts",
100
+ "plugins/agent-kit/tests/free-resets.test.ts",
101
+ "plugins/agent-kit/tests/kept-admission.test.ts",
102
+ "plugins/agent-kit/tests/kept-cli.test.ts",
103
+ "plugins/agent-kit/tests/kept-clock.test.ts",
104
+ "plugins/agent-kit/tests/kept-fake.ts",
105
+ "plugins/agent-kit/tests/kept-fixes.test.ts",
106
+ "plugins/agent-kit/tests/kept-hydration.test.ts",
107
+ "plugins/agent-kit/tests/kept-observation.test.ts",
108
+ "plugins/agent-kit/tests/kept-plan.test.ts",
109
+ "plugins/agent-kit/tests/kept-relocation.test.ts",
110
+ "plugins/agent-kit/tests/kept-runner.test.ts",
111
+ "plugins/agent-kit/tests/kept.test.ts",
112
+ "plugins/agent-kit/tests/pool-order.test.ts",
113
+ "plugins/agent-kit/tests/pool-quota.test.ts",
114
+ "plugins/agent-kit/tests/provider-slots.test.ts",
115
+ "plugins/agent-kit/tests/proxy-quota.test.ts",
116
+ "plugins/agent-kit/tests/queue-fixture.ts",
117
+ "plugins/agent-kit/tests/queue-members.test.ts",
118
+ "plugins/agent-kit/tests/queue-plan.test.ts",
119
+ "plugins/agent-kit/tests/queue-resets.test.ts",
120
+ "plugins/agent-kit/tests/queue-unread.test.ts",
121
+ "plugins/agent-kit/tests/queue-upkeep.test.ts",
122
+ "plugins/agent-kit/tests/queue-usage.test.ts",
123
+ "plugins/agent-kit/tests/queue.test.ts",
124
+ "plugins/agent-kit/tests/request-ready.test.ts",
125
+ "plugins/agent-kit/tests/trust-hooks.test.ts",
126
+ "plugins/agent-kit/tests/unbound-census.test.ts",
127
+ "plugins/agent-kit/tests/wait-ready.test.ts",
128
+ "tests/exact-versions.test.ts",
129
+ "tests/ready-main.test.ts",
130
+ "tests/ready-request.test.ts",
131
+ "tests/spawned-commands.test.ts",
132
+ "tests/standard-plugin-skills.test.ts",
133
+ "tests/toolchain-adoption.test.ts",
134
+ "tests/workflow-policy.test.ts",
135
+ "tests/workflow-shell.test.ts",
136
+ ],
137
+ rules: ["birbprophet/no-test-internal-imports"],
138
+ issue: "https://github.com/birbprophet/agent-kit/issues/532",
139
+ },
8
140
  {
9
141
  files: ["packages/toolchain/src/conformance.ts"],
10
142
  rules: [
package/src/plugin.ts CHANGED
@@ -1,14 +1,24 @@
1
1
  import { Plugin } from "effect-oxlint";
2
2
 
3
3
  import { noCommentsRule } from "./rules/no-comments.ts";
4
+ import { noMockCallMirrorsRule } from "./rules/no-mock-call-mirrors.ts";
4
5
  import { noProcessEnvRule } from "./rules/no-process-env.ts";
6
+ import { noTestInternalImportsRule } from "./rules/no-test-internal-imports.ts";
7
+ import { noTestTimeoutsRule } from "./rules/no-test-timeouts.ts";
8
+ import { noTestWaitsRule } from "./rules/no-test-waits.ts";
5
9
  import { preferAccessibleSceneLocatorsRule } from "./rules/prefer-accessible-scene-locators.ts";
6
10
  import { requireCommandAnswerNamesRule } from "./rules/require-command-answer-names.ts";
7
11
  import { requirePastTenseMessagesRule } from "./rules/require-past-tense-messages.ts";
12
+ import { requireTestQuarantineRule } from "./rules/require-test-quarantine.ts";
8
13
 
9
14
  const plugin = Plugin.define({
10
15
  name: "birbprophet",
11
16
  rules: {
17
+ "no-test-internal-imports": noTestInternalImportsRule,
18
+ "no-mock-call-mirrors": noMockCallMirrorsRule,
19
+ "require-test-quarantine": requireTestQuarantineRule,
20
+ "no-test-waits": noTestWaitsRule,
21
+ "no-test-timeouts": noTestTimeoutsRule,
12
22
  "no-comments": noCommentsRule,
13
23
  "no-process-env": noProcessEnvRule,
14
24
  "prefer-accessible-scene-locators": preferAccessibleSceneLocatorsRule,
@@ -6,9 +6,11 @@ export const headRequest =
6
6
  export const renovateRequest =
7
7
  "github.event.action != 'labeled' && github.event.pull_request.user.login == 'renovate[bot]' && github.event.pull_request.head.repo.full_name == github.repository";
8
8
  export const readyRequest = `github.event_name == 'push' || (github.event.pull_request.draft == false && !startsWith(github.head_ref, 'probe/') && ((${headRequest}) || (${renovateRequest})))`;
9
- export const budgetRequest = `github.event_name == 'pull_request' && github.event.pull_request.draft == false && (${renovateRequest})`;
9
+ export const budgetRequest = `github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.draft == false && (${renovateRequest}))`;
10
10
  export const checksRequest = `always() && (${readyRequest}) && (needs.budget.result == 'success' || needs.budget.result == 'skipped')`;
11
11
  export const resultRequest = `always() && (${readyRequest})`;
12
+ export const mainOnlyRequest =
13
+ "always() && github.event_name == 'push' && needs.budget.result == 'success'";
12
14
  export const readyGroup = `\${{ github.workflow }}-\${{ github.event_name == 'pull_request' && !((${headRequest}) || (${renovateRequest})) && format('label-{0}-{1}', github.event.pull_request.number, github.event.label.name) || github.event.pull_request.number || github.ref }}`;
13
15
  export const readyCancellation = `\${{ github.event_name == 'pull_request' && ((${headRequest}) || (${renovateRequest})) }}`;
14
16
  export const readyRunName = `\${{ github.event_name == 'push' && format('ready {0} at {1}', github.ref_name, github.sha) || ((${headRequest}) || (${renovateRequest})) && format('ready #{0} at {1}', github.event.pull_request.number, github.event.pull_request.head.sha) || format('label {0} on #{1}', github.event.label.name, github.event.pull_request.number) }}`;
@@ -66,7 +68,8 @@ const Layout = Schema.Struct({
66
68
  });
67
69
 
68
70
  const MainOnlyJob = Schema.Struct({
69
- if: Schema.Literal("github.event_name == 'push'"),
71
+ needs: Schema.Literal("budget"),
72
+ if: Schema.Literal(mainOnlyRequest),
70
73
  });
71
74
 
72
75
  export const isRenovateCi = (text: string): boolean => {
@@ -0,0 +1,121 @@
1
+ import { createRequire } from "node:module";
2
+ import { dirname } from "node:path";
3
+
4
+ import { Diagnostic, Rule, RuleContext } from "effect-oxlint";
5
+ import type { ESTree } from "effect-oxlint";
6
+ import * as Effect from "effect/Effect";
7
+ import * as Option from "effect/Option";
8
+
9
+ import { importedPath, lastName } from "../shared/member-path.ts";
10
+ import {
11
+ isStringLiteral,
12
+ memberPropertyName,
13
+ unwrapExpression,
14
+ } from "../shared/syntax.ts";
15
+ import { isTestFile, testPath } from "./test-api.ts";
16
+ import { packageAt } from "./test-package.ts";
17
+
18
+ export const noMockCallMirrorsRule = Rule.define({
19
+ *create() {
20
+ const context = yield* RuleContext;
21
+ if (!isTestFile(context.filename)) return {};
22
+ const own = packageAt(dirname(context.filename));
23
+ const require = createRequire(context.filename);
24
+ const local = (source: string): boolean => {
25
+ if (
26
+ /^(?:\.|#)/u.test(source) ||
27
+ Option.exists(
28
+ own,
29
+ ({ manifest }) =>
30
+ manifest.name !== undefined &&
31
+ (source === manifest.name || source.startsWith(`${manifest.name}/`))
32
+ )
33
+ )
34
+ return true;
35
+ try {
36
+ const resolved = require.resolve(source);
37
+ return resolved.startsWith("/") && !resolved.includes("/node_modules/");
38
+ } catch {
39
+ return false;
40
+ }
41
+ };
42
+ const mocked = new Set<string>();
43
+ const assertions: Array<{
44
+ readonly node: ESTree.Node;
45
+ readonly source: string;
46
+ }> = [];
47
+ const sourceOf = (node: ESTree.Node): Option.Option<string> => {
48
+ const value = unwrapExpression(node);
49
+ if (
50
+ value.type === "CallExpression" &&
51
+ ["mocked", "expect"].includes(
52
+ Option.getOrElse(lastName(value.callee), () => "")
53
+ )
54
+ ) {
55
+ const [first] = value.arguments;
56
+ return first === undefined ? Option.none() : sourceOf(first);
57
+ }
58
+ return Option.map(
59
+ importedPath(context.sourceCode, value),
60
+ ({ source }) => source
61
+ );
62
+ };
63
+ return {
64
+ CallExpression: (node: ESTree.Node) => {
65
+ if (node.type !== "CallExpression") return Effect.void;
66
+ const path = testPath(context.sourceCode, node.callee);
67
+ const [first] = node.arguments;
68
+ if (
69
+ ["vi", "vitest"].includes(path[0] ?? "") &&
70
+ ["mock", "doMock"].includes(path[1] ?? "") &&
71
+ first !== undefined &&
72
+ isStringLiteral(first)
73
+ ) {
74
+ mocked.add(first.value);
75
+ }
76
+ const callee = unwrapExpression(node.callee);
77
+ if (
78
+ callee.type === "MemberExpression" &&
79
+ Option.getOrElse(memberPropertyName(callee), () => "").startsWith(
80
+ "toHaveBeenCalled"
81
+ )
82
+ ) {
83
+ let object = unwrapExpression(callee.object);
84
+ while (object.type === "MemberExpression")
85
+ object = unwrapExpression(object.object);
86
+ if (
87
+ object.type === "CallExpression" &&
88
+ testPath(context.sourceCode, object.callee)[0] === "expect"
89
+ ) {
90
+ const [subject] = object.arguments;
91
+ if (subject !== undefined)
92
+ Option.match(sourceOf(subject), {
93
+ onNone: () => undefined,
94
+ onSome: (source) => assertions.push({ node, source }),
95
+ });
96
+ }
97
+ }
98
+ return Effect.void;
99
+ },
100
+ "Program:exit": () =>
101
+ Effect.forEach(
102
+ assertions.filter(
103
+ ({ source }) => mocked.has(source) && local(source)
104
+ ),
105
+ ({ node }) =>
106
+ context.report(Diagnostic.fromId({ node, messageId: "behavior" })),
107
+ { discard: true, concurrency: 1 }
108
+ ),
109
+ };
110
+ },
111
+ meta: Rule.meta({
112
+ description:
113
+ "Local module mocks are not asserted through their call history",
114
+ messages: {
115
+ behavior:
116
+ "Run the real local module and assert its observable result. Delete the local vi.mock and the toHaveBeenCalled mirror.",
117
+ },
118
+ type: "problem",
119
+ }),
120
+ name: "no-mock-call-mirrors",
121
+ });
@@ -0,0 +1,102 @@
1
+ import { dirname, join, resolve } from "node:path";
2
+
3
+ import { Diagnostic, Rule, RuleContext } from "effect-oxlint";
4
+ import type { ESTree } from "effect-oxlint";
5
+ import * as Effect from "effect/Effect";
6
+ import * as Option from "effect/Option";
7
+
8
+ import { isStringLiteral } from "../shared/syntax.ts";
9
+ import { isTestFile } from "./test-api.ts";
10
+ import { manifestAt, packageAt } from "./test-package.ts";
11
+
12
+ const publicSubpath = (exports: unknown, subpath: string): boolean => {
13
+ if (exports === undefined) return subpath === ".";
14
+ if (typeof exports === "string" || exports === null || Array.isArray(exports))
15
+ return subpath === "." && exports !== null;
16
+ if (typeof exports !== "object") return false;
17
+ const keys = Object.keys(exports);
18
+ if (!keys.some((key) => key.startsWith("."))) return subpath === ".";
19
+ const entries = Object.entries(exports);
20
+ const exact = entries.find(([key]) => key === subpath);
21
+ if (exact !== undefined) return exact[1] !== null;
22
+ const patterns = entries
23
+ .filter(([key]) => key.includes("*"))
24
+ .toSorted(([a], [b]) => {
25
+ const prefix = b.indexOf("*") - a.indexOf("*");
26
+ return prefix === 0 ? b.length - a.length : prefix;
27
+ });
28
+ const matched = patterns.find(([key]) => {
29
+ const [prefix, suffix] = key.split("*");
30
+ return subpath.startsWith(prefix ?? "") && subpath.endsWith(suffix ?? "");
31
+ });
32
+ return matched !== undefined && matched[1] !== null;
33
+ };
34
+
35
+ export const noTestInternalImportsRule = Rule.define({
36
+ *create() {
37
+ const context = yield* RuleContext;
38
+ if (!isTestFile(context.filename)) return {};
39
+ const folder = dirname(context.filename);
40
+ const own = packageAt(folder);
41
+ const internal = (source: string): boolean => {
42
+ if (source.startsWith(".")) {
43
+ const target = resolve(folder, source);
44
+ if (
45
+ dirname(target) === folder ||
46
+ /\/(?:tests?|__tests__)\//u.test(target)
47
+ )
48
+ return false;
49
+ return true;
50
+ }
51
+ const parts = source.split("/");
52
+ const name = source.startsWith("@")
53
+ ? parts.slice(0, 2).join("/")
54
+ : (parts[0] ?? "");
55
+ const subpath = source === name ? "." : `.${source.slice(name.length)}`;
56
+ if (source.startsWith("#")) return true;
57
+ if (
58
+ Option.exists(
59
+ own,
60
+ ({ manifest }) =>
61
+ manifest.name === name && !publicSubpath(manifest.exports, subpath)
62
+ )
63
+ )
64
+ return true;
65
+ let directory = folder;
66
+ while (dirname(directory) !== directory) {
67
+ const dependency = manifestAt(join(directory, "node_modules", name));
68
+ if (Option.isSome(dependency))
69
+ return !publicSubpath(dependency.value.exports, subpath);
70
+ directory = dirname(directory);
71
+ }
72
+ return /(?:^|\/)(?:src|internal)\//u.test(source);
73
+ };
74
+ const check = (node: ESTree.Node) =>
75
+ isStringLiteral(node) && internal(node.value)
76
+ ? context.report(Diagnostic.fromId({ node, messageId: "public" }))
77
+ : Effect.void;
78
+ return {
79
+ ImportDeclaration: (node: ESTree.Node) =>
80
+ node.type === "ImportDeclaration" ? check(node.source) : Effect.void,
81
+ ImportExpression: (node: ESTree.Node) =>
82
+ node.type === "ImportExpression" ? check(node.source) : Effect.void,
83
+ CallExpression: (node: ESTree.Node) =>
84
+ node.type === "CallExpression" &&
85
+ node.callee.type === "Identifier" &&
86
+ node.callee.name === "require" &&
87
+ node.arguments[0] !== undefined
88
+ ? check(node.arguments[0])
89
+ : Effect.void,
90
+ };
91
+ },
92
+ meta: Rule.meta({
93
+ description:
94
+ "Tests use public package exports unless colocated with their subject",
95
+ messages: {
96
+ public:
97
+ "Import the package's public entry point or exported subpath. Move this test beside its subject if it needs internal files.",
98
+ },
99
+ type: "problem",
100
+ }),
101
+ name: "no-test-internal-imports",
102
+ });
@@ -0,0 +1,83 @@
1
+ import { dirname } from "node:path";
2
+
3
+ import { Diagnostic, Rule, RuleContext } from "effect-oxlint";
4
+ import type { ESTree } from "effect-oxlint";
5
+ import * as Effect from "effect/Effect";
6
+ import * as Option from "effect/Option";
7
+
8
+ import { propertyName } from "../shared/syntax.ts";
9
+ import { isTestCall, isTestFile, testPath } from "./test-api.ts";
10
+ import { packageAt } from "./test-package.ts";
11
+
12
+ export const noTestTimeoutsRule = Rule.define({
13
+ *create() {
14
+ const context = yield* RuleContext;
15
+ const test = isTestFile(context.filename);
16
+ const config = /(?:vitest|vite)\.config\.[cm]?[jt]s$/u.test(
17
+ context.filename
18
+ );
19
+ const report = (node: ESTree.Node) =>
20
+ context.report(Diagnostic.fromId({ node, messageId: "remove" }));
21
+ return {
22
+ Program: (node: ESTree.Node) =>
23
+ (test || config) &&
24
+ Option.exists(packageAt(dirname(context.filename)), ({ manifest }) =>
25
+ Object.values(manifest.scripts ?? {}).some((command) =>
26
+ /(?:^|\s)--retry(?:[=\s]|$)/u.test(command)
27
+ )
28
+ )
29
+ ? report(node)
30
+ : Effect.void,
31
+ CallExpression: (node: ESTree.Node) => {
32
+ if (!test || node.type !== "CallExpression") return Effect.void;
33
+ const path = testPath(context.sourceCode, node.callee);
34
+ const overrides = node.arguments.some(
35
+ (argument) =>
36
+ argument.type === "ObjectExpression" &&
37
+ argument.properties.some(
38
+ (property) =>
39
+ property.type === "Property" &&
40
+ ["timeout", "testTimeout", "hookTimeout", "retry"].some(
41
+ (name) => Option.contains(propertyName(property), name)
42
+ )
43
+ )
44
+ );
45
+ return (isTestCall(context.sourceCode, node.callee) &&
46
+ (node.arguments.length > 2 || path.includes("retry") || overrides)) ||
47
+ path.includes("setTimeout") ||
48
+ (path.includes("setConfig") && overrides)
49
+ ? report(node)
50
+ : Effect.void;
51
+ },
52
+ Property: (node: ESTree.Node) =>
53
+ config &&
54
+ node.type === "Property" &&
55
+ ["timeout", "testTimeout", "hookTimeout", "retry"].some((name) =>
56
+ Option.contains(propertyName(node), name)
57
+ )
58
+ ? report(node)
59
+ : Effect.void,
60
+ Literal: (node: ESTree.Node) =>
61
+ (test || config) &&
62
+ node.type === "Literal" &&
63
+ typeof node.value === "string" &&
64
+ !(
65
+ node.parent.type === "Property" &&
66
+ Option.contains(propertyName(node.parent), "code")
67
+ ) &&
68
+ /(?:^|\s)--retry(?:[=\s]|$)/u.test(node.value)
69
+ ? report(node)
70
+ : Effect.void,
71
+ };
72
+ },
73
+ meta: Rule.meta({
74
+ description:
75
+ "Tests use runner defaults without retries or timeout overrides",
76
+ messages: {
77
+ remove:
78
+ "Remove the test timeout or retry override. Fix the slow or flaky test and use the runner defaults.",
79
+ },
80
+ type: "problem",
81
+ }),
82
+ name: "no-test-timeouts",
83
+ });