lintmax 0.1.106 → 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/eslint.d.mts CHANGED
@@ -1,7 +1,5 @@
1
- import { n as EslintOptions } from "./lintmax-types-yjUuaLkM.mjs";
2
1
  import { Linter } from "eslint";
3
- //#region src/eslint.d.ts
2
+ import { n as EslintOptions } from "./lintmax-types-Dj_XPbID.mjs";
4
3
  declare const eslintFactory: (options?: EslintOptions) => Promise<Linter.Config[]>;
5
4
  declare const defaultConfig: Linter.Config[];
6
- //#endregion
7
5
  export { type EslintOptions, defaultConfig as default, eslintFactory as eslint };
package/dist/eslint.mjs CHANGED
@@ -1,9 +1,8 @@
1
- import { A as normalizePathListInput, D as isRecord, E as findUnknownRules, M as normalizeTailwindOption, P as warnToError, R as DEFAULT_SHARED_IGNORE_PATTERNS, S as joinPath, U as SHARED_OVERRIDE_SYMBOL_KEY, W as TAILWIND_ENTRY_CANDIDATES, j as normalizeRulesOffInput, k as normalizeObjectListInput, n as listProjectFiles, x as isAbsolutePath, z as ESLINT_TEST_FILE_PATTERNS } from "./project-files-C4cvEhY7.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,19 +15,28 @@ 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";
19
- //#region src/eslint.ts
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
+ // src/eslint.ts
20
20
  const sharedOverrideMarker = Symbol.for(SHARED_OVERRIDE_SYMBOL_KEY);
21
21
  const normalizeAppendInput = ({ append }) => {
22
22
  const out = [];
23
- for (const value of normalizeObjectListInput({
23
+ const values = normalizeObjectListInput({
24
24
  allowNonPlain: true,
25
25
  label: "eslint.append",
26
26
  value: append
27
- })) out.push(value);
27
+ });
28
+ for (const value of values) out.push(value);
28
29
  return out;
29
30
  };
30
- const validateEslintOptions = async ({ options }) => {
31
- if (!options) return;
31
+ const validateTailwindEntry = async ({ tailwind, tsconfigRootDir }) => {
32
+ const tailwindEntrySetting = tailwind;
33
+ if (typeof tailwindEntrySetting === "string") {
34
+ const root = tsconfigRootDir ?? process.cwd();
35
+ const resolved = isAbsolutePath(tailwindEntrySetting) ? tailwindEntrySetting : joinPath(root, tailwindEntrySetting);
36
+ if (!await file(resolved).exists()) throw new Error(`eslint.tailwind file not found: ${resolved}. Use an existing path, set eslint.tailwind to false, or remove eslint.tailwind to use auto-detection.`);
37
+ }
38
+ };
39
+ const validateEslintLists = (options) => {
32
40
  if (options.ignores !== void 0) normalizePathListInput({
33
41
  allowUndefined: true,
34
42
  label: "eslint.ignores",
@@ -39,15 +47,18 @@ const validateEslintOptions = async ({ options }) => {
39
47
  value: options.off
40
48
  });
41
49
  if (options.append !== void 0) normalizeAppendInput({ append: options.append });
42
- const tailwindEntrySetting = normalizeTailwindOption({
50
+ };
51
+ const validateEslintOptions = async ({ options }) => {
52
+ if (!options) return;
53
+ validateEslintLists(options);
54
+ const tailwind = normalizeTailwindOption({
43
55
  label: "eslint.tailwind",
44
56
  value: options.tailwind
45
57
  });
46
- if (typeof tailwindEntrySetting === "string") {
47
- const root = options.tsconfigRootDir ?? process.cwd();
48
- const resolved = isAbsolutePath(tailwindEntrySetting) ? tailwindEntrySetting : joinPath(root, tailwindEntrySetting);
49
- if (!await file(resolved).exists()) throw new Error(`eslint.tailwind file not found: ${resolved}. Use an existing path, set eslint.tailwind to false, or remove eslint.tailwind to use auto-detection.`);
50
- }
58
+ await validateTailwindEntry({
59
+ tailwind,
60
+ tsconfigRootDir: options.tsconfigRootDir
61
+ });
51
62
  if (options.tsconfigRootDir !== void 0 && typeof options.tsconfigRootDir !== "string") throw new Error("eslint.tsconfigRootDir must be a string");
52
63
  };
53
64
  const collectKnownEslintRuleNames = ({ appendConfigs, baseConfigs }) => {
@@ -87,7 +98,7 @@ const collectKnownEslintRuleNames = ({ appendConfigs, baseConfigs }) => {
87
98
  return knownRuleNames;
88
99
  };
89
100
  const getSharedAppendConfig = ({ config }) => {
90
- if (Reflect.get(config, sharedOverrideMarker) !== true) return null;
101
+ if (Reflect.get(config, sharedOverrideMarker) !== true) return;
91
102
  /** biome-ignore lint/nursery/noUnsafeTypeAssertion: internal marker identifies this external config as the shared append shape */
92
103
  return config;
93
104
  };
@@ -107,7 +118,6 @@ const resolveTailwindEntry = async ({ root, tailwind }) => {
107
118
  const relMatches = matches.map((path) => path.slice(root.length + 1));
108
119
  throw new Error(`Multiple Tailwind entry files found: ${relMatches.join(", ")}. Set eslint.tailwind to an explicit path.`);
109
120
  };
110
- /** The files whose rules need a JavaScript AST. A config that carries JS rules and NO `files` matches every path eslint is handed — harmless while the gate only ever linted JS/TS, and a hard crash the moment a non-JS file type joins the target set, because a type-aware rule then runs against (say) the JSON parser's tree. Every such config is scoped to these. */
111
121
  const SOURCE_FILE_PATTERNS = [
112
122
  "**/*.js",
113
123
  "**/*.jsx",
@@ -117,7 +127,6 @@ const SOURCE_FILE_PATTERNS = [
117
127
  "**/*.tsx"
118
128
  ];
119
129
  const tailwindRules = (entryPoint) => entryPoint ? eslintPluginBetterTailwindcss.configs["recommended-error"].rules : {};
120
- /** 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. */
121
130
  const regexpRecommendedAtError = () => {
122
131
  /** biome-ignore lint/nursery/noUnsafeTypeAssertion: external regexp plugin config is structurally compatible with ESLint's config boundary */
123
132
  const rec = configs$2["flat/recommended"];
@@ -126,7 +135,6 @@ const regexpRecommendedAtError = () => {
126
135
  rules: warnToError(rec.rules ?? {})
127
136
  };
128
137
  };
129
- /** 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. */
130
138
  const packageJsonConfig = () => {
131
139
  /** biome-ignore lint/nursery/noUnsafeTypeAssertion: external package-json plugin config is structurally compatible with ESLint's config boundary */
132
140
  const recommended = configs.recommended;
@@ -370,9 +378,7 @@ const buildOffOverrideConfigs = ({ knownRuleNames, normalizedRules }) => {
370
378
  rules: normalizedRules
371
379
  });
372
380
  if (unknownRules.length > 0) throw new Error(`eslint.off contains unknown eslint rules: ${unknownRules.join(", ")}`);
373
- const overrideRules = {};
374
- for (const [key, value] of Object.entries(normalizedRules)) overrideRules[key] = value;
375
- return [{ rules: overrideRules }];
381
+ return [{ rules: Object.fromEntries(Object.entries(normalizedRules)) }];
376
382
  };
377
383
  const buildAppendOverrideConfigs = ({ appendConfigs, knownRuleNames }) => {
378
384
  const out = [];
@@ -383,7 +389,7 @@ const buildAppendOverrideConfigs = ({ appendConfigs, knownRuleNames }) => {
383
389
  rules: config.rules
384
390
  }) : [];
385
391
  if (unknownRules.length > 0) throw new Error(`overrides.eslint contains unknown eslint rules: ${unknownRules.join(", ")}`);
386
- const sanitized = shared === null ? config : (() => {
392
+ const sanitized = shared === void 0 ? config : (() => {
387
393
  const sanitizedShared = {};
388
394
  if (shared.files !== void 0) sanitizedShared.files = shared.files;
389
395
  if (shared.rules !== void 0) sanitizedShared.rules = shared.rules;
@@ -403,36 +409,42 @@ const buildParserOptionsConfigs = ({ root }) => [{
403
409
  tsconfigRootDir: root
404
410
  } }
405
411
  }, { linterOptions: { reportUnusedDisableDirectives: true } }];
406
- const eslintFactory = async (options) => {
407
- await validateEslintOptions({ options });
408
- const opts = options ?? {};
409
- const root = opts.tsconfigRootDir ?? process.cwd();
412
+ const projectIgnoreConfig = (gitignorePath) => {
413
+ try {
414
+ return includeIgnoreFile(gitignorePath);
415
+ } catch (error) {
416
+ if (error instanceof Error) {
417
+ const message = error.message.toLowerCase();
418
+ if (!(message.includes("enoent") || message.includes("no such file"))) throw error;
419
+ } else throw error;
420
+ }
421
+ };
422
+ const buildIgnoreConfigs = ({ options, root }) => {
410
423
  const configs = [];
411
424
  const gitignorePath = joinPath(root, ".gitignore");
412
425
  const normalizedIgnores = normalizePathListInput({
413
426
  allowUndefined: true,
414
427
  label: "eslint.ignores",
415
- value: opts.ignores
428
+ value: options.ignores
416
429
  });
430
+ configs.push(globalIgnores([...DEFAULT_SHARED_IGNORE_PATTERNS, ...normalizedIgnores]));
431
+ const gitignoreConfig = projectIgnoreConfig(gitignorePath);
432
+ if (gitignoreConfig) configs.push(gitignoreConfig);
433
+ return configs;
434
+ };
435
+ const buildTailwindSettings = async (root, tailwind) => {
417
436
  const tailwindEntry = await resolveTailwindEntry({
418
437
  root,
419
- tailwind: opts.tailwind
438
+ tailwind
420
439
  });
421
440
  const tailwindSettings = {};
422
441
  if (tailwindEntry) tailwindSettings["better-tailwindcss"] = { entryPoint: tailwindEntry };
423
- configs.push(globalIgnores([...DEFAULT_SHARED_IGNORE_PATTERNS, ...normalizedIgnores]));
424
- try {
425
- configs.push(includeIgnoreFile(gitignorePath));
426
- } catch (error) {
427
- if (error instanceof Error) {
428
- const message = error.message.toLowerCase();
429
- if (!(message.includes("enoent") || message.includes("no such file"))) throw error;
430
- } else throw error;
431
- }
432
- configs.push(packageJsonConfig(), ...buildBaseTypescriptConfigs(), ...buildReactConfigs({
442
+ return {
433
443
  tailwindEntry,
434
444
  tailwindSettings
435
- }), ...buildNextConfigs(), ...buildTestFileConfigs(), ...buildConvexTestConfigs(), ...buildScriptFileConfigs(), ...buildAuthConfigConfigs());
445
+ };
446
+ };
447
+ const appendEslintOverrides = (configs, opts, root) => {
436
448
  const appendConfigs = normalizeAppendInput({ append: opts.append });
437
449
  const knownRuleNames = collectKnownEslintRuleNames({
438
450
  appendConfigs,
@@ -449,8 +461,22 @@ const eslintFactory = async (options) => {
449
461
  appendConfigs,
450
462
  knownRuleNames
451
463
  }), ...buildParserOptionsConfigs({ root }));
464
+ };
465
+ const eslintFactory = async (options) => {
466
+ await validateEslintOptions({ options });
467
+ const opts = options ?? {};
468
+ const root = opts.tsconfigRootDir ?? process.cwd();
469
+ const configs = [];
470
+ const { tailwindEntry, tailwindSettings } = await buildTailwindSettings(root, opts.tailwind);
471
+ configs.push(...buildIgnoreConfigs({
472
+ options: opts,
473
+ root
474
+ }), packageJsonConfig(), ...buildBaseTypescriptConfigs(), ...buildReactConfigs({
475
+ tailwindEntry,
476
+ tailwindSettings
477
+ }), ...buildNextConfigs(), ...buildTestFileConfigs(), ...buildConvexTestConfigs(), ...buildScriptFileConfigs(), ...buildAuthConfigConfigs());
478
+ appendEslintOverrides(configs, opts, root);
452
479
  return defineConfig(...configs);
453
480
  };
454
481
  const defaultConfig = await eslintFactory();
455
- //#endregion
456
482
  export { defaultConfig as default, eslintFactory as eslint };
package/dist/index.d.mts CHANGED
@@ -1,7 +1,5 @@
1
- import { r as SyncOptions, t as EslintImportAppendEntry } from "./lintmax-types-yjUuaLkM.mjs";
2
- //#region src/index.d.ts
1
+ import { r as SyncOptions, t as EslintImportAppendEntry } from "./lintmax-types-Dj_XPbID.mjs";
3
2
  declare const sync: (options?: SyncOptions) => Promise<void>;
4
3
  declare const eslintImport: ({ files, from, ignores, name }: Omit<EslintImportAppendEntry, "$lintmax">) => EslintImportAppendEntry;
5
4
  declare const defineConfig: <T extends SyncOptions>(options: T) => T;
6
- //#endregion
7
5
  export { type EslintImportAppendEntry, type SyncOptions, defineConfig, eslintImport, sync };
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- export { t as defineConfig, n as eslintImport, r as sync } from "./src-DDkinCyR.mjs";
1
+ export { t as defineConfig, n as eslintImport, r as sync } from "./src-Cu2vOuEp.mjs";
@@ -1,5 +1,4 @@
1
1
  import { Linter } from "eslint";
2
- //#region src/lintmax-types.d.ts
3
2
  interface BiomeOptions {
4
3
  ignores?: PathListInput;
5
4
  off?: RulesOffInput;
@@ -64,5 +63,4 @@ interface SyncOptions {
64
63
  tsconfigRootDir?: string;
65
64
  }
66
65
  type TailwindOption = boolean | string;
67
- //#endregion
68
66
  export { EslintOptions as n, SyncOptions as r, EslintImportAppendEntry as t };
@@ -2,8 +2,12 @@ import { $, Glob, env, env as bunEnv, file, spawn } from "bun";
2
2
  import { lstat, mkdtemp, realpath, rm, writeFile } from "node:fs/promises";
3
3
  import { dirname, join, resolve } from "node:path";
4
4
  import { tmpdir } from "node:os";
5
- //#region src/constants.ts
5
+ // src/constants.ts
6
6
  const BIOME_RULES_OFF = [
7
+ ...Object.keys({
8
+ usePackageJsonCpu: "CPU support is project policy; portable packages need no architecture restriction.",
9
+ usePackageJsonEngines: "Runtime support is project policy; every project need not declare an engines constraint."
10
+ }),
7
11
  "noBarrelFile",
8
12
  "noConditionalExpect",
9
13
  "noConsole",
@@ -186,29 +190,31 @@ const OXLINT_CLI_ALLOW = [
186
190
  "node/no-top-level-await",
187
191
  "eslint/one-var"
188
192
  ];
189
- //#endregion
190
- //#region src/normalize.ts
193
+ // src/normalize.ts
191
194
  const normalizeIgnorePattern = ({ pattern }) => {
192
195
  const trimmed = pattern.trim();
193
196
  if (trimmed.length === 0) return "";
194
197
  return trimmed.startsWith("./") ? trimmed.slice(2) : trimmed;
195
198
  };
199
+ const normalizePathItem = (item, label) => {
200
+ if (typeof item !== "string") throw new TypeError(`${label} must be a string`);
201
+ const normalized = normalizeIgnorePattern({ pattern: item });
202
+ if (normalized.length === 0) throw new Error(`${label} must not be empty`);
203
+ return normalized;
204
+ };
205
+ const appendNormalizedPath = (out, item, label) => {
206
+ const normalized = normalizePathItem(item, label);
207
+ if (!out.includes(normalized)) out.push(normalized);
208
+ };
196
209
  const normalizePathListInput = ({ allowUndefined = false, label, value }) => {
197
210
  if (value === void 0 && allowUndefined) return [];
198
- if (!Array.isArray(value)) throw new Error(`${label} must be an array of strings`);
211
+ if (!Array.isArray(value)) throw new TypeError(`${label} must be an array of strings`);
199
212
  const out = [];
200
213
  const arr = value;
201
- for (let i = 0; i < arr.length; i += 1) {
202
- const item = arr[i];
203
- if (typeof item !== "string") throw new Error(`${label}[${i}] must be a string`);
204
- const normalized = normalizeIgnorePattern({ pattern: item });
205
- if (normalized.length === 0) throw new Error(`${label}[${i}] must not be empty`);
206
- if (!out.includes(normalized)) out.push(normalized);
207
- }
214
+ for (let i = 0; i < arr.length; i += 1) appendNormalizedPath(out, arr[i], `${label}[${i}]`);
208
215
  return out;
209
216
  };
210
217
  const hasPlainObjectPrototype = ({ value }) => {
211
- /** biome-ignore lint/nursery/noUnsafeTypeAssertion: Object.getPrototypeOf returns an untyped external object boundary */
212
218
  const prototype = Object.getPrototypeOf(value);
213
219
  return prototype === null || prototype === Object.prototype;
214
220
  };
@@ -230,68 +236,92 @@ const findUnknownRules = ({ knownRules, normalizeRule, rules }) => {
230
236
  }
231
237
  return unknown;
232
238
  };
233
- const assertJsonSerializable = ({ label, seen, value }) => {
234
- if (value === null) return;
235
- if (typeof value === "string" || typeof value === "boolean") return;
236
- if (typeof value === "number") {
237
- if (!Number.isFinite(value)) throw new Error(`${label} must be JSON-serializable`);
239
+ const assertJsonChildren = ({ label, seen, value, visit }) => {
240
+ if (Array.isArray(value)) {
241
+ for (let i = 0; i < value.length; i += 1) visit({
242
+ label: `${label}[${i}]`,
243
+ seen,
244
+ value: value[i]
245
+ });
238
246
  return;
239
247
  }
240
- if (typeof value !== "object") throw new Error(`${label} must be JSON-serializable`);
241
- const objectValue = value;
248
+ if (!isRecord(value)) throw new Error(`${label} must be JSON-serializable`);
249
+ for (const [key, nested] of Object.entries(value)) visit({
250
+ label: `${label}.${key}`,
251
+ seen,
252
+ value: nested
253
+ });
254
+ };
255
+ const assertJsonObject = ({ label, seen, value, visit }) => {
242
256
  const objectSeen = seen ?? /* @__PURE__ */ new WeakSet();
243
- if (objectSeen.has(objectValue)) throw new Error(`${label} must be JSON-serializable`);
244
- objectSeen.add(objectValue);
257
+ if (objectSeen.has(value)) throw new Error(`${label} must be JSON-serializable`);
258
+ objectSeen.add(value);
245
259
  try {
246
- if (Array.isArray(value)) {
247
- for (let i = 0; i < value.length; i += 1) assertJsonSerializable({
248
- label: `${label}[${i}]`,
249
- seen: objectSeen,
250
- value: value[i]
251
- });
252
- return;
253
- }
254
- if (!isRecord(value)) throw new Error(`${label} must be JSON-serializable`);
255
- for (const [key, nested] of Object.entries(value)) assertJsonSerializable({
256
- label: `${label}.${key}`,
260
+ assertJsonChildren({
261
+ label,
257
262
  seen: objectSeen,
258
- value: nested
263
+ value,
264
+ visit
259
265
  });
260
266
  } finally {
261
- objectSeen.delete(objectValue);
267
+ objectSeen.delete(value);
262
268
  }
263
269
  };
270
+ const assertJsonSerializable = ({ label, seen, value }) => {
271
+ if (value === null || typeof value === "string" || typeof value === "boolean") return;
272
+ if (typeof value === "number") {
273
+ if (!Number.isFinite(value)) throw new TypeError(`${label} must be JSON-serializable`);
274
+ return;
275
+ }
276
+ if (typeof value !== "object") throw new TypeError(`${label} must be JSON-serializable`);
277
+ assertJsonObject({
278
+ label,
279
+ seen,
280
+ value,
281
+ visit: assertJsonSerializable
282
+ });
283
+ };
284
+ const normalizeObjectItem = ({ allowNonPlain, label, value }) => {
285
+ if (isObjectLike(value) && (allowNonPlain || hasPlainObjectPrototype({ value }))) return value;
286
+ throw new Error(`${label} must be an object`);
287
+ };
264
288
  const normalizeObjectListInput = ({ allowNonPlain = false, label, value }) => {
265
289
  if (value === void 0) return [];
266
- if (!Array.isArray(value)) throw new Error(`${label} must be an array of objects`);
290
+ if (!Array.isArray(value)) throw new TypeError(`${label} must be an array of objects`);
267
291
  const out = [];
268
292
  const arr = value;
269
293
  for (let i = 0; i < arr.length; i += 1) {
270
- const item = arr[i];
271
- let normalizedItem;
272
- if (allowNonPlain) {
273
- if (isObjectLike(item)) normalizedItem = item;
274
- } else if (isRecord(item)) normalizedItem = item;
275
- if (!normalizedItem) throw new Error(`${label}[${i}] must be an object`);
294
+ const normalizedItem = normalizeObjectItem({
295
+ allowNonPlain,
296
+ label: `${label}[${i}]`,
297
+ value: arr[i]
298
+ });
276
299
  out.push(normalizedItem);
277
300
  }
278
301
  return out;
279
302
  };
303
+ const normalizeRuleName = (value, label) => {
304
+ if (typeof value !== "string") throw new TypeError(`${label} must be a string rule name`);
305
+ const ruleName = value.trim();
306
+ if (ruleName.length === 0) throw new Error(`${label} must not be empty`);
307
+ return ruleName;
308
+ };
309
+ const sortOffRules = (rules) => {
310
+ const sorted = {};
311
+ const keys = Object.keys(rules).toSorted((a, b) => a.localeCompare(b));
312
+ for (const key of keys) sorted[key] = "off";
313
+ return sorted;
314
+ };
280
315
  const normalizeRulesOffInput = ({ label, value }) => {
281
316
  if (value === void 0) return;
282
- if (!Array.isArray(value)) throw new Error(`${label} must be an array of rule names`);
317
+ if (!Array.isArray(value)) throw new TypeError(`${label} must be an array of rule names`);
283
318
  const out = {};
284
319
  const arr = value;
285
320
  for (let i = 0; i < arr.length; i += 1) {
286
- const item = arr[i];
287
- if (typeof item !== "string") throw new Error(`${label}[${i}] must be a string rule name`);
288
- const ruleName = item.trim();
289
- if (ruleName.length === 0) throw new Error(`${label}[${i}] must not be empty`);
321
+ const ruleName = normalizeRuleName(arr[i], `${label}[${i}]`);
290
322
  out[ruleName] = "off";
291
323
  }
292
- const sorted = {};
293
- for (const key of Object.keys(out).toSorted((a, b) => a.localeCompare(b))) sorted[key] = "off";
294
- return sorted;
324
+ return sortOffRules(out);
295
325
  };
296
326
  const normalizeTailwindOption = ({ label, value }) => {
297
327
  if (value === void 0) return;
@@ -306,8 +336,7 @@ const warnToError = (rules) => {
306
336
  else result[key] = value;
307
337
  return result;
308
338
  };
309
- //#endregion
310
- //#region src/path.ts
339
+ // src/path.ts
311
340
  const DRIVE_PATH_REGEX = /^[A-Za-z]:\//v;
312
341
  const MULTI_SLASH_REGEX = /\/+/gv;
313
342
  const normalizeSlashes = (value) => value.replaceAll("\\", "/");
@@ -328,20 +357,24 @@ const fromFileUrl = (value) => {
328
357
  if (DRIVE_PATH_REGEX.test(normalized.slice(1))) return normalized.slice(1);
329
358
  return normalized;
330
359
  };
331
- const joinPath = (...parts) => {
332
- if (parts.length === 0) return "";
360
+ const nonemptyPathParts = (parts) => {
333
361
  const normalizedParts = [];
334
362
  for (const part of parts) {
335
363
  const normalized = normalizeSlashes(part);
336
364
  if (normalized.length > 0) normalizedParts.push(normalized);
337
365
  }
366
+ return normalizedParts;
367
+ };
368
+ const joinPath = (...parts) => {
369
+ if (parts.length === 0) return "";
370
+ const normalizedParts = nonemptyPathParts(parts);
338
371
  if (normalizedParts.length === 0) return "";
339
372
  const first = normalizedParts[0] ?? "";
340
373
  const isAbsolute = first.startsWith("/") || DRIVE_PATH_REGEX.test(first);
341
374
  const [head, ...tail] = normalizedParts;
342
375
  const segments = [trimTrailingSlash(head ?? "")];
343
376
  for (const segment of tail) segments.push(trimLeadingSlash(trimTrailingSlash(segment)));
344
- const joined = segments.join("/").replace(MULTI_SLASH_REGEX, "/");
377
+ const joined = segments.join("/").replaceAll(MULTI_SLASH_REGEX, "/");
345
378
  return isAbsolute && !joined.startsWith("/") && !DRIVE_PATH_REGEX.test(joined) ? `/${joined}` : joined;
346
379
  };
347
380
  const dirnamePath = (value) => {
@@ -355,8 +388,7 @@ const isAbsolutePath = (value) => {
355
388
  const normalized = normalizeSlashes(value);
356
389
  return normalized.startsWith("/") || DRIVE_PATH_REGEX.test(normalized);
357
390
  };
358
- //#endregion
359
- //#region src/core.ts
391
+ // src/core.ts
360
392
  var CliExitError = class extends Error {
361
393
  code;
362
394
  name = "CliExitError";
@@ -388,9 +420,9 @@ const parseJsonObject = ({ text }) => {
388
420
  return isRecord(parsed) ? parsed : {};
389
421
  };
390
422
  const decodeText = (bytes) => decoder.decode(bytes ?? /* @__PURE__ */ new Uint8Array());
391
- const pathExists = async ({ path }) => file(path).exists();
423
+ const doesPathExist = async ({ path }) => file(path).exists();
392
424
  const readJson = async ({ path }) => {
393
- if (!await pathExists({ path })) return {};
425
+ if (!await doesPathExist({ path })) return {};
394
426
  try {
395
427
  const text = await file(path).text();
396
428
  return parseJsonObject({ text });
@@ -413,13 +445,13 @@ const resolvePackageJsonPath = async ({ pkg }) => {
413
445
  return fromFileUrl(import.meta.resolve(`${pkg}/package.json`));
414
446
  } catch {
415
447
  const consumerCandidate = joinPath(cwd, "node_modules", pkg, "package.json");
416
- if (await pathExists({ path: consumerCandidate })) return consumerCandidate;
417
- return null;
448
+ if (await doesPathExist({ path: consumerCandidate })) return consumerCandidate;
449
+ return;
418
450
  }
419
451
  };
420
452
  const resolveBin = async ({ bin, pkg }) => {
421
453
  const packageJsonPath = await resolvePackageJsonPath({ pkg });
422
- if (!packageJsonPath) throw new CliExitError({
454
+ if (packageJsonPath === void 0) throw new CliExitError({
423
455
  code: 1,
424
456
  message: `Cannot find ${pkg} — run: bun add -d ${pkg}`
425
457
  });
@@ -441,18 +473,18 @@ const run = async ({ args, command, env, label, silent = false }) => {
441
473
  }
442
474
  throw new CliExitError({ code: result.exitCode });
443
475
  };
444
- const runCapture = async ({ args, command, env, label }) => {
445
- const directory = await mkdtemp(joinPath(tmpdir(), "lintmax-output-"));
446
- try {
447
- const stdoutPath = joinPath(directory, "stdout");
448
- const stderrPath = joinPath(directory, "stderr");
449
- const outputPath = joinPath(directory, "diagnostics");
450
- const outputArgs = label === "eslint" ? ["--output-file", outputPath] : [];
451
- const nativeOutput = outputArgs.length > 0;
452
- const captureArgs = [...args, ...outputArgs];
453
- if (nativeOutput) await writeFile(outputPath, "");
454
- const windows = process.platform === "win32";
455
- const commandArgs = windows ? [command, ...captureArgs] : [
476
+ const STEP_TIMEOUT_MS = 18e5;
477
+ const prepareCapture = async (directory, { args, command, label }) => {
478
+ const stdoutPath = joinPath(directory, "stdout");
479
+ const stderrPath = joinPath(directory, "stderr");
480
+ const outputPath = joinPath(directory, "diagnostics");
481
+ const outputArgs = label === "eslint" ? ["--output-file", outputPath] : [];
482
+ const hasNativeOutput = outputArgs.length > 0;
483
+ const captureArgs = [...args, ...outputArgs];
484
+ if (hasNativeOutput) await writeFile(outputPath, "");
485
+ const isWindows = process.platform === "win32";
486
+ return {
487
+ commandArgs: isWindows ? [command, ...captureArgs] : [
456
488
  "/bin/sh",
457
489
  "-c",
458
490
  "stdout=$1; stderr=$2; shift 2; exec \"$@\" > \"$stdout\" 2> \"$stderr\"",
@@ -461,20 +493,40 @@ const runCapture = async ({ args, command, env, label }) => {
461
493
  stderrPath,
462
494
  command,
463
495
  ...captureArgs
464
- ];
465
- const exitCode = await spawn(commandArgs, {
466
- cwd,
496
+ ],
497
+ hasNativeOutput,
498
+ isWindows,
499
+ outputPath,
500
+ stderrPath,
501
+ stdoutPath
502
+ };
503
+ };
504
+ const executeCapture = async (opts, directory, timeoutMs) => {
505
+ const { commandArgs, hasNativeOutput, outputPath, stderrPath, stdoutPath, isWindows } = await prepareCapture(directory, opts);
506
+ const child = spawn(commandArgs, {
507
+ cwd,
508
+ env: opts.env,
509
+ stderr: isWindows ? file(stderrPath) : "ignore",
510
+ stdout: isWindows ? file(stdoutPath) : "ignore",
511
+ timeout: timeoutMs
512
+ });
513
+ const exitCode = await child.exited;
514
+ const [stderr, stdout] = await Promise.all([file(stderrPath).text(), file(hasNativeOutput ? outputPath : stdoutPath).text()]);
515
+ return {
516
+ exitCode,
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` : ""}`,
518
+ stdout
519
+ };
520
+ };
521
+ const runCapture = async ({ args, command, env, label, timeoutMs = STEP_TIMEOUT_MS }) => {
522
+ const directory = await mkdtemp(joinPath(tmpdir(), "lintmax-output-"));
523
+ try {
524
+ return await executeCapture({
525
+ args,
526
+ command,
467
527
  env,
468
- stderr: windows ? file(stderrPath) : "ignore",
469
- stdout: windows ? file(stdoutPath) : "ignore",
470
- timeout: 6e5
471
- }).exited;
472
- const [stderr, stdout] = await Promise.all([file(stderrPath).text(), file(nativeOutput ? outputPath : stdoutPath).text()]);
473
- return {
474
- exitCode,
475
- stderr,
476
- stdout
477
- };
528
+ label
529
+ }, directory, timeoutMs);
478
530
  } finally {
479
531
  await rm(directory, { recursive: true });
480
532
  }
@@ -492,10 +544,11 @@ const usage = ({ version }) => {
492
544
  process.stdout.write(" rules List all enabled rules\n");
493
545
  process.stdout.write(" version Show version\n");
494
546
  };
495
- //#endregion
496
- //#region src/project-files.ts
547
+ // src/glob.ts
548
+ const doesMatchGlob = (glob, path) => glob.match(path);
549
+ // src/project-files.ts
497
550
  const fixedIgnoreGlobs = ["**/node_modules/**", ...DEFAULT_SHARED_IGNORE_PATTERNS].map((pattern) => new Glob(pattern));
498
- const isIncludedProjectFile = (path) => !fixedIgnoreGlobs.some((glob) => glob.match(path));
551
+ const isIncludedProjectFile = (path) => fixedIgnoreGlobs.every((glob) => !doesMatchGlob(glob, path));
499
552
  const hasGitDirectory = async (directory) => {
500
553
  try {
501
554
  await lstat(join(directory, ".git"));
@@ -508,7 +561,7 @@ const hasGitDirectory = async (directory) => {
508
561
  };
509
562
  const escapeGlobPath = (path) => Array.from(path, (character) => String.raw`\*?()[]{}!+@|`.includes(character) ? `\\${character}` : character).join("");
510
563
  const listVersionControlFiles = async ({ env: env$1 = env, root }) => {
511
- if (!await hasGitDirectory(await realpath(resolve(root)))) return null;
564
+ if (!await hasGitDirectory(await realpath(resolve(root)))) return;
512
565
  const subprocess = spawn({
513
566
  cmd: [
514
567
  "git",
@@ -541,7 +594,7 @@ const listProjectFiles = async ({ env, root }) => {
541
594
  env,
542
595
  root
543
596
  });
544
- if (entries !== null) {
597
+ if (entries !== void 0) {
545
598
  const present = await Promise.all(entries.map(async (entry) => {
546
599
  try {
547
600
  const stats = await lstat(join(root, entry));
@@ -554,13 +607,13 @@ const listProjectFiles = async ({ env, root }) => {
554
607
  return entries.filter((_entry, index) => present[index]).filter(isIncludedProjectFile);
555
608
  }
556
609
  const files = [];
557
- for await (const path of new Glob("**/*").scan({
610
+ const entriesOnDisk = new Glob("**/*").scan({
558
611
  cwd: root,
559
612
  dot: true,
560
613
  followSymlinks: false,
561
614
  onlyFiles: true
562
- })) files.push(path);
615
+ });
616
+ for await (const path of entriesOnDisk) files.push(path);
563
617
  return files.filter(isIncludedProjectFile);
564
618
  };
565
- //#endregion
566
- export { normalizePathListInput as A, OXLINT_CLI_ALLOW as B, assertJsonSerializable as C, isRecord as D, findUnknownRules as E, BIOME_IGNORE_PATTERNS as F, PARSE_DIALECTS as H, BIOME_PATTERN_RULE_OVERRIDES as I, BIOME_RULES_OFF as L, normalizeTailwindOption as M, stripPluginNamespace as N, normalizeIgnorePattern as O, warnToError as P, DEFAULT_SHARED_IGNORE_PATTERNS as R, joinPath as S, assertOptionalString as T, SHARED_OVERRIDE_SYMBOL_KEY as U, OXLINT_PATTERN_RULE_OVERRIDES as V, TAILWIND_ENTRY_CANDIDATES as W, runCapture as _, cacheDir as a, fromFileUrl as b, ensureDirectory as c, pathExists as d, readJson as f, run as g, resolveBin as h, PRETTIER_MD_ARGS as i, normalizeRulesOffInput as j, normalizeObjectListInput as k, envValue as l, readVersion as m, listProjectFiles as n, cwd as o, readRequiredJson as p, CliExitError as r, decodeText as s, escapeGlobPath as t, lintmaxRoot as u, usage as v, assertObject as w, isAbsolutePath as x, dirnamePath as y, ESLINT_TEST_FILE_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 };