lintmax 0.1.107 → 0.1.108

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,13 +1,13 @@
1
1
  #!/usr/bin/env bun
2
- import { B as ESLINT_TEST_FILE_PATTERNS, C as joinPath, O as isRecord, U as PARSE_DIALECTS, V as OXLINT_CLI_ALLOW, _ as run, a as PRETTIER_MD_ARGS, b as dirnamePath, c as decodeText, d as lintmaxRoot, f as pathExists, g as resolveBin, h as readVersion, i as CliExitError, l as ensureDirectory, m as readRequiredJson, n as listProjectFiles, o as cacheDir, p as readJson, r as matchesGlob, s as cwd, t as escapeGlobPath, u as envValue, v as runCapture, x as fromFileUrl, y as usage, z as DEFAULT_SHARED_IGNORE_PATTERNS } from "./project-files-BJWR09gY.mjs";
3
- import { r as sync } from "./src-C2vei_sO.mjs";
4
- import { $, Glob, env, file, write } from "bun";
5
- import { lstat, unlink } from "node:fs/promises";
6
- import { join } from "node:path";
7
- import { homedir, platform, tmpdir } from "node:os";
2
+ import { B as ESLINT_TEST_FILE_PATTERNS, C as joinPath, O as isRecord, U as PARSE_DIALECTS, V as OXLINT_CLI_ALLOW, _ as run, a as PRETTIER_MD_ARGS, b as dirnamePath, c as decodeText, d as envValue, f as lintmaxRoot, g as resolveBin, h as readVersion, i as CliExitError, l as doesPathExist, m as readRequiredJson, n as listProjectFiles, o as cacheDir, p as readJson, r as doesMatchGlob, s as cwd, t as escapeGlobPath, u as ensureDirectory, v as runCapture, x as fromFileUrl, y as usage, z as DEFAULT_SHARED_IGNORE_PATTERNS } from "./project-files-DkcnsKmB.mjs";
3
+ import { $, Glob, env, file, which, write } from "bun";
8
4
  import { Buffer } from "node:buffer";
5
+ import { homedir, platform, tmpdir } from "node:os";
9
6
  import { parse } from "oxc-parser";
10
7
  import { ESLint } from "eslint";
8
+ import { lstat, unlink } from "node:fs/promises";
9
+ import { join } from "node:path";
10
+ import { r as sync } from "./src-Cu2vOuEp.mjs";
11
11
  import { createHash } from "node:crypto";
12
12
  // src/rule-equivalence.ts
13
13
  const equivalenceGroups = [
@@ -126,23 +126,16 @@ const normalizePath = (filePath) => {
126
126
  if (filePath.startsWith(cwdPrefix)) return filePath.slice(cwdPrefix.length);
127
127
  return filePath;
128
128
  };
129
- const biomeEntries = (diagnostics) => {
130
- const results = [];
131
- for (const d of diagnostics) {
132
- const filePath = d.location?.path;
133
- const { category } = d;
134
- if (filePath && category) {
135
- const line = d.location?.start?.line ?? 0;
136
- results.push({
137
- file: normalizePath(filePath),
138
- line,
139
- linter: "biome",
140
- rule: category
141
- });
142
- }
143
- }
144
- return results;
145
- };
129
+ const biomeEntries = (diagnostics) => diagnostics.flatMap((d) => {
130
+ const filePath = d.location?.path;
131
+ const { category } = d;
132
+ return filePath && category ? [{
133
+ file: normalizePath(filePath),
134
+ line: d.location?.start?.line ?? 0,
135
+ linter: "biome",
136
+ rule: category
137
+ }] : [];
138
+ });
146
139
  const parseBiomeDiagnostics = ({ stdout }) => {
147
140
  let parsed;
148
141
  try {
@@ -153,23 +146,16 @@ const parseBiomeDiagnostics = ({ stdout }) => {
153
146
  if (!Array.isArray(parsed.diagnostics)) return [];
154
147
  return biomeEntries(parsed.diagnostics);
155
148
  };
156
- const oxlintEntries = (diagnostics) => {
157
- const results = [];
158
- for (const d of diagnostics) {
159
- const filePath = d.filename ?? "";
160
- const rule = d.code;
161
- if (rule) {
162
- const line = d.labels?.[0]?.span?.line ?? 0;
163
- results.push({
164
- file: filePath.length > 0 ? normalizePath(filePath) : "<unknown>",
165
- line,
166
- linter: "oxlint",
167
- rule
168
- });
169
- }
170
- }
171
- return results;
172
- };
149
+ const oxlintEntries = (diagnostics) => diagnostics.flatMap((d) => {
150
+ const filePath = d.filename ?? "";
151
+ const rule = d.code;
152
+ return rule ? [{
153
+ file: filePath.length > 0 ? normalizePath(filePath) : "<unknown>",
154
+ line: d.labels?.[0]?.span?.line ?? 0,
155
+ linter: "oxlint",
156
+ rule
157
+ }] : [];
158
+ });
173
159
  const parseOxlintDiagnostics = ({ stdout }) => {
174
160
  let parsed;
175
161
  try {
@@ -662,8 +648,8 @@ const addRuleVariants = (rule, target) => {
662
648
  const loadOxlintOffRules = async () => {
663
649
  const config = await readOxlintConfig();
664
650
  const off = new Set(OXLINT_CLI_ALLOW);
665
- const configuredRules = Object.entries(config.rules ?? {});
666
- for (const [rule, val] of configuredRules) if ((Array.isArray(val) ? String(val[0]) : val) === "off") {
651
+ const offRules = Object.entries(config.rules ?? {}).filter(([, val]) => (Array.isArray(val) ? String(val[0]) : val) === "off");
652
+ for (const [rule] of offRules) {
667
653
  off.add(rule);
668
654
  addRuleVariants(rule, off);
669
655
  }
@@ -840,11 +826,11 @@ const extOf = (path) => {
840
826
  };
841
827
  const isCommentCandidate = (path) => COMMENT_EXTENSIONS.has(extOf(path));
842
828
  const isBlockOnlyComment = (sourceText, comments, c) => {
843
- const inComment = (idx) => comments.some((o) => idx >= o.start && idx < o.end);
829
+ const isInComment = (idx) => comments.some((o) => idx >= o.start && idx < o.end);
844
830
  let before = c.start - 1;
845
- while (before >= 0 && (WS_CHAR.test(sourceText[before] ?? "") || inComment(before))) before -= 1;
831
+ while (before >= 0 && (WS_CHAR.test(sourceText[before] ?? "") || isInComment(before))) before -= 1;
846
832
  let after = c.end;
847
- while (after < sourceText.length && (WS_CHAR.test(sourceText[after] ?? "") || inComment(after))) after += 1;
833
+ while (after < sourceText.length && (WS_CHAR.test(sourceText[after] ?? "") || isInComment(after))) after += 1;
848
834
  return sourceText[before] === "{" && sourceText[after] === "}";
849
835
  };
850
836
  const findDeletableComments = async ({ sourceText }) => {
@@ -919,7 +905,7 @@ const processFile = async (filePath) => {
919
905
  modified: false
920
906
  };
921
907
  };
922
- const processFileForFix = async (filePath) => {
908
+ const didStripCommentsInFile = async (filePath) => {
923
909
  if (!isCommentCandidate(filePath)) return false;
924
910
  const f = file(filePath);
925
911
  if (!await f.exists()) return false;
@@ -935,7 +921,7 @@ const checkComments = async ({ files }) => {
935
921
  return (await Promise.all(files.map(async (f) => processFile(f)))).flatMap((r) => r.diagnostics);
936
922
  };
937
923
  const fixComments = async ({ files }) => {
938
- return (await Promise.all(files.map(async (f) => processFileForFix(f)))).filter(Boolean).length;
924
+ return (await Promise.all(files.map(async (f) => didStripCommentsInFile(f)))).filter(Boolean).length;
939
925
  };
940
926
  // src/compact.ts
941
927
  const isSymlinkSafe = async (p) => {
@@ -1047,10 +1033,10 @@ const printCompactCounts = (results, changed) => {
1047
1033
  process.stdout.write(`[compact] Scanned ${scanned} files\n`);
1048
1034
  process.stdout.write(`[compact] Updated ${changed.length} files\n`);
1049
1035
  };
1050
- const reportCompact = (results, mode, human) => {
1036
+ const reportCompact = (results, mode, isHuman) => {
1051
1037
  const changed = results.filter((result) => result.changed).map((result) => result.relativePath);
1052
1038
  if (mode === "fix") {
1053
- if (human) printCompactCounts(results, changed);
1039
+ if (isHuman) printCompactCounts(results, changed);
1054
1040
  return;
1055
1041
  }
1056
1042
  if (changed.length === 0) return;
@@ -1336,7 +1322,7 @@ const DANGEROUS_NON_TEST_PATTERNS = [
1336
1322
  "no-explicit-any",
1337
1323
  "noExplicitAny"
1338
1324
  ];
1339
- const isTestFile = (f) => ESLINT_TEST_FILE_PATTERNS.some((p) => matchesGlob(new Glob(p), f));
1325
+ const isTestFile = (f) => ESLINT_TEST_FILE_PATTERNS.some((p) => doesMatchGlob(new Glob(p), f));
1340
1326
  const parseRules = (line, re) => {
1341
1327
  const rules = [];
1342
1328
  re.lastIndex = 0;
@@ -1371,7 +1357,7 @@ const rulesFromContent = (content) => {
1371
1357
  };
1372
1358
  const findDangerousSuppressions = async (cwd) => {
1373
1359
  const ignoreGlobs = DEFAULT_SHARED_IGNORE_PATTERNS.map((p) => new Glob(p));
1374
- const files = (await listProjectFiles({ root: cwd })).filter((p) => (p.endsWith(".ts") || p.endsWith(".tsx")) && !p.endsWith(".d.ts") && ignoreGlobs.every((g) => !matchesGlob(g, p)));
1360
+ const files = (await listProjectFiles({ root: cwd })).filter((p) => (p.endsWith(".ts") || p.endsWith(".tsx")) && !p.endsWith(".d.ts") && ignoreGlobs.every((g) => !doesMatchGlob(g, p)));
1375
1361
  return (await Promise.all(files.map(async (relativePath) => {
1376
1362
  const lines = (await file(joinPath(cwd, relativePath)).text()).split("\n");
1377
1363
  const findings = [];
@@ -1386,27 +1372,27 @@ const findDangerousSuppressions = async (cwd) => {
1386
1372
  }))).flat();
1387
1373
  };
1388
1374
  // src/jsx-extension.ts
1389
- const containsJsxNode = (program) => {
1390
- let found = false;
1375
+ const hasJsxNode = (program) => {
1376
+ let isFound = false;
1391
1377
  const visit = (node) => {
1392
- if (found || !node || typeof node !== "object") return;
1378
+ if (isFound || !node || typeof node !== "object") return;
1393
1379
  if (Array.isArray(node)) {
1394
1380
  for (const child of node) visit(child);
1395
1381
  return;
1396
1382
  }
1397
1383
  if ("type" in node && (node.type === "JSXElement" || node.type === "JSXFragment")) {
1398
- found = true;
1384
+ isFound = true;
1399
1385
  return;
1400
1386
  }
1401
1387
  for (const [key, child] of Object.entries(node)) if (key !== "type") visit(child);
1402
1388
  };
1403
1389
  visit(program);
1404
- return found;
1390
+ return isFound;
1405
1391
  };
1406
1392
  const hasJsx = async (sourceText) => {
1407
1393
  if ((await parse("file.ts", sourceText)).errors.length === 0) return false;
1408
1394
  const asTsx = await parse("file.tsx", sourceText);
1409
- return containsJsxNode(asTsx.program);
1395
+ return hasJsxNode(asTsx.program);
1410
1396
  };
1411
1397
  const checkJsxExtension = async ({ root }) => {
1412
1398
  const ignoreGlobs = DEFAULT_SHARED_IGNORE_PATTERNS.map((p) => new Glob(p));
@@ -1627,10 +1613,8 @@ const findOxlintDisableFiles = async (filePaths) => {
1627
1613
  const out = [];
1628
1614
  for (const fp of filePaths) {
1629
1615
  const f = file(fp);
1630
- if (await f.exists()) {
1631
- const content = await f.text();
1632
- if (oxlintDisablePresentRe.test(content)) out.push(fp);
1633
- }
1616
+ const content = await f.exists() ? await f.text() : "";
1617
+ if (oxlintDisablePresentRe.test(content)) out.push(fp);
1634
1618
  }
1635
1619
  return out;
1636
1620
  };
@@ -1638,9 +1622,7 @@ const findBiomeIgnoreAllFiles = async (filePaths) => {
1638
1622
  const out = [];
1639
1623
  for (const fp of filePaths) {
1640
1624
  const f = file(fp);
1641
- if (await f.exists()) {
1642
- if ((await f.text()).includes("biome-ignore-all")) out.push(fp);
1643
- }
1625
+ if ((await f.exists() ? await f.text() : "").includes("biome-ignore-all")) out.push(fp);
1644
1626
  }
1645
1627
  return out;
1646
1628
  };
@@ -1680,16 +1662,20 @@ const matchBiomeDirective = (line) => {
1680
1662
  };
1681
1663
  const parseBiomeDirectiveLines = (lines) => {
1682
1664
  const directiveLines = [];
1683
- for (let index = 0; index < lines.length; index += 1) {
1684
- const match = matchBiomeDirective(lines[index] ?? "");
1685
- if (match) {
1686
- const first = match.groups?.first ?? "";
1687
- const rest = match.groups?.rest ?? "";
1688
- directiveLines.push({
1689
- index,
1690
- rules: [first, ...splitBiomeRest(rest)]
1691
- });
1692
- }
1665
+ const matched = lines.flatMap((line, index) => {
1666
+ const match = matchBiomeDirective(line);
1667
+ return match ? [{
1668
+ index,
1669
+ match
1670
+ }] : [];
1671
+ });
1672
+ for (const { index, match } of matched) {
1673
+ const first = match.groups?.first ?? "";
1674
+ const rest = match.groups?.rest ?? "";
1675
+ directiveLines.push({
1676
+ index,
1677
+ rules: [first, ...splitBiomeRest(rest)]
1678
+ });
1693
1679
  }
1694
1680
  return directiveLines;
1695
1681
  };
@@ -1840,6 +1826,20 @@ const formatFailureDetails = (failures) => failures.map((item) => {
1840
1826
  const messageLine = item.message ? `\n${item.message}` : "";
1841
1827
  return `- ${item.label} (exit ${item.code})${messageLine}`;
1842
1828
  }).join("\n");
1829
+ const recordFlowmarkResult = (result, failures) => {
1830
+ const { exitCode, stderr, stdout } = result;
1831
+ if (exitCode === 0) return;
1832
+ const output = [stdout.trim(), stderr.trim()].filter(Boolean).join("\n");
1833
+ failures.push({
1834
+ code: exitCode,
1835
+ label: "flowmark",
1836
+ message: output || "Flowmark failed without reporting details"
1837
+ });
1838
+ };
1839
+ const runFlowmark = async (opts, failures) => {
1840
+ const result = await runCapture(opts);
1841
+ recordFlowmarkResult(result, failures);
1842
+ };
1843
1843
  const createStepExecutor = ({ env, failures, root }) => {
1844
1844
  const runContinue = async (opts) => {
1845
1845
  try {
@@ -1886,7 +1886,7 @@ const createStepExecutor = ({ env, failures, root }) => {
1886
1886
  label: step.label,
1887
1887
  silent: step.silent
1888
1888
  };
1889
- await runContinue(opts);
1889
+ await (step.label === "flowmark" ? runFlowmark(opts, failures) : runContinue(opts));
1890
1890
  }
1891
1891
  };
1892
1892
  const runStepsSilent = async ({ steps }) => {
@@ -1897,7 +1897,8 @@ const createStepExecutor = ({ env, failures, root }) => {
1897
1897
  env,
1898
1898
  label: step.label
1899
1899
  });
1900
- if (result.exitCode !== 0) failures.push({
1900
+ if (step.label === "flowmark") recordFlowmarkResult(result, failures);
1901
+ else if (result.exitCode !== 0) failures.push({
1901
1902
  code: result.exitCode,
1902
1903
  label: step.label,
1903
1904
  message: result.stderr.length > 0 ? result.stderr.trim() : void 0
@@ -1905,7 +1906,7 @@ const createStepExecutor = ({ env, failures, root }) => {
1905
1906
  }
1906
1907
  };
1907
1908
  const clearFailures = () => {
1908
- failures.length = 0;
1909
+ failures.splice(0, failures.length, ...failures.filter((step) => step.label === "flowmark"));
1909
1910
  };
1910
1911
  const throwIfFailures = () => {
1911
1912
  if (failures.length === 0) return;
@@ -1924,7 +1925,7 @@ const createStepExecutor = ({ env, failures, root }) => {
1924
1925
  throwIfFailures
1925
1926
  };
1926
1927
  };
1927
- const createCheckSteps = ({ biomeBin, dir, eslintArgs, eslintBin, oxlintBin, oxlintIgnorePatterns, prettierBin, prettierMarkdownTargets, sortPkgJson, targets }) => {
1928
+ const createCheckSteps = ({ biomeBin, dir, eslintArgs, eslintBin, flowmarkStep, oxlintBin, oxlintIgnorePatterns, prettierBin, prettierMarkdownTargets, sortPkgJson, targets }) => {
1928
1929
  const oxlintCliAllow = [...OXLINT_CLI_ALLOW.flatMap((r) => ["--allow", r]), ...oxlintIgnorePatterns.flatMap((p) => ["--ignore-pattern", p])];
1929
1930
  const steps = [
1930
1931
  {
@@ -1967,6 +1968,7 @@ const createCheckSteps = ({ biomeBin, dir, eslintArgs, eslintBin, oxlintBin, oxl
1967
1968
  label: "eslint"
1968
1969
  }
1969
1970
  ];
1971
+ if (flowmarkStep) steps.push(flowmarkStep);
1970
1972
  if (prettierMarkdownTargets.length > 0) steps.push({
1971
1973
  args: [
1972
1974
  prettierBin,
@@ -1986,7 +1988,7 @@ const createCheckSteps = ({ biomeBin, dir, eslintArgs, eslintBin, oxlintBin, oxl
1986
1988
  });
1987
1989
  };
1988
1990
  const DESTRUCTIVE_FIX_OVERRIDES = ["--rule", "{\"@eslint-react/no-missing-context-display-name\":\"off\"}"];
1989
- const createFixSteps = ({ biomeBin, dir, eslintArgs, eslintBin, hasFlowmark, oxlintBin, oxlintIgnorePatterns, prettierBin, prettierMarkdownTargets, sortPkgJson, targets }) => {
1991
+ const createFixSteps = ({ biomeBin, dir, eslintArgs, eslintBin, flowmarkStep, oxlintBin, oxlintIgnorePatterns, prettierBin, prettierMarkdownTargets, sortPkgJson, targets }) => {
1990
1992
  const oxlintCliAllow = [...OXLINT_CLI_ALLOW.flatMap((r) => ["--allow", r]), ...oxlintIgnorePatterns.flatMap((p) => ["--ignore-pattern", p])];
1991
1993
  const steps = [
1992
1994
  {
@@ -2046,18 +2048,7 @@ const createFixSteps = ({ biomeBin, dir, eslintArgs, eslintBin, hasFlowmark, oxl
2046
2048
  silent: true
2047
2049
  }
2048
2050
  ];
2049
- const markdownFiles = prettierMarkdownTargets.filter((p) => p.endsWith(".md"));
2050
- if (hasFlowmark) for (const target of markdownFiles) steps.push({
2051
- args: [
2052
- "-w",
2053
- "0",
2054
- "--auto",
2055
- target
2056
- ],
2057
- command: "flowmark",
2058
- label: "flowmark",
2059
- silent: true
2060
- });
2051
+ if (flowmarkStep) steps.push(flowmarkStep);
2061
2052
  if (prettierMarkdownTargets.length > 0) steps.push({
2062
2053
  args: [
2063
2054
  prettierBin,
@@ -2149,7 +2140,7 @@ const captureAndParse = async ({ env, failures, label, opts, parser }) => {
2149
2140
  result
2150
2141
  });
2151
2142
  };
2152
- const runAgentCheck = async ({ biomeBin, dir, env, eslintArgs, eslintBin, failures, oxlintBin, oxlintIgnorePatterns, prettierBin, prettierMarkdownTargets, sortPkgJson, targets }) => {
2143
+ const runAgentCheck = async ({ biomeBin, dir, env, eslintArgs, eslintBin, failures, flowmarkStep, oxlintBin, oxlintIgnorePatterns, prettierBin, prettierMarkdownTargets, sortPkgJson, targets }) => {
2153
2144
  const oxlintCliAllow = [...OXLINT_CLI_ALLOW.flatMap((r) => ["--allow", r]), ...oxlintIgnorePatterns.flatMap((p) => ["--ignore-pattern", p])];
2154
2145
  const allDiagnostics = [];
2155
2146
  const push = (d) => {
@@ -2222,6 +2213,10 @@ const runAgentCheck = async ({ biomeBin, dir, env, eslintArgs, eslintBin, failur
2222
2213
  },
2223
2214
  parser: ({ stdout }) => parseEslintDiagnostics({ stdout })
2224
2215
  }));
2216
+ if (flowmarkStep) await runFlowmark({
2217
+ ...flowmarkStep,
2218
+ env
2219
+ }, failures);
2225
2220
  if (prettierMarkdownTargets.length > 0) push(await captureAndParse({
2226
2221
  env,
2227
2222
  failures,
@@ -2410,7 +2405,7 @@ const buildLintEnv = () => {
2410
2405
  };
2411
2406
  };
2412
2407
  const synchronizeConfig = async ({ configPath, env }) => {
2413
- await (await pathExists({ path: configPath }) ? run({
2408
+ await (await doesPathExist({ path: configPath }) ? run({
2414
2409
  args: ["-e", `const m = await import('${configPath}'); const { sync: s } = await import('lintmax'); await s(m.default);`],
2415
2410
  command: "bun",
2416
2411
  env,
@@ -2450,6 +2445,46 @@ const resolveAllBins = async () => {
2450
2445
  })
2451
2446
  ]);
2452
2447
  };
2448
+ const runUvInstaller = async (env, installDir, message) => {
2449
+ try {
2450
+ return await runCapture({
2451
+ args: ["-c", "curl -LsSf https://astral.sh/uv/install.sh | env UV_NO_MODIFY_PATH=1 sh"],
2452
+ command: "sh",
2453
+ env: {
2454
+ ...env,
2455
+ UV_INSTALL_DIR: installDir
2456
+ },
2457
+ label: "uv installer",
2458
+ timeoutMs: 12e4
2459
+ });
2460
+ } catch (installError) {
2461
+ const detail = installError instanceof Error ? installError.message : String(installError);
2462
+ const error = new CliExitError({
2463
+ code: 1,
2464
+ message: `${message}\n${detail}`
2465
+ });
2466
+ throw Object.assign(error, { cause: installError });
2467
+ }
2468
+ };
2469
+ const installUvx = async (env, installDir) => {
2470
+ const message = `Cannot find uvx after attempting to install uv. Expected ${joinPath(installDir, "uvx")}`;
2471
+ const result = await runUvInstaller(env, installDir, message);
2472
+ const installedUvx = which("uvx", { PATH: installDir });
2473
+ if (installedUvx) return installedUvx;
2474
+ const detail = result.stderr.trim() || result.stdout.trim();
2475
+ throw new CliExitError({
2476
+ code: result.exitCode || 1,
2477
+ message: detail ? `${message}\n${detail}` : message
2478
+ });
2479
+ };
2480
+ const resolveUvx = async (env) => {
2481
+ const uvxOnPath = which("uvx", { PATH: env.PATH ?? "" });
2482
+ if (uvxOnPath) return uvxOnPath;
2483
+ const installDir = joinPath(homedir(), ".local", "bin");
2484
+ const localUvx = which("uvx", { PATH: installDir });
2485
+ if (localUvx) return localUvx;
2486
+ return await installUvx(env, installDir);
2487
+ };
2453
2488
  const runFixCommand = async ({ clearFailures, ctx, fixSteps, human, runStepsSilent }) => {
2454
2489
  if (ctx.shouldComments) await fixComments({ files: ctx.sourceFiles });
2455
2490
  if (ctx.sourceFiles.length > 0) await cleanIgnores(ctx.sourceFiles.map((f) => joinPath(cwd, f)));
@@ -2503,7 +2538,54 @@ const prepareLintFiles = async ({ command, dir, env, human, runCompactContinue,
2503
2538
  oxlintIgnorePatternsEarly
2504
2539
  };
2505
2540
  };
2506
- const prepareLintCommands = async ({ allGitFiles, dir, env, failures, oxlintIgnorePatternsEarly, targets }) => {
2541
+ const createFlowmarkStep = async (command, env, prettierMarkdownTargets) => {
2542
+ const markdownFiles = prettierMarkdownTargets.filter((p) => p.endsWith(".md"));
2543
+ if (markdownFiles.length === 0) return;
2544
+ const uvx = await resolveUvx(env);
2545
+ if (uvx.length === 0) return;
2546
+ return {
2547
+ args: [
2548
+ "--from",
2549
+ "flowmark@latest",
2550
+ "flowmark",
2551
+ "-w",
2552
+ "0",
2553
+ ...command === "fix" ? ["--auto"] : [
2554
+ "--check",
2555
+ "--semantic",
2556
+ "--cleanups",
2557
+ "--smartquotes",
2558
+ "--ellipses"
2559
+ ],
2560
+ ...markdownFiles
2561
+ ],
2562
+ command: uvx,
2563
+ label: "flowmark",
2564
+ silent: true
2565
+ };
2566
+ };
2567
+ const createLintCommands = ({ command, commandParams, env, failures, flowmarkStep }) => {
2568
+ const flowmarkCheckStep = command === "check" ? flowmarkStep : void 0;
2569
+ const checkSteps = createCheckSteps({
2570
+ ...commandParams,
2571
+ flowmarkStep: flowmarkCheckStep
2572
+ });
2573
+ const fixSteps = createFixSteps({
2574
+ ...commandParams,
2575
+ flowmarkStep: command === "fix" ? flowmarkStep : void 0
2576
+ });
2577
+ return {
2578
+ agentParams: {
2579
+ ...commandParams,
2580
+ env,
2581
+ failures,
2582
+ flowmarkStep: flowmarkCheckStep
2583
+ },
2584
+ checkSteps,
2585
+ fixSteps
2586
+ };
2587
+ };
2588
+ const prepareLintCommands = async ({ allGitFiles, command, dir, env, failures, oxlintIgnorePatternsEarly, targets }) => {
2507
2589
  const eslintArgs = [
2508
2590
  "--config",
2509
2591
  joinPath(dir, "eslint.generated.mjs"),
@@ -2515,49 +2597,45 @@ const prepareLintCommands = async ({ allGitFiles, dir, env, failures, oxlintIgno
2515
2597
  dprint: dprintBin,
2516
2598
  tombi: tombiBin
2517
2599
  };
2518
- const hasFlowmark = (await $`which flowmark`.env(env).quiet().nothrow()).exitCode === 0;
2519
- const commandParams = {
2520
- biomeBin,
2521
- dir,
2522
- eslintArgs,
2523
- eslintBin,
2524
- oxlintBin,
2525
- oxlintIgnorePatterns: oxlintIgnorePatternsEarly,
2526
- prettierBin,
2527
- prettierMarkdownTargets: allGitFiles.filter((p) => hasExtension(p, PRETTIER_EXTENSIONS)).map((p) => joinPath(cwd, p)),
2528
- sortPkgJson,
2529
- targets
2530
- };
2531
- const checkSteps = createCheckSteps(commandParams);
2532
- const fixSteps = createFixSteps({
2533
- ...commandParams,
2534
- hasFlowmark
2535
- });
2600
+ const prettierMarkdownTargets = allGitFiles.filter((p) => hasExtension(p, PRETTIER_EXTENSIONS)).map((p) => joinPath(cwd, p));
2601
+ const flowmarkStep = await createFlowmarkStep(command, env, prettierMarkdownTargets);
2536
2602
  return {
2537
- agentParams: {
2538
- ...commandParams,
2603
+ ...createLintCommands({
2604
+ command,
2605
+ commandParams: {
2606
+ biomeBin,
2607
+ dir,
2608
+ eslintArgs,
2609
+ eslintBin,
2610
+ oxlintBin,
2611
+ oxlintIgnorePatterns: oxlintIgnorePatternsEarly,
2612
+ prettierBin,
2613
+ prettierMarkdownTargets,
2614
+ sortPkgJson,
2615
+ targets
2616
+ },
2539
2617
  env,
2540
- failures
2541
- },
2542
- checkSteps,
2543
- extraBins,
2544
- fixSteps
2618
+ failures,
2619
+ flowmarkStep
2620
+ }),
2621
+ extraBins
2545
2622
  };
2546
2623
  };
2547
- const prepareLintContext = async (command, human) => {
2624
+ const prepareLintContext = async (command, isHuman) => {
2548
2625
  const { dir, env, executor, failures, runtime } = await prepareLintRuntime();
2549
2626
  const { clearFailures, runCompactContinue, runSteps, runStepsSilent, throwIfFailures } = executor;
2550
2627
  const { allGitFiles, isIgnored, oxlintIgnorePatternsEarly } = await prepareLintFiles({
2551
2628
  command,
2552
2629
  dir,
2553
2630
  env,
2554
- human,
2631
+ human: isHuman,
2555
2632
  runCompactContinue,
2556
2633
  runtime
2557
2634
  });
2558
2635
  const targets = createLintTargets(allGitFiles);
2559
2636
  const { agentParams, checkSteps, extraBins, fixSteps } = await prepareLintCommands({
2560
2637
  allGitFiles,
2638
+ command,
2561
2639
  dir,
2562
2640
  env,
2563
2641
  failures,
@@ -2751,12 +2829,12 @@ const toIssue = (name, publishedAt) => {
2751
2829
  name
2752
2830
  };
2753
2831
  };
2754
- const scanStaleness = async (force = false) => {
2832
+ const scanStaleness = async (shouldForce = false) => {
2755
2833
  if (envValue(envSkip) === "1") return [];
2756
- const ci = envValue("CI") === "true" || envValue("CI") === "1";
2757
- const forced = force || ci || envValue(envForce) === "1";
2834
+ const isCi = envValue("CI") === "true" || envValue("CI") === "1";
2835
+ const isForced = shouldForce || isCi || envValue(envForce) === "1";
2758
2836
  const state = await loadState();
2759
- if (!forced && state.lastCheck > 0 && Date.now() - state.lastCheck < cacheTtlMs) return state.staleIssues.filter((issue) => !Object.hasOwn(staleExceptions, issue.name));
2837
+ if (!isForced && state.lastCheck > 0 && Date.now() - state.lastCheck < cacheTtlMs) return state.staleIssues.filter((issue) => !Object.hasOwn(staleExceptions, issue.name));
2760
2838
  const names = await trackedPackages();
2761
2839
  const issues = (await Promise.all(names.map(async (name) => {
2762
2840
  const publishedAt = await fetchLatestPublish(name);
@@ -2784,7 +2862,7 @@ const computeGreenKey = async (version) => {
2784
2862
  version
2785
2863
  });
2786
2864
  };
2787
- const tryCached = async (greenKey) => {
2865
+ const didReuseGreenCache = async (greenKey) => {
2788
2866
  if (greenKey === void 0) return false;
2789
2867
  if ((await loadState()).lastGreenByCwd[cwd] !== greenKey) return false;
2790
2868
  process.stdout.write("ok (cached)\n");
@@ -2811,7 +2889,7 @@ const emitStaleness = async () => {
2811
2889
  };
2812
2890
  const runGate = async ({ command, human, version }) => {
2813
2891
  const startKey = await computeGreenKey(version);
2814
- if (await tryCached(startKey)) return;
2892
+ if (await didReuseGreenCache(startKey)) return;
2815
2893
  const stalePromise = emitStaleness();
2816
2894
  await runLint({
2817
2895
  command,
@@ -2825,9 +2903,9 @@ const runGate = async ({ command, human, version }) => {
2825
2903
  // src/cli.ts
2826
2904
  const command = process.argv[2];
2827
2905
  const printRules = async () => {
2828
- const human = process.argv.includes("--human");
2906
+ const isHuman = process.argv.includes("--human");
2829
2907
  const rules = await extractAllRules();
2830
- const output = human ? formatRulesHuman(rules) : formatRulesCompact(rules);
2908
+ const output = isHuman ? formatRulesHuman(rules) : formatRulesCompact(rules);
2831
2909
  process.stdout.write(`${output}\n`);
2832
2910
  };
2833
2911
  const runLintCommand = async (version) => {
@@ -2836,10 +2914,10 @@ const runLintCommand = async (version) => {
2836
2914
  if (command === "--help" || command === "-h") return;
2837
2915
  throw new CliExitError({ code: 1 });
2838
2916
  }
2839
- const human = process.argv.includes("--human");
2917
+ const isHuman = process.argv.includes("--human");
2840
2918
  await runGate({
2841
2919
  command,
2842
- human,
2920
+ human: isHuman,
2843
2921
  version
2844
2922
  });
2845
2923
  };
package/dist/eslint.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { n as EslintOptions } from "./lintmax-types-Dj_XPbID.mjs";
2
1
  import { Linter } from "eslint";
2
+ import { n as EslintOptions } from "./lintmax-types-Dj_XPbID.mjs";
3
3
  declare const eslintFactory: (options?: EslintOptions) => Promise<Linter.Config[]>;
4
4
  declare const defaultConfig: Linter.Config[];
5
5
  export { type EslintOptions, defaultConfig as default, eslintFactory as eslint };
package/dist/eslint.mjs CHANGED
@@ -1,9 +1,8 @@
1
- import { A as normalizeObjectListInput, B as ESLINT_TEST_FILE_PATTERNS, C as joinPath, D as findUnknownRules, F as warnToError, G as TAILWIND_ENTRY_CANDIDATES, M as normalizeRulesOffInput, N as normalizeTailwindOption, O as isRecord, S as isAbsolutePath, W as SHARED_OVERRIDE_SYMBOL_KEY, j as normalizePathListInput, n as listProjectFiles, z as DEFAULT_SHARED_IGNORE_PATTERNS } from "./project-files-BJWR09gY.mjs";
2
- import { file } from "bun";
3
1
  import eslintReact from "@eslint-react/eslint-plugin";
4
2
  import { includeIgnoreFile } from "@eslint/compat";
5
3
  import eslint from "@eslint/js";
6
4
  import nextPlugin from "@next/eslint-plugin-next";
5
+ import { file } from "bun";
7
6
  import eslintPluginBetterTailwindcss from "eslint-plugin-better-tailwindcss";
8
7
  import erasableSyntaxOnly from "eslint-plugin-erasable-syntax-only";
9
8
  import { configs } from "eslint-plugin-package-json";
@@ -16,6 +15,7 @@ import sonarjs from "eslint-plugin-sonarjs";
16
15
  import turbo from "eslint-plugin-turbo";
17
16
  import { defineConfig, globalIgnores } from "eslint/config";
18
17
  import tseslint from "typescript-eslint";
18
+ import { A as normalizeObjectListInput, B as ESLINT_TEST_FILE_PATTERNS, C as joinPath, D as findUnknownRules, F as warnToError, G as TAILWIND_ENTRY_CANDIDATES, M as normalizeRulesOffInput, N as normalizeTailwindOption, O as isRecord, S as isAbsolutePath, W as SHARED_OVERRIDE_SYMBOL_KEY, j as normalizePathListInput, n as listProjectFiles, z as DEFAULT_SHARED_IGNORE_PATTERNS } from "./project-files-DkcnsKmB.mjs";
19
19
  // src/eslint.ts
20
20
  const sharedOverrideMarker = Symbol.for(SHARED_OVERRIDE_SYMBOL_KEY);
21
21
  const normalizeAppendInput = ({ append }) => {
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- export { t as defineConfig, n as eslintImport, r as sync } from "./src-C2vei_sO.mjs";
1
+ export { t as defineConfig, n as eslintImport, r as sync } from "./src-Cu2vOuEp.mjs";
@@ -420,9 +420,9 @@ const parseJsonObject = ({ text }) => {
420
420
  return isRecord(parsed) ? parsed : {};
421
421
  };
422
422
  const decodeText = (bytes) => decoder.decode(bytes ?? /* @__PURE__ */ new Uint8Array());
423
- const pathExists = async ({ path }) => file(path).exists();
423
+ const doesPathExist = async ({ path }) => file(path).exists();
424
424
  const readJson = async ({ path }) => {
425
- if (!await pathExists({ path })) return {};
425
+ if (!await doesPathExist({ path })) return {};
426
426
  try {
427
427
  const text = await file(path).text();
428
428
  return parseJsonObject({ text });
@@ -445,7 +445,7 @@ const resolvePackageJsonPath = async ({ pkg }) => {
445
445
  return fromFileUrl(import.meta.resolve(`${pkg}/package.json`));
446
446
  } catch {
447
447
  const consumerCandidate = joinPath(cwd, "node_modules", pkg, "package.json");
448
- if (await pathExists({ path: consumerCandidate })) return consumerCandidate;
448
+ if (await doesPathExist({ path: consumerCandidate })) return consumerCandidate;
449
449
  return;
450
450
  }
451
451
  };
@@ -479,12 +479,12 @@ const prepareCapture = async (directory, { args, command, label }) => {
479
479
  const stderrPath = joinPath(directory, "stderr");
480
480
  const outputPath = joinPath(directory, "diagnostics");
481
481
  const outputArgs = label === "eslint" ? ["--output-file", outputPath] : [];
482
- const nativeOutput = outputArgs.length > 0;
482
+ const hasNativeOutput = outputArgs.length > 0;
483
483
  const captureArgs = [...args, ...outputArgs];
484
- if (nativeOutput) await writeFile(outputPath, "");
485
- const windows = process.platform === "win32";
484
+ if (hasNativeOutput) await writeFile(outputPath, "");
485
+ const isWindows = process.platform === "win32";
486
486
  return {
487
- commandArgs: windows ? [command, ...captureArgs] : [
487
+ commandArgs: isWindows ? [command, ...captureArgs] : [
488
488
  "/bin/sh",
489
489
  "-c",
490
490
  "stdout=$1; stderr=$2; shift 2; exec \"$@\" > \"$stdout\" 2> \"$stderr\"",
@@ -494,24 +494,24 @@ const prepareCapture = async (directory, { args, command, label }) => {
494
494
  command,
495
495
  ...captureArgs
496
496
  ],
497
- nativeOutput,
497
+ hasNativeOutput,
498
+ isWindows,
498
499
  outputPath,
499
500
  stderrPath,
500
- stdoutPath,
501
- windows
501
+ stdoutPath
502
502
  };
503
503
  };
504
504
  const executeCapture = async (opts, directory, timeoutMs) => {
505
- const { commandArgs, nativeOutput, outputPath, stderrPath, stdoutPath, windows } = await prepareCapture(directory, opts);
505
+ const { commandArgs, hasNativeOutput, outputPath, stderrPath, stdoutPath, isWindows } = await prepareCapture(directory, opts);
506
506
  const child = spawn(commandArgs, {
507
507
  cwd,
508
508
  env: opts.env,
509
- stderr: windows ? file(stderrPath) : "ignore",
510
- stdout: windows ? file(stdoutPath) : "ignore",
509
+ stderr: isWindows ? file(stderrPath) : "ignore",
510
+ stdout: isWindows ? file(stdoutPath) : "ignore",
511
511
  timeout: timeoutMs
512
512
  });
513
513
  const exitCode = await child.exited;
514
- const [stderr, stdout] = await Promise.all([file(stderrPath).text(), file(nativeOutput ? outputPath : stdoutPath).text()]);
514
+ const [stderr, stdout] = await Promise.all([file(stderrPath).text(), file(hasNativeOutput ? outputPath : stdoutPath).text()]);
515
515
  return {
516
516
  exitCode,
517
517
  stderr: `${stderr}${child.signalCode === "SIGTERM" ? `lintmax: ${opts.label} timed out after ${Math.round(timeoutMs / 1e3)} s and was killed; it reported no findings\n` : ""}`,
@@ -545,10 +545,10 @@ const usage = ({ version }) => {
545
545
  process.stdout.write(" version Show version\n");
546
546
  };
547
547
  // src/glob.ts
548
- const matchesGlob = (glob, path) => glob.match(path);
548
+ const doesMatchGlob = (glob, path) => glob.match(path);
549
549
  // src/project-files.ts
550
550
  const fixedIgnoreGlobs = ["**/node_modules/**", ...DEFAULT_SHARED_IGNORE_PATTERNS].map((pattern) => new Glob(pattern));
551
- const isIncludedProjectFile = (path) => fixedIgnoreGlobs.every((glob) => !matchesGlob(glob, path));
551
+ const isIncludedProjectFile = (path) => fixedIgnoreGlobs.every((glob) => !doesMatchGlob(glob, path));
552
552
  const hasGitDirectory = async (directory) => {
553
553
  try {
554
554
  await lstat(join(directory, ".git"));
@@ -616,4 +616,4 @@ const listProjectFiles = async ({ env, root }) => {
616
616
  for await (const path of entriesOnDisk) files.push(path);
617
617
  return files.filter(isIncludedProjectFile);
618
618
  };
619
- export { normalizeObjectListInput as A, ESLINT_TEST_FILE_PATTERNS as B, joinPath as C, findUnknownRules as D, assertOptionalString as E, warnToError as F, TAILWIND_ENTRY_CANDIDATES as G, OXLINT_PATTERN_RULE_OVERRIDES as H, BIOME_IGNORE_PATTERNS as I, BIOME_PATTERN_RULE_OVERRIDES as L, normalizeRulesOffInput as M, normalizeTailwindOption as N, isRecord as O, stripPluginNamespace as P, BIOME_RULES_OFF as R, isAbsolutePath as S, assertObject as T, PARSE_DIALECTS as U, OXLINT_CLI_ALLOW as V, SHARED_OVERRIDE_SYMBOL_KEY as W, run as _, PRETTIER_MD_ARGS as a, dirnamePath as b, decodeText as c, lintmaxRoot as d, pathExists as f, resolveBin as g, readVersion as h, CliExitError as i, normalizePathListInput as j, normalizeIgnorePattern as k, ensureDirectory as l, readRequiredJson as m, listProjectFiles as n, cacheDir as o, readJson as p, matchesGlob as r, cwd as s, escapeGlobPath as t, envValue as u, runCapture as v, assertJsonSerializable as w, fromFileUrl as x, usage as y, DEFAULT_SHARED_IGNORE_PATTERNS as z };
619
+ export { normalizeObjectListInput as A, ESLINT_TEST_FILE_PATTERNS as B, joinPath as C, findUnknownRules as D, assertOptionalString as E, warnToError as F, TAILWIND_ENTRY_CANDIDATES as G, OXLINT_PATTERN_RULE_OVERRIDES as H, BIOME_IGNORE_PATTERNS as I, BIOME_PATTERN_RULE_OVERRIDES as L, normalizeRulesOffInput as M, normalizeTailwindOption as N, isRecord as O, stripPluginNamespace as P, BIOME_RULES_OFF as R, isAbsolutePath as S, assertObject as T, PARSE_DIALECTS as U, OXLINT_CLI_ALLOW as V, SHARED_OVERRIDE_SYMBOL_KEY as W, run as _, PRETTIER_MD_ARGS as a, dirnamePath as b, decodeText as c, envValue as d, lintmaxRoot as f, resolveBin as g, readVersion as h, CliExitError as i, normalizePathListInput as j, normalizeIgnorePattern as k, doesPathExist as l, readRequiredJson as m, listProjectFiles as n, cacheDir as o, readJson as p, doesMatchGlob as r, cwd as s, escapeGlobPath as t, ensureDirectory as u, runCapture as v, assertJsonSerializable as w, fromFileUrl as x, usage as y, DEFAULT_SHARED_IGNORE_PATTERNS as z };
@@ -1,7 +1,7 @@
1
- import { A as normalizeObjectListInput, C as joinPath, D as findUnknownRules, E as assertOptionalString, H as OXLINT_PATTERN_RULE_OVERRIDES, I as BIOME_IGNORE_PATTERNS, L as BIOME_PATTERN_RULE_OVERRIDES, M as normalizeRulesOffInput, N as normalizeTailwindOption, P as stripPluginNamespace, R as BIOME_RULES_OFF, T as assertObject, W as SHARED_OVERRIDE_SYMBOL_KEY, b as dirnamePath, j as normalizePathListInput, k as normalizeIgnorePattern, l as ensureDirectory, m as readRequiredJson, n as listProjectFiles, o as cacheDir, w as assertJsonSerializable, x as fromFileUrl, z as DEFAULT_SHARED_IGNORE_PATTERNS } from "./project-files-BJWR09gY.mjs";
2
1
  import { file, write } from "bun";
3
2
  import { lstat } from "node:fs/promises";
4
3
  import { join, relative } from "node:path";
4
+ import { A as normalizeObjectListInput, C as joinPath, D as findUnknownRules, E as assertOptionalString, H as OXLINT_PATTERN_RULE_OVERRIDES, I as BIOME_IGNORE_PATTERNS, L as BIOME_PATTERN_RULE_OVERRIDES, M as normalizeRulesOffInput, N as normalizeTailwindOption, P as stripPluginNamespace, R as BIOME_RULES_OFF, T as assertObject, W as SHARED_OVERRIDE_SYMBOL_KEY, b as dirnamePath, j as normalizePathListInput, k as normalizeIgnorePattern, m as readRequiredJson, n as listProjectFiles, o as cacheDir, u as ensureDirectory, w as assertJsonSerializable, x as fromFileUrl, z as DEFAULT_SHARED_IGNORE_PATTERNS } from "./project-files-DkcnsKmB.mjs";
5
5
  // src/index.ts
6
6
  const SHARED_OVERRIDE_KEYS = [
7
7
  "biome",
@@ -68,12 +68,16 @@ const assertKnownOxlintRuleNames = ({ label, rules, knownRules }) => {
68
68
  };
69
69
  const groupByCategory = ({ categoryMap, ruleNames }) => {
70
70
  const result = {};
71
- for (const rule of ruleNames) {
71
+ const categorized = ruleNames.flatMap((rule) => {
72
72
  const cat = categoryMap.get(rule);
73
- if (cat) {
74
- result[cat] ??= {};
75
- result[cat][rule] = "off";
76
- }
73
+ return cat ? [{
74
+ cat,
75
+ rule
76
+ }] : [];
77
+ });
78
+ for (const { cat, rule } of categorized) {
79
+ result[cat] ??= {};
80
+ result[cat][rule] = "off";
77
81
  }
78
82
  return result;
79
83
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lintmax",
3
- "version": "0.1.107",
3
+ "version": "0.1.108",
4
4
  "description": "The #1 anti AI slop typescript tooling. Designed for coding agents, not humans.",
5
5
  "keywords": [
6
6
  "agent",