@milkenjoyer/toolchain 0.22.0 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/TESTING.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Test hygiene
2
2
 
3
- Toolchain 0.22.0 enables these `birbprophet` rules at error in `lint()`. `guard` rejects lowering them outside the shared exact-file exceptions. They apply to `.test`, `.spec` and `.fake` TypeScript/JavaScript files and files inside `test`, `tests` or `__tests__` directories. Timeout/retry configuration is also checked in Vite and Vitest config files. The timeout rule also rejects `--retry` in the containing package's scripts.
3
+ Toolchain 0.22.0 enables these `birbprophet` rules at error in `lint()`. `guard` rejects lowering them outside issue-linked exact-file exceptions. They apply to `.test`, `.spec` and `.fake` TypeScript/JavaScript files and files inside `test`, `tests` or `__tests__` directories. Timeout/retry configuration is also checked in Vite and Vitest config files. The timeout rule also rejects `--retry` in the containing package's scripts.
4
4
 
5
5
  | Rule | Required repair | Replaces |
6
6
  | --- | --- | --- |
@@ -23,4 +23,6 @@ The issue marker must be on the immediately preceding line. Empty, zero and miss
23
23
 
24
24
  Existing agent-kit violations are listed by exact filename and rule in `exceptions.ts`, linked to #532. Remove each exception as that cleanup repairs its file. No directory-wide exemption is shipped.
25
25
 
26
+ A consumer can pass its cleanup list to `lint({ exceptions })`. Each entry names `files`, `rules` and a full GitHub `issue` URL, using the exported `Exception` type. The preset rejects file patterns and missing issue links. Its generated settings retain that list for `ruleFindings` and `standard`; merge custom settings with the preset's settings to keep those issue links. Existing violations stay with the repo's cleanup campaign; new files keep the shared rules at error.
27
+
26
28
  Siglata, vibebattler and OptionHouse need `@milkenjoyer/toolchain` pinned to `0.22.0` or a later compatible release. Their `0.18`/`0.10` pins do not contain these rules. Update the dependency pin after publication; consume the package's preset rather than copying rule files. Siglata #3564 and OptionHouse #1142 own their ongoing ports. Each repo's cleanup campaign owns its existing violations.
@@ -1,7 +1,7 @@
1
1
  import { d as otherTags, l as latestOf, u as onLatestLine } from "./compatible-CRaMYpBM.mjs";
2
2
  import { i as enforcedTsgoRules } from "./effect-tsgo-D0QfeKGD.mjs";
3
3
  import { t as exceptions } from "./exceptions-D0yZUk8P.mjs";
4
- import { a as toolchainScopes, n as effectRules, r as foldkitPreset, t as birbprophetRules } from "./lint-Bx4NP_kA.mjs";
4
+ import { a as toolchainScopes, n as effectRules, o as configuredExceptions, r as foldkitPreset, s as exceptionFindings, t as birbprophetRules } from "./lint-C24rC9QX.mjs";
5
5
  import { c as lead, f as versionOf } from "./versions-KbYa8kbF.mjs";
6
6
  import * as Effect from "effect/Effect";
7
7
  import * as Schema from "effect/Schema";
@@ -120,23 +120,21 @@ const inheritedFindings = (where, { extends: extendedConfigs = [] }) => Arr.flat
120
120
  const path = `${where}extends[${index}]`;
121
121
  return [...overrideFindings(path, overrides, []), ...inheritedFindings(`${path}.`, extended)];
122
122
  });
123
- const ruleFindings = dual((args) => args[0] !== void 0 && !Schema.is(Schema.Array(Schema.Unknown))(args[0]), ({ overrides = [], ...config }, list = exceptions) => [
124
- ...Arr.flatMap(guarded, (rule) => Option.match(settingOf(config.rules, rule), {
125
- onNone: () => [`${rule} is not set`],
126
- onSome: (setting) => atError(setting) ? [] : [`${rule} is ${severityOf(setting)}`]
127
- })),
128
- ...overrideFindings("the config's", overrides, list),
129
- ...scopeFindings(overrides),
130
- ...inheritedFindings("", config)
131
- ]);
132
- const GLOB = /[*?[\]{}!]/u;
133
- const ISSUE = /^https:\/\/github\.com\/[\w.-]+\/[\w.-]+\/issues\/\d+$/u;
134
- const exceptionFindings = (list = exceptions) => Arr.flatMap(list, (exception, index) => [
135
- ...Arr.isReadonlyArrayEmpty(exception.files) ? [`exception ${index} names no file`] : [],
136
- ...Arr.flatMap(exception.files, (file) => GLOB.test(file) ? [`exception ${index} names ${file}, a pattern rather than a file`] : []),
137
- ...Arr.isReadonlyArrayEmpty(exception.rules) ? [`exception ${index} names no rule`] : [],
138
- ...ISSUE.test(exception.issue) ? [] : [`exception ${index} has no issue link: ${exception.issue}`]
139
- ]);
123
+ const ruleFindings = dual((args) => args[0] !== void 0 && !Schema.is(Schema.Array(Schema.Unknown))(args[0]), ({ overrides = [], ...config }, list = exceptions) => {
124
+ const local = configuredExceptions(config);
125
+ const configured = local.kind === "Read" ? local.exceptions : [];
126
+ return [
127
+ ...local.kind === "Invalid" ? ["the config has invalid issue-linked exceptions"] : [],
128
+ ...exceptionFindings(configured),
129
+ ...Arr.flatMap(guarded, (rule) => Option.match(settingOf(config.rules, rule), {
130
+ onNone: () => [`${rule} is not set`],
131
+ onSome: (setting) => atError(setting) ? [] : [`${rule} is ${severityOf(setting)}`]
132
+ })),
133
+ ...overrideFindings("the config's", overrides, [...list, ...configured]),
134
+ ...scopeFindings(overrides),
135
+ ...inheritedFindings("", config)
136
+ ];
137
+ });
140
138
  const familyTagFindings = (registry, family) => Option.match(latestOf(registry, family), {
141
139
  onNone: () => [`${lead(family)} has no latest tag in the registry record`],
142
140
  onSome: (latest) => family.version === latest ? [] : Option.match(Arr.findFirst(otherTags(registry, family), ([, version]) => version === family.version), {
@@ -145,4 +143,4 @@ const familyTagFindings = (registry, family) => Option.match(latestOf(registry,
145
143
  })
146
144
  });
147
145
  const tagFindings = dual(2, (current, registry) => Arr.flatMap(current.families, (family) => familyTagFindings(registry, family)));
148
- export { ruleFindings as a, exactFindings as c, pinFindings as i, manifestRanges as l, foldkitViteFindings as n, tagFindings as o, isFoldkitViteInput as r, PLAIN as s, exceptionFindings as t, resolveCatalog as u };
146
+ export { tagFindings as a, manifestRanges as c, ruleFindings as i, resolveCatalog as l, isFoldkitViteInput as n, PLAIN as o, pinFindings as r, exactFindings as s, foldkitViteFindings as t };
package/dist/guard.d.mts CHANGED
@@ -2,6 +2,7 @@ import { r as Packuments } from "./compatible-BKEJ_p20.mjs";
2
2
  import { t as Exception } from "./exceptions-LNZ022dl.mjs";
3
3
  import { t as Catalog } from "./versions-DqZd0jF9.mjs";
4
4
  import { OxlintConfig } from "vite-plus/lint";
5
+ export declare const exceptionFindings: (list?: ReadonlyArray<Exception>) => ReadonlyArray<string>;
5
6
  type Ranges = Readonly<Record<string, string>>;
6
7
  export declare const manifestRanges: (text: string) => ReadonlyArray<readonly [string, Ranges]>;
7
8
  export declare const exactFindings: {
@@ -18,7 +19,6 @@ export declare const ruleFindings: {
18
19
  (list?: ReadonlyArray<Exception>): (config: OxlintConfig) => ReadonlyArray<string>;
19
20
  (config: OxlintConfig, list?: ReadonlyArray<Exception>): ReadonlyArray<string>;
20
21
  };
21
- export declare const exceptionFindings: (list?: ReadonlyArray<Exception>) => ReadonlyArray<string>;
22
22
  export declare const tagFindings: {
23
23
  (registry: Packuments): (current: Catalog) => ReadonlyArray<string>;
24
24
  (current: Catalog, registry: Packuments): ReadonlyArray<string>;
package/dist/guard.mjs CHANGED
@@ -1 +1,3 @@
1
- export { c as exactFindings, t as exceptionFindings, n as foldkitViteFindings, r as isFoldkitViteInput, l as manifestRanges, i as pinFindings, a as ruleFindings, o as tagFindings } from "./guard-n0LC_buo.mjs";
1
+ import { s as exceptionFindings } from "./lint-C24rC9QX.mjs";
2
+ import { a as tagFindings, c as manifestRanges, i as ruleFindings, n as isFoldkitViteInput, r as pinFindings, s as exactFindings, t as foldkitViteFindings } from "./guard-D33fM6yS.mjs";
3
+ export { exactFindings, exceptionFindings, foldkitViteFindings, isFoldkitViteInput, manifestRanges, pinFindings, ruleFindings, tagFindings };
@@ -10,6 +10,28 @@ import * as R from "effect/Record";
10
10
  import * as Str from "effect/String";
11
11
  import foldkitRecommended from "@foldkit/oxlint-plugin/recommended.json" with { type: "json" };
12
12
  import ultraciteCore from "ultracite/oxlint/core";
13
+ // src/lint/exceptions.ts
14
+ const exceptionSetting = "birbprophet/exceptions";
15
+ const ExceptionList = Schema.Array(Schema.Struct({
16
+ files: Schema.Array(Schema.String),
17
+ rules: Schema.Array(Schema.String),
18
+ issue: Schema.String
19
+ }));
20
+ const configuredExceptions = (config) => {
21
+ const value = config.settings?.["birbprophet/exceptions"] ?? [];
22
+ return Schema.is(ExceptionList)(value) ? {
23
+ kind: "Read",
24
+ exceptions: value
25
+ } : { kind: "Invalid" };
26
+ };
27
+ const GLOB = /[*?[\]{}!]/u;
28
+ const ISSUE = /^https:\/\/github\.com\/[\w.-]+\/[\w.-]+\/issues\/\d+$/u;
29
+ const exceptionFindings = (list = exceptions) => Arr.flatMap(list, (exception, index) => [
30
+ ...Arr.isReadonlyArrayEmpty(exception.files) ? [`exception ${index} names no file`] : [],
31
+ ...Arr.flatMap(exception.files, (file) => GLOB.test(file) ? [`exception ${index} names ${file}, a pattern rather than a file`] : []),
32
+ ...Arr.isReadonlyArrayEmpty(exception.rules) ? [`exception ${index} names no rule`] : [],
33
+ ...ISSUE.test(exception.issue) ? [] : [`exception ${index} has no issue link: ${exception.issue}`]
34
+ ]);
13
35
  // src/lint.ts
14
36
  const plugins = [
15
37
  "typescript",
@@ -97,44 +119,49 @@ const exceptionTier = (exception) => ({
97
119
  files: [...exception.files],
98
120
  rules: R.fromEntries(Arr.map(exception.rules, (rule) => [rule, "off"]))
99
121
  });
100
- const lint = ({ ignores = [] } = {}) => ({
101
- plugins,
102
- categories,
103
- jsPlugins: [
104
- {
105
- name: "vite-plus",
106
- specifier: resolved("vite-plus/oxlint-plugin")
107
- },
108
- {
109
- name: "foldkit",
110
- specifier: sibling("foldkit-plugin")
122
+ const lint = ({ ignores = [], exceptions: local = [] } = {}) => {
123
+ const findings = exceptionFindings(local);
124
+ if (findings.length > 0) throw new Error(findings.join("\n"));
125
+ return {
126
+ ...local.length > 0 ? { settings: { [exceptionSetting]: local } } : {},
127
+ plugins,
128
+ categories,
129
+ jsPlugins: [
130
+ {
131
+ name: "vite-plus",
132
+ specifier: resolved("vite-plus/oxlint-plugin")
133
+ },
134
+ {
135
+ name: "foldkit",
136
+ specifier: sibling("foldkit-plugin")
137
+ },
138
+ {
139
+ name: plugin.meta.name,
140
+ specifier: sibling("effect-plugin")
141
+ },
142
+ {
143
+ name: plugin$1.meta.name,
144
+ specifier: sibling("plugin")
145
+ }
146
+ ],
147
+ options: {
148
+ typeAware: true,
149
+ typeCheck: true
111
150
  },
112
- {
113
- name: plugin.meta.name,
114
- specifier: sibling("effect-plugin")
151
+ rules: {
152
+ ...foldkitPreset.rules,
153
+ ...staticRules,
154
+ "vite-plus/prefer-vite-plus-imports": "error",
155
+ ...effectRules,
156
+ ...birbprophetRules,
157
+ ...effectTsgoRules
115
158
  },
116
- {
117
- name: plugin$1.meta.name,
118
- specifier: sibling("plugin")
119
- }
120
- ],
121
- options: {
122
- typeAware: true,
123
- typeCheck: true
124
- },
125
- rules: {
126
- ...foldkitPreset.rules,
127
- ...staticRules,
128
- "vite-plus/prefer-vite-plus-imports": "error",
129
- ...effectRules,
130
- ...birbprophetRules,
131
- ...effectTsgoRules
132
- },
133
- overrides: [
134
- ...foldkitPreset.overrides,
135
- ...toolchainScopes,
136
- ...Arr.map(exceptions, exceptionTier)
137
- ],
138
- ignorePatterns: [...coreIgnores, ...ignores]
139
- });
140
- export { toolchainScopes as a, lint as i, effectRules as n, foldkitPreset as r, birbprophetRules as t };
159
+ overrides: [
160
+ ...foldkitPreset.overrides,
161
+ ...toolchainScopes,
162
+ ...Arr.map([...exceptions, ...local], exceptionTier)
163
+ ],
164
+ ignorePatterns: [...coreIgnores, ...ignores]
165
+ };
166
+ };
167
+ export { toolchainScopes as a, lint as i, effectRules as n, configuredExceptions as o, foldkitPreset as r, exceptionFindings as s, birbprophetRules as t };
package/dist/lint.d.mts CHANGED
@@ -1,6 +1,8 @@
1
+ import { t as Exception } from "./exceptions-LNZ022dl.mjs";
1
2
  import { OxlintConfig, OxlintOverride } from "vite-plus/lint";
2
3
  export type LintOptions = {
3
4
  readonly ignores?: ReadonlyArray<string>;
5
+ readonly exceptions?: ReadonlyArray<Exception>;
4
6
  };
5
7
  export declare const foldkitPreset: {
6
8
  readonly jsPlugins: readonly {
@@ -21,4 +23,4 @@ export declare const foldkitPreset: {
21
23
  export declare const toolchainScopes: ReadonlyArray<OxlintOverride>;
22
24
  export declare const effectRules: Record<string, "error">;
23
25
  export declare const birbprophetRules: Record<string, "error">;
24
- export declare const lint: ({ ignores }?: LintOptions) => OxlintConfig;
26
+ export declare const lint: ({ ignores, exceptions: local }?: LintOptions) => OxlintConfig;
package/dist/lint.mjs CHANGED
@@ -1 +1 @@
1
- export { t as birbprophetRules, n as effectRules, r as foldkitPreset, i as lint, a as toolchainScopes } from "./lint-Bx4NP_kA.mjs";
1
+ export { t as birbprophetRules, n as effectRules, r as foldkitPreset, i as lint, a as toolchainScopes } from "./lint-C24rC9QX.mjs";
@@ -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";
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-n0LC_buo.mjs";
3
+ import { c as manifestRanges, i as ruleFindings, l as resolveCatalog, o as PLAIN, s as exactFindings } from "./guard-D33fM6yS.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.22.0",
3
+ "version": "0.23.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/birbprophet/agent-kit.git",
package/src/guard.ts CHANGED
@@ -21,6 +21,8 @@ import {
21
21
  foldkitPreset,
22
22
  toolchainScopes,
23
23
  } from "./lint.ts";
24
+ import { configuredExceptions, exceptionFindings } from "./lint/exceptions.ts";
25
+ export { exceptionFindings } from "./lint/exceptions.ts";
24
26
  import { manifestRanges, type Ranges } from "./standard/manifest.ts";
25
27
  export { exactFindings, manifestRanges } from "./standard/manifest.ts";
26
28
  import { type Catalog, type Family, lead, versionOf } from "./versions.ts";
@@ -233,44 +235,28 @@ export const ruleFindings: {
233
235
  (
234
236
  { overrides = [], ...config }: OxlintConfig,
235
237
  list: ReadonlyArray<Exception> = shared
236
- ): ReadonlyArray<string> => [
237
- ...Arr.flatMap(guarded, (rule) =>
238
- Option.match(settingOf(config.rules, rule), {
239
- onNone: () => [`${rule} is not set`],
240
- onSome: (setting) =>
241
- atError(setting) ? [] : [`${rule} is ${severityOf(setting)}`],
242
- })
243
- ),
244
- ...overrideFindings("the config's", overrides, list),
245
- ...scopeFindings(overrides),
246
- ...inheritedFindings("", config),
247
- ]
238
+ ): ReadonlyArray<string> => {
239
+ const local = configuredExceptions(config);
240
+ const configured = local.kind === "Read" ? local.exceptions : [];
241
+ return [
242
+ ...(local.kind === "Invalid"
243
+ ? ["the config has invalid issue-linked exceptions"]
244
+ : []),
245
+ ...exceptionFindings(configured),
246
+ ...Arr.flatMap(guarded, (rule) =>
247
+ Option.match(settingOf(config.rules, rule), {
248
+ onNone: () => [`${rule} is not set`],
249
+ onSome: (setting) =>
250
+ atError(setting) ? [] : [`${rule} is ${severityOf(setting)}`],
251
+ })
252
+ ),
253
+ ...overrideFindings("the config's", overrides, [...list, ...configured]),
254
+ ...scopeFindings(overrides),
255
+ ...inheritedFindings("", config),
256
+ ];
257
+ }
248
258
  );
249
259
 
250
- const GLOB = /[*?[\]{}!]/u;
251
-
252
- const ISSUE = /^https:\/\/github\.com\/[\w.-]+\/[\w.-]+\/issues\/\d+$/u;
253
-
254
- export const exceptionFindings = (
255
- list: ReadonlyArray<Exception> = shared
256
- ): ReadonlyArray<string> =>
257
- Arr.flatMap(list, (exception, index) => [
258
- ...(Arr.isReadonlyArrayEmpty(exception.files)
259
- ? [`exception ${index} names no file`]
260
- : []),
261
- ...Arr.flatMap(exception.files, (file) =>
262
- GLOB.test(file)
263
- ? [`exception ${index} names ${file}, a pattern rather than a file`]
264
- : []
265
- ),
266
- ...(Arr.isReadonlyArrayEmpty(exception.rules)
267
- ? [`exception ${index} names no rule`]
268
- : []),
269
- ...(ISSUE.test(exception.issue)
270
- ? []
271
- : [`exception ${index} has no issue link: ${exception.issue}`]),
272
- ]);
273
-
274
260
  const familyTagFindings = (
275
261
  registry: Packuments,
276
262
  family: Family
@@ -0,0 +1,50 @@
1
+ import * as Arr from "effect/Array";
2
+ import * as Schema from "effect/Schema";
3
+ import type { OxlintConfig } from "vite-plus/lint";
4
+
5
+ import { type Exception, exceptions as shared } from "../exceptions.ts";
6
+
7
+ export const exceptionSetting = "birbprophet/exceptions";
8
+
9
+ const ExceptionList = Schema.Array(
10
+ Schema.Struct({
11
+ files: Schema.Array(Schema.String),
12
+ rules: Schema.Array(Schema.String),
13
+ issue: Schema.String,
14
+ })
15
+ );
16
+
17
+ export const configuredExceptions = (
18
+ config: OxlintConfig
19
+ ):
20
+ | { readonly kind: "Read"; readonly exceptions: ReadonlyArray<Exception> }
21
+ | { readonly kind: "Invalid" } => {
22
+ const value = config.settings?.[exceptionSetting] ?? [];
23
+ return Schema.is(ExceptionList)(value)
24
+ ? { kind: "Read", exceptions: value }
25
+ : { kind: "Invalid" };
26
+ };
27
+
28
+ const GLOB = /[*?[\]{}!]/u;
29
+
30
+ const ISSUE = /^https:\/\/github\.com\/[\w.-]+\/[\w.-]+\/issues\/\d+$/u;
31
+
32
+ export const exceptionFindings = (
33
+ list: ReadonlyArray<Exception> = shared
34
+ ): ReadonlyArray<string> =>
35
+ Arr.flatMap(list, (exception, index) => [
36
+ ...(Arr.isReadonlyArrayEmpty(exception.files)
37
+ ? [`exception ${index} names no file`]
38
+ : []),
39
+ ...Arr.flatMap(exception.files, (file) =>
40
+ GLOB.test(file)
41
+ ? [`exception ${index} names ${file}, a pattern rather than a file`]
42
+ : []
43
+ ),
44
+ ...(Arr.isReadonlyArrayEmpty(exception.rules)
45
+ ? [`exception ${index} names no rule`]
46
+ : []),
47
+ ...(ISSUE.test(exception.issue)
48
+ ? []
49
+ : [`exception ${index} has no issue link: ${exception.issue}`]),
50
+ ]);
package/src/lint.ts CHANGED
@@ -10,11 +10,13 @@ import type { OxlintConfig, OxlintOverride } from "vite-plus/lint";
10
10
  import effectPlugin from "./effect-plugin.ts";
11
11
  import { effectTsgoPlugin, effectTsgoRules } from "./effect-tsgo.ts";
12
12
  import { type Exception, exceptions } from "./exceptions.ts";
13
+ import { exceptionFindings, exceptionSetting } from "./lint/exceptions.ts";
13
14
  import birbprophetPlugin from "./plugin.ts";
14
15
  import { staticRules } from "./rules.ts";
15
16
 
16
17
  export type LintOptions = {
17
18
  readonly ignores?: ReadonlyArray<string>;
19
+ readonly exceptions?: ReadonlyArray<Exception>;
18
20
  };
19
21
 
20
22
  const plugins: OxlintConfig["plugins"] = [
@@ -143,28 +145,36 @@ const exceptionTier = (exception: Exception): OxlintOverride => ({
143
145
  ),
144
146
  });
145
147
 
146
- export const lint = ({ ignores = [] }: LintOptions = {}): OxlintConfig => ({
147
- plugins,
148
- categories,
149
- jsPlugins: [
150
- { name: "vite-plus", specifier: resolved("vite-plus/oxlint-plugin") },
151
- { name: "foldkit", specifier: sibling("foldkit-plugin") },
152
- { name: effectPlugin.meta.name, specifier: sibling("effect-plugin") },
153
- { name: birbprophetPlugin.meta.name, specifier: sibling("plugin") },
154
- ],
155
- options: { typeAware: true, typeCheck: true },
156
- rules: {
157
- ...foldkitPreset.rules,
158
- ...staticRules,
159
- "vite-plus/prefer-vite-plus-imports": "error",
160
- ...effectRules,
161
- ...birbprophetRules,
162
- ...effectTsgoRules,
163
- },
164
- overrides: [
165
- ...foldkitPreset.overrides,
166
- ...toolchainScopes,
167
- ...Arr.map(exceptions, exceptionTier),
168
- ],
169
- ignorePatterns: [...coreIgnores, ...ignores],
170
- });
148
+ export const lint = ({
149
+ ignores = [],
150
+ exceptions: local = [],
151
+ }: LintOptions = {}): OxlintConfig => {
152
+ const findings = exceptionFindings(local);
153
+ if (findings.length > 0) throw new Error(findings.join("\n"));
154
+ return {
155
+ ...(local.length > 0 ? { settings: { [exceptionSetting]: local } } : {}),
156
+ plugins,
157
+ categories,
158
+ jsPlugins: [
159
+ { name: "vite-plus", specifier: resolved("vite-plus/oxlint-plugin") },
160
+ { name: "foldkit", specifier: sibling("foldkit-plugin") },
161
+ { name: effectPlugin.meta.name, specifier: sibling("effect-plugin") },
162
+ { name: birbprophetPlugin.meta.name, specifier: sibling("plugin") },
163
+ ],
164
+ options: { typeAware: true, typeCheck: true },
165
+ rules: {
166
+ ...foldkitPreset.rules,
167
+ ...staticRules,
168
+ "vite-plus/prefer-vite-plus-imports": "error",
169
+ ...effectRules,
170
+ ...birbprophetRules,
171
+ ...effectTsgoRules,
172
+ },
173
+ overrides: [
174
+ ...foldkitPreset.overrides,
175
+ ...toolchainScopes,
176
+ ...Arr.map([...exceptions, ...local], exceptionTier),
177
+ ],
178
+ ignorePatterns: [...coreIgnores, ...ignores],
179
+ };
180
+ };
@@ -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 => {