@ariestools/toolchain 8.7.11 → 8.7.13

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/bin/xy.mjs CHANGED
@@ -26231,6 +26231,191 @@ function collectExternalUsage(folderRoots, targetPackageNames) {
26231
26231
  return usage;
26232
26232
  }
26233
26233
  //#endregion
26234
+ //#region src/actions/lintlintGitignore.ts
26235
+ const GITIGNORE_NAME = "XY repository .gitignore";
26236
+ function parseConfig(source) {
26237
+ return ts.createSourceFile("eslint.config.ts", source, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
26238
+ }
26239
+ function importDeclarations(sourceFile) {
26240
+ return sourceFile.statements.filter(ts.isImportDeclaration);
26241
+ }
26242
+ function moduleName(declaration) {
26243
+ return ts.isStringLiteral(declaration.moduleSpecifier) ? declaration.moduleSpecifier.text : void 0;
26244
+ }
26245
+ function importedReference(sourceFile, moduleSpecifier, importedName) {
26246
+ for (const declaration of importDeclarations(sourceFile)) {
26247
+ if (moduleName(declaration) !== moduleSpecifier) continue;
26248
+ const bindings = declaration.importClause?.namedBindings;
26249
+ if (bindings === void 0) continue;
26250
+ if (ts.isNamespaceImport(bindings)) return `${bindings.name.text}.${importedName}`;
26251
+ for (const specifier of bindings.elements) if ((specifier.propertyName?.text ?? specifier.name.text) === importedName) return specifier.name.text;
26252
+ }
26253
+ }
26254
+ function variableInitializers(sourceFile) {
26255
+ const initializers = /* @__PURE__ */ new Map();
26256
+ for (const statement of sourceFile.statements) {
26257
+ if (!ts.isVariableStatement(statement)) continue;
26258
+ for (const declaration of statement.declarationList.declarations) if (ts.isIdentifier(declaration.name) && declaration.initializer !== void 0) initializers.set(declaration.name.text, declaration.initializer);
26259
+ }
26260
+ return initializers;
26261
+ }
26262
+ function unwrapConfigArray(expression, initializers) {
26263
+ const visited = /* @__PURE__ */ new Set();
26264
+ let current = expression;
26265
+ while (!ts.isArrayLiteralExpression(current)) {
26266
+ if (ts.isParenthesizedExpression(current) || ts.isAsExpression(current) || ts.isSatisfiesExpression(current) || ts.isTypeAssertionExpression(current)) {
26267
+ current = current.expression;
26268
+ continue;
26269
+ }
26270
+ if (ts.isCallExpression(current)) {
26271
+ const [firstArgument] = current.arguments;
26272
+ if (firstArgument === void 0) return void 0;
26273
+ current = firstArgument;
26274
+ continue;
26275
+ }
26276
+ if (!ts.isIdentifier(current) || visited.has(current.text)) return void 0;
26277
+ visited.add(current.text);
26278
+ const initializer = initializers.get(current.text);
26279
+ if (initializer === void 0) return void 0;
26280
+ current = initializer;
26281
+ }
26282
+ return current;
26283
+ }
26284
+ function findConfigArray(sourceFile) {
26285
+ const initializers = variableInitializers(sourceFile);
26286
+ for (const statement of sourceFile.statements) {
26287
+ if (!ts.isExportAssignment(statement) || statement.isExportEquals) continue;
26288
+ return unwrapConfigArray(statement.expression, initializers);
26289
+ }
26290
+ }
26291
+ function expressionReferencesGitignore(expression, sourceFile, initializers, visited = /* @__PURE__ */ new Set()) {
26292
+ if (expression.getText(sourceFile).includes(".gitignore")) return true;
26293
+ if (!ts.isIdentifier(expression) || visited.has(expression.text)) return false;
26294
+ visited.add(expression.text);
26295
+ const initializer = initializers.get(expression.text);
26296
+ return initializer !== void 0 && expressionReferencesGitignore(initializer, sourceFile, initializers, visited);
26297
+ }
26298
+ function enablesGitignoreResolution(expression) {
26299
+ if (expression === void 0 || !ts.isObjectLiteralExpression(expression)) return false;
26300
+ return expression.properties.some((property) => {
26301
+ if (!ts.isPropertyAssignment(property)) return false;
26302
+ return property.name.getText().replaceAll(/["']/g, "") === "gitignoreResolution" && property.initializer.kind === ts.SyntaxKind.TrueKeyword;
26303
+ });
26304
+ }
26305
+ function isRequiredGitignoreCall(node, includeReference, sourceFile, initializers) {
26306
+ if (!ts.isCallExpression(node) || node.expression.getText(sourceFile) !== includeReference) return false;
26307
+ const [ignorePath, options] = node.arguments;
26308
+ return ignorePath !== void 0 && expressionReferencesGitignore(ignorePath, sourceFile, initializers) && enablesGitignoreResolution(options);
26309
+ }
26310
+ function hasGitignoreConfig(source) {
26311
+ const sourceFile = parseConfig(source);
26312
+ const includeReference = importedReference(sourceFile, "eslint/config", "includeIgnoreFile");
26313
+ const configArray = findConfigArray(sourceFile);
26314
+ if (includeReference === void 0 || configArray === void 0) return false;
26315
+ const resolvedIncludeReference = includeReference;
26316
+ const initializers = variableInitializers(sourceFile);
26317
+ let found = false;
26318
+ function visit(node) {
26319
+ if (found) return;
26320
+ if (isRequiredGitignoreCall(node, resolvedIncludeReference, sourceFile, initializers)) {
26321
+ found = true;
26322
+ return;
26323
+ }
26324
+ ts.forEachChild(node, visit);
26325
+ }
26326
+ visit(configArray);
26327
+ return found;
26328
+ }
26329
+ function updateNamedImport(declaration, importedName, sourceFile) {
26330
+ const clause = declaration.importClause;
26331
+ const bindings = clause?.namedBindings;
26332
+ const elements = bindings !== void 0 && ts.isNamedImports(bindings) ? [...bindings.elements] : [];
26333
+ const namedImports = ts.factory.createNamedImports([...elements, ts.factory.createImportSpecifier(false, void 0, ts.factory.createIdentifier(importedName))]);
26334
+ const updatedClause = ts.factory.updateImportClause(clause ?? ts.factory.createImportClause(false, void 0, namedImports), false, clause?.name, namedImports);
26335
+ const updated = ts.factory.updateImportDeclaration(declaration, declaration.modifiers, updatedClause, declaration.moduleSpecifier, declaration.attributes);
26336
+ const printer = ts.createPrinter({
26337
+ newLine: ts.NewLineKind.LineFeed,
26338
+ omitTrailingSemicolon: true
26339
+ });
26340
+ return {
26341
+ end: declaration.getEnd(),
26342
+ start: declaration.getStart(sourceFile),
26343
+ text: printer.printNode(ts.EmitHint.Unspecified, updated, sourceFile)
26344
+ };
26345
+ }
26346
+ function resolveImportReference(sourceFile, moduleSpecifier, importedName, newImports) {
26347
+ const existingReference = importedReference(sourceFile, moduleSpecifier, importedName);
26348
+ if (existingReference !== void 0) return { reference: existingReference };
26349
+ for (const declaration of importDeclarations(sourceFile)) {
26350
+ if (moduleName(declaration) !== moduleSpecifier || declaration.importClause?.isTypeOnly === true) continue;
26351
+ const bindings = declaration.importClause?.namedBindings;
26352
+ if (bindings !== void 0 && ts.isNamespaceImport(bindings)) return { reference: `${bindings.name.text}.${importedName}` };
26353
+ return {
26354
+ edit: updateNamedImport(declaration, importedName, sourceFile),
26355
+ reference: importedName
26356
+ };
26357
+ }
26358
+ newImports.push(`import { ${importedName} } from '${moduleSpecifier}'`);
26359
+ return { reference: importedName };
26360
+ }
26361
+ function newImportsEdit(sourceFile, imports) {
26362
+ if (imports.length === 0) return void 0;
26363
+ const lastImport = importDeclarations(sourceFile).at(-1);
26364
+ if (lastImport === void 0) return {
26365
+ end: 0,
26366
+ start: 0,
26367
+ text: `${imports.join("\n")}\n\n`
26368
+ };
26369
+ return {
26370
+ end: lastImport.getEnd(),
26371
+ start: lastImport.getEnd(),
26372
+ text: `\n${imports.join("\n")}`
26373
+ };
26374
+ }
26375
+ function lineIndent(source, position) {
26376
+ const lineStart = source.lastIndexOf("\n", position - 1) + 1;
26377
+ return /^\s*/.exec(source.slice(lineStart, position))?.[0] ?? "";
26378
+ }
26379
+ function gitignoreConfigEntryLines(indent, includeReference = "includeIgnoreFile", fileUrlReference = "fileURLToPath") {
26380
+ return [
26381
+ `${indent}${includeReference}(${fileUrlReference}(new URL('.gitignore', import.meta.url)), {`,
26382
+ `${indent} gitignoreResolution: true,`,
26383
+ `${indent} name: '${GITIGNORE_NAME}',`,
26384
+ `${indent}}),`
26385
+ ];
26386
+ }
26387
+ function configArrayEdit(source, sourceFile, array, includeReference, fileUrlReference) {
26388
+ const start = array.getStart(sourceFile) + 1;
26389
+ const indent = `${lineIndent(source, array.getStart(sourceFile))} `;
26390
+ return {
26391
+ end: start,
26392
+ start,
26393
+ text: `\n${gitignoreConfigEntryLines(indent, includeReference, fileUrlReference).join("\n")}${source[start] === "\n" || source[start] === "\r" ? "" : `\n${indent}`}`
26394
+ };
26395
+ }
26396
+ function applyEdits(source, edits) {
26397
+ let updated = source;
26398
+ const descendingEdits = [...edits].toSorted((left, right) => right.start - left.start);
26399
+ for (const edit of descendingEdits) updated = `${updated.slice(0, edit.start)}${edit.text}${updated.slice(edit.end)}`;
26400
+ return updated;
26401
+ }
26402
+ function addGitignoreConfig(source) {
26403
+ if (hasGitignoreConfig(source)) return source;
26404
+ const sourceFile = parseConfig(source);
26405
+ const configArray = findConfigArray(sourceFile);
26406
+ if (configArray === void 0) return void 0;
26407
+ const edits = [];
26408
+ const newImports = [];
26409
+ const includeImport = resolveImportReference(sourceFile, "eslint/config", "includeIgnoreFile", newImports);
26410
+ const fileUrlImport = resolveImportReference(sourceFile, "node:url", "fileURLToPath", newImports);
26411
+ if (includeImport.edit !== void 0) edits.push(includeImport.edit);
26412
+ if (fileUrlImport.edit !== void 0) edits.push(fileUrlImport.edit);
26413
+ const importsEdit = newImportsEdit(sourceFile, newImports);
26414
+ if (importsEdit !== void 0) edits.push(importsEdit);
26415
+ edits.push(configArrayEdit(source, sourceFile, configArray, includeImport.reference, fileUrlImport.reference));
26416
+ return applyEdits(source, edits);
26417
+ }
26418
+ //#endregion
26234
26419
  //#region src/actions/lint-init.ts
26235
26420
  function askConfirmation(question) {
26236
26421
  const rl = createInterface({
@@ -26280,16 +26465,21 @@ function getBarrelDescriptorsForRepo(isReact) {
26280
26465
  function formatDisallowedArray(name, imports, message) {
26281
26466
  return `const ${name} = [\n${imports.map((i) => ` { name: '${i}', message: "${message}" },`).join("\n")}\n]`;
26282
26467
  }
26283
- function generateEslintConfig({ barrels, isReact }) {
26468
+ function generateEslintConfig({ barrels, hasGitignore, isReact }) {
26284
26469
  const configPkg = isReact ? "@ariestools/eslint-config-react-flat" : "@ariestools/eslint-config-flat";
26285
26470
  const defaultConfigVarName = "xylabsConfig";
26286
26471
  const recommendedCall = "recommendedConfig({ tier: 3, isTypeChecked: true })";
26287
26472
  const lines = [];
26473
+ if (hasGitignore) lines.push("import { fileURLToPath } from 'node:url'", "");
26288
26474
  if (isReact) lines.push("import {", " configReactStorybook,", " recommendedConfig,", `} from '${configPkg}'`, "");
26289
26475
  else lines.push(`import { recommendedConfig } from '${configPkg}'`, "");
26290
- lines.push("import type { Linter } from 'eslint'", "", `const ${defaultConfigVarName} = ${recommendedCall}`, "");
26476
+ lines.push("import type { Linter } from 'eslint'");
26477
+ if (hasGitignore) lines.push("import { includeIgnoreFile } from 'eslint/config'");
26478
+ lines.push("", `const ${defaultConfigVarName} = ${recommendedCall}`, "");
26291
26479
  for (const barrel of barrels) lines.push(formatDisallowedArray(barrel.configVarName, barrel.imports, barrel.message), "");
26292
- lines.push("const config: Linter.Config[] = [", " { ignores: ['.yarn/**', 'build', '**/build/**', '**/dist/**', 'dist', 'node_modules/**', '**/node_modules/**', '**/*.md', '.claude/worktrees/*'] },", ` ...${defaultConfigVarName},`);
26480
+ lines.push("const config: Linter.Config[] = [");
26481
+ if (hasGitignore) lines.push(...gitignoreConfigEntryLines(" "));
26482
+ lines.push(" { ignores: ['.yarn/**', 'build', '**/build/**', '**/dist/**', 'dist', 'node_modules/**', '**/node_modules/**', '**/*.md', '.claude/worktrees/*'] },", ` ...${defaultConfigVarName},`);
26293
26483
  if (isReact) lines.push(" ...configReactStorybook,");
26294
26484
  if (barrels.length > 0) {
26295
26485
  lines.push(" {", " rules:", " {", " 'no-restricted-imports': [", " 'warn',", " {", " paths: [");
@@ -26385,6 +26575,7 @@ async function lintInit({ isVerbose } = {}) {
26385
26575
  for (const descriptor of getBarrelDescriptorsForRepo(isReact)) if (await askConfirmation(chalk.cyan(`Disallow ${descriptor.pkg} barrel imports? (y/N) `))) enabledBarrels.push(descriptor);
26386
26576
  writeFileSync(configPath, generateEslintConfig({
26387
26577
  barrels: resolveEnabledBarrels(cwd, enabledBarrels, isVerbose),
26578
+ hasGitignore: existsSync(PATH.resolve(cwd, ".gitignore")),
26388
26579
  isReact
26389
26580
  }), "utf8");
26390
26581
  console.log(chalk.green("Generated eslint.config.ts"));
@@ -31478,6 +31669,7 @@ import path from 'node:path'
31478
31669
  import { performance } from 'node:perf_hooks'
31479
31670
  import readline from 'node:readline'
31480
31671
  import { ESLint } from 'eslint'
31672
+ import { includeIgnoreFile } from 'eslint/config'
31481
31673
 
31482
31674
  const marker = ${JSON.stringify(lintNextResultMarker)}
31483
31675
  const cycleRuleFilePatterns = ${JSON.stringify([
@@ -31556,21 +31748,35 @@ function cycleOverrideBlock(options) {
31556
31748
  }
31557
31749
  }
31558
31750
 
31751
+ function gitignoreOverrideBlock(options) {
31752
+ if (options.gitignorePath === undefined) return undefined
31753
+ return includeIgnoreFile(options.gitignorePath, {
31754
+ gitignoreResolution: true,
31755
+ name: 'XY repository .gitignore',
31756
+ })
31757
+ }
31758
+
31759
+ function additionalOverrideBlocks(options) {
31760
+ return [gitignoreOverrideBlock(options), cycleOverrideBlock(options)].filter(Boolean)
31761
+ }
31762
+
31559
31763
  async function createLintEngine(cwd, options) {
31560
31764
  // analyzeTier (legacy) or configOverride force a recommendedConfig preset
31561
31765
  const overrideSpec = options.configOverride ?? options.analyzeTier
31562
31766
  if (overrideSpec) {
31563
- let overrideConfig = await resolveAnalyzeOverrideConfig(cwd, overrideSpec)
31767
+ const gitignoreBlock = gitignoreOverrideBlock(options)
31564
31768
  const cycleBlock = cycleOverrideBlock(options)
31565
- if (cycleBlock !== undefined) {
31566
- overrideConfig = [...overrideConfig, cycleBlock]
31567
- }
31769
+ const overrideConfig = [
31770
+ ...(gitignoreBlock === undefined ? [] : [gitignoreBlock]),
31771
+ ...await resolveAnalyzeOverrideConfig(cwd, overrideSpec),
31772
+ ...(cycleBlock === undefined ? [] : [cycleBlock]),
31773
+ ]
31568
31774
  return new ESLint({
31569
31775
  cache: options.cache,
31570
31776
  cacheLocation: options.cacheLocation ?? path.join(cwd, '.eslintcache'),
31571
31777
  cacheStrategy: 'content',
31572
31778
  cwd,
31573
- // analyze never auto-fixes; light/type-checked overrides may
31779
+ // analyze never auto-fixes; type-checked overrides may
31574
31780
  fix: options.analyze === true ? false : options.fix === true,
31575
31781
  ignorePatterns: options.ignorePatterns ?? defaultIgnorePatterns,
31576
31782
  overrideConfig,
@@ -31586,7 +31792,7 @@ async function createLintEngine(cwd, options) {
31586
31792
  cwd,
31587
31793
  fix: options.fix,
31588
31794
  ignorePatterns: options.ignorePatterns ?? defaultIgnorePatterns,
31589
- overrideConfig: cycleOverrideBlock(options),
31795
+ overrideConfig: additionalOverrideBlocks(options),
31590
31796
  warnIgnored: false,
31591
31797
  })
31592
31798
  }
@@ -31962,13 +32168,13 @@ function classifyLintPackage(rootDir, workspace, allWorkspaces, options = {}) {
31962
32168
  reason: "no lintable source files",
31963
32169
  sourceFiles
31964
32170
  };
31965
- const metaMode = options.meta ?? "light";
32171
+ const metaMode = options.meta ?? "full";
31966
32172
  if (!isMetaLintPackage(packageDir, workspace, sourceFiles, allWorkspaces.length > 1) || metaMode === "full") return {
31967
32173
  mode: "full",
31968
32174
  sourceFiles
31969
32175
  };
31970
32176
  return {
31971
- mode: metaMode,
32177
+ mode: "skip",
31972
32178
  reason: isRoot ? "meta root package (config/tooling only)" : "meta package (no src/, tiny surface)",
31973
32179
  sourceFiles
31974
32180
  };
@@ -31984,11 +32190,10 @@ function buildForcedConfigOverride(tierContext, isTypeChecked) {
31984
32190
  tier: tierContext.currentTier ?? tierContext.recommendedOptions?.tier ?? 3
31985
32191
  };
31986
32192
  }
31987
- function resolvePackageConfigOverride(packageMode, typeChecked, tierContext, analyzeTier) {
32193
+ function resolvePackageConfigOverride(typeChecked, tierContext, analyzeTier) {
31988
32194
  if (analyzeTier !== void 0) return analyzeTier;
31989
32195
  if (tierContext === void 0 || !tierContext.hasXylabsConfig) return void 0;
31990
32196
  if (typeChecked === true || typeChecked === false) return buildForcedConfigOverride(tierContext, typeChecked);
31991
- if (packageMode === "light") return buildForcedConfigOverride(tierContext, false);
31992
32197
  }
31993
32198
  function printSkippedPackage(pkg, reason) {
31994
32199
  console.log(chalk.gray(`Skip [${pkg}]`) + chalk.gray(` (${reason})`));
@@ -32008,7 +32213,7 @@ function emptyPackageResult(pkg) {
32008
32213
  * Classify packages, skip empty/meta as configured, then lint the rest via
32009
32214
  * the persistent ESLint worker pool.
32010
32215
  */
32011
- async function runLintNextPackages({ analyze, analyzeTier, cache, concurrency, cycleDepth, fix, meta, onPackageResult, profile, rootDir, skipEmpty, tierContext, typeChecked, verbose, workspaces }) {
32216
+ async function runLintNextPackages({ analyze, analyzeTier, cache, concurrency, cycleDepth, fix, gitignore, meta, onPackageResult, profile, rootDir, skipEmpty, tierContext, typeChecked, verbose, workspaces }) {
32012
32217
  const forceFull = workspaces.length === 1;
32013
32218
  const classified = workspaces.map((ws) => {
32014
32219
  return {
@@ -32030,6 +32235,8 @@ async function runLintNextPackages({ analyze, analyzeTier, cache, concurrency, c
32030
32235
  }
32031
32236
  const poolSize = Math.min(Math.max(1, concurrency), toLint.length);
32032
32237
  const pool = new LintWorkerPool(rootDir, poolSize);
32238
+ const repositoryGitignorePath = PATH.resolve(rootDir, ".gitignore");
32239
+ const gitignorePath = gitignore && existsSync(repositoryGitignorePath) ? repositoryGitignorePath : void 0;
32033
32240
  if (profile) {
32034
32241
  console.log(chalk.gray(` ESLint workers: ${poolSize} (persistent pool)`));
32035
32242
  if (typeChecked !== "auto") console.log(chalk.gray(` type-checked: ${typeChecked ? "forced on" : "forced off"}`));
@@ -32041,13 +32248,12 @@ async function runLintNextPackages({ analyze, analyzeTier, cache, concurrency, c
32041
32248
  entry,
32042
32249
  i
32043
32250
  })), concurrency, async ({ entry, i }) => {
32044
- const { classification, ws } = entry;
32251
+ const { ws } = entry;
32045
32252
  const pkgStart = Date.now();
32046
32253
  const absCwd = PATH.resolve(rootDir, ws.location);
32047
32254
  const cacheLocation = cache ? workspaceEslintCachePath(rootDir, ws.location) : void 0;
32048
32255
  if (cacheLocation !== void 0) ensureEslintCacheDir(cacheLocation);
32049
- const configOverride = resolvePackageConfigOverride(classification.mode, typeChecked, analyze ? void 0 : tierContext, analyzeTier);
32050
- if ((verbose || profile) && classification.mode === "light") console.log(chalk.gray(` light [${ws.name}]: ${classification.reason ?? "non-type-checked"}`));
32256
+ const configOverride = resolvePackageConfigOverride(typeChecked, analyze ? void 0 : tierContext, analyzeTier);
32051
32257
  const worker = await pool.run({
32052
32258
  cacheLocation,
32053
32259
  cwd: absCwd,
@@ -32058,6 +32264,7 @@ async function runLintNextPackages({ analyze, analyzeTier, cache, concurrency, c
32058
32264
  configOverride: analyze ? void 0 : configOverride,
32059
32265
  cycleDepth,
32060
32266
  fix,
32267
+ gitignorePath,
32061
32268
  profile,
32062
32269
  verbose
32063
32270
  }
@@ -32528,13 +32735,14 @@ function resolveTierForLint(analyze, rootDir) {
32528
32735
  tierContext: analyzeContext.kind === "ready" ? analyzeContext.tierContext : detectedContext.hasXylabsConfig ? detectedContext : void 0
32529
32736
  };
32530
32737
  }
32531
- function logLintProfileHeader(cache, typeChecked, detectedContext, meta, skipEmpty) {
32738
+ function logLintProfileHeader(cache, gitignore, typeChecked, detectedContext, meta, skipEmpty) {
32532
32739
  console.log(chalk.gray(` ESLint cache: ${cache ? "on" : "off"}`));
32533
- const typeCheckedLabel = typeChecked === "auto" ? `auto (project ${detectedContext.isTypeChecked ? "on" : "off"}; meta → light)` : typeChecked ? "forced on" : "forced off";
32740
+ console.log(chalk.gray(` .gitignore: ${gitignore ? "on" : "off"}`));
32741
+ const typeCheckedLabel = typeChecked === "auto" ? `auto (project ${detectedContext.isTypeChecked ? "on" : "off"})` : typeChecked ? "forced on" : "forced off";
32534
32742
  console.log(chalk.gray(` type-checked: ${typeCheckedLabel}`));
32535
32743
  console.log(chalk.gray(` meta packages: ${meta} · skip empty: ${skipEmpty ? "on" : "off"}`));
32536
32744
  }
32537
- async function lintNext({ analyze = false, cache = true, cycleDepth, fix = false, jobs, meta = "light", pkg, profile = false, skipEmpty = true, typeChecked = "auto", verbose = false, workspaces: targetWorkspaces }) {
32745
+ async function lintNext({ analyze = false, cache = true, cycleDepth, fix = false, gitignore = true, jobs, meta = "full", pkg, profile = false, skipEmpty = true, typeChecked = "auto", verbose = false, workspaces: targetWorkspaces }) {
32538
32746
  const rootDir = INIT_CWD();
32539
32747
  const { analyzeContext, detectedContext, tierContext } = resolveTierForLint(analyze, rootDir);
32540
32748
  if (analyzeContext.kind === "invalid") return resultFromExitCode(1);
@@ -32545,7 +32753,7 @@ async function lintNext({ analyze = false, cache = true, cycleDepth, fix = false
32545
32753
  const analyzeStarted = Date.now();
32546
32754
  const label = getLintLabel(analyze, fix, cycleDepth);
32547
32755
  if (analyze && tierContext !== void 0) printAnalyzeRunHeader(workspaces);
32548
- if (profile) logLintProfileHeader(cache, typeChecked, detectedContext, meta, skipEmpty);
32756
+ if (profile) logLintProfileHeader(cache, gitignore, typeChecked, detectedContext, meta, skipEmpty);
32549
32757
  return finishLintNext({
32550
32758
  analyze,
32551
32759
  analyzeStarted,
@@ -32558,6 +32766,7 @@ async function lintNext({ analyze = false, cache = true, cycleDepth, fix = false
32558
32766
  concurrency: jobs,
32559
32767
  cycleDepth,
32560
32768
  fix,
32769
+ gitignore,
32561
32770
  label,
32562
32771
  meta,
32563
32772
  onPackageResult: (index, total, result) => {
@@ -32589,9 +32798,11 @@ function shouldUseIncremental$2(incremental) {
32589
32798
  function shouldUseIncrementalLint({ analyze, fix, incremental, pkg }) {
32590
32799
  return pkg === void 0 && fix !== true && analyze !== true && shouldUseIncremental$2(incremental);
32591
32800
  }
32592
- function lintOptionsHash({ cycleDepth }) {
32801
+ function lintOptionsHash({ cycleDepth, gitignore }) {
32802
+ const gitignorePath = PATH.resolve(INIT_CWD(), ".gitignore");
32593
32803
  return {
32594
32804
  cycleDepth,
32805
+ gitignore: gitignore === false ? false : existsSync(gitignorePath) ? readFileSync(gitignorePath, "utf8") : null,
32595
32806
  strict: isStrictMode()
32596
32807
  };
32597
32808
  }
@@ -32599,13 +32810,14 @@ const lintPackage = ({ pkg, fix, verbose }) => {
32599
32810
  const pm = getPackageManager();
32600
32811
  return runSteps(`${fix ?? false ? "Fix" : "Lint"} [${pkg}]`, [pm.runInWorkspace(pkg, fix ?? false ? "package-fix" : verbose ?? false ? "package-lint-verbose" : "package-lint")]);
32601
32812
  };
32602
- async function lintIncremental({ cache, cycleDepth, fix, jobs, meta, profile, skipEmpty, typeChecked, verbose, workspaces: targetWorkspaces }) {
32813
+ async function lintIncremental({ cache, cycleDepth, fix, gitignore, jobs, meta, profile, skipEmpty, typeChecked, verbose, workspaces: targetWorkspaces }) {
32603
32814
  const pm = getPackageManager();
32604
32815
  const allWorkspaces = targetWorkspaces ?? pm.listWorkspaces();
32605
32816
  if (allWorkspaces.length === 0) return await lintNext({
32606
32817
  cache,
32607
32818
  cycleDepth,
32608
32819
  fix,
32820
+ gitignore,
32609
32821
  jobs,
32610
32822
  meta,
32611
32823
  profile,
@@ -32615,7 +32827,10 @@ async function lintIncremental({ cache, cycleDepth, fix, jobs, meta, profile, sk
32615
32827
  });
32616
32828
  const plan = createIncrementalPlan({
32617
32829
  action: "lint",
32618
- options: lintOptionsHash({ cycleDepth }),
32830
+ options: lintOptionsHash({
32831
+ cycleDepth,
32832
+ gitignore
32833
+ }),
32619
32834
  pm,
32620
32835
  isVerbose: verbose,
32621
32836
  workspaces: allWorkspaces
@@ -32625,7 +32840,10 @@ async function lintIncremental({ cache, cycleDepth, fix, jobs, meta, profile, sk
32625
32840
  console.log(chalk.gray(" No changed packages to lint."));
32626
32841
  writeIncrementalSnapshot({
32627
32842
  action: "lint",
32628
- options: lintOptionsHash({ cycleDepth }),
32843
+ options: lintOptionsHash({
32844
+ cycleDepth,
32845
+ gitignore
32846
+ }),
32629
32847
  pm,
32630
32848
  workspaces: allWorkspaces
32631
32849
  });
@@ -32635,6 +32853,7 @@ async function lintIncremental({ cache, cycleDepth, fix, jobs, meta, profile, sk
32635
32853
  cache,
32636
32854
  cycleDepth,
32637
32855
  fix,
32856
+ gitignore,
32638
32857
  jobs,
32639
32858
  meta,
32640
32859
  profile,
@@ -32645,13 +32864,16 @@ async function lintIncremental({ cache, cycleDepth, fix, jobs, meta, profile, sk
32645
32864
  });
32646
32865
  if (isCleanResult(result)) writeIncrementalSnapshot({
32647
32866
  action: "lint",
32648
- options: lintOptionsHash({ cycleDepth }),
32867
+ options: lintOptionsHash({
32868
+ cycleDepth,
32869
+ gitignore
32870
+ }),
32649
32871
  pm,
32650
32872
  workspaces: allWorkspaces
32651
32873
  });
32652
32874
  return result;
32653
32875
  }
32654
- const lint = ({ analyze, cache, cycleDepth, fix, incremental, jobs, meta, prev, pkg, profile, skipEmpty, typeChecked, verbose, workspaces }) => {
32876
+ const lint = ({ analyze, cache, cycleDepth, fix, gitignore, incremental, jobs, meta, prev, pkg, profile, skipEmpty, typeChecked, verbose, workspaces }) => {
32655
32877
  if (analyze === true && fix === true) {
32656
32878
  console.error("The --analyze option cannot be combined with --fix");
32657
32879
  return 1;
@@ -32666,6 +32888,7 @@ const lint = ({ analyze, cache, cycleDepth, fix, incremental, jobs, meta, prev,
32666
32888
  cache,
32667
32889
  cycleDepth,
32668
32890
  fix,
32891
+ gitignore,
32669
32892
  jobs,
32670
32893
  meta,
32671
32894
  profile,
@@ -32678,6 +32901,7 @@ const lint = ({ analyze, cache, cycleDepth, fix, incremental, jobs, meta, prev,
32678
32901
  analyze,
32679
32902
  cache,
32680
32903
  fix,
32904
+ gitignore,
32681
32905
  jobs,
32682
32906
  meta,
32683
32907
  pkg,
@@ -39940,7 +40164,15 @@ function fixRedundantRules(eslintConfigPath, redundant) {
39940
40164
  }
39941
40165
  }
39942
40166
  function formatConfigFile(eslintConfigPath) {
39943
- spawnSync("eslint", ["--shouldFix", eslintConfigPath], { stdio: "inherit" });
40167
+ spawnSync("eslint", ["--fix", eslintConfigPath], { stdio: "inherit" });
40168
+ }
40169
+ function fixGitignoreConfig(eslintConfigPath) {
40170
+ const source = readFileSync(eslintConfigPath, "utf8");
40171
+ const updated = addGitignoreConfig(source);
40172
+ if (updated === void 0 || updated === source) return false;
40173
+ writeFileSync(eslintConfigPath, updated, "utf8");
40174
+ console.log(chalk.green("Fixed: added repository .gitignore to ESLint config"));
40175
+ return true;
39944
40176
  }
39945
40177
  function fixConfigMismatch(eslintConfigPath, configDir, source, sharedPkg, expectedPkg) {
39946
40178
  writeFileSync(eslintConfigPath, source.replaceAll(sharedPkg, () => expectedPkg), "utf8");
@@ -40004,6 +40236,19 @@ const LINTLINT_RULES = [
40004
40236
  fixable: true,
40005
40237
  id: "lintlint.config-package"
40006
40238
  },
40239
+ {
40240
+ check: ({ eslintConfigPath, hasGitignoreFile, source }, { fix }) => {
40241
+ if (!hasGitignoreFile || hasGitignoreConfig(source)) return {};
40242
+ const message = "ESLint config does not include the repository .gitignore with Git-relative pattern resolution";
40243
+ if (!fix) return { diagnostics: lintlintDiagnostics("lintlint.gitignore", [message]) };
40244
+ if (fixGitignoreConfig(eslintConfigPath)) return { fixedCount: 1 };
40245
+ return { diagnostics: lintlintDiagnostics("lintlint.gitignore", [`${message}; automatic fix could not find the exported flat-config array`]) };
40246
+ },
40247
+ defaultLevel: "warn",
40248
+ description: "ESLint config includes the repository .gitignore for CLI and editor parity",
40249
+ fixable: true,
40250
+ id: "lintlint.gitignore"
40251
+ },
40007
40252
  {
40008
40253
  check: ({ eslintConfigPath, results }, { fix }) => {
40009
40254
  if (results.redundant.length === 0) return {};
@@ -40039,6 +40284,7 @@ async function runLintlintChecks(eslintConfigPath, configDir, source, sharedPkg,
40039
40284
  context: {
40040
40285
  configDir,
40041
40286
  eslintConfigPath,
40287
+ hasGitignoreFile: existsSync(PATH.resolve(configDir, ".gitignore")),
40042
40288
  isVerbose,
40043
40289
  mismatch,
40044
40290
  results,
@@ -40051,7 +40297,7 @@ async function runLintlintChecks(eslintConfigPath, configDir, source, sharedPkg,
40051
40297
  strict: isStrictMode()
40052
40298
  });
40053
40299
  if (shouldFix && result.envelope.data.fixedCount > 0) formatConfigFile(eslintConfigPath);
40054
- if (result.envelope.data.diagnostics.length === 0 && result.envelope.data.fixedCount === 0) console.log(chalk.green("No redundant or overridden rules found"));
40300
+ if (result.envelope.data.diagnostics.length === 0 && result.envelope.data.fixedCount === 0) console.log(chalk.green("ESLint config checks passed"));
40055
40301
  return result;
40056
40302
  }
40057
40303
  async function lintlint({ shouldFix, isVerbose } = {}) {
@@ -42265,13 +42511,14 @@ const relintPackage = ({ pkg, fix, verbose }) => {
42265
42511
  const pm = getPackageManager();
42266
42512
  return runSteps(`${fix ?? false ? "Fix" : "Lint"} [${pkg}]`, [pm.runInWorkspace(pkg, fix ?? false ? "package-fix" : verbose ?? false ? "package-lint-verbose" : "package-lint")]);
42267
42513
  };
42268
- const relint = ({ fix, jobs, pkg, prev, verbose }) => {
42514
+ const relint = ({ fix, gitignore, jobs, pkg, prev, verbose }) => {
42269
42515
  if (!(prev ?? false)) {
42270
42516
  cleanLintCaches(pkg);
42271
42517
  clearIncrementalSnapshot("lint");
42272
42518
  return lint({
42273
42519
  cache: false,
42274
42520
  fix,
42521
+ gitignore,
42275
42522
  incremental: true,
42276
42523
  jobs,
42277
42524
  pkg,
@@ -51484,7 +51731,7 @@ const fixCommand = {
51484
51731
  function lintLintBuilder(yargs) {
51485
51732
  return yargs.option("fix", {
51486
51733
  default: false,
51487
- description: "Remove redundant rules from local config",
51734
+ description: "Fix supported ESLint config issues",
51488
51735
  type: "boolean"
51489
51736
  }).option("rules", {
51490
51737
  default: false,
@@ -51506,7 +51753,7 @@ async function handleLintLintCommand(argv) {
51506
51753
  const lintLintSubcommand = {
51507
51754
  builder: lintLintBuilder,
51508
51755
  command: "lint",
51509
- describe: "Check redundant or overridden ESLint rules vs shared config",
51756
+ describe: "Check the local ESLint config against toolchain conventions",
51510
51757
  handler: handleLintLintCommand
51511
51758
  };
51512
51759
  const lintlintCommand = {
@@ -51577,6 +51824,10 @@ const runCommand = {
51577
51824
  default: false,
51578
51825
  description: "Clear lint caches and run ESLint from a fresh snapshot",
51579
51826
  type: "boolean"
51827
+ }).option("gitignore", {
51828
+ default: true,
51829
+ description: "Ignore files matched by the repository root .gitignore (disable with --no-gitignore)",
51830
+ type: "boolean"
51580
51831
  }).option("next", {
51581
51832
  default: false,
51582
51833
  description: "Deprecated: per-package lint is the default",
@@ -51596,20 +51847,16 @@ const runCommand = {
51596
51847
  type: "boolean"
51597
51848
  }).option("type-checked", {
51598
51849
  default: void 0,
51599
- description: "Force type-aware ESLint (true) or disable it (false). Default auto uses project config; meta packages lint without type-checking",
51850
+ description: "Force type-aware ESLint (true) or disable it (false). Default auto uses project config",
51600
51851
  type: "boolean"
51601
51852
  }).option("skip-empty", {
51602
51853
  default: true,
51603
51854
  description: "Skip packages with no lintable source files (disable with --no-skip-empty)",
51604
51855
  type: "boolean"
51605
51856
  }).option("meta", {
51606
- choices: [
51607
- "full",
51608
- "light",
51609
- "skip"
51610
- ],
51611
- default: "light",
51612
- description: "Monorepo meta/root packages (no src/): full lint, light (non-type-checked), or skip",
51857
+ choices: ["full", "skip"],
51858
+ default: "full",
51859
+ description: "Monorepo meta/root packages (no src/): full lint or skip",
51613
51860
  type: "string"
51614
51861
  });
51615
51862
  },
@@ -51623,6 +51870,7 @@ const runCommand = {
51623
51870
  }
51624
51871
  if (Boolean(argv.fresh)) {
51625
51872
  await withEnvelope("lint", () => relint({
51873
+ gitignore: argv.gitignore,
51626
51874
  jobs: argv.jobs,
51627
51875
  pkg: argv.package,
51628
51876
  prev: argv.prev,
@@ -51635,6 +51883,7 @@ const runCommand = {
51635
51883
  analyze: argv.analyze,
51636
51884
  cache: argv.cache,
51637
51885
  fix: argv.fix,
51886
+ gitignore: argv.gitignore,
51638
51887
  incremental: argv.incremental !== false,
51639
51888
  jobs: argv.jobs,
51640
51889
  meta: argv.meta,