lintmax 0.1.93 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env bun
2
- import { S as OXLINT_CLI_ALLOW, b as DEFAULT_SHARED_IGNORE_PATTERNS, i as joinPath, l as isRecord, n as fromFileUrl, t as dirnamePath, w as PARSE_DIALECTS, x as ESLINT_TEST_FILE_PATTERNS } from "./path-DfaiIsLo.mjs";
3
- import { _ as resolveBin, a as PRETTIER_MD_ARGS, b as usage, c as cwd, d as envValue, f as lintmaxRoot, g as readVersion, h as readRequiredJson, i as CliExitError, l as decodeText, m as readJson, o as bunEnv, p as pathExists, r as sync, s as cacheDir, u as ensureDirectory, v as run, y as runCapture } from "./src-ioM8CeP8.mjs";
2
+ import { S as OXLINT_CLI_ALLOW, b as DEFAULT_SHARED_IGNORE_PATTERNS, i as joinPath, l as isRecord, n as fromFileUrl, t as dirnamePath, w as PARSE_DIALECTS, x as ESLINT_TEST_FILE_PATTERNS } from "./path-CVd5J9sx.mjs";
3
+ import { _ as resolveBin, a as PRETTIER_MD_ARGS, b as usage, c as cwd, d as envValue, f as lintmaxRoot, g as readVersion, h as readRequiredJson, i as CliExitError, l as decodeText, m as readJson, o as bunEnv, p as pathExists, r as sync, s as cacheDir, u as ensureDirectory, v as run, y as runCapture } from "./src-apGJLN8u.mjs";
4
4
  import { $, Glob, env, file, write } from "bun";
5
5
  import { lstat, unlink } from "node:fs/promises";
6
6
  import { join } from "node:path";
@@ -128,7 +128,7 @@ const normalizePath = (filePath) => {
128
128
  const parseBiomeDiagnostics = ({ stdout }) => {
129
129
  let parsed;
130
130
  try {
131
- parsed = JSON.parse(stdout);
131
+ parsed = readRequiredJson(stdout);
132
132
  } catch {
133
133
  return [];
134
134
  }
@@ -152,7 +152,7 @@ const parseBiomeDiagnostics = ({ stdout }) => {
152
152
  const parseOxlintDiagnostics = ({ stdout }) => {
153
153
  let parsed;
154
154
  try {
155
- parsed = JSON.parse(stdout);
155
+ parsed = readRequiredJson(stdout);
156
156
  } catch {
157
157
  return [];
158
158
  }
@@ -192,7 +192,7 @@ const eslintDiagnosticsForFile = (fileEntry) => {
192
192
  const parseEslintDiagnostics = ({ stdout }) => {
193
193
  let parsed;
194
194
  try {
195
- parsed = JSON.parse(stdout);
195
+ parsed = readRequiredJson(stdout);
196
196
  } catch {
197
197
  return [];
198
198
  }
@@ -316,7 +316,11 @@ const BANNED_CALLEE_NAMES = /* @__PURE__ */ new Set([
316
316
  "cx",
317
317
  "twMerge"
318
318
  ]);
319
- const asNode = (v) => v && typeof v === "object" && typeof v.type === "string" ? v : null;
319
+ const asNode = (v) => {
320
+ if (!v || typeof v !== "object" || !("type" in v) || typeof v.type !== "string") return null;
321
+ /** biome-ignore lint/nursery/noUnsafeTypeAssertion: external parser AST node is narrowed only at this boundary */
322
+ return v;
323
+ };
320
324
  const strName = (n) => typeof n?.name === "string" ? n.name : "";
321
325
  const lineAt$1 = (sourceText, offset) => {
322
326
  let line = 1;
@@ -372,7 +376,7 @@ const findClassNameViolations = ({ sourceText }) => {
372
376
  }
373
377
  const node = asNode(raw);
374
378
  if (!node) {
375
- if (raw && typeof raw === "object") for (const key of Object.keys(raw)) visit(raw[key], parent, grand);
379
+ if (raw && typeof raw === "object") for (const child of Object.values(raw)) visit(child, parent, grand);
376
380
  return;
377
381
  }
378
382
  collectClassNameAttrViolation(node, sourceText, violations);
@@ -422,7 +426,7 @@ const checkClassName = async ({ root }) => {
422
426
  //#region src/rules.ts
423
427
  const extractBiomeRules = async () => {
424
428
  const pkgPath = fromFileUrl(import.meta.resolve("@biomejs/biome/configuration_schema.json"));
425
- const defs = JSON.parse(await file(pkgPath).text()).$defs ?? {};
429
+ const defs = readRequiredJson(await file(pkgPath).text()).$defs ?? {};
426
430
  const categories = [
427
431
  "a11y",
428
432
  "complexity",
@@ -480,7 +484,7 @@ const extractEslintRules = async () => {
480
484
  if (result.exitCode !== 0) throw new Error(`eslint --print-config failed, so its rule set is unknown: ${result.stderr.toString().trim()}`);
481
485
  let parsed;
482
486
  try {
483
- parsed = JSON.parse(result.stdout.toString());
487
+ parsed = readRequiredJson(result.stdout.toString());
484
488
  } catch (error) {
485
489
  throw new Error(`eslint --print-config returned unreadable JSON: ${error instanceof Error ? error.message : ""}`, { cause: error });
486
490
  }
@@ -621,7 +625,12 @@ const normalizeRule = (rule) => {
621
625
  };
622
626
  const loadOxlintOffRules = async () => {
623
627
  const configPath = joinPath(process.cwd(), cacheDir, ".oxlintrc.json");
624
- const config = await readRequiredJson({ path: configPath }).catch(() => null);
628
+ let config;
629
+ try {
630
+ config = readRequiredJson(await file(configPath).text());
631
+ } catch {
632
+ config = null;
633
+ }
625
634
  if (!config) return /* @__PURE__ */ new Set();
626
635
  const off = /* @__PURE__ */ new Set();
627
636
  for (const [rule, val] of Object.entries(config.rules ?? {})) if ((Array.isArray(val) ? String(val[0]) : val) === "off") {
@@ -1327,12 +1336,11 @@ const containsJsxNode = (program) => {
1327
1336
  for (const child of node) visit(child);
1328
1337
  return;
1329
1338
  }
1330
- const typed = node;
1331
- if (typed.type === "JSXElement" || typed.type === "JSXFragment") {
1339
+ if ("type" in node && (node.type === "JSXElement" || node.type === "JSXFragment")) {
1332
1340
  found = true;
1333
1341
  return;
1334
1342
  }
1335
- for (const key of Object.keys(node)) if (key !== "type") visit(node[key]);
1343
+ for (const [key, child] of Object.entries(node)) if (key !== "type") visit(child);
1336
1344
  };
1337
1345
  visit(program);
1338
1346
  return found;
@@ -1428,6 +1436,27 @@ const rebuildBiomeLine = ({ line, rules }) => {
1428
1436
  const reason = biomeReasonOf(line) ?? "suppressed";
1429
1437
  return `${leadingWhitespaceRe.exec(line)?.[0] ?? ""}/** biome-ignore-all ${rules.join(", ")}: ${reason} */`;
1430
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
+ };
1431
1460
  const firedOxlintByFile = async ({ configPath, files, oxlintBin }) => {
1432
1461
  const result = await runCapture({
1433
1462
  args: [
@@ -1442,7 +1471,12 @@ const firedOxlintByFile = async ({ configPath, files, oxlintBin }) => {
1442
1471
  env: buildEnv(),
1443
1472
  label: "oxlint-unused"
1444
1473
  });
1445
- const diagnostics = parseOxlintDiagnostics({ stdout: extractJson(result.stdout) });
1474
+ const diagnostics = parseOxlintDiagnostics({ stdout: requireLintAnswer({
1475
+ exitCode: result.exitCode,
1476
+ label: "oxlint-unused",
1477
+ stderr: result.stderr,
1478
+ stdout: result.stdout
1479
+ }) });
1446
1480
  const byFile = /* @__PURE__ */ new Map();
1447
1481
  for (const d of diagnostics) {
1448
1482
  const key = absFile(d.file);
@@ -1571,7 +1605,12 @@ const firedBiomeByFile = async ({ biomeBin, configDir, files }) => {
1571
1605
  env: buildEnv(),
1572
1606
  label: "biome-unused"
1573
1607
  });
1574
- const diagnostics = parseBiomeDiagnostics({ stdout: extractJson(result.stdout) });
1608
+ const diagnostics = parseBiomeDiagnostics({ stdout: requireLintAnswer({
1609
+ exitCode: result.exitCode,
1610
+ label: "biome-unused",
1611
+ stderr: result.stderr,
1612
+ stdout: result.stdout
1613
+ }) });
1575
1614
  const byFile = /* @__PURE__ */ new Map();
1576
1615
  for (const d of diagnostics) {
1577
1616
  const key = absFile(d.file);
@@ -2136,7 +2175,7 @@ const throwAgentResults = ({ diagnostics, failures }) => {
2136
2175
  const readOxlintIgnorePatterns = async ({ dir }) => {
2137
2176
  const generated = file(joinPath(dir, ".oxlintrc.json"));
2138
2177
  if (!await generated.exists()) return [...DEFAULT_SHARED_IGNORE_PATTERNS];
2139
- const patterns = (await generated.json()).ignorePatterns;
2178
+ const patterns = readRequiredJson(await generated.text()).ignorePatterns;
2140
2179
  if (!Array.isArray(patterns)) return [...DEFAULT_SHARED_IGNORE_PATTERNS];
2141
2180
  return patterns.filter((x) => typeof x === "string");
2142
2181
  };
@@ -2314,7 +2353,7 @@ const runLint = async ({ command, human = false }) => {
2314
2353
  configPath,
2315
2354
  env
2316
2355
  });
2317
- const runtime = await readJson({ path: runtimePath });
2356
+ const runtime = readRequiredJson(await file(runtimePath).text());
2318
2357
  const failures = [];
2319
2358
  const { clearFailures, runCompactContinue, runSteps, runStepsSilent, throwIfFailures } = createStepExecutor({
2320
2359
  env,
package/dist/eslint.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { E as TAILWIND_ENTRY_CANDIDATES, T as SHARED_OVERRIDE_SYMBOL_KEY, b as DEFAULT_SHARED_IGNORE_PATTERNS, c as findUnknownRules, d as normalizeObjectListInput, f as normalizePathListInput, g as warnToError, i as joinPath, l as isRecord, m as normalizeTailwindOption, p as normalizeRulesOffInput, r as isAbsolutePath, x as ESLINT_TEST_FILE_PATTERNS } from "./path-DfaiIsLo.mjs";
1
+ import { E as TAILWIND_ENTRY_CANDIDATES, T as SHARED_OVERRIDE_SYMBOL_KEY, b as DEFAULT_SHARED_IGNORE_PATTERNS, c as findUnknownRules, d as normalizeObjectListInput, f as normalizePathListInput, g as warnToError, i as joinPath, l as isRecord, m as normalizeTailwindOption, p as normalizeRulesOffInput, r as isAbsolutePath, x as ESLINT_TEST_FILE_PATTERNS } from "./path-CVd5J9sx.mjs";
2
2
  import { file } from "bun";
3
3
  import eslintReact from "@eslint-react/eslint-plugin";
4
4
  import { includeIgnoreFile } from "@eslint/compat";
@@ -87,7 +87,9 @@ const collectKnownEslintRuleNames = ({ appendConfigs, baseConfigs }) => {
87
87
  return knownRuleNames;
88
88
  };
89
89
  const getSharedAppendConfig = ({ config }) => {
90
- return config[sharedOverrideMarker] === true ? config : null;
90
+ if (Reflect.get(config, sharedOverrideMarker) !== true) return null;
91
+ /** biome-ignore lint/nursery/noUnsafeTypeAssertion: internal marker identifies this external config as the shared append shape */
92
+ return config;
91
93
  };
92
94
  const resolveTailwindEntry = async ({ root, tailwind }) => {
93
95
  const tailwindSetting = tailwind ?? true;
@@ -115,6 +117,7 @@ const SOURCE_FILE_PATTERNS = [
115
117
  const tailwindRules = (entryPoint) => entryPoint ? eslintPluginBetterTailwindcss.configs["recommended-error"].rules : {};
116
118
  /** regexp's `flat/recommended` is the curated set: it keeps every correctness rule (no-super-linear-backtracking — the real ReDoS — plus no-misleading-capturing-group, no-dupe-disjunctions, no-unused-capturing-group) and drops the pure-style ones `flat/all` adds (prefer-named-capture-group, require-unicode-sets-regexp, sort-character-class-elements) and the author-excluded advisory no-super-linear-move. Its rules ship at warn, and a warn enforces nothing because the gate's `warnToError` covers consumer overrides, not a config reached through `extends`, so they are lifted to error here. */
117
119
  const regexpRecommendedAtError = () => {
120
+ /** biome-ignore lint/nursery/noUnsafeTypeAssertion: external regexp plugin config is structurally compatible with ESLint's config boundary */
118
121
  const rec = configs$2["flat/recommended"];
119
122
  return {
120
123
  ...rec,
@@ -123,7 +126,9 @@ const regexpRecommendedAtError = () => {
123
126
  };
124
127
  /** package.json is a file type the gate would otherwise never lint. The plugin ships its own `files` glob and JSON parser, so it stands alone rather than riding the TypeScript block. Its `recommended` + `stylistic` are the curated set; the `require-*` family stays out because those demand OPT-IN metadata (`bin`, `browser`, `cpu`, `gypfile`, `libc`, `man`, `os`) that no ordinary package declares. `require-type` is disabled with cause: its autofix stamps `"type": "commonjs"` onto any manifest missing `type`, which silently BREAKS an ESM package (a Next/MDX app relying on extension-based resolution) — a rule that guesses a load-bearing field and defaults it wrong is harm, not strictness. */
125
128
  const packageJsonConfig = () => {
129
+ /** biome-ignore lint/nursery/noUnsafeTypeAssertion: external package-json plugin config is structurally compatible with ESLint's config boundary */
126
130
  const recommended = configs.recommended;
131
+ /** biome-ignore lint/nursery/noUnsafeTypeAssertion: external package-json plugin config is structurally compatible with ESLint's config boundary */
127
132
  const stylistic = configs.stylistic;
128
133
  return {
129
134
  ...recommended,
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { n as eslintImport, r as sync, t as defineConfig } from "./src-ioM8CeP8.mjs";
1
+ import { n as eslintImport, r as sync, t as defineConfig } from "./src-apGJLN8u.mjs";
2
2
  export { defineConfig, eslintImport, sync };
@@ -173,6 +173,7 @@ const OXLINT_CLI_ALLOW = [
173
173
  "react/jsx-no-literals",
174
174
  "unicorn/prefer-export-from",
175
175
  "react/react-compiler",
176
+ "react/todo",
176
177
  "react/function-component-definition",
177
178
  "react/memo-dependencies",
178
179
  "react/preserve-manual-memoization",
@@ -201,6 +202,7 @@ const normalizePathListInput = ({ allowUndefined = false, label, value }) => {
201
202
  return out;
202
203
  };
203
204
  const hasPlainObjectPrototype = ({ value }) => {
205
+ /** biome-ignore lint/nursery/noUnsafeTypeAssertion: Object.getPrototypeOf returns an untyped external object boundary */
204
206
  const prototype = Object.getPrototypeOf(value);
205
207
  return prototype === null || prototype === Object.prototype;
206
208
  };
@@ -1,4 +1,4 @@
1
- import { C as OXLINT_PATTERN_RULE_OVERRIDES, T as SHARED_OVERRIDE_SYMBOL_KEY, _ as BIOME_IGNORE_PATTERNS, a as assertJsonSerializable, b as DEFAULT_SHARED_IGNORE_PATTERNS, c as findUnknownRules, d as normalizeObjectListInput, f as normalizePathListInput, h as stripPluginNamespace, i as joinPath, l as isRecord, m as normalizeTailwindOption, n as fromFileUrl, o as assertObject, p as normalizeRulesOffInput, s as assertOptionalString, t as dirnamePath, u as normalizeIgnorePattern, v as BIOME_PATTERN_RULE_OVERRIDES, y as BIOME_RULES_OFF } from "./path-DfaiIsLo.mjs";
1
+ import { C as OXLINT_PATTERN_RULE_OVERRIDES, T as SHARED_OVERRIDE_SYMBOL_KEY, _ as BIOME_IGNORE_PATTERNS, a as assertJsonSerializable, b as DEFAULT_SHARED_IGNORE_PATTERNS, c as findUnknownRules, d as normalizeObjectListInput, f as normalizePathListInput, h as stripPluginNamespace, i as joinPath, l as isRecord, m as normalizeTailwindOption, n as fromFileUrl, o as assertObject, p as normalizeRulesOffInput, s as assertOptionalString, t as dirnamePath, u as normalizeIgnorePattern, v as BIOME_PATTERN_RULE_OVERRIDES, y as BIOME_RULES_OFF } from "./path-CVd5J9sx.mjs";
2
2
  import { $, env as bunEnv, file, write } from "bun";
3
3
  import { lstat } from "node:fs/promises";
4
4
  import { join, relative } from "node:path";
@@ -44,10 +44,7 @@ const readJson = async ({ path }) => {
44
44
  return {};
45
45
  }
46
46
  };
47
- const readRequiredJson = async ({ path }) => {
48
- const text = await file(path).text();
49
- return JSON.parse(text);
50
- };
47
+ const readRequiredJson = (text) => JSON.parse(text);
51
48
  const ensureDirectory = async ({ directory }) => {
52
49
  const result = await $`mkdir -p ${directory}`.quiet().nothrow();
53
50
  if (result.exitCode === 0) return;
@@ -72,7 +69,7 @@ const resolveBin = async ({ bin, pkg }) => {
72
69
  code: 1,
73
70
  message: `Cannot find ${pkg} — run: bun add -d ${pkg}`
74
71
  });
75
- const pkgJson = await readRequiredJson({ path: packageJsonPath });
72
+ const pkgJson = readRequiredJson(await file(packageJsonPath).text());
76
73
  const pkgDir = dirnamePath(packageJsonPath);
77
74
  const binPath = typeof pkgJson.bin === "string" ? pkgJson.bin : pkgJson.bin?.[bin] ?? "";
78
75
  return joinPath(pkgDir, binPath);
@@ -100,7 +97,7 @@ const runCapture = async ({ args, command, env }) => {
100
97
  };
101
98
  const envValue = (name) => bunEnv[name] ?? "";
102
99
  const readVersion = async () => {
103
- return (await readRequiredJson({ path: joinPath(lintmaxRoot, "package.json") })).version;
100
+ return readRequiredJson(await file(joinPath(lintmaxRoot, "package.json")).text()).version;
104
101
  };
105
102
  const usage = ({ version }) => {
106
103
  process.stdout.write(`lintmax v${version}\n\n`);
@@ -138,7 +135,7 @@ const resolveSchemaPath = async ({ cwd }) => {
138
135
  };
139
136
  const resolveBiomeSchema = async ({ cwd }) => {
140
137
  const schemaPath = await resolveSchemaPath({ cwd });
141
- const schema = await readRequiredJson({ path: schemaPath });
138
+ const schema = readRequiredJson(await file(schemaPath).text());
142
139
  const rulesProps = schema.$defs.Rules?.properties ?? {};
143
140
  const categories = Object.keys(rulesProps).filter((k) => {
144
141
  return schema.$defs[k.charAt(0).toUpperCase() + k.slice(1)]?.properties !== void 0;
@@ -225,7 +222,7 @@ const normalizeSharedOverrides = ({ label, value }) => {
225
222
  label: `${label}.${pattern}`,
226
223
  value: rawOverride
227
224
  });
228
- for (const key of Object.keys(override)) if (!SHARED_OVERRIDE_KEYS.includes(key)) throw new Error(`${label}.${pattern}.${key} is not supported. Use biome, eslint, or oxlint.`);
225
+ for (const key of Object.keys(override)) if (!SHARED_OVERRIDE_KEYS.some((k) => k === key)) throw new Error(`${label}.${pattern}.${key} is not supported. Use biome, eslint, or oxlint.`);
229
226
  entries.push({
230
227
  ...override,
231
228
  files: [pattern]
@@ -663,7 +660,7 @@ const createBiomeConfig = async ({ cwd, options, sharedIgnorePatterns }) => {
663
660
  };
664
661
  };
665
662
  const createOxlintConfig = async ({ options, sharedIgnorePatterns }) => {
666
- const base = await readRequiredJson({ path: joinPath(pkgRoot, "oxlintrc.json") });
663
+ const base = readRequiredJson(await file(joinPath(pkgRoot, "oxlintrc.json")).text());
667
664
  const knownRules = /* @__PURE__ */ new Set([
668
665
  ...Object.keys(base.rules),
669
666
  ...(base.overrides ?? []).flatMap((override) => Object.keys(override.rules)),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lintmax",
3
- "version": "0.1.93",
3
+ "version": "0.1.95",
4
4
  "description": "The #1 anti AI slop typescript tooling. Designed for coding agents, not humans.",
5
5
  "keywords": [
6
6
  "agent",