@mark1russell7/conventions 0.36.2 → 0.37.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.
@@ -2211,6 +2211,325 @@ const securityOneJob = {
2211
2211
  return breaks;
2212
2212
  }
2213
2213
  };
2214
+ // src/rules/shared-ci.ts
2215
+ /**
2216
+ * The rule `shared-ci`: a repository uses the shared workflows and actions of the template, and keeps no copy of them.
2217
+ * Its `ci.yml` uses the shared workflow `reusable-ci.yml` of the template. No workflow file and no action of the
2218
+ * repository has the name of a shared workflow or a shared action. The template itself is the home, so the rule does
2219
+ * not examine it.
2220
+ */
2221
+ /** The shared workflows of the template, by file name. */
2222
+ const SHARED_WORKFLOWS = [
2223
+ "reusable-ai-review.yml",
2224
+ "reusable-ci.yml",
2225
+ "reusable-codex-review.yml",
2226
+ "reusable-mutation.yml",
2227
+ "reusable-pages.yml",
2228
+ "reusable-release-build.yml",
2229
+ "reusable-release-tag.yml",
2230
+ "reusable-security.yml"
2231
+ ];
2232
+ /** The shared actions of the template, by folder name under `.github/actions`. */
2233
+ const SHARED_ACTIONS = [
2234
+ "changes",
2235
+ "changeset-check",
2236
+ "coverage",
2237
+ "data-stamps",
2238
+ "gate-summary",
2239
+ "green-main",
2240
+ "npm-publish",
2241
+ "security-scan",
2242
+ "setup-playwright",
2243
+ "site-check",
2244
+ "site-pages"
2245
+ ];
2246
+ /** The `uses` value of a job that calls the shared CI, with no pin. */
2247
+ const SHARED_CI = "mark1russell7/template/.github/workflows/reusable-ci.yml";
2248
+ /** The action folder of a path: `.github/actions/<name>/action.yml` gives `<name>`. */
2249
+ const ACTION = /^\.github\/actions\/([^/]+)\//;
2250
+ /** The file name of a path. */
2251
+ const baseName = (path) => path.slice(path.lastIndexOf("/") + 1);
2252
+ /** This function tells if a job of a workflow text uses the shared CI of the template. */
2253
+ function callsSharedCi(file, text) {
2254
+ return readWorkflow(file, text).jobs.some((job) => job.steps.some((step) => step.uses === SHARED_CI));
2255
+ }
2256
+ const sharedCi = {
2257
+ id: "shared-ci",
2258
+ title: "`ci.yml` calls the shared workflow `reusable-ci.yml` of the template, and no workflow or action copies a shared one.",
2259
+ reason: "The shared CI is the one place where each check of a repository is set: the typecheck, the tests, the conventions, the API report and the summary check CI OK that the ruleset needs. A ci.yml with its own steps, or a copy of a shared workflow or action, does not get the fixes and the new checks of the template, and it drifts with no sign. On 2026-11-07, 3 of 19 repositories of the account ran CI steps of their own, and the rule was only text in each CLAUDE.md.",
2260
+ fix: "Make ci.yml call mark1russell7/template/.github/workflows/reusable-ci.yml at a pinned commit, and give the differences as its inputs (CI.md). Remove the local copy of a shared workflow or action, and call the one of the template. A repository that cannot call the shared CI turns the rule off with its reason.",
2261
+ sources: [
2262
+ {
2263
+ repo: "template",
2264
+ rule: "shared-workflows",
2265
+ doc: "CLAUDE.md: the workflows use the shared workflows and actions of the template; a repository changes only the inputs of its callers"
2266
+ },
2267
+ {
2268
+ repo: "template",
2269
+ rule: "ci",
2270
+ doc: "CI.md, CI: a caller of reusable-ci.yml needs no inputs, and gives each difference as an input"
2271
+ },
2272
+ {
2273
+ repo: "highways",
2274
+ rule: "ci",
2275
+ doc: ".github/workflows/ci.yml:1: the job ci is the shared CI (reusable-ci.yml, CI.md)"
2276
+ },
2277
+ {
2278
+ repo: "packing",
2279
+ rule: "ci",
2280
+ doc: ".github/workflows/ci.yml:1: the job ci is the shared CI (reusable-ci.yml, CI.md)"
2281
+ },
2282
+ {
2283
+ repo: "ste-lint",
2284
+ rule: "ci",
2285
+ doc: ".github/workflows/ci.yml (2026-11-07): its own steps, no call of reusable-ci.yml; the same in optional and lag"
2286
+ }
2287
+ ],
2288
+ options: {
2289
+ home: {
2290
+ type: "strings",
2291
+ default: ["template-monorepo"],
2292
+ description: "The names of the root packages that own the shared workflows. The rule does not examine them."
2293
+ },
2294
+ ciFile: {
2295
+ type: "string",
2296
+ default: ".github/workflows/ci.yml",
2297
+ description: "The workflow file that must call the shared CI."
2298
+ }
2299
+ },
2300
+ check(context, options) {
2301
+ const home = options["home"];
2302
+ const name = context.rootPackage.manifest["name"];
2303
+ if (typeof name === "string" && home.includes(name)) return { skipped: `the repository is the home of the shared workflows (${name})` };
2304
+ const files = context.gitFiles();
2305
+ if (files === void 0) return { skipped: "the root is not in a git repository" };
2306
+ const breaks = [];
2307
+ for (const file of files.filter((path) => WORKFLOW$1.test(path)).sort(byCode)) if (SHARED_WORKFLOWS.includes(baseName(file))) breaks.push({
2308
+ file,
2309
+ message: `${file} has the name of a shared workflow of the template: it is a local copy, which does not get the fixes of the template.`
2310
+ });
2311
+ const actions = /* @__PURE__ */ new Set();
2312
+ for (const file of files) {
2313
+ const folder = ACTION.exec(file)?.[1];
2314
+ if (folder !== void 0 && SHARED_ACTIONS.includes(folder) && !actions.has(folder)) {
2315
+ actions.add(folder);
2316
+ breaks.push({
2317
+ file: `.github/actions/${folder}`,
2318
+ message: `.github/actions/${folder} has the name of a shared action of the template: it is a local copy, which does not get the fixes of the template.`
2319
+ });
2320
+ }
2321
+ }
2322
+ const ciFile = options["ciFile"];
2323
+ const path = join(context.root, ciFile);
2324
+ if (!existsSync(path)) breaks.push({
2325
+ file: ciFile,
2326
+ message: `${ciFile} is missing, so no job calls the shared CI of the template.`
2327
+ });
2328
+ else if (!callsSharedCi(ciFile, readFileSync(path, "utf8"))) breaks.push({
2329
+ file: ciFile,
2330
+ message: `No job of ${ciFile} calls ${SHARED_CI}: the CI runs its own steps, and does not get the checks of the template.`
2331
+ });
2332
+ return breaks;
2333
+ }
2334
+ };
2335
+ // src/rules/tsconfig-test.ts
2336
+ /**
2337
+ * The rule `tsconfig-test`: each TypeScript package has a `tsconfig.test.json`, and its typecheck
2338
+ * examines it.
2339
+ */
2340
+ /** The ends of the name of a test file: `.test.` or `.spec.`, then an extension of JavaScript or TypeScript. */
2341
+ const TEST_ENDS = ["test", "spec"].flatMap((kind) => [
2342
+ "",
2343
+ "c",
2344
+ "m"
2345
+ ].flatMap((module) => ["j", "t"].flatMap((lang) => ["", "x"].map((jsx) => `.${kind}.${module}${lang}s${jsx}`))));
2346
+ /**
2347
+ * This function tells if a path is a test file: `*.test.*` or `*.spec.*` of JavaScript or TypeScript, or a file in a
2348
+ * folder `__tests__`. It uses string operations, with no regular expression, so a long path takes linear time.
2349
+ */
2350
+ function isTestFile(path) {
2351
+ const segments = path.split("/");
2352
+ const name = segments[segments.length - 1] ?? "";
2353
+ if (name !== "" && segments.slice(0, -1).includes("__tests__")) return true;
2354
+ return TEST_ENDS.some((end) => name.length > end.length && name.endsWith(end));
2355
+ }
2356
+ /** This function tells if git tracks a test file in the package folder `folder` (`""` is the root). */
2357
+ function hasTests(files, folder) {
2358
+ const prefix = folder === "" ? "" : `${folder}/`;
2359
+ return files.some((path) => path.startsWith(prefix) && isTestFile(path.slice(prefix.length)));
2360
+ }
2361
+ const tsconfigTest = {
2362
+ id: "tsconfig-test",
2363
+ title: "Each package with a `tsconfig.json` and test files has a `tsconfig.test.json`, and its `typecheck` script examines it.",
2364
+ reason: "The build config leaves out the tests. Without a second config, `pnpm typecheck` does not examine the tests, and a type error in a test hides until the test runs.",
2365
+ fix: "Add `tsconfig.test.json` (extends `./tsconfig.json`, includes the tests, `noEmit`), and set the script `typecheck` to `tsc -p tsconfig.json --noEmit && tsc -p tsconfig.test.json`. Keep `--noEmit` on the first call when the build config emits, so that a typecheck writes no build output.",
2366
+ sources: [
2367
+ {
2368
+ repo: "coeval",
2369
+ rule: "package-tsconfig-test",
2370
+ doc: "CLAUDE.md:18"
2371
+ },
2372
+ {
2373
+ repo: "coeval",
2374
+ rule: "tsconfig-test",
2375
+ doc: "CLAUDE.md:18"
2376
+ },
2377
+ {
2378
+ repo: "crawler",
2379
+ rule: "pkg-tsconfig-test",
2380
+ doc: "CLAUDE.md:18"
2381
+ },
2382
+ {
2383
+ repo: "crawler",
2384
+ rule: "tsconfig-test",
2385
+ doc: "CLAUDE.md:18"
2386
+ },
2387
+ {
2388
+ repo: "headroom",
2389
+ rule: "tsconfig-test",
2390
+ doc: "CLAUDE.md:32"
2391
+ },
2392
+ {
2393
+ repo: "headroom",
2394
+ rule: "tsconfig-test-per-package",
2395
+ doc: "CLAUDE.md:32"
2396
+ },
2397
+ {
2398
+ repo: "Vex",
2399
+ rule: "package-tsconfig-test",
2400
+ doc: "CLAUDE.md:23"
2401
+ },
2402
+ {
2403
+ repo: "Vex",
2404
+ rule: "tsconfig-test",
2405
+ doc: "CLAUDE.md:23"
2406
+ }
2407
+ ],
2408
+ options: { file: {
2409
+ type: "string",
2410
+ default: "tsconfig.test.json",
2411
+ description: "The name of the config of the tests."
2412
+ } },
2413
+ check(context, options) {
2414
+ const file = typeof options["file"] === "string" ? options["file"] : "tsconfig.test.json";
2415
+ const tracked = context.gitFiles();
2416
+ const breaks = [];
2417
+ for (const info of codePackages(context)) {
2418
+ if (!hasFile(info.dir, "tsconfig.json")) continue;
2419
+ if (tracked !== void 0 && !hasTests(tracked, info.folder)) continue;
2420
+ if (!hasFile(info.dir, file)) {
2421
+ breaks.push({
2422
+ file: inFolder(info.folder, file),
2423
+ message: `The package has a tsconfig.json and no ${file}.`
2424
+ });
2425
+ continue;
2426
+ }
2427
+ const scripts = info.manifest["scripts"];
2428
+ const typecheck = typeof scripts === "object" && scripts !== null ? scripts["typecheck"] : void 0;
2429
+ if (typeof typecheck === "string" && !typecheck.includes(file)) {
2430
+ const line = lineOf(info.text, "\"typecheck\"");
2431
+ breaks.push({
2432
+ file: info.file,
2433
+ ...line === void 0 ? {} : { line },
2434
+ message: `The script typecheck ("${typecheck}") does not examine ${file}.`,
2435
+ fix: `Add \`tsc -p ${file}\` to the script typecheck.`
2436
+ });
2437
+ }
2438
+ }
2439
+ return breaks;
2440
+ }
2441
+ };
2442
+ // src/rules/service-run-main.ts
2443
+ /**
2444
+ * The rule `service-run-main`: in a server package, only the entry `src/main.ts` starts the service with `run()`. A
2445
+ * server package is a package with a dependency on `@mark1russell7/service` and a file `src/main.ts`, as the preset
2446
+ * `service` of `pnpm package add` writes it. The other source files declare the service and give it to the entry.
2447
+ */
2448
+ /** The package of the service. */
2449
+ const SERVICE_PACKAGE = "@mark1russell7/service";
2450
+ /** An import of the service package or of one of its entries. */
2451
+ const SERVICE_IMPORT = /\bfrom\s+["']@mark1russell7\/service(\/[^"']*)?["']|\bimport\s*\(\s*["']@mark1russell7\/service(\/[^"']*)?["']\s*\)/;
2452
+ /** A call of `run(` on a value, but not on `this`. */
2453
+ const RUN_CALL = /(?<!\bthis)\.run\s*\(/;
2454
+ /** The source files that the rule reads. */
2455
+ const SOURCE = /\.(c|m)?tsx?$/;
2456
+ /** This function gives the lines (from 1) of the calls of `run(` in a source text that imports the service package. */
2457
+ function runCalls(text) {
2458
+ if (!SERVICE_IMPORT.test(text)) return [];
2459
+ const found = [];
2460
+ text.split(/\r?\n/).forEach((line, index) => {
2461
+ const comment = line.indexOf("//");
2462
+ const code = comment < 0 ? line : line.slice(0, comment);
2463
+ const trimmed = code.trimStart();
2464
+ if (trimmed.startsWith("*") || trimmed.startsWith("/*")) return;
2465
+ if (RUN_CALL.test(code)) found.push(index + 1);
2466
+ });
2467
+ return found;
2468
+ }
2469
+ /** This function tells if a manifest has a dependency on the service package. */
2470
+ const dependsOnService = (manifest) => {
2471
+ const dependencies = manifest["dependencies"];
2472
+ return typeof dependencies === "object" && dependencies !== null && "@mark1russell7/service" in dependencies;
2473
+ };
2474
+ const serviceRunMain = {
2475
+ id: "service-run-main",
2476
+ title: "In a server package, only the entry `src/main.ts` starts the service with `run()`.",
2477
+ reason: "run() of @mark1russell7/service owns the process: it starts the listeners, it reads the signals, and it ends the process. A module that starts it cannot be imported by a test or by a second entry without a second server. When only the entry starts it, each other module gives a service that a test can start, check and stop.",
2478
+ fix: "Move the call of run() to src/main.ts. Export the service (or a function that makes it) from the module, and start it in the entry.",
2479
+ sources: [
2480
+ {
2481
+ repo: "template",
2482
+ rule: "service-preset",
2483
+ doc: "CLAUDE.md: make a server package with --preset=service; only its entry src/main.ts uses run() of @mark1russell7/service"
2484
+ },
2485
+ {
2486
+ repo: "template",
2487
+ rule: "service-preset",
2488
+ doc: "packages/cli/src/commands/package/add.ts: the preset service writes src/main.ts and the script start"
2489
+ },
2490
+ {
2491
+ repo: "systems",
2492
+ rule: "service-run-main",
2493
+ doc: "packages/reference/src/main.ts:3: only this file starts run()"
2494
+ },
2495
+ {
2496
+ repo: "vex",
2497
+ rule: "service-run-main",
2498
+ doc: "packages/mcp/src/main.ts: the one call of run() of the package"
2499
+ }
2500
+ ],
2501
+ options: { main: {
2502
+ type: "string",
2503
+ default: "src/main.ts",
2504
+ description: "The entry of a server package, the one file that starts the service."
2505
+ } },
2506
+ check(context, options) {
2507
+ const main = typeof options["main"] === "string" ? options["main"] : "src/main.ts";
2508
+ const tracked = context.gitFiles();
2509
+ if (tracked === void 0) return { skipped: "the root is not in a git repository" };
2510
+ const breaks = [];
2511
+ for (const info of codePackages(context)) {
2512
+ if (!dependsOnService(info.manifest) || !hasFile(info.dir, main)) continue;
2513
+ const prefix = info.folder === "" ? "" : `${info.folder}/`;
2514
+ const entry = inFolder(info.folder, main);
2515
+ const own = tracked.filter((path) => path.startsWith(`${prefix}src/`) && SOURCE.test(path) && !/\.d\.(c|m)?ts$/.test(path) && path !== entry && !isTestFile(path.slice(prefix.length)));
2516
+ for (const file of own.sort(byCode)) {
2517
+ let text;
2518
+ try {
2519
+ text = readFileSync(join(context.root, file), "utf8");
2520
+ } catch {
2521
+ continue;
2522
+ }
2523
+ for (const line of runCalls(text)) breaks.push({
2524
+ file,
2525
+ line,
2526
+ message: `${file} starts the service with run(). In a server package only ${entry} does.`
2527
+ });
2528
+ }
2529
+ }
2530
+ return breaks;
2531
+ }
2532
+ };
2214
2533
  // src/change.ts
2215
2534
  /**
2216
2535
  * The change that a check examines: the option `--base`, the merge commit of a pull request, or a push to the default
@@ -9115,7 +9434,10 @@ const noBuildOutput = {
9115
9434
  };
9116
9435
  // src/rules/no-local-paths.ts
9117
9436
  /**
9118
- * The rule `no-local-paths`: no tracked file names the home folder of a user of a computer.
9437
+ * The rule `no-local-paths`: no tracked file names the home folder of a user of a computer. The commit messages of a
9438
+ * change and the title and the body of its pull request do not name one either. The same is true for each private
9439
+ * pattern of the environment variable `CONVENTIONS_PRIVATE_PATTERNS`. A break of a private pattern does not show the
9440
+ * text or the pattern, because a public log must not name them.
9119
9441
  */
9120
9442
  /** The extensions of files that are not text. The rule does not read them. */
9121
9443
  const BINARY = new Set(".png .jpg .jpeg .gif .webp .avif .ico .bmp .tiff .pdf .zip .gz .tgz .bz2 .xz .7z .tar .woff .woff2 .ttf .otf .eot .mp3 .mp4 .webm .mov .wav .ogg .wasm .node .exe .dll .so .dylib .bin .db .sqlite .duckdb".split(" "));
@@ -9148,9 +9470,56 @@ const HOME_PATTERNS = [
9148
9470
  /(?<![\w.~-])\/Users\/(?<user>[^/\s"'`<>|:*?%$(){}[\],;]+)/g,
9149
9471
  /(?<![\w.~-])\/home\/(?<user>[^/\s"'`<>|:*?%$(){}[\],;]+)/g
9150
9472
  ];
9473
+ /** The name of the environment variable of the private patterns. */
9474
+ const PRIVATE_PATTERNS_VARIABLE = "CONVENTIONS_PRIVATE_PATTERNS";
9475
+ /** This function gives the private patterns of the environment variable, with the line of each (from 1). */
9476
+ function privatePatterns(env) {
9477
+ return (env["CONVENTIONS_PRIVATE_PATTERNS"] ?? "").split("\n").map((source, index) => ({
9478
+ source: source.trim(),
9479
+ line: index + 1
9480
+ })).filter((pattern) => pattern.source !== "");
9481
+ }
9482
+ /**
9483
+ * This function gives the texts of the change that are not files. They are each commit message of a pull request (or of the
9484
+ * range of `--base`). They are also the title and the body of the pull request, from the event file of GitHub Actions.
9485
+ */
9486
+ function changeTexts(context) {
9487
+ const texts = [];
9488
+ const range = rangeOf(context);
9489
+ if (!("skipped" in range)) {
9490
+ const log = context.git([
9491
+ "log",
9492
+ "--no-merges",
9493
+ "--format=%H%x00%B%x1e",
9494
+ ...range.log
9495
+ ]) ?? "";
9496
+ for (const entry of log.split("")) {
9497
+ const [sha, message] = entry.replace(/^\s+/, "").split("\0");
9498
+ if (sha !== void 0 && sha !== "" && message !== void 0) texts.push({
9499
+ name: `commit ${sha.slice(0, 12)}`,
9500
+ text: message
9501
+ });
9502
+ }
9503
+ }
9504
+ const file = context.env["GITHUB_EVENT_PATH"];
9505
+ if (file !== void 0 && file !== "" && existsSync(file)) try {
9506
+ const event = JSON.parse(readFileSync(file, "utf8"));
9507
+ const title = event.pull_request?.title;
9508
+ const body = event.pull_request?.body;
9509
+ if (typeof title === "string") texts.push({
9510
+ name: "pull request title",
9511
+ text: title
9512
+ });
9513
+ if (typeof body === "string") texts.push({
9514
+ name: "pull request body",
9515
+ text: body
9516
+ });
9517
+ } catch {}
9518
+ return texts;
9519
+ }
9151
9520
  const noLocalPaths = {
9152
9521
  id: "no-local-paths",
9153
- title: "No tracked file has the home folder of a user (`C:\\Users\\<name>`, `/Users/<name>`, `/home/<name>`).",
9522
+ title: "No tracked file, commit message of the change or text of its pull request has a private pattern or the home folder of a user (`C:\\Users\\<name>`, `/Users/<name>`, `/home/<name>`).",
9154
9523
  reason: "A public file must not name a computer, a user or a path of a computer. A local path also works only on one computer.",
9155
9524
  fix: "Use a path relative to the repository, `~`, an environment variable, or a placeholder such as `<you>`.",
9156
9525
  sources: [
@@ -9196,10 +9565,41 @@ const noLocalPaths = {
9196
9565
  const files = context.gitFiles();
9197
9566
  if (files === void 0) return { skipped: "the root is not in a git repository" };
9198
9567
  const allowed = new Set([...DEFAULT_ALLOWED, ...Array.isArray(options["allow"]) ? options["allow"] : []].map((name) => name.toLowerCase()));
9199
- const fromEnv = (context.env["CONVENTIONS_PRIVATE_PATTERNS"] ?? "").split("\n").map((line) => line.trim()).filter((line) => line !== "");
9200
- const extra = [...Array.isArray(options["patterns"]) ? options["patterns"] : [], ...fromEnv].map((source) => new RegExp(source, "g"));
9568
+ const extra = [...(Array.isArray(options["patterns"]) ? options["patterns"] : []).map((source) => ({ regex: new RegExp(source, "g") })), ...privatePatterns(context.env).map((pattern) => ({
9569
+ regex: new RegExp(pattern.source, "g"),
9570
+ privateLine: pattern.line
9571
+ }))];
9201
9572
  const rootFile = context.rootPackage.file;
9202
9573
  const breaks = [];
9574
+ /** This function adds the breaks of the extra patterns on one line. A break of a private pattern shows no text. */
9575
+ const extraBreaks = (file, line, at, isRootFile) => {
9576
+ for (const pattern of extra) {
9577
+ if (isRootFile && pattern.privateLine === void 0 && line.trim().replace(/,$/, "") === JSON.stringify(pattern.regex.source)) continue;
9578
+ for (const match of line.matchAll(pattern.regex)) breaks.push(pattern.privateLine === void 0 ? {
9579
+ file,
9580
+ line: at,
9581
+ message: `The text "${match[0]}" matches the pattern ${pattern.regex.source}.`,
9582
+ fix: "Remove the text."
9583
+ } : {
9584
+ file,
9585
+ line: at,
9586
+ message: `A text matches the private pattern on line ${String(pattern.privateLine)} of ${PRIVATE_PATTERNS_VARIABLE}.`,
9587
+ fix: "Remove the text. The check does not show the text, because the pattern is private."
9588
+ });
9589
+ }
9590
+ };
9591
+ /** This function adds the breaks of the home folders on one line. */
9592
+ const homeBreaks = (file, line, at) => {
9593
+ for (const pattern of HOME_PATTERNS) for (const match of line.matchAll(pattern)) {
9594
+ const user = match.groups?.["user"] ?? "";
9595
+ if (user.length < 2 || allowed.has(user.toLowerCase())) continue;
9596
+ breaks.push({
9597
+ file,
9598
+ line: at,
9599
+ message: `The text "${match[0]}" is the home folder of a user.`
9600
+ });
9601
+ }
9602
+ };
9203
9603
  for (const file of files) {
9204
9604
  if (BINARY.has(extname(file).toLowerCase())) continue;
9205
9605
  const path = join(context.root, file);
@@ -9214,25 +9614,15 @@ const noLocalPaths = {
9214
9614
  const lines = text.split(/\r?\n/);
9215
9615
  for (let index = 0; index < lines.length; index++) {
9216
9616
  const line = lines[index] ?? "";
9217
- const isReason = file === rootFile && /^\s*"(?:reason|off)"\s*:/.test(line);
9218
- for (const pattern of isReason ? [] : HOME_PATTERNS) for (const match of line.matchAll(pattern)) {
9219
- const user = match.groups?.["user"] ?? "";
9220
- if (user.length < 2 || allowed.has(user.toLowerCase())) continue;
9221
- breaks.push({
9222
- file,
9223
- line: index + 1,
9224
- message: `The text "${match[0]}" is the home folder of a user.`
9225
- });
9226
- }
9227
- for (const pattern of extra) {
9228
- if (file === rootFile && line.trim().replace(/,$/, "") === JSON.stringify(pattern.source)) continue;
9229
- for (const match of line.matchAll(pattern)) breaks.push({
9230
- file,
9231
- line: index + 1,
9232
- message: `The text "${match[0]}" matches the pattern ${pattern.source}.`,
9233
- fix: "Remove the text."
9234
- });
9235
- }
9617
+ if (!(file === rootFile && /^\s*"(?:reason|off)"\s*:/.test(line))) homeBreaks(file, line, index + 1);
9618
+ extraBreaks(file, line, index + 1, file === rootFile);
9619
+ }
9620
+ }
9621
+ for (const change of changeTexts(context)) {
9622
+ const lines = change.text.split(/\r?\n/);
9623
+ for (let index = 0; index < lines.length; index++) {
9624
+ homeBreaks(change.name, lines[index] ?? "", index + 1);
9625
+ extraBreaks(change.name, lines[index] ?? "", index + 1, false);
9236
9626
  }
9237
9627
  }
9238
9628
  return breaks;
@@ -11792,113 +12182,6 @@ const sourceMain = {
11792
12182
  return breaks;
11793
12183
  }
11794
12184
  };
11795
- // src/rules/tsconfig-test.ts
11796
- /**
11797
- * The rule `tsconfig-test`: each TypeScript package has a `tsconfig.test.json`, and its typecheck
11798
- * examines it.
11799
- */
11800
- /** The ends of the name of a test file: `.test.` or `.spec.`, then an extension of JavaScript or TypeScript. */
11801
- const TEST_ENDS = ["test", "spec"].flatMap((kind) => [
11802
- "",
11803
- "c",
11804
- "m"
11805
- ].flatMap((module) => ["j", "t"].flatMap((lang) => ["", "x"].map((jsx) => `.${kind}.${module}${lang}s${jsx}`))));
11806
- /**
11807
- * This function tells if a path is a test file: `*.test.*` or `*.spec.*` of JavaScript or TypeScript, or a file in a
11808
- * folder `__tests__`. It uses string operations, with no regular expression, so a long path takes linear time.
11809
- */
11810
- function isTestFile(path) {
11811
- const segments = path.split("/");
11812
- const name = segments[segments.length - 1] ?? "";
11813
- if (name !== "" && segments.slice(0, -1).includes("__tests__")) return true;
11814
- return TEST_ENDS.some((end) => name.length > end.length && name.endsWith(end));
11815
- }
11816
- /** This function tells if git tracks a test file in the package folder `folder` (`""` is the root). */
11817
- function hasTests(files, folder) {
11818
- const prefix = folder === "" ? "" : `${folder}/`;
11819
- return files.some((path) => path.startsWith(prefix) && isTestFile(path.slice(prefix.length)));
11820
- }
11821
- const tsconfigTest = {
11822
- id: "tsconfig-test",
11823
- title: "Each package with a `tsconfig.json` and test files has a `tsconfig.test.json`, and its `typecheck` script examines it.",
11824
- reason: "The build config leaves out the tests. Without a second config, `pnpm typecheck` does not examine the tests, and a type error in a test hides until the test runs.",
11825
- fix: "Add `tsconfig.test.json` (extends `./tsconfig.json`, includes the tests, `noEmit`), and set the script `typecheck` to `tsc -p tsconfig.json --noEmit && tsc -p tsconfig.test.json`. Keep `--noEmit` on the first call when the build config emits, so that a typecheck writes no build output.",
11826
- sources: [
11827
- {
11828
- repo: "coeval",
11829
- rule: "package-tsconfig-test",
11830
- doc: "CLAUDE.md:18"
11831
- },
11832
- {
11833
- repo: "coeval",
11834
- rule: "tsconfig-test",
11835
- doc: "CLAUDE.md:18"
11836
- },
11837
- {
11838
- repo: "crawler",
11839
- rule: "pkg-tsconfig-test",
11840
- doc: "CLAUDE.md:18"
11841
- },
11842
- {
11843
- repo: "crawler",
11844
- rule: "tsconfig-test",
11845
- doc: "CLAUDE.md:18"
11846
- },
11847
- {
11848
- repo: "headroom",
11849
- rule: "tsconfig-test",
11850
- doc: "CLAUDE.md:32"
11851
- },
11852
- {
11853
- repo: "headroom",
11854
- rule: "tsconfig-test-per-package",
11855
- doc: "CLAUDE.md:32"
11856
- },
11857
- {
11858
- repo: "Vex",
11859
- rule: "package-tsconfig-test",
11860
- doc: "CLAUDE.md:23"
11861
- },
11862
- {
11863
- repo: "Vex",
11864
- rule: "tsconfig-test",
11865
- doc: "CLAUDE.md:23"
11866
- }
11867
- ],
11868
- options: { file: {
11869
- type: "string",
11870
- default: "tsconfig.test.json",
11871
- description: "The name of the config of the tests."
11872
- } },
11873
- check(context, options) {
11874
- const file = typeof options["file"] === "string" ? options["file"] : "tsconfig.test.json";
11875
- const tracked = context.gitFiles();
11876
- const breaks = [];
11877
- for (const info of codePackages(context)) {
11878
- if (!hasFile(info.dir, "tsconfig.json")) continue;
11879
- if (tracked !== void 0 && !hasTests(tracked, info.folder)) continue;
11880
- if (!hasFile(info.dir, file)) {
11881
- breaks.push({
11882
- file: inFolder(info.folder, file),
11883
- message: `The package has a tsconfig.json and no ${file}.`
11884
- });
11885
- continue;
11886
- }
11887
- const scripts = info.manifest["scripts"];
11888
- const typecheck = typeof scripts === "object" && scripts !== null ? scripts["typecheck"] : void 0;
11889
- if (typeof typecheck === "string" && !typecheck.includes(file)) {
11890
- const line = lineOf(info.text, "\"typecheck\"");
11891
- breaks.push({
11892
- file: info.file,
11893
- ...line === void 0 ? {} : { line },
11894
- message: `The script typecheck ("${typecheck}") does not examine ${file}.`,
11895
- fix: `Add \`tsc -p ${file}\` to the script typecheck.`
11896
- });
11897
- }
11898
- }
11899
- return breaks;
11900
- }
11901
- };
11902
12185
  // src/rules/tests-required.ts
11903
12186
  /**
11904
12187
  * The rule `tests-required`: no test runner passes when it finds no test (`passWithNoTests`).
@@ -12851,6 +13134,7 @@ const RULES = [
12851
13134
  workspaceProtocol,
12852
13135
  trustPolicy,
12853
13136
  sourceMain,
13137
+ serviceRunMain,
12854
13138
  tsconfigTest,
12855
13139
  cuePreset,
12856
13140
  requiredScripts,
@@ -12875,6 +13159,7 @@ const RULES = [
12875
13159
  gateAfterCancel,
12876
13160
  gateTrigger,
12877
13161
  securityOneJob,
13162
+ sharedCi,
12878
13163
  homePackage,
12879
13164
  licenseFile,
12880
13165
  pagesSite,
@@ -13315,6 +13600,6 @@ function runMap(args, io) {
13315
13600
  else io.stdout(mapText(found));
13316
13601
  return 0;
13317
13602
  }
13318
- export { isPinned as $, codePackages as $t, pathsOf as A, findHomes as At, lockedVersions as B, securityOneJob as Bt, configsOfScript as C, declaredName as Ct, hasTests as D, signaturesOf as Dt, testsRequired as E, repoOf as Et, sharedDocsRule as F, HOME_EXPORTS as Ft, NPM_REGISTRY as G, prPathFilters as Gt, publishedMinor as H, ACTIONS_COMMIT as Ht, roadmapOfLine as I, SECURITY_SCAN_COMMIT as It, npmLookup as J, readWorkflow as Jt, SHIPPED_FIELDS as K, summaryName as Kt, roadmapParses as L, SECURITY_SCAN_INPUTS as Lt, HOME_TIMEOUT_MS as M, mapText as Mt, blockHash as N, mergeHomes as Nt, tsconfigTest as O, HOMES as Ot, githubFetch as P, readOverlay as Pt, isGitSpecifier as Q, cleanPath as Qt, requiredScripts as R, SECURITY_TIMEOUT_MINUTES as Rt, typedScripts as S, repositoryIsPublic as St, typedFiles as T, messageOf as Tt, publishedMinorRule as U, convertGate as Ut, minorOf as V, withOneJob as Vt, reachOf as W, gateTrigger as Wt, unreleasedChangeRule as X, cuePreset as Xt, unreleasedChange as Y, STRICT_OPTIONS as Yt, pipeFails as Z, DEPENDENCY_FIELDS as Zt, setVersions as _, LICENSE_TEXTS as _t, listRules as a, parseJsonc as an, pushMainOnly as at, TRAIN_SCOPES as b, licenseFileOf as bt, runCli as c, runGit as cn, pagesSite as ct, RULES as d, globToRegExp as dn, HOME_PATTERNS as dt, hasFile as en, pinnedGitDeps as et, workspaceProtocol as f, packageFolders as fn, noLocalPaths as ft, namedVersions as g, mainCheck as gt, yamlFaults as h, parseConfig as hn, hasImportMetaMain as ht, formatResult as i, matchesAny as in, scheduleMinute as it, sourceMain as j, mapMarkdown as jt, isSourcePath as k, MAP_RULE as kt, runFix as l, specifiersOf as ln, apiReportScript as lt, workflowParses as m, defaultOptions as mn, REAL_COMPARE as mt, annotations as n, keyLine as nn, repositoryOfRemote as nt, readConfig as o, readJsonc as on, PAGES_WORKFLOWS as ot, GITHUB_YAML as p, workspaceGlobs as pn, noBuildOutput as pt, UNSHIPPED_FILES as q, gateAfterCancel as qt, createContext as r, lineOf as rn, runnerBudget as rt, runChecks as s, replaceLine as sn, pagesCalls as st, USAGE as t, inFolder as tn, pagesAfterRelease as tt, summaryMarkdown as u, globFolders as un, DEFAULT_ALLOWED as ut, versionTitle as v, authorOf as vt, scriptsOf as w, homePackage as wt, trustPolicy as x, mitText as xt, IGNORE_AFTER as y, licenseFile as yt, releaseFiles as z, securityCallers as zt };
13603
+ export { pagesAfterRelease as $, prPathFilters as $t, HOME_TIMEOUT_MS as A, mapText as At, publishedMinor as B, SHARED_CI as Bt, configsOfScript as C, parseConfig as Cn, messageOf as Ct, isSourcePath as D, MAP_RULE as Dt, testsRequired as E, HOMES as Et, roadmapParses as F, runCalls as Ft, UNSHIPPED_FILES as G, SECURITY_SCAN_INPUTS as Gt, reachOf as H, callsSharedCi as Ht, requiredScripts as I, serviceRunMain as It, unreleasedChangeRule as J, securityOneJob as Jt, npmLookup as K, SECURITY_TIMEOUT_MINUTES as Kt, releaseFiles as L, hasTests as Lt, githubFetch as M, readOverlay as Mt, sharedDocsRule as N, HOME_EXPORTS as Nt, pathsOf as O, findHomes as Ot, roadmapOfLine as P, SERVICE_PACKAGE as Pt, pinnedGitDeps as Q, gateTrigger as Qt, lockedVersions as R, tsconfigTest as Rt, typedScripts as S, defaultOptions as Sn, homePackage as St, typedFiles as T, signaturesOf as Tt, NPM_REGISTRY as U, sharedCi as Ut, publishedMinorRule as V, SHARED_WORKFLOWS as Vt, SHIPPED_FIELDS as W, SECURITY_SCAN_COMMIT as Wt, isGitSpecifier as X, ACTIONS_COMMIT as Xt, pipeFails as Y, withOneJob as Yt, isPinned as Z, convertGate as Zt, setVersions as _, specifiersOf as _n, licenseFile as _t, listRules as a, DEPENDENCY_FIELDS as an, pagesCalls as at, TRAIN_SCOPES as b, packageFolders as bn, repositoryIsPublic as bt, runCli as c, hasFile as cn, DEFAULT_ALLOWED as ct, RULES as d, lineOf as dn, noBuildOutput as dt, summaryName as en, repositoryOfRemote as et, workspaceProtocol as f, matchesAny as fn, REAL_COMPARE as ft, namedVersions as g, runGit as gn, authorOf as gt, yamlFaults as h, replaceLine as hn, LICENSE_TEXTS as ht, formatResult as i, cuePreset as in, PAGES_WORKFLOWS as it, blockHash as j, mergeHomes as jt, sourceMain as k, mapMarkdown as kt, runFix as l, inFolder as ln, HOME_PATTERNS as lt, workflowParses as m, readJsonc as mn, mainCheck as mt, annotations as n, readWorkflow as nn, scheduleMinute as nt, readConfig as o, cleanPath as on, pagesSite as ot, GITHUB_YAML as p, parseJsonc as pn, hasImportMetaMain as pt, unreleasedChange as q, securityCallers as qt, createContext as r, STRICT_OPTIONS as rn, pushMainOnly as rt, runChecks as s, codePackages as sn, apiReportScript as st, USAGE as t, gateAfterCancel as tn, runnerBudget as tt, summaryMarkdown as u, keyLine as un, noLocalPaths as ut, versionTitle as v, globFolders as vn, licenseFileOf as vt, scriptsOf as w, repoOf as wt, trustPolicy as x, workspaceGlobs as xn, declaredName as xt, IGNORE_AFTER as y, globToRegExp as yn, mitText as yt, minorOf as z, SHARED_ACTIONS as zt };
13319
13604
 
13320
- //# sourceMappingURL=run-CDGXnpQk.js.map
13605
+ //# sourceMappingURL=run-DWyPhbeH.js.map