@antelopejs/tooling-configs 0.5.8 → 0.7.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.
Files changed (42) hide show
  1. package/README.md +39 -49
  2. package/dist/{api-CCOiLN3w.mjs → api-BQLrI_S1.mjs} +19 -2
  3. package/dist/bin/api-diff.mjs +155 -37
  4. package/dist/bin/body-check.mjs +6 -3
  5. package/dist/bin/check-size.mjs +1 -1
  6. package/dist/bin/checks.mjs +1 -1
  7. package/dist/bin/comment-proof.mjs +3 -5
  8. package/dist/bin/garden.mjs +86 -34
  9. package/dist/bin/lease.mjs +314 -26
  10. package/dist/bin/ratchet.mjs +4 -4
  11. package/dist/bin/readme-strip.mjs +1 -1
  12. package/dist/bin/suppressions.mjs +10 -6
  13. package/dist/bin/sync.mjs +23 -98
  14. package/dist/bin/triage.mjs +1 -1
  15. package/dist/bin/verify.mjs +1 -1
  16. package/dist/{checks-BC-F8bsv.mjs → checks-BefrkjiT.mjs} +729 -25
  17. package/dist/{docs-compat-Ft1r2sf0.mjs → docs-compat-CSljVi3O.mjs} +13 -8
  18. package/dist/eslint.d.mts +13 -4
  19. package/dist/eslint.mjs +48 -6
  20. package/dist/guardrails-BfGwehVj.mjs +2414 -0
  21. package/dist/installed-typescript-6MtIWlE4.mjs +84 -0
  22. package/dist/oxc/anti-slop/index.mjs +541 -34
  23. package/dist/oxc/guardrails/index.d.mts +1 -1
  24. package/dist/oxc/guardrails/index.mjs +2 -1854
  25. package/dist/oxc/lint.d.mts +10 -1
  26. package/dist/oxc/lint.mjs +13 -5
  27. package/dist/{oxlint-CCOJqj3d.mjs → oxlint-CkHhK5K_.mjs} +33 -11
  28. package/dist/{package-DnxZ2CXZ.mjs → package-DDG3YH7W.mjs} +10 -5
  29. package/dist/{ports-DGP6bPJy.mjs → ports-DAeEJsYh.mjs} +22 -0
  30. package/dist/{proof-stamp-lyD84zmj.mjs → proof-stamp-BFV7JTZT.mjs} +5 -4
  31. package/dist/{ratchet-SQ7vTR0i.mjs → ratchet-2FeMs1kh.mjs} +4 -3
  32. package/dist/{suppression-base-whhvw-IJ.mjs → suppression-base-CYaLZAq7.mjs} +2 -2
  33. package/dist/{suppression-budget-CtIYSoDO.mjs → suppression-budget-CPDSFg4X.mjs} +1 -1
  34. package/dist/{suppressions-C79kRvYI.mjs → suppressions-CxPnh4sC.mjs} +2 -2
  35. package/dist/{templates-Dg188oRC.mjs → templates-HG0fel2S.mjs} +1 -1
  36. package/dist/{type-aware-rules-DMuN6sHb.mjs → type-aware-rules-Da3769fI.mjs} +9 -1
  37. package/dist/{typescript--_8og8AM.mjs → typescript-CxfNxyr2.mjs} +59 -98
  38. package/dist/{workflow-CPcNc8KL.mjs → workflow-C-oBwL2H.mjs} +25 -1
  39. package/package.json +9 -5
  40. package/dist/bin/check-interface-ranges.d.mts +0 -1
  41. package/dist/bin/check-interface-ranges.mjs +0 -44
  42. package/dist/interface-ranges-CcVSr59f.mjs +0 -116
@@ -132,9 +132,17 @@ declare function antelopePreset(options?: AntelopePresetOptions): {
132
132
  "ts-nocheck": false;
133
133
  }];
134
134
  };
135
+ overrides: {
136
+ files: string[];
137
+ rules: {
138
+ "unicorn/no-thenable": "off";
139
+ };
140
+ }[];
135
141
  } | {
136
142
  rules: {
137
- [k: string]: "error";
143
+ [k: string]: "error" | ["error", {
144
+ checkUnknown: boolean;
145
+ }];
138
146
  };
139
147
  } | {
140
148
  jsPlugins: {
@@ -190,6 +198,7 @@ declare function antelopePreset(options?: AntelopePresetOptions): {
190
198
  specifier: string;
191
199
  }[];
192
200
  rules: {
201
+ "antelopejs/no-unrun-query": "off" | "error";
193
202
  "antelopejs/no-unsafe-object-assign": "off" | "error";
194
203
  "antelopejs/require-tsconfig-include": "off" | "error";
195
204
  "antelopejs/require-tsconfig-types": "off" | "error";
package/dist/oxc/lint.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { i as findGitRoot } from "../ceilings-B7KayYIG.mjs";
2
2
  import { t as readCarriedCeilings } from "../renames-L2owF5GD.mjs";
3
- import { t as PRESET_CONFIGS } from "../templates-Dg188oRC.mjs";
4
- import { t as TYPE_AWARE_RULES } from "../type-aware-rules-DMuN6sHb.mjs";
3
+ import { t as PRESET_CONFIGS } from "../templates-HG0fel2S.mjs";
4
+ import { n as typeAwareRuleSetting, t as TYPE_AWARE_RULES } from "../type-aware-rules-Da3769fI.mjs";
5
5
  import { n as TEST_FILE_GLOBS, t as ASSERTION_FUNCTION_NAMES } from "../shared-WC0z3y9F.mjs";
6
6
  import { n as IGNORE_PATTERNS, r as SYNCED_AGENT_PATTERNS } from "../shared-BCFFyp3l.mjs";
7
7
  import { defineConfig } from "oxlint";
@@ -36,7 +36,10 @@ const ANTI_SLOP_RULES = [
36
36
  "no-widen-then-assert",
37
37
  "require-safety-comment-for-type-assertion"
38
38
  ];
39
- /** Correctness must fail CI; underscore bindings and omitted rest siblings are intentional; `@ts-ignore` is banned because `@ts-expect-error` fails once the error is gone. */
39
+ /**
40
+ * Correctness must fail CI; underscore bindings and omitted rest siblings are intentional; `@ts-ignore` is banned because `@ts-expect-error` fails once the error is gone.
41
+ * A test builds thenable stand-ins on purpose, so `unicorn/no-thenable` checks production code only.
42
+ */
40
43
  function basePreset(importCycles) {
41
44
  return defineConfig({
42
45
  categories: { correctness: "error" },
@@ -71,7 +74,11 @@ function basePreset(importCycles) {
71
74
  "ts-ignore": true,
72
75
  "ts-nocheck": false
73
76
  }]
74
- }
77
+ },
78
+ overrides: [{
79
+ files: TEST_FILE_GLOBS,
80
+ rules: { "unicorn/no-thenable": "off" }
81
+ }]
75
82
  });
76
83
  }
77
84
  /**
@@ -147,6 +154,7 @@ function guardrailsPreset(typeAware) {
147
154
  specifier: "@antelopejs/tooling-configs/oxc/guardrails"
148
155
  }],
149
156
  rules: {
157
+ "antelopejs/no-unrun-query": typeAware ? "error" : "off",
150
158
  "antelopejs/no-unsafe-object-assign": typeAware ? "error" : "off",
151
159
  "antelopejs/require-tsconfig-include": typeAware ? "error" : "off",
152
160
  "antelopejs/require-tsconfig-types": typeAware ? "error" : "off"
@@ -179,7 +187,7 @@ function complexityPreset(thresholds) {
179
187
  }
180
188
  /** The {@link TYPE_AWARE_RULES} as oxlint names them. */
181
189
  function typeAwarePreset() {
182
- return defineConfig({ rules: Object.fromEntries(TYPE_AWARE_RULES.map((rule) => [`typescript/${rule}`, "error"])) });
190
+ return defineConfig({ rules: Object.fromEntries(TYPE_AWARE_RULES.map((rule) => [`typescript/${rule}`, typeAwareRuleSetting(rule)])) });
183
191
  }
184
192
  /** Side-effect imports register classes, so sorting may never relocate them. */
185
193
  function importSortingPreset() {
@@ -21,6 +21,7 @@ function ruleId(code) {
21
21
  return `${plugin === "typescript-eslint" ? "typescript" : plugin}/${rule}`;
22
22
  }
23
23
  const NO_FILES = "No files found to lint.";
24
+ const PLUGIN_ERROR = "Error running JS plugin.";
24
25
  /** Whether oxlint matched no file, in which case it prints a notice before its report and exits 1. */
25
26
  function foundNoFiles(stdout) {
26
27
  return stdout.startsWith(NO_FILES) && stdout.includes("{");
@@ -34,10 +35,12 @@ function parseReport(text) {
34
35
  return report.diagnostics;
35
36
  }
36
37
  function toDiagnostic(item, root) {
38
+ const rule = ruleId(item.code ?? "");
39
+ if (item.filename === void 0) throw new Error(`oxlint reported ${rule} with no file: ${item.message}`);
37
40
  const file = repositoryPath(root, item.filename);
38
41
  const span = item.labels?.[0]?.span;
39
42
  return {
40
- rule: ruleId(item.code ?? ""),
43
+ rule,
41
44
  file,
42
45
  location: span ? `${file}:${span.line}:${span.column}` : file,
43
46
  message: item.message,
@@ -75,6 +78,8 @@ function runOxlint(root, config, files, flags) {
75
78
  const diagnostics = parseReport(result.stdout);
76
79
  if (diagnostics === void 0) throw new Error(`oxlint failed (exit ${result.status}): ${result.stdout}${result.stderr}`.trimEnd());
77
80
  if (result.status !== 0 && diagnostics.length === 0 && !foundNoFiles(result.stdout)) throw new Error(`oxlint failed without diagnostics: ${result.stderr || result.stdout}`);
81
+ const crash = diagnostics.find(({ code, message }) => code === void 0 && message.startsWith(PLUGIN_ERROR));
82
+ if (crash) throw new Error(crash.message);
78
83
  return diagnostics;
79
84
  } finally {
80
85
  if (temporary) rmSync(temporary, {
@@ -90,18 +95,35 @@ function lintDiagnostics(root, config, files, { rejectBrokenProject = false } =
90
95
  return diagnostics;
91
96
  }
92
97
  const UNUSED_RULES = /\(no problems were reported from (.+)\)/u;
98
+ function isUnusedDirective(message) {
99
+ return message.startsWith("Unused ") && message.includes("-disable directive");
100
+ }
93
101
  /**
94
102
  * The disable directives in `files` that suppress nothing, with every ratchet
95
- * rule enabled as in a measurement. `files` must not be empty, which would
96
- * lint the whole repository.
103
+ * rule enabled as in a measurement, and the files oxlint could not read.
104
+ * `files` must not be empty, which would lint the whole repository.
97
105
  */
98
- function unusedDirectives(root, files) {
99
- return runOxlint(root, void 0, files, ["--report-unused-disable-directives"]).filter(({ code, message }) => code === void 0 && message.startsWith("Unused ") && message.includes("-disable directive")).map((item) => ({
100
- file: repositoryPath(root, item.filename),
101
- line: item.labels?.[0]?.span.line ?? 0,
102
- message: item.message,
103
- rules: UNUSED_RULES.exec(item.message)?.[1].split(/,\s*/u)
104
- }));
106
+ function directiveReport(root, files) {
107
+ const report = {
108
+ unused: [],
109
+ unreadable: []
110
+ };
111
+ for (const item of runOxlint(root, void 0, files, ["--report-unused-disable-directives"])) {
112
+ if (item.code !== void 0) continue;
113
+ const file = item.filename === void 0 ? void 0 : repositoryPath(root, item.filename);
114
+ const span = item.labels?.[0]?.span;
115
+ if (file !== void 0 && isUnusedDirective(item.message)) report.unused.push({
116
+ file,
117
+ line: span?.line ?? 0,
118
+ message: item.message,
119
+ rules: UNUSED_RULES.exec(item.message)?.[1].split(/,\s*/u)
120
+ });
121
+ else report.unreadable.push({
122
+ location: file !== void 0 && span ? `${file}:${span.line}:${span.column}` : file,
123
+ message: item.message
124
+ });
125
+ }
126
+ return report;
105
127
  }
106
128
  //#endregion
107
- export { unusedDirectives as n, lintDiagnostics as t };
129
+ export { lintDiagnostics as n, directiveReport as t };
@@ -52,14 +52,19 @@ function toolingRoot() {
52
52
  directory = parent;
53
53
  }
54
54
  }
55
+ /** The range of `spec` when it is the npm alias `npm:<name>@<range>`. */
56
+ function aliasedRange(spec, name) {
57
+ const prefix = `npm:${name}@`;
58
+ if (!spec.startsWith(prefix)) throw new Error(`tooling-configs must declare @typescript/native as ${prefix}<range>.`);
59
+ return spec.slice(prefix.length);
60
+ }
55
61
  function toolingVersions() {
56
62
  const manifest = parseManifest(readFileSync(join(toolingRoot(), "package.json"), "utf8"));
57
- const declared = (field, name) => {
58
- const range = manifest[field]?.[name];
59
- if (!range) throw new Error(`tooling-configs must declare ${name} in ${field}.`);
63
+ const dev = (name) => {
64
+ const range = manifest.devDependencies?.[name];
65
+ if (!range) throw new Error(`tooling-configs must declare ${name} in devDependencies.`);
60
66
  return range;
61
67
  };
62
- const dev = (name) => declared("devDependencies", name);
63
68
  if (!manifest.version) throw new Error("tooling-configs must declare its version.");
64
69
  return {
65
70
  lefthook: dev("lefthook"),
@@ -67,7 +72,7 @@ function toolingVersions() {
67
72
  tsgolint: dev("oxlint-tsgolint"),
68
73
  oxlint: dev("oxlint"),
69
74
  oxfmt: dev("oxfmt"),
70
- typescript: declared("dependencies", "typescript"),
75
+ typescript: aliasedRange(dev("@typescript/native"), "typescript"),
71
76
  nodeTypes: dev("@types/node"),
72
77
  capture: CAPTURE_PEERS.map((name) => [name, dev(name)]),
73
78
  packageManager: packageManager$1,
@@ -263,10 +263,31 @@ function lsofListenerPids(port) {
263
263
  return [];
264
264
  }
265
265
  }
266
+ const NETSTAT_LISTENER = /^\s*TCP\s+\S+:(\d+)\s+(?:0\.0\.0\.0|\[::\]):0\s+.*?(\d+)\s*$/u;
267
+ /** The pids `netstat` shows listening on `port`, read by the foreign address, which the state's localized name is not. */
268
+ function netstatListenerPids(port) {
269
+ try {
270
+ return execFileSync("netstat", ["-ano"], {
271
+ encoding: "utf8",
272
+ stdio: [
273
+ "ignore",
274
+ "pipe",
275
+ "ignore"
276
+ ],
277
+ windowsHide: true
278
+ }).split(/\r?\n/u).flatMap((line) => {
279
+ const [, local, pid] = NETSTAT_LISTENER.exec(line) ?? [];
280
+ return Number(local) === port && pid !== void 0 ? [Number(pid)] : [];
281
+ }).filter((pid, at, all) => all.indexOf(pid) === at);
282
+ } catch {
283
+ return [];
284
+ }
285
+ }
266
286
  /** The pids listening on `port` that this user may inspect; empty when none can be read. */
267
287
  function listenerPids(port) {
268
288
  if (process.platform === "linux") return linuxListenerPids(port);
269
289
  if (process.platform === "darwin") return lsofListenerPids(port);
290
+ if (process.platform === "win32") return netstatListenerPids(port);
270
291
  return [];
271
292
  }
272
293
  /**
@@ -276,6 +297,7 @@ function listenerPids(port) {
276
297
  async function listensOn(pid, port) {
277
298
  if (process.platform === "linux") return holdsSocket(String(pid), listenSockets(port));
278
299
  if (process.platform === "darwin") return lsofListenerPids(port).includes(pid);
300
+ if (process.platform === "win32") return netstatListenerPids(port).includes(pid);
279
301
  return accepting(port);
280
302
  }
281
303
  //#endregion
@@ -1,6 +1,6 @@
1
- import { s as parseManifest } from "./package-DnxZ2CXZ.mjs";
1
+ import { s as parseManifest } from "./package-DDG3YH7W.mjs";
2
2
  import { l as resolveRevision, u as trackedManifests } from "./files-C-JJhExM.mjs";
3
- import { o as revisionSuppressions, r as countSuppressions } from "./suppressions-C79kRvYI.mjs";
3
+ import { o as revisionSuppressions, r as countSuppressions } from "./suppressions-CxPnh4sC.mjs";
4
4
  import { copyFileSync, existsSync, lstatSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, realpathSync, rmSync, statSync, symlinkSync } from "node:fs";
5
5
  import { dirname, isAbsolute, join, matchesGlob, relative, sep } from "node:path";
6
6
  import { execFileSync, spawnSync } from "node:child_process";
@@ -161,7 +161,7 @@ function linkDependencies(root, worktree, ownWorkspace) {
161
161
  }
162
162
  }
163
163
  /** Compares isolated committed revisions and removes both worktrees even when compilation fails; a policy lets matching `@internal` additions through. */
164
- function compareRevisions(root, baseRef, label, emit, { policy, ownWorkspace = false } = {}) {
164
+ function compareRevisions(root, baseRef, label, emit, { policy, ownWorkspace = false, collate, annotate } = {}) {
165
165
  const temporary = mkdtempSync(join(tmpdir(), "antelope-proof-"));
166
166
  const worktrees = [];
167
167
  const results = [];
@@ -204,6 +204,7 @@ function compareRevisions(root, baseRef, label, emit, { policy, ownWorkspace = f
204
204
  results.push(emit(worktree, output, join(temporary, "emit", side)));
205
205
  }
206
206
  const allowedAdditions = policy === void 0 ? 0 : applyAllowance(policy, results[0].published ?? [], results[1].published ?? [], (path) => rmSync(join(temporary, "head", path), { force: true }));
207
+ if (collate !== void 0) for (const side of ["base", "head"]) collate(join(temporary, side));
207
208
  const diff = spawnSync("git", [
208
209
  "diff",
209
210
  "--no-index",
@@ -224,7 +225,7 @@ function compareRevisions(root, baseRef, label, emit, { policy, ownWorkspace = f
224
225
  const packages = new Set(results.flatMap((result) => result.packages)).size;
225
226
  return {
226
227
  different: diff.status === 1,
227
- output: diff.status === 1 ? `${label}: differences against ${baseRef} (committed HEAD).\n${diff.stdout}` : `${label}: ${packages} packages, ${results[1].entries - allowedAdditions} entries unchanged against ${baseRef} (committed HEAD).\n`
228
+ output: diff.status === 1 ? `${label}: differences against ${baseRef} (committed HEAD).\n${annotate === void 0 ? diff.stdout : annotate(diff.stdout, temporary)}` : `${label}: ${packages} packages, ${results[1].entries - allowedAdditions} entries unchanged against ${baseRef} (committed HEAD).\n`
228
229
  };
229
230
  } finally {
230
231
  for (const worktree of worktrees.reverse()) execFileSync("git", [
@@ -1,9 +1,9 @@
1
1
  import { a as formatCeilings, c as parseCeilings, n as MAX_FILE_BYTES, o as isPackRelease, s as isRetired, t as CEILINGS_FILE } from "./ceilings-B7KayYIG.mjs";
2
2
  import { n as renamedPaths, t as readCarriedCeilings } from "./renames-L2owF5GD.mjs";
3
- import { f as toolingVersions } from "./package-DnxZ2CXZ.mjs";
3
+ import { f as toolingVersions } from "./package-DDG3YH7W.mjs";
4
4
  import { n as authoredSizes, o as isAgentFile, r as changedFiles, t as LINT_CONFIG } from "./files-C-JJhExM.mjs";
5
- import { t as lintDiagnostics } from "./oxlint-CCOJqj3d.mjs";
6
- import "./suppression-budget-CtIYSoDO.mjs";
5
+ import { n as lintDiagnostics } from "./oxlint-CkHhK5K_.mjs";
6
+ import "./suppression-budget-CPDSFg4X.mjs";
7
7
  import { n as sizeFailure } from "./size-CCGLY4Ke.mjs";
8
8
  import { copyFileSync, existsSync, mkdirSync, mkdtempSync, rmSync, symlinkSync, unlinkSync, writeFileSync } from "node:fs";
9
9
  import { dirname, join } from "node:path";
@@ -21,6 +21,7 @@ const PACK_NEW_RULES = /* @__PURE__ */ new Map([
21
21
  ["antelopejs/no-inherited-key-lookup", "0.2.17"],
22
22
  ["antelopejs/no-presence-only-type-guard", "0.2.17"],
23
23
  ["antelopejs/no-read-then-insert", "0.5.1"],
24
+ ["antelopejs/no-unrun-query", "0.6.0"],
24
25
  ["antelopejs/no-unsafe-object-assign", "0.4.2"],
25
26
  ["antelopejs/require-tsconfig-include", "0.2.18"],
26
27
  ["antelopejs/require-tsconfig-types", "0.4.2"],
@@ -1,6 +1,6 @@
1
1
  import { l as resolveRevision, o as isAgentFile } from "./files-C-JJhExM.mjs";
2
- import { a as parseBudget, n as SUPPRESSIONS_FILE, o as safetyCeiling, p as coveredLimits } from "./suppression-budget-CtIYSoDO.mjs";
3
- import { o as revisionSuppressions, r as countSuppressions } from "./suppressions-C79kRvYI.mjs";
2
+ import { a as parseBudget, n as SUPPRESSIONS_FILE, o as safetyCeiling, p as coveredLimits } from "./suppression-budget-CPDSFg4X.mjs";
3
+ import { o as revisionSuppressions, r as countSuppressions } from "./suppressions-CxPnh4sC.mjs";
4
4
  import { readFileSync } from "node:fs";
5
5
  import { join } from "node:path";
6
6
  import { spawnSync } from "node:child_process";
@@ -1,6 +1,6 @@
1
1
  import { n as renamedPaths } from "./renames-L2owF5GD.mjs";
2
2
  import { o as isAgentFile, r as changedFiles } from "./files-C-JJhExM.mjs";
3
- import { a as openDisablesIn, i as inWorktree, l as worktreeSuppressions, n as configKey, o as revisionSuppressions, r as countSuppressions, s as sortedKeys, t as atRevision } from "./suppressions-C79kRvYI.mjs";
3
+ import { a as openDisablesIn, i as inWorktree, l as worktreeSuppressions, n as configKey, o as revisionSuppressions, r as countSuppressions, s as sortedKeys, t as atRevision } from "./suppressions-CxPnh4sC.mjs";
4
4
  import { existsSync, readFileSync, writeFileSync } from "node:fs";
5
5
  import { join, matchesGlob } from "node:path";
6
6
  import { execFileSync, spawnSync } from "node:child_process";
@@ -6,9 +6,9 @@ import { join } from "node:path";
6
6
  import { execFileSync } from "node:child_process";
7
7
  //#region src/guardrails/parser.ts
8
8
  let compiler;
9
- /** This package's own TypeScript 5, loaded on first use, so the count never depends on the compiler a repository installs (TypeScript 7 has no parser API). */
9
+ /** This package's own TypeScript 6, loaded on first use, so the count never depends on the compiler a repository installs (TypeScript 7 has no parser API). */
10
10
  function typescript() {
11
- compiler ??= createRequire(import.meta.url)("typescript");
11
+ compiler ??= createRequire(import.meta.url)("@typescript/typescript6");
12
12
  return compiler;
13
13
  }
14
14
  //#endregion
@@ -1,4 +1,4 @@
1
- import { i as execCommand } from "./package-DnxZ2CXZ.mjs";
1
+ import { i as execCommand } from "./package-DDG3YH7W.mjs";
2
2
  import { isMap, parseDocument } from "yaml";
3
3
  //#region src/guardrails/templates.ts
4
4
  const PRESET_CONFIGS = [
@@ -26,5 +26,13 @@ const TYPE_AWARE_RULES = [
26
26
  "restrict-template-expressions",
27
27
  "require-array-sort-compare"
28
28
  ];
29
+ /**
30
+ * The setting a type-aware rule runs at. `no-base-to-string` pins
31
+ * `checkUnknown: false`, typescript-eslint's default, so `String(value)` on an
32
+ * `unknown` stays allowed if a release changes that default.
33
+ */
34
+ function typeAwareRuleSetting(rule) {
35
+ return rule === "no-base-to-string" ? ["error", { checkUnknown: false }] : "error";
36
+ }
29
37
  //#endregion
30
- export { TYPE_AWARE_RULES as t };
38
+ export { typeAwareRuleSetting as n, TYPE_AWARE_RULES as t };
@@ -1,9 +1,10 @@
1
- import { s as parseManifest } from "./package-DnxZ2CXZ.mjs";
1
+ import { s as parseManifest } from "./package-DDG3YH7W.mjs";
2
+ import { n as installedCompilerDefaults, r as installedTypeScriptMajor } from "./installed-typescript-6MtIWlE4.mjs";
2
3
  import { u as trackedManifests } from "./files-C-JJhExM.mjs";
3
- import { n as workspaceDirectories, r as workspacePatterns } from "./docs-compat-Ft1r2sf0.mjs";
4
- import { createRequire } from "node:module";
4
+ import { n as workspaceDirectories, r as workspacePatterns } from "./docs-compat-CSljVi3O.mjs";
5
5
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
6
6
  import { dirname, join, matchesGlob, relative, resolve, sep } from "node:path";
7
+ import ts from "@typescript/typescript6";
7
8
  //#region src/guardrails/declared-typescript.ts
8
9
  const DEPENDENCY_FIELDS = [
9
10
  "dependencies",
@@ -92,62 +93,11 @@ function unpublishedAt(root) {
92
93
  }];
93
94
  });
94
95
  }
95
- function packageRoot(file) {
96
- let directory = dirname(file);
97
- while (!existsSync(join(directory, "package.json"))) {
98
- const parent = dirname(directory);
99
- if (parent === directory) return dirname(file);
100
- directory = parent;
101
- }
102
- return directory;
103
- }
104
- function resolveTypeScript(directory) {
105
- try {
106
- return {
107
- file: createRequire(join(directory, "package.json")).resolve("typescript"),
108
- fallback: false
109
- };
110
- } catch (error) {
111
- if (declaresTypeScript(directory)) throw new Error(`${describePackage(directory)} declares typescript but it cannot be resolved from the package directory, so the compiler it builds with is not available. Install dependencies (run pnpm install) and retry.`, { cause: error });
112
- return {
113
- file: packTypeScript(),
114
- fallback: true
115
- };
116
- }
117
- }
118
- /** The TypeScript `dts-bundle-generator` brings, which the pack falls back to. */
119
- function packTypeScript() {
120
- return createRequire(createRequire(import.meta.url).resolve("dts-bundle-generator")).resolve("typescript");
121
- }
122
- /** Loads the TypeScript at `file`; one without the programmatic API (7 and later) yields only its `version`, so the caller reports it rather than crashing. */
123
- function requireTypeScript(file) {
124
- const compiler = createRequire(file)("typescript");
125
- const root = packageRoot(file);
126
- if (compiler.sys === void 0 || !("createProgram" in compiler)) return {
127
- root,
128
- version: compiler.version
129
- };
130
- return {
131
- root,
132
- compiler
133
- };
134
- }
135
- /** Loads the compiler a package builds with, including a package-local installation in a workspace. A package that declares `typescript` (itself or through its workspace root) but cannot resolve it is an error; only a package that declares none falls back to the one `dts-bundle-generator` brings, with a `notice`. A TypeScript without the programmatic API (7 and later) is an error, unless `javascriptOnly` says the caller only strips comments and emits JavaScript, so the pack's TypeScript emits both revisions instead, with a `notice`. */
136
- function loadTypeScript(directory, javascriptOnly = false) {
137
- const { file, fallback } = resolveTypeScript(directory);
138
- const loaded = requireTypeScript(file);
139
- if (loaded.compiler !== void 0) return {
140
- compiler: loaded.compiler,
141
- root: loaded.root,
142
- notice: fallback ? `${repositoryDirectory(directory)}: declares no typescript; using the pack's TypeScript ${loaded.compiler.version}\n` : void 0
143
- };
144
- const pack = javascriptOnly && !fallback ? requireTypeScript(packTypeScript()) : loaded;
145
- if (pack.compiler === void 0) throw new Error(`TypeScript ${loaded.version} at ${loaded.root} has no programmatic compiler API (sys, createProgram), so this package cannot be analysed. Build it with a TypeScript that has one, or mark the package private.`);
146
- return {
147
- compiler: pack.compiler,
148
- root: pack.root,
149
- notice: `${repositoryDirectory(directory)}: TypeScript ${loaded.version} has no programmatic compiler API; emitting JavaScript with the pack's TypeScript ${pack.compiler.version}\n`
150
- };
96
+ /** The TypeScript major the package at `directory` builds with, which decides how its config reads; undefined when it declares none. A package that declares `typescript` (itself or through its workspace root) but cannot resolve it is an error. */
97
+ function packageMajor(directory) {
98
+ const major = installedTypeScriptMajor(directory);
99
+ if (major === void 0 && declaresTypeScript(directory)) throw new Error(`${describePackage(directory)} declares typescript but it cannot be resolved from the package directory, so the compiler version it builds with is not known. Install dependencies (run pnpm install) and retry.`);
100
+ return major;
151
101
  }
152
102
  const TEST_SOURCE_GLOBS = [
153
103
  "**/*.test.*",
@@ -160,15 +110,15 @@ function isTestSource(root, file) {
160
110
  const path = relative(root, file).split("\\").join("/");
161
111
  return TEST_SOURCE_GLOBS.some((pattern) => matchesGlob(path, pattern));
162
112
  }
163
- function formatErrors(compiler, diagnostics) {
164
- return compiler.formatDiagnostics(diagnostics.filter((item) => item.category === compiler.DiagnosticCategory.Error), {
113
+ function formatErrors(diagnostics) {
114
+ return ts.formatDiagnostics(diagnostics.filter((item) => item.category === ts.DiagnosticCategory.Error), {
165
115
  getCanonicalFileName: (file) => file,
166
116
  getCurrentDirectory: () => process.cwd(),
167
117
  getNewLine: () => "\n"
168
118
  });
169
119
  }
170
- function failDiagnostics(compiler, diagnostics) {
171
- const errors = formatErrors(compiler, diagnostics);
120
+ function failDiagnostics(diagnostics) {
121
+ const errors = formatErrors(diagnostics);
172
122
  if (errors) throw new Error(errors);
173
123
  }
174
124
  /** Declaration inputs are part of the local closure but TypeScript does not emit copies of them. */
@@ -193,35 +143,36 @@ function copyDeclarations(program, directory, output, modules) {
193
143
  }
194
144
  /** TS18002: `"files": []` without references. */
195
145
  const EMPTY_FILES_LIST = 18002;
196
- function readConfig(directory, javascriptOnly = false) {
197
- const { compiler, root, notice } = loadTypeScript(directory, javascriptOnly);
146
+ function readConfig(directory) {
198
147
  const file = join(directory, "tsconfig.json");
199
- const config = compiler.readConfigFile(file, compiler.sys.readFile);
200
- if (config.error) failDiagnostics(compiler, [config.error]);
148
+ const config = ts.readConfigFile(file, ts.sys.readFile);
149
+ if (config.error) failDiagnostics([config.error]);
150
+ return ts.parseJsonConfigFileContent(config.config, ts.sys, directory, void 0, file);
151
+ }
152
+ /** Parses `tsconfig.json` as the package's own `tsc -p` would from the package directory, failing on any configuration error. */
153
+ function parseConfig(directory) {
154
+ const parsed = readConfig(directory);
155
+ failDiagnostics(parsed.errors);
156
+ const defaults = installedCompilerDefaults(parsed.options, packageMajor(directory));
201
157
  return {
202
- compiler,
203
- root,
204
- notice,
205
- parsed: compiler.parseJsonConfigFileContent(config.config, compiler.sys, directory, void 0, file)
158
+ ...parsed,
159
+ defaults,
160
+ options: {
161
+ ...parsed.options,
162
+ ...ts.convertCompilerOptionsFromJson(defaults, directory).options
163
+ }
206
164
  };
207
165
  }
208
- /** Parses `tsconfig.json` as `tsc -p` would from the package directory, failing on any configuration error. */
209
- function parseConfig(directory, javascriptOnly = false) {
210
- const config = readConfig(directory, javascriptOnly);
211
- failDiagnostics(config.compiler, config.parsed.errors);
212
- return config;
213
- }
214
- /** Whether `tsconfig.json` has an empty `files` list, references nothing, and so parses to no inputs; read for a JavaScript-only emit, so a compiler without the API falls back as `emitPackage` does. */
166
+ /** Whether `tsconfig.json` has an empty `files` list, references nothing, and so parses to no inputs. */
215
167
  function listsNoFiles(directory) {
216
- const { parsed } = readConfig(directory, true);
168
+ const parsed = readConfig(directory);
217
169
  return parsed.fileNames.length === 0 && parsed.errors.some((error) => error.code === EMPTY_FILES_LIST);
218
170
  }
219
- /** The absolute paths of the configs `tsconfig.json` extends, directly or through another config; read for a JavaScript-only emit, as `listsNoFiles` is. */
171
+ /** The absolute paths of the configs `tsconfig.json` extends, directly or through another config. */
220
172
  function extendedConfigs(directory) {
221
- const { compiler } = loadTypeScript(directory, true);
222
173
  const file = join(directory, "tsconfig.json");
223
- const source = compiler.readJsonConfigFile(file, compiler.sys.readFile);
224
- compiler.parseJsonSourceFileConfigFileContent(source, compiler.sys, directory, void 0, file);
174
+ const source = ts.readJsonConfigFile(file, ts.sys.readFile);
175
+ ts.parseJsonSourceFileConfigFileContent(source, ts.sys, directory, void 0, file);
225
176
  return (source.extendedSourceFiles ?? []).map((path) => resolve(path));
226
177
  }
227
178
  /** TypeScript records on parsed options, untyped, the directory of the config that declares `paths`, which its targets resolve against when no `baseUrl` is set. */
@@ -237,7 +188,7 @@ function absolutePaths(options) {
237
188
  }
238
189
  /** The configured `outDir`, the root under which the declaration half already judges a built path as test output. */
239
190
  function outputRoot(directory) {
240
- return resolve(directory, parseConfig(directory).parsed.options.outDir ?? ".");
191
+ return resolve(directory, parseConfig(directory).options.outDir ?? ".");
241
192
  }
242
193
  /** The root TypeScript lays its emit out under: `rootDir`, else the common directory of every authored source in `program`, wherever it sits. */
243
194
  function emitRoot(program) {
@@ -257,10 +208,10 @@ function withheldDeclarations(program, diagnostics, output, directory) {
257
208
  }
258
209
  return withheld;
259
210
  }
260
- /** Emits with the package's compiler and config, or for JavaScript alone with the pack's when the package's has no compiler API; test roots and outputs never enter either proof. `modules` maps each emitted, copied or `withheld` file to its source module; `paths` is the configured `paths` with absolute targets. */
211
+ /** Emits with the pack's TypeScript 6, reading the package's config as the TypeScript it installs does, and lays the output out under `rootDir`, else the common directory of its sources as TypeScript 5 does; test roots and outputs never enter either proof. `defaults` is what `installedCompilerDefaults` adds to the config. `modules` maps each emitted, copied or `withheld` file to its source module; `paths` is the configured `paths` with absolute targets. */
261
212
  function emitPackage(directory, output, declarations) {
262
- const { compiler, root, notice, parsed } = parseConfig(directory, !declarations);
263
- const options = {
213
+ const parsed = parseConfig(directory);
214
+ const configured = {
264
215
  ...parsed.options,
265
216
  rootDir: parsed.options.rootDir ?? (parsed.options.outDir ? void 0 : directory),
266
217
  outDir: output,
@@ -279,12 +230,24 @@ function emitPackage(directory, output, declarations) {
279
230
  outFile: void 0,
280
231
  allowImportingTsExtensions: declarations ? parsed.options.allowImportingTsExtensions : false
281
232
  };
282
- const program = compiler.createProgram({
283
- rootNames: parsed.fileNames.filter((file) => !isTestSource(directory, file)),
284
- options,
285
- projectReferences: parsed.projectReferences
233
+ const rootNames = parsed.fileNames.filter((file) => !isTestSource(directory, file));
234
+ const projectReferences = parsed.projectReferences;
235
+ const laidOut = ts.createProgram({
236
+ rootNames,
237
+ options: configured,
238
+ projectReferences
286
239
  });
287
- if (declarations) failDiagnostics(compiler, [
240
+ const options = {
241
+ ...configured,
242
+ rootDir: configured.rootDir ?? emitRoot(laidOut)
243
+ };
244
+ const program = configured.rootDir === void 0 ? ts.createProgram({
245
+ rootNames,
246
+ options,
247
+ projectReferences,
248
+ oldProgram: laidOut
249
+ }) : laidOut;
250
+ if (declarations) failDiagnostics([
288
251
  ...program.getConfigFileParsingDiagnostics(),
289
252
  ...program.getOptionsDiagnostics(),
290
253
  ...program.getSyntacticDiagnostics(),
@@ -306,9 +269,7 @@ function emitPackage(directory, output, declarations) {
306
269
  if (declarations) files.push(...copyDeclarations(program, directory, output, modules));
307
270
  for (const [file, source] of withheld) modules.set(file, source);
308
271
  return {
309
- compiler,
310
- compilerRoot: root,
311
- notice,
272
+ defaults: parsed.defaults,
312
273
  files,
313
274
  withheld: [...withheld.keys()],
314
275
  modules,
@@ -317,15 +278,15 @@ function emitPackage(directory, output, declarations) {
317
278
  /** The formatted declaration errors of the modules `sources` reach; empty when there are none. A declaration error in a module no published entry reaches never fails the proof. */
318
279
  declarationErrors(sources) {
319
280
  if (!declarationDiagnostics.length) return "";
320
- const reached = new Set(compiler.createProgram({
281
+ const reached = new Set(ts.createProgram({
321
282
  rootNames: sources,
322
283
  options,
323
284
  projectReferences: parsed.projectReferences,
324
285
  oldProgram: program
325
286
  }).getSourceFiles().map((source) => source.fileName));
326
- return formatErrors(compiler, declarationDiagnostics.filter((item) => item.file !== void 0 && reached.has(item.file.fileName)));
287
+ return formatErrors(declarationDiagnostics.filter((item) => item.file !== void 0 && reached.has(item.file.fileName)));
327
288
  }
328
289
  };
329
290
  }
330
291
  //#endregion
331
- export { listsNoFiles as a, packagesAt as c, isTestSource as i, unpublishedAt as l, extendedConfigs as n, loadTypeScript as o, isExportPath as r, outputRoot as s, emitPackage as t };
292
+ export { listsNoFiles as a, unpublishedAt as c, isTestSource as i, extendedConfigs as n, outputRoot as o, isExportPath as r, packagesAt as s, emitPackage as t };
@@ -518,6 +518,30 @@ function ciWorkflow(current, callers, syncCallers, docsFiles, placeholderTests =
518
518
  });
519
519
  }
520
520
  //#endregion
521
+ //#region src/guardrails/gitattributes.ts
522
+ /** The repository attributes file git reads at checkout. */
523
+ const GITATTRIBUTES = ".gitattributes";
524
+ /** Checks text files out with LF on every platform, whatever `core.autocrlf` says, so a shell script still runs after a Windows clone. */
525
+ const LF_ATTRIBUTES = "* text=auto eol=lf";
526
+ /** Whether `text` holds the LF line, whitespace between its fields aside. */
527
+ function enforcesLf(text) {
528
+ return text.split("\n").some((line) => line.trim().split(/\s+/).join(" ") === LF_ATTRIBUTES);
529
+ }
530
+ /** `current` unchanged when it already enforces LF, else with the LF line first, so the patterns it already lists still override it. */
531
+ function lfGitattributes(current) {
532
+ if (current === void 0) return `${LF_ATTRIBUTES}\n`;
533
+ return enforcesLf(current) ? current : `${LF_ATTRIBUTES}\n${current}`;
534
+ }
535
+ /** The `.gitattributes` sync manages under both profiles, templates included, since a scaffold is cloned on Windows too. */
536
+ const GITATTRIBUTES_ARTIFACT = {
537
+ path: GITATTRIBUTES,
538
+ profiles: ["full", "template"],
539
+ desired: (current) => ({
540
+ content: lfGitattributes(current),
541
+ notes: []
542
+ })
543
+ };
544
+ //#endregion
521
545
  //#region src/guardrails/renovate.ts
522
546
  /** The Renovate config file sync writes when a repository has none. */
523
547
  const RENOVATE_PATH = "renovate.json";
@@ -624,4 +648,4 @@ function ciRenovateSyncCallers(text) {
624
648
  return callers(text, CI_RENOVATE_SYNC_PATTERN);
625
649
  }
626
650
  //#endregion
627
- export { RENOVATE_CONFIGS as a, CI_CONTEXT as c, CI_RENOVATE_SYNC_REF as d, ciWorkflow as f, hasChecksWorkflow as i, CI_NODE_REF as l, ciNodeCallers as n, RENOVATE_PRESET as o, placeholderTestScript as p, ciRenovateSyncCallers as r, renovateArtifacts as s, MISSING_CHECKS_WORKFLOW as t, CI_PATH as u };
651
+ export { placeholderTestScript as _, RENOVATE_CONFIGS as a, GITATTRIBUTES as c, enforcesLf as d, CI_CONTEXT as f, ciWorkflow as g, CI_RENOVATE_SYNC_REF as h, hasChecksWorkflow as i, GITATTRIBUTES_ARTIFACT as l, CI_PATH as m, ciNodeCallers as n, RENOVATE_PRESET as o, CI_NODE_REF as p, ciRenovateSyncCallers as r, renovateArtifacts as s, MISSING_CHECKS_WORKFLOW as t, LF_ATTRIBUTES as u };