lintmax 0.1.94 → 0.1.96

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 (2) hide show
  1. package/dist/cli.mjs +35 -2
  2. package/package.json +1 -1
package/dist/cli.mjs CHANGED
@@ -1436,7 +1436,30 @@ const rebuildBiomeLine = ({ line, rules }) => {
1436
1436
  const reason = biomeReasonOf(line) ?? "suppressed";
1437
1437
  return `${leadingWhitespaceRe.exec(line)?.[0] ?? ""}/** biome-ignore-all ${rules.join(", ")}: ${reason} */`;
1438
1438
  };
1439
+ /**
1440
+ * A lint run that could not ANSWER must refuse, never resolve to an empty fired set. An empty map reads as
1441
+ * `no rule fired anywhere`, which marks EVERY directive in the tree unused — MEASURED on one CI lane, 35 of 35
1442
+ * directives reported while each one was genuinely needed. A clean run is not this shape: both linters emit
1443
+ * `{"diagnostics": []}` and exit 0 when they find nothing, so requiring a parsed diagnostics array refuses a
1444
+ * crash without ever refusing a clean tree.
1445
+ */
1446
+ const requireLintAnswer = ({ exitCode, label, stderr, stdout }) => {
1447
+ const json = extractJson(stdout);
1448
+ const refuse = (why) => {
1449
+ const said = [stderr.trim(), stdout.trim()].filter((part) => part !== "").join(" | ");
1450
+ throw new Error(`${label}: ${why} (exit ${exitCode}). Refusing rather than reading it as "nothing fired", which would report every directive unused. ${said.slice(0, 600)}`);
1451
+ };
1452
+ let parsed;
1453
+ try {
1454
+ parsed = readRequiredJson(json);
1455
+ } catch {
1456
+ refuse("produced no parseable JSON");
1457
+ }
1458
+ if (!Array.isArray(parsed.diagnostics)) refuse("returned JSON carrying no diagnostics array");
1459
+ return json;
1460
+ };
1439
1461
  const firedOxlintByFile = async ({ configPath, files, oxlintBin }) => {
1462
+ if (!await file(configPath).exists()) throw new Error(`oxlint-unused: the generated config is absent at ${configPath}, so no rule can fire and every directive would read as unused. The stage that writes it did not run.`);
1440
1463
  const result = await runCapture({
1441
1464
  args: [
1442
1465
  oxlintBin,
@@ -1450,7 +1473,12 @@ const firedOxlintByFile = async ({ configPath, files, oxlintBin }) => {
1450
1473
  env: buildEnv(),
1451
1474
  label: "oxlint-unused"
1452
1475
  });
1453
- const diagnostics = parseOxlintDiagnostics({ stdout: extractJson(result.stdout) });
1476
+ const diagnostics = parseOxlintDiagnostics({ stdout: requireLintAnswer({
1477
+ exitCode: result.exitCode,
1478
+ label: "oxlint-unused",
1479
+ stderr: result.stderr,
1480
+ stdout: result.stdout
1481
+ }) });
1454
1482
  const byFile = /* @__PURE__ */ new Map();
1455
1483
  for (const d of diagnostics) {
1456
1484
  const key = absFile(d.file);
@@ -1579,7 +1607,12 @@ const firedBiomeByFile = async ({ biomeBin, configDir, files }) => {
1579
1607
  env: buildEnv(),
1580
1608
  label: "biome-unused"
1581
1609
  });
1582
- const diagnostics = parseBiomeDiagnostics({ stdout: extractJson(result.stdout) });
1610
+ const diagnostics = parseBiomeDiagnostics({ stdout: requireLintAnswer({
1611
+ exitCode: result.exitCode,
1612
+ label: "biome-unused",
1613
+ stderr: result.stderr,
1614
+ stdout: result.stdout
1615
+ }) });
1583
1616
  const byFile = /* @__PURE__ */ new Map();
1584
1617
  for (const d of diagnostics) {
1585
1618
  const key = absFile(d.file);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lintmax",
3
- "version": "0.1.94",
3
+ "version": "0.1.96",
4
4
  "description": "The #1 anti AI slop typescript tooling. Designed for coding agents, not humans.",
5
5
  "keywords": [
6
6
  "agent",