lintmax 0.1.94 → 0.1.95
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/dist/cli.mjs +33 -2
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -1436,6 +1436,27 @@ 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
|
+
throw new Error(`${label}: ${why} (exit ${exitCode}). Refusing rather than reading it as "nothing fired", which would report every directive unused. ${stderr.slice(0, 400)}`);
|
|
1450
|
+
};
|
|
1451
|
+
let parsed;
|
|
1452
|
+
try {
|
|
1453
|
+
parsed = readRequiredJson(json);
|
|
1454
|
+
} catch {
|
|
1455
|
+
refuse("produced no parseable JSON");
|
|
1456
|
+
}
|
|
1457
|
+
if (!Array.isArray(parsed.diagnostics)) refuse("returned JSON carrying no diagnostics array");
|
|
1458
|
+
return json;
|
|
1459
|
+
};
|
|
1439
1460
|
const firedOxlintByFile = async ({ configPath, files, oxlintBin }) => {
|
|
1440
1461
|
const result = await runCapture({
|
|
1441
1462
|
args: [
|
|
@@ -1450,7 +1471,12 @@ const firedOxlintByFile = async ({ configPath, files, oxlintBin }) => {
|
|
|
1450
1471
|
env: buildEnv(),
|
|
1451
1472
|
label: "oxlint-unused"
|
|
1452
1473
|
});
|
|
1453
|
-
const diagnostics = parseOxlintDiagnostics({ stdout:
|
|
1474
|
+
const diagnostics = parseOxlintDiagnostics({ stdout: requireLintAnswer({
|
|
1475
|
+
exitCode: result.exitCode,
|
|
1476
|
+
label: "oxlint-unused",
|
|
1477
|
+
stderr: result.stderr,
|
|
1478
|
+
stdout: result.stdout
|
|
1479
|
+
}) });
|
|
1454
1480
|
const byFile = /* @__PURE__ */ new Map();
|
|
1455
1481
|
for (const d of diagnostics) {
|
|
1456
1482
|
const key = absFile(d.file);
|
|
@@ -1579,7 +1605,12 @@ const firedBiomeByFile = async ({ biomeBin, configDir, files }) => {
|
|
|
1579
1605
|
env: buildEnv(),
|
|
1580
1606
|
label: "biome-unused"
|
|
1581
1607
|
});
|
|
1582
|
-
const diagnostics = parseBiomeDiagnostics({ stdout:
|
|
1608
|
+
const diagnostics = parseBiomeDiagnostics({ stdout: requireLintAnswer({
|
|
1609
|
+
exitCode: result.exitCode,
|
|
1610
|
+
label: "biome-unused",
|
|
1611
|
+
stderr: result.stderr,
|
|
1612
|
+
stdout: result.stdout
|
|
1613
|
+
}) });
|
|
1583
1614
|
const byFile = /* @__PURE__ */ new Map();
|
|
1584
1615
|
for (const d of diagnostics) {
|
|
1585
1616
|
const key = absFile(d.file);
|