cspell 9.6.1 → 9.6.3

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.
@@ -20,13 +20,13 @@ import { IssueType, MessageTypes as MessageTypes$1, unknownWordsChoices } from "
20
20
  import { dictionaryCacheEnableLogging, dictionaryCacheGetLog } from "cspell-dictionary";
21
21
  import { GitIgnore, findRepoRoot } from "cspell-gitignore";
22
22
  import { GlobMatcher, fileOrGlobToGlob, workaroundPicomatchBug } from "cspell-glob";
23
+ import { dynamicImport } from "@cspell/dynamic-import";
23
24
  import crypto from "node:crypto";
24
25
  import streamConsumers from "node:stream/consumers";
25
26
  import { getStat, readFileText, toURL } from "cspell-io";
26
27
  import { glob } from "tinyglobby";
27
28
  import * as readline from "node:readline";
28
29
  import { parse, stringify } from "flatted";
29
- import { dynamicImport } from "@cspell/dynamic-import";
30
30
 
31
31
  //#region src/console.ts
32
32
  var ImplChannel = class {
@@ -150,7 +150,7 @@ function getPerfMeasurements() {
150
150
  p.nestedTimeMs += m.duration;
151
151
  return updateChild(p.children, m, p.depth + 1);
152
152
  }
153
- function updateChild(children, m, depth$1) {
153
+ function updateChild(children, m, depth) {
154
154
  const p = children.get(m.name);
155
155
  if (p) {
156
156
  p.totalTimeMs += m.duration;
@@ -161,7 +161,7 @@ function getPerfMeasurements() {
161
161
  }
162
162
  const n = {
163
163
  name: m.name,
164
- depth: depth$1,
164
+ depth,
165
165
  totalTimeMs: m.duration,
166
166
  nestedTimeMs: 0,
167
167
  count: 1,
@@ -236,20 +236,20 @@ function parseAnsiStr(str) {
236
236
  * @param pad - the string to use for padding, default is '…'
237
237
  * @returns the pruned text
238
238
  */
239
- function pruneAnsiTextEnd(str, maxWidth, pad$1 = "…") {
239
+ function pruneAnsiTextEnd(str, maxWidth, pad = "…") {
240
240
  if (!maxWidth || maxWidth <= 0) return str;
241
241
  if (str.length <= maxWidth) return str;
242
242
  if (ansiWidth(str) <= maxWidth) return str;
243
- const padWidth$1 = ansiWidth(pad$1);
243
+ const padWidth = ansiWidth(pad);
244
244
  const fragments = parseAnsiStr(str);
245
- let remaining = maxWidth - padWidth$1;
245
+ let remaining = maxWidth - padWidth;
246
246
  for (const frag of fragments) {
247
247
  if (frag.type !== "text") continue;
248
248
  if (remaining <= 0) {
249
249
  frag.text = "";
250
250
  continue;
251
251
  }
252
- const pruned = pruneTextEnd(frag.text, remaining, pad$1);
252
+ const pruned = pruneTextEnd(frag.text, remaining, pad);
253
253
  if (pruned !== frag.text) {
254
254
  frag.text = pruned;
255
255
  remaining = 0;
@@ -266,20 +266,20 @@ function pruneAnsiTextEnd(str, maxWidth, pad$1 = "…") {
266
266
  * @param pad - the string to use for padding, default is '…'
267
267
  * @returns the pruned text
268
268
  */
269
- function pruneAnsiTextStart(str, maxWidth, pad$1 = "…") {
269
+ function pruneAnsiTextStart(str, maxWidth, pad = "…") {
270
270
  if (!maxWidth || maxWidth <= 0) return str;
271
271
  if (str.length <= maxWidth) return str;
272
272
  if (ansiWidth(str) <= maxWidth) return str;
273
- const padWidth$1 = ansiWidth(pad$1);
273
+ const padWidth = ansiWidth(pad);
274
274
  const fragments = parseAnsiStr(str);
275
- let remaining = maxWidth - padWidth$1;
275
+ let remaining = maxWidth - padWidth;
276
276
  for (const frag of fragments.reverse()) {
277
277
  if (frag.type !== "text") continue;
278
278
  if (remaining <= 0) {
279
279
  frag.text = "";
280
280
  continue;
281
281
  }
282
- const pruned = pruneTextStart(frag.text, remaining, pad$1);
282
+ const pruned = pruneTextStart(frag.text, remaining, pad);
283
283
  if (pruned !== frag.text) {
284
284
  frag.text = pruned;
285
285
  remaining = 0;
@@ -296,11 +296,11 @@ function pruneAnsiTextStart(str, maxWidth, pad$1 = "…") {
296
296
  * @param pad - the string to use for padding, default is '…'
297
297
  * @returns the pruned text
298
298
  */
299
- function pruneTextEnd(str, maxWidth, pad$1 = "…") {
299
+ function pruneTextEnd(str, maxWidth, pad = "…") {
300
300
  if (!maxWidth || maxWidth <= 0) return str;
301
301
  if (str.length <= maxWidth) return str;
302
- if (isAnsiString(str)) return pruneAnsiTextEnd(str, maxWidth, pad$1);
303
- const maxWidthWithPad = maxWidth - width(pad$1);
302
+ if (isAnsiString(str)) return pruneAnsiTextEnd(str, maxWidth, pad);
303
+ const maxWidthWithPad = maxWidth - width(pad);
304
304
  const letters = [...str];
305
305
  let len = 0;
306
306
  for (let i = 0; i < letters.length; i++) {
@@ -309,7 +309,7 @@ function pruneTextEnd(str, maxWidth, pad$1 = "…") {
309
309
  if (len > maxWidthWithPad) {
310
310
  let j = i + 1;
311
311
  while (j < letters.length && width(letters[j]) === 0) ++j;
312
- return j === letters.length ? str : letters.slice(0, i).join("") + pad$1;
312
+ return j === letters.length ? str : letters.slice(0, i).join("") + pad;
313
313
  }
314
314
  }
315
315
  return str;
@@ -321,10 +321,10 @@ function pruneTextEnd(str, maxWidth, pad$1 = "…") {
321
321
  * @param pad - the string to use for padding, default is '…'
322
322
  * @returns the pruned text
323
323
  */
324
- function pruneTextStart(str, maxWidth, pad$1 = "…") {
324
+ function pruneTextStart(str, maxWidth, pad = "…") {
325
325
  if (!maxWidth || maxWidth <= 0) return str;
326
326
  if (str.length <= maxWidth) return str;
327
- const maxWidthWithPad = maxWidth - width(pad$1);
327
+ const maxWidthWithPad = maxWidth - width(pad);
328
328
  const letters = [...str];
329
329
  let len = 0;
330
330
  for (let i = letters.length - 1; i >= 1; i--) {
@@ -333,7 +333,7 @@ function pruneTextStart(str, maxWidth, pad$1 = "…") {
333
333
  if (len > maxWidthWithPad) {
334
334
  i += 1;
335
335
  while (i < letters.length && width(letters[i]) === 0) ++i;
336
- return pad$1 + letters.slice(i).join("");
336
+ return pad + letters.slice(i).join("");
337
337
  }
338
338
  }
339
339
  return str;
@@ -386,8 +386,8 @@ function tableToLines(table, deliminator) {
386
386
  function getRCText(row, col, maxWidth) {
387
387
  return getText(getCell(row, col), maxWidth);
388
388
  }
389
- function recordHeaderWidths(header$1) {
390
- header$1.forEach((col, idx) => {
389
+ function recordHeaderWidths(header) {
390
+ header.forEach((col, idx) => {
391
391
  columnWidths[idx] = Math.max(ansiWidth(col), columnWidths[idx] || 0);
392
392
  });
393
393
  }
@@ -397,19 +397,19 @@ function tableToLines(table, deliminator) {
397
397
  function justifyRow(c, i) {
398
398
  return columnAlignments[i] === "R" ? padLeft(c, columnWidths[i]) : pad(c, columnWidths[i]);
399
399
  }
400
- function toHeaderLine(header$1) {
401
- return tableIndent + decorateRowWith(header$1.map((c, i) => getText(c, columnWidths[i])), justifyRow, headerDecorator).join(del);
400
+ function toHeaderLine(header) {
401
+ return tableIndent + decorateRowWith(header.map((c, i) => getText(c, columnWidths[i])), justifyRow, headerDecorator).join(del);
402
402
  }
403
403
  function toLine(row) {
404
404
  return tableIndent + decorateRowWith(rowToCells(row).map((c, i) => getText(c, columnWidths[i])), justifyRow).join(del);
405
405
  }
406
- function* process$1() {
406
+ function* process() {
407
407
  if (table.title) yield table.title;
408
408
  yield toHeaderLine(simpleHeader);
409
409
  yield* rows.map(toLine);
410
410
  }
411
411
  function sumColumnWidths() {
412
- return columnWidths.reduce((sum, width$1) => sum + width$1, 0);
412
+ return columnWidths.reduce((sum, width) => sum + width, 0);
413
413
  }
414
414
  function adjustColWidths() {
415
415
  for (let i = 0; i < columnWidths.length; i++) {
@@ -444,13 +444,13 @@ function tableToLines(table, deliminator) {
444
444
  recordHeaderWidths(simpleHeader);
445
445
  recordColWidths();
446
446
  adjustColWidths();
447
- return [...process$1()];
447
+ return [...process()];
448
448
  }
449
449
  function headerDecorator(t) {
450
450
  return chalk.bold(chalk.underline(t));
451
451
  }
452
452
  function decorateRowWith(row, ...decorators) {
453
- return decorators.reduce((row$1, decorator) => row$1.map(decorator), row);
453
+ return decorators.reduce((row, decorator) => row.map(decorator), row);
454
454
  }
455
455
 
456
456
  //#endregion
@@ -618,9 +618,9 @@ function getReporter(options, config) {
618
618
  }
619
619
  const resultEmitter = (result) => {
620
620
  if (!fileGlobs.length && !result.files) return;
621
- const { files, issues: issues$1, cachedFiles, filesWithIssues, errors, skippedFiles } = result;
621
+ const { files, issues, cachedFiles, filesWithIssues, errors, skippedFiles } = result;
622
622
  const numFilesWithIssues = filesWithIssues.size;
623
- const chalk$1 = stderr.chalk;
623
+ const chalk = stderr.chalk;
624
624
  if (stderr.getColorLevel() > 0) {
625
625
  stderr.write("\r");
626
626
  stderr.clearLine(0);
@@ -634,8 +634,8 @@ function getReporter(options, config) {
634
634
  const cachedFilesText = cachedFiles ? ` (${cachedFiles} from cache)` : "";
635
635
  const skippedFilesText = skippedFiles ? `, skipped: ${skippedFiles}` : "";
636
636
  const withErrorsText = errors ? ` with ${errors} error${errors === 1 ? "" : "s"}` : "";
637
- consoleError(`CSpell\u003A Files checked: ${filesChecked}${cachedFilesText}${skippedFilesText}, Issues found: ${issues$1} in ${numFilesWithIssues === 1 ? "1 file" : `${numFilesWithIssues} files`}${withErrorsText}.`);
638
- if (errorCollection?.length && issues$1 > 5) {
637
+ consoleError(`CSpell\u003A Files checked: ${filesChecked}${cachedFilesText}${skippedFilesText}, Issues found: ${issues} in ${numFilesWithIssues === 1 ? "1 file" : `${numFilesWithIssues} files`}${withErrorsText}.`);
638
+ if (errorCollection?.length && issues > 5) {
639
639
  consoleError("-------------------------------------------");
640
640
  consoleError("Errors:");
641
641
  errorCollection.forEach((error) => consoleError(error));
@@ -650,7 +650,7 @@ function getReporter(options, config) {
650
650
  consoleError(` Processing Time : ${perfStats.accumulatedTimeMs.toFixed(2).padStart(9)}ms`);
651
651
  consoleError(` Total Time : ${elapsedTotal.toFixed(2).padStart(9)}ms`);
652
652
  const tableStats = {
653
- title: chalk$1.bold("Perf Stats:"),
653
+ title: chalk.bold("Perf Stats:"),
654
654
  header: ["Name", "Time (ms)"],
655
655
  columnAlignments: ["L", "R"],
656
656
  indent: 2,
@@ -665,15 +665,15 @@ function getReporter(options, config) {
665
665
  const perfMeasurements = getPerfMeasurements();
666
666
  if (!perfMeasurements.length) return;
667
667
  const notable = extractNotableBySelfTimeInGroup(perfMeasurements);
668
- const chalk$1 = stderr.chalk;
668
+ const chalk = stderr.chalk;
669
669
  const maxDepth = Math.max(...perfMeasurements.map((m) => m.depth));
670
670
  const depthIndicator = (d) => "⋅".repeat(d) + " ".repeat(maxDepth - d);
671
671
  const rows = perfMeasurements.map((m) => {
672
- const cbd = (text) => colorByDepth(chalk$1, m.depth, text);
673
- const cNotable = (text) => notable.has(m) ? chalk$1.yellow(text) : text;
672
+ const cbd = (text) => colorByDepth(chalk, m.depth, text);
673
+ const cNotable = (text) => notable.has(m) ? chalk.yellow(text) : text;
674
674
  return [
675
- chalk$1.dim("⋅".repeat(m.depth)) + colorByDepthGrayscale(stderr.chalk, m.depth, m.name),
676
- cbd(m.totalTimeMs.toFixed(2) + chalk$1.dim(depthIndicator(m.depth))),
675
+ chalk.dim("⋅".repeat(m.depth)) + colorByDepthGrayscale(stderr.chalk, m.depth, m.name),
676
+ cbd(m.totalTimeMs.toFixed(2) + chalk.dim(depthIndicator(m.depth))),
677
677
  cbd(cNotable((m.totalTimeMs - m.nestedTimeMs).toFixed(2))),
678
678
  cbd(m.count.toString()),
679
679
  cbd(m.minTimeMs.toFixed(2)),
@@ -682,7 +682,7 @@ function getReporter(options, config) {
682
682
  ];
683
683
  });
684
684
  const table = tableToLines({
685
- title: chalk$1.bold("Detailed Measurements:"),
685
+ title: chalk.bold("Detailed Measurements:"),
686
686
  header: [
687
687
  "Name",
688
688
  "Total Time (ms)",
@@ -707,21 +707,21 @@ function getReporter(options, config) {
707
707
  consoleError("\n-------------------------------------------\n");
708
708
  for (const line of table) consoleError(line);
709
709
  }
710
- function colorByDepth(chalk$1, depth, text) {
710
+ function colorByDepth(chalk, depth, text) {
711
711
  const colors = [
712
- chalk$1.green,
713
- chalk$1.cyan,
714
- chalk$1.blue,
715
- chalk$1.magenta,
716
- chalk$1.red
712
+ chalk.green,
713
+ chalk.cyan,
714
+ chalk.blue,
715
+ chalk.magenta,
716
+ chalk.red
717
717
  ];
718
718
  const color = colors[depth % colors.length];
719
- if (depth / colors.length >= 1) return chalk$1.dim(color(text));
719
+ if (depth / colors.length >= 1) return chalk.dim(color(text));
720
720
  return color(text);
721
721
  }
722
- function colorByDepthGrayscale(chalk$1, depth, text) {
722
+ function colorByDepthGrayscale(chalk, depth, text) {
723
723
  const grayLevel = Math.max(32, 255 - depth * 20);
724
- return chalk$1.rgb(grayLevel, grayLevel, grayLevel)(text);
724
+ return chalk.rgb(grayLevel, grayLevel, grayLevel)(text);
725
725
  }
726
726
  function collectPerfStats(p) {
727
727
  if (p.cached) {
@@ -770,18 +770,18 @@ function extractNotableBySelfTimeInGroup(measurements) {
770
770
  return notable;
771
771
  }
772
772
  function formatIssue(io, templateStr, issue, maxIssueTextWidth) {
773
- function clean$1(t$1) {
774
- return t$1.replace(/\s+/, " ");
773
+ function clean(t) {
774
+ return t.replace(/\s+/, " ");
775
775
  }
776
776
  const { uri = "", filename, row, col, text, context = issue.line, offset } = issue;
777
- const contextLeft = clean$1(context.text.slice(0, offset - context.offset));
778
- const contextRight = clean$1(context.text.slice(offset + text.length - context.offset));
779
- const contextFull = clean$1(context.text);
777
+ const contextLeft = clean(context.text.slice(0, offset - context.offset));
778
+ const contextRight = clean(context.text.slice(offset + text.length - context.offset));
779
+ const contextFull = clean(context.text);
780
780
  const padContext = " ".repeat(Math.max(maxIssueTextWidth - text.length, 0));
781
781
  const rowText = row.toString();
782
782
  const colText = col.toString();
783
783
  const padRowCol = " ".repeat(Math.max(1, 8 - (rowText.length + colText.length)));
784
- const suggestions$1 = formatSuggestions(io, issue);
784
+ const suggestions = formatSuggestions(io, issue);
785
785
  const msg = issue.message || (issue.isFlagged ? "Forbidden word" : "Unknown word");
786
786
  const messageColored = issue.isFlagged ? `{yellow ${msg}}` : msg;
787
787
  const substitutions = {
@@ -793,7 +793,7 @@ function formatIssue(io, templateStr, issue, maxIssueTextWidth) {
793
793
  $padContext: padContext,
794
794
  $padRowCol: padRowCol,
795
795
  $row: rowText,
796
- $suggestions: suggestions$1,
796
+ $suggestions: suggestions,
797
797
  $text: text,
798
798
  $uri: uri,
799
799
  $quickFix: formatQuickFix(io, issue),
@@ -818,16 +818,16 @@ function substitute(text, substitutions) {
818
818
  const subs = [];
819
819
  for (const [match, replaceWith] of Object.entries(substitutions)) {
820
820
  const len = match.length;
821
- for (let i$1 = text.indexOf(match); i$1 >= 0; i$1 = text.indexOf(match, i$1)) {
822
- const end = i$1 + len;
821
+ for (let i = text.indexOf(match); i >= 0; i = text.indexOf(match, i)) {
822
+ const end = i + len;
823
823
  const reg = /\b/y;
824
824
  reg.lastIndex = end;
825
825
  if (reg.test(text)) subs.push([
826
- i$1,
826
+ i,
827
827
  end,
828
828
  replaceWith
829
829
  ]);
830
- i$1 = end;
830
+ i = end;
831
831
  }
832
832
  }
833
833
  subs.sort((a, b) => a[0] - b[0]);
@@ -886,9 +886,9 @@ async function resolveImports(configFile, imports) {
886
886
  const fromConfigDir = new URL("./", configFile.url);
887
887
  const fromCurrentDir = toFileDirURL("./");
888
888
  const require = createRequire(fromConfigDir);
889
- function isPackageName(name$1) {
889
+ function isPackageName(name) {
890
890
  try {
891
- require.resolve(name$1, { paths: [fileURLToPath(fromConfigDir)] });
891
+ require.resolve(name, { paths: [fileURLToPath(fromConfigDir)] });
892
892
  return true;
893
893
  } catch {
894
894
  return false;
@@ -957,12 +957,12 @@ function setConfigFieldValue(configFile, key, value, comment) {
957
957
  function addDictionariesToConfigFile(configFile, dictionaries, comment) {
958
958
  if (configFile instanceof MutableCSpellConfigFile) {
959
959
  const found = configFile.getValue("dictionaries");
960
- const dicts$1 = configFile.getNode("dictionaries", []);
961
- assert(isCfgArrayNode(dicts$1));
962
- const knownDicts$1 = new Set(dicts$1.value);
963
- for (const dict of dictionaries) if (!knownDicts$1.has(dict)) {
964
- dicts$1.push(dict);
965
- knownDicts$1.add(dict);
960
+ const dicts = configFile.getNode("dictionaries", []);
961
+ assert(isCfgArrayNode(dicts));
962
+ const knownDicts = new Set(dicts.value);
963
+ for (const dict of dictionaries) if (!knownDicts.has(dict)) {
964
+ dicts.push(dict);
965
+ knownDicts.add(dict);
966
966
  }
967
967
  if (!found && comment) configFile.setComment("dictionaries", comment);
968
968
  return;
@@ -1109,9 +1109,9 @@ function determineFileNameURL(options) {
1109
1109
  if (options.config) return toFileURL(options.config);
1110
1110
  const defaultFileName = determineDefaultFileName(options);
1111
1111
  const outputUrl = toFileURL(options.output || defaultFileName);
1112
- const path$2 = outputUrl.pathname;
1113
- if (path$2.endsWith(".json") || path$2.endsWith(".jsonc") || path$2.endsWith(".yaml") || path$2.endsWith(".yml")) return outputUrl;
1114
- if (/\.{m,c}?{j,t}s$/.test(path$2)) throw new Error(`Unsupported file extension: ${path$2}`);
1112
+ const path = outputUrl.pathname;
1113
+ if (path.endsWith(".json") || path.endsWith(".jsonc") || path.endsWith(".yaml") || path.endsWith(".yml")) return outputUrl;
1114
+ if (/\.{m,c}?{j,t}s$/.test(path)) throw new Error(`Unsupported file extension: ${path}`);
1115
1115
  return new URL(defaultFileName, toFileDirURL(outputUrl));
1116
1116
  }
1117
1117
  function determineDefaultFileName(options) {
@@ -1150,11 +1150,11 @@ function parseFeatureFlags(flags, featureFlags = getFeatureFlags()) {
1150
1150
  if (!flags) return featureFlags;
1151
1151
  const flagsKvP = flags.map((f) => f.split(":", 2));
1152
1152
  for (const flag of flagsKvP) {
1153
- const [name$1, value] = flag;
1153
+ const [name, value] = flag;
1154
1154
  try {
1155
- featureFlags.setFlag(name$1, value);
1155
+ featureFlags.setFlag(name, value);
1156
1156
  } catch {
1157
- console.warn(`Unknown flag: "${name$1}"`);
1157
+ console.warn(`Unknown flag: "${name}"`);
1158
1158
  }
1159
1159
  }
1160
1160
  return featureFlags;
@@ -1201,7 +1201,7 @@ const pkgDir = _dirname;
1201
1201
  //#endregion
1202
1202
  //#region src/pkgInfo.ts
1203
1203
  const name = "cspell";
1204
- const version$1 = "9.6.1";
1204
+ const version$1 = "9.6.3";
1205
1205
  const engines = { node: ">=20.18" };
1206
1206
  const npmPackage = {
1207
1207
  name,
@@ -1209,6 +1209,209 @@ const npmPackage = {
1209
1209
  engines
1210
1210
  };
1211
1211
 
1212
+ //#endregion
1213
+ //#region src/reporters/reporters.ts
1214
+ function filterFeatureIssues(features, issue, reportOptions) {
1215
+ if (issue.issueType === IssueType.directive) return features?.issueType && reportOptions?.validateDirectives || false;
1216
+ if (features?.unknownWords) return true;
1217
+ if (!reportOptions) return true;
1218
+ if (issue.isFlagged || !reportOptions.unknownWords || reportOptions.unknownWords === unknownWordsChoices.ReportAll) return true;
1219
+ if (issue.hasPreferredSuggestions && reportOptions.unknownWords !== unknownWordsChoices.ReportFlagged) return true;
1220
+ if (issue.hasSimpleSuggestions && reportOptions.unknownWords === unknownWordsChoices.ReportSimple) return true;
1221
+ return false;
1222
+ }
1223
+ function handleIssue(reporter, issue, reportOptions) {
1224
+ if (!reporter.issue) return;
1225
+ if (!filterFeatureIssues(reporter.features, issue, reportOptions)) return;
1226
+ if (!reporter.features?.contextGeneration && !issue.context) {
1227
+ issue = { ...issue };
1228
+ issue.context = issue.line;
1229
+ }
1230
+ return reporter.issue(issue, reportOptions);
1231
+ }
1232
+ /**
1233
+ * Loads reporter modules configured in cspell config file
1234
+ */
1235
+ async function loadReporters(reporters, defaultReporter, config) {
1236
+ async function loadReporter(reporterSettings) {
1237
+ if (reporterSettings === "default") return defaultReporter;
1238
+ if (!Array.isArray(reporterSettings)) reporterSettings = [reporterSettings];
1239
+ const [moduleName, settings] = reporterSettings;
1240
+ try {
1241
+ const { getReporter } = await dynamicImport(moduleName, [process.cwd(), pkgDir]);
1242
+ return getReporter(settings, config);
1243
+ } catch (e) {
1244
+ throw new ApplicationError(`Failed to load reporter ${moduleName}: ${toError$1(e).message}`);
1245
+ }
1246
+ }
1247
+ reporters = !reporters || !reporters.length ? ["default"] : [...reporters];
1248
+ return (await Promise.all(reporters.map(loadReporter))).filter((v) => v !== void 0);
1249
+ }
1250
+ function finalizeReporter(reporter) {
1251
+ if (!reporter) return void 0;
1252
+ if (reporterIsFinalized(reporter)) return reporter;
1253
+ return {
1254
+ issue: (...params) => reporter.issue?.(...params),
1255
+ info: (...params) => reporter.info?.(...params),
1256
+ debug: (...params) => reporter.debug?.(...params),
1257
+ progress: (...params) => reporter.progress?.(...params),
1258
+ error: (...params) => reporter.error?.(...params),
1259
+ result: (...params) => reporter.result?.(...params),
1260
+ features: reporter.features
1261
+ };
1262
+ }
1263
+ function reporterIsFinalized(reporter) {
1264
+ return !!reporter && reporter.features && typeof reporter.issue === "function" && typeof reporter.info === "function" && typeof reporter.debug === "function" && typeof reporter.error === "function" && typeof reporter.progress === "function" && typeof reporter.result === "function" || false;
1265
+ }
1266
+ const reportIssueOptionsKeyMap = {
1267
+ unknownWords: "unknownWords",
1268
+ validateDirectives: "validateDirectives",
1269
+ showContext: "showContext"
1270
+ };
1271
+ function setValue(options, key, value) {
1272
+ if (value !== void 0) options[key] = value;
1273
+ }
1274
+ function extractReporterIssueOptions(settings) {
1275
+ const src = settings;
1276
+ const options = {};
1277
+ for (const key in reportIssueOptionsKeyMap) {
1278
+ const k = key;
1279
+ setValue(options, k, src[k]);
1280
+ }
1281
+ return options;
1282
+ }
1283
+ function mergeReportIssueOptions(a, b) {
1284
+ const options = extractReporterIssueOptions(a);
1285
+ if (!b) return options;
1286
+ for (const key in reportIssueOptionsKeyMap) {
1287
+ const k = key;
1288
+ setValue(options, k, b[k]);
1289
+ }
1290
+ return options;
1291
+ }
1292
+ var LintReporter = class {
1293
+ #reporters = [];
1294
+ #config;
1295
+ #finalized = false;
1296
+ constructor(defaultReporter, config) {
1297
+ this.defaultReporter = defaultReporter;
1298
+ this.#config = config;
1299
+ if (defaultReporter) this.#reporters.push(finalizeReporter(defaultReporter));
1300
+ }
1301
+ get config() {
1302
+ return this.#config;
1303
+ }
1304
+ set config(config) {
1305
+ assert(!this.#finalized, "Cannot change the configuration of a finalized reporter");
1306
+ this.#config = config;
1307
+ }
1308
+ issue(issue, reportOptions) {
1309
+ for (const reporter of this.#reporters) handleIssue(reporter, issue, reportOptions);
1310
+ }
1311
+ info(...params) {
1312
+ for (const reporter of this.#reporters) reporter.info(...params);
1313
+ }
1314
+ debug(...params) {
1315
+ for (const reporter of this.#reporters) reporter.debug(...params);
1316
+ }
1317
+ error(...params) {
1318
+ for (const reporter of this.#reporters) reporter.error(...params);
1319
+ }
1320
+ progress(...params) {
1321
+ for (const reporter of this.#reporters) reporter.progress(...params);
1322
+ }
1323
+ async result(result) {
1324
+ await Promise.all(this.#reporters.map((reporter) => reporter.result?.(result)));
1325
+ }
1326
+ get features() {
1327
+ return {
1328
+ unknownWords: true,
1329
+ issueType: true
1330
+ };
1331
+ }
1332
+ async loadReportersAndFinalize(reporters) {
1333
+ assert(!this.#finalized, "Cannot change the configuration of a finalized reporter");
1334
+ const loaded = await loadReporters(reporters, this.defaultReporter, this.config);
1335
+ this.#reporters = [...new Set(loaded)].map((reporter) => finalizeReporter(reporter));
1336
+ }
1337
+ emitProgressBegin(filename, fileNum, fileCount) {
1338
+ this.progress({
1339
+ type: "ProgressFileBegin",
1340
+ fileNum,
1341
+ fileCount,
1342
+ filename
1343
+ });
1344
+ }
1345
+ emitProgressComplete(filename, fileNum, fileCount, result) {
1346
+ const numIssues = result.issues.filter((issue) => filterFeatureIssues({}, issue, result.reportIssueOptions)).length;
1347
+ for (const reporter of this.#reporters) {
1348
+ const progress = clean({
1349
+ type: "ProgressFileComplete",
1350
+ fileNum,
1351
+ fileCount,
1352
+ filename,
1353
+ elapsedTimeMs: result.elapsedTimeMs,
1354
+ processed: result.processed,
1355
+ skippedReason: result.skippedReason,
1356
+ numErrors: numIssues || result.errors,
1357
+ cached: result.cached,
1358
+ perf: result.perf,
1359
+ issues: reporter.features && result.issues,
1360
+ reportIssueOptions: reporter.features && result.reportIssueOptions
1361
+ });
1362
+ reporter.progress(progress);
1363
+ }
1364
+ result.issues.forEach((issue) => this.issue(issue, result.reportIssueOptions));
1365
+ return numIssues;
1366
+ }
1367
+ };
1368
+ var ReportItemCollector = class {
1369
+ #collection;
1370
+ constructor(collection) {
1371
+ this.#collection = collection;
1372
+ }
1373
+ get #items() {
1374
+ if (!this.#collection.reportItems) this.#collection.reportItems = [];
1375
+ return this.#collection.reportItems;
1376
+ }
1377
+ get items() {
1378
+ return this.#collection.reportItems;
1379
+ }
1380
+ info(...params) {
1381
+ this.#items.push({
1382
+ type: "info",
1383
+ payload: params
1384
+ });
1385
+ }
1386
+ debug(...params) {
1387
+ this.#items.push({
1388
+ type: "debug",
1389
+ payload: params
1390
+ });
1391
+ }
1392
+ error(...params) {
1393
+ this.#items.push({
1394
+ type: "error",
1395
+ payload: params
1396
+ });
1397
+ }
1398
+ };
1399
+ function replayReportItems(reportItemsCollection, reporter) {
1400
+ const items = reportItemsCollection.reportItems;
1401
+ if (!items) return;
1402
+ for (const item of items) switch (item.type) {
1403
+ case "info":
1404
+ reporter.info(...item.payload);
1405
+ break;
1406
+ case "debug":
1407
+ reporter.debug(...item.payload);
1408
+ break;
1409
+ case "error":
1410
+ reporter.error(...item.payload);
1411
+ break;
1412
+ }
1413
+ }
1414
+
1212
1415
  //#endregion
1213
1416
  //#region src/util/async.ts
1214
1417
  const asyncMap = operators.opMapAsync;
@@ -1248,12 +1451,12 @@ async function globP(pattern, options) {
1248
1451
  followSymbolicLinks: false,
1249
1452
  expandDirectories: false
1250
1453
  });
1251
- const compare$1 = new Intl.Collator("en").compare;
1252
- return (await glob$1(patterns, useOptions)).sort(compare$1).map((absFilename) => path$1.relative(cwd, absFilename));
1454
+ const compare = new Intl.Collator("en").compare;
1455
+ return (await glob$1(patterns, useOptions)).sort(compare).map((absFilename) => path$1.relative(cwd, absFilename));
1253
1456
  }
1254
1457
  function calcGlobs(commandLineExclude) {
1255
1458
  const commandLineExcludes = {
1256
- globs: [...new Set((commandLineExclude || []).flatMap((glob$2) => glob$2.split(/(?<!\\)\s+/g)).map((g) => g.replaceAll("\\ ", " ")))],
1459
+ globs: [...new Set((commandLineExclude || []).flatMap((glob) => glob.split(/(?<!\\)\s+/g)).map((g) => g.replaceAll("\\ ", " ")))],
1257
1460
  source: "arguments"
1258
1461
  };
1259
1462
  const defaultExcludes = {
@@ -1266,8 +1469,8 @@ function extractPatterns(globs) {
1266
1469
  return globs.reduce((info, g) => {
1267
1470
  const source = g.source;
1268
1471
  const patterns = g.matcher.patternsNormalizedToRoot;
1269
- return [...info, ...patterns.map((glob$2) => ({
1270
- glob: glob$2,
1472
+ return [...info, ...patterns.map((glob) => ({
1473
+ glob,
1271
1474
  source
1272
1475
  }))];
1273
1476
  }, []);
@@ -1314,29 +1517,29 @@ const isPossibleUrlRegExp = /^[\d_a-z-]{3,}:\/\//;
1314
1517
  * @param root - root to use.
1315
1518
  * @returns `**` is appended directories.
1316
1519
  */
1317
- async function adjustPossibleDirectory(glob$2, root) {
1318
- const g = typeof glob$2 === "string" ? {
1319
- glob: glob$2,
1520
+ async function adjustPossibleDirectory(glob, root) {
1521
+ const g = typeof glob === "string" ? {
1522
+ glob,
1320
1523
  root
1321
1524
  } : {
1322
- glob: glob$2.glob,
1323
- root: glob$2.root ?? root
1525
+ glob: glob.glob,
1526
+ root: glob.root ?? root
1324
1527
  };
1325
- if (isPossibleGlobRegExp.test(g.glob)) return glob$2;
1326
- if (isPossibleUrlRegExp.test(g.glob)) return glob$2;
1528
+ if (isPossibleGlobRegExp.test(g.glob)) return glob;
1529
+ if (isPossibleUrlRegExp.test(g.glob)) return glob;
1327
1530
  const dirPath = path$1.resolve(g.root, g.glob);
1328
1531
  try {
1329
1532
  if ((await promises.stat(dirPath)).isDirectory()) {
1330
1533
  const useGlob = posix.join(posixPath(g.glob), "**");
1331
- return typeof glob$2 === "string" ? useGlob : {
1332
- ...glob$2,
1534
+ return typeof glob === "string" ? useGlob : {
1535
+ ...glob,
1333
1536
  glob: useGlob
1334
1537
  };
1335
1538
  }
1336
1539
  } catch {
1337
- return glob$2;
1540
+ return glob;
1338
1541
  }
1339
- return glob$2;
1542
+ return glob;
1340
1543
  }
1341
1544
  function posixPath(p) {
1342
1545
  return path$1.sep === "\\" ? p.replaceAll("\\", "/") : p;
@@ -1369,9 +1572,9 @@ function isStdinUrl(url) {
1369
1572
  */
1370
1573
  function resolveStdinUrl(url, cwd) {
1371
1574
  assert(url.startsWith(STDINProtocol), `Expected url to start with ${STDINProtocol}`);
1372
- const path$2 = decodeURIComponent(url).slice(STDINProtocol.length).replace(/^\/\//, "").replace(/^\/([a-z]:)/i, "$1");
1373
- const fileUrl = toFileURL(path$2, cwd);
1374
- return new URL(fileUrl.toString().replace(/^file:/, STDINProtocol) + (path$2 ? "" : "/"));
1575
+ const path = decodeURIComponent(url).slice(STDINProtocol.length).replace(/^\/\//, "").replace(/^\/([a-z]:)/i, "$1");
1576
+ const fileUrl = toFileURL(path, cwd);
1577
+ return new URL(fileUrl.toString().replace(/^file:/, STDINProtocol) + (path ? "" : "/"));
1375
1578
  }
1376
1579
 
1377
1580
  //#endregion
@@ -1463,9 +1666,9 @@ const resolveFilenames = asyncMap(resolveFilename);
1463
1666
  function readFileListFiles(listFiles) {
1464
1667
  let useStdin = false;
1465
1668
  return asyncPipe(mergeAsyncIterables(asyncPipe(listFiles.filter((file) => {
1466
- const isStdin$1 = file === "stdin";
1467
- useStdin = useStdin || isStdin$1;
1468
- return !isStdin$1;
1669
+ const isStdin = file === "stdin";
1670
+ useStdin = useStdin || isStdin;
1671
+ return !isStdin;
1469
1672
  }), asyncMap((file) => readFileListFile(file)), asyncAwait(), asyncFlatten()), useStdin ? readStdin() : []), resolveFilenames);
1470
1673
  }
1471
1674
  /**
@@ -1693,11 +1896,11 @@ var ImplFileEntryCache = class {
1693
1896
  }
1694
1897
  async #getMetaForFileUsingMtimeAndSize(cacheEntry) {
1695
1898
  const filePath = this.resolveKeyToFile(cacheEntry.key);
1696
- const stat$1 = await fs.stat(filePath);
1899
+ const stat = await fs.stat(filePath);
1697
1900
  const meta = {
1698
1901
  ...cacheEntry.meta,
1699
- size: stat$1.size,
1700
- mtime: stat$1.mtime.getTime()
1902
+ size: stat.size,
1903
+ mtime: stat.mtime.getTime()
1701
1904
  };
1702
1905
  delete meta.hash;
1703
1906
  return meta;
@@ -1938,8 +2141,8 @@ function getTreeEntry(tree, keys) {
1938
2141
  }
1939
2142
  function setTreeEntry(tree, deps, update = false) {
1940
2143
  let r = tree;
1941
- for (const d$1 of deps) {
1942
- const k = d$1.f;
2144
+ for (const d of deps) {
2145
+ const k = d.f;
1943
2146
  if (!r.c) r.c = /* @__PURE__ */ new Map();
1944
2147
  const cn = r.c.get(k);
1945
2148
  const n = cn ?? {};
@@ -1956,8 +2159,8 @@ function setTreeEntry(tree, deps, update = false) {
1956
2159
  function compDep(a, b) {
1957
2160
  return a.f === b.f && a.h === b.h;
1958
2161
  }
1959
- function calcVersion(version$2) {
1960
- return version$2 + META_DATA_VERSION_SUFFIX;
2162
+ function calcVersion(version) {
2163
+ return version + META_DATA_VERSION_SUFFIX;
1961
2164
  }
1962
2165
  function normalizePath(filePath) {
1963
2166
  if (sep === "/") return filePath;
@@ -1995,9 +2198,9 @@ async function createCache(options) {
1995
2198
  const { useCache, cacheLocation, cacheStrategy, reset } = options;
1996
2199
  const location = toFileURL(cacheLocation);
1997
2200
  const useChecksum = cacheStrategy === "content";
1998
- const version$2 = normalizeVersion(options.version);
2201
+ const version = normalizeVersion(options.version);
1999
2202
  const useUniversal = options.cacheFormat === "universal";
2000
- const cache = useCache ? await createDiskCache(location, useChecksum, version$2, useUniversal) : new DummyCache();
2203
+ const cache = useCache ? await createDiskCache(location, useChecksum, version, useUniversal) : new DummyCache();
2001
2204
  if (reset) await cache.reset();
2002
2205
  return cache;
2003
2206
  }
@@ -2031,8 +2234,8 @@ async function resolveCacheLocation(cacheLocation) {
2031
2234
  * Normalizes the version and return only `major.minor + versionSuffix`
2032
2235
  * @param version The cspell semantic version.
2033
2236
  */
2034
- function normalizeVersion(version$2) {
2035
- const parts = version$2.split(".").slice(0, 2);
2237
+ function normalizeVersion(version) {
2238
+ const parts = version.split(".").slice(0, 2);
2036
2239
  assert(parts.length === 2);
2037
2240
  return parts.join(".") + versionSuffix;
2038
2241
  }
@@ -2078,163 +2281,6 @@ async function readConfigHandleError(filename) {
2078
2281
  }
2079
2282
  }
2080
2283
 
2081
- //#endregion
2082
- //#region src/util/reporters.ts
2083
- function filterFeatureIssues(features, issue, reportOptions) {
2084
- if (issue.issueType === IssueType.directive) return features?.issueType && reportOptions?.validateDirectives || false;
2085
- if (features?.unknownWords) return true;
2086
- if (!reportOptions) return true;
2087
- if (issue.isFlagged || !reportOptions.unknownWords || reportOptions.unknownWords === unknownWordsChoices.ReportAll) return true;
2088
- if (issue.hasPreferredSuggestions && reportOptions.unknownWords !== unknownWordsChoices.ReportFlagged) return true;
2089
- if (issue.hasSimpleSuggestions && reportOptions.unknownWords === unknownWordsChoices.ReportSimple) return true;
2090
- return false;
2091
- }
2092
- function handleIssue(reporter, issue, reportOptions) {
2093
- if (!reporter.issue) return;
2094
- if (!filterFeatureIssues(reporter.features, issue, reportOptions)) return;
2095
- if (!reporter.features?.contextGeneration && !issue.context) {
2096
- issue = { ...issue };
2097
- issue.context = issue.line;
2098
- }
2099
- return reporter.issue(issue, reportOptions);
2100
- }
2101
- /**
2102
- * Loads reporter modules configured in cspell config file
2103
- */
2104
- async function loadReporters(reporters, defaultReporter, config) {
2105
- async function loadReporter(reporterSettings) {
2106
- if (reporterSettings === "default") return defaultReporter;
2107
- if (!Array.isArray(reporterSettings)) reporterSettings = [reporterSettings];
2108
- const [moduleName, settings] = reporterSettings;
2109
- try {
2110
- const { getReporter: getReporter$1 } = await dynamicImport(moduleName, [process.cwd(), pkgDir]);
2111
- return getReporter$1(settings, config);
2112
- } catch (e) {
2113
- throw new ApplicationError(`Failed to load reporter ${moduleName}: ${toError$1(e).message}`);
2114
- }
2115
- }
2116
- reporters = !reporters || !reporters.length ? ["default"] : [...reporters];
2117
- return (await Promise.all(reporters.map(loadReporter))).filter((v) => v !== void 0);
2118
- }
2119
- function finalizeReporter(reporter) {
2120
- if (!reporter) return void 0;
2121
- if (reporterIsFinalized(reporter)) return reporter;
2122
- return {
2123
- issue: (...params) => reporter.issue?.(...params),
2124
- info: (...params) => reporter.info?.(...params),
2125
- debug: (...params) => reporter.debug?.(...params),
2126
- progress: (...params) => reporter.progress?.(...params),
2127
- error: (...params) => reporter.error?.(...params),
2128
- result: (...params) => reporter.result?.(...params),
2129
- features: reporter.features
2130
- };
2131
- }
2132
- function reporterIsFinalized(reporter) {
2133
- return !!reporter && reporter.features && typeof reporter.issue === "function" && typeof reporter.info === "function" && typeof reporter.debug === "function" && typeof reporter.error === "function" && typeof reporter.progress === "function" && typeof reporter.result === "function" || false;
2134
- }
2135
- const reportIssueOptionsKeyMap = {
2136
- unknownWords: "unknownWords",
2137
- validateDirectives: "validateDirectives",
2138
- showContext: "showContext"
2139
- };
2140
- function setValue(options, key, value) {
2141
- if (value !== void 0) options[key] = value;
2142
- }
2143
- function extractReporterIssueOptions(settings) {
2144
- const src = settings;
2145
- const options = {};
2146
- for (const key in reportIssueOptionsKeyMap) {
2147
- const k = key;
2148
- setValue(options, k, src[k]);
2149
- }
2150
- return options;
2151
- }
2152
- function mergeReportIssueOptions(a, b) {
2153
- const options = extractReporterIssueOptions(a);
2154
- if (!b) return options;
2155
- for (const key in reportIssueOptionsKeyMap) {
2156
- const k = key;
2157
- setValue(options, k, b[k]);
2158
- }
2159
- return options;
2160
- }
2161
- var LintReporter = class {
2162
- #reporters = [];
2163
- #config;
2164
- #finalized = false;
2165
- constructor(defaultReporter, config) {
2166
- this.defaultReporter = defaultReporter;
2167
- this.#config = config;
2168
- if (defaultReporter) this.#reporters.push(finalizeReporter(defaultReporter));
2169
- }
2170
- get config() {
2171
- return this.#config;
2172
- }
2173
- set config(config) {
2174
- assert(!this.#finalized, "Cannot change the configuration of a finalized reporter");
2175
- this.#config = config;
2176
- }
2177
- issue(issue, reportOptions) {
2178
- for (const reporter of this.#reporters) handleIssue(reporter, issue, reportOptions);
2179
- }
2180
- info(...params) {
2181
- for (const reporter of this.#reporters) reporter.info(...params);
2182
- }
2183
- debug(...params) {
2184
- for (const reporter of this.#reporters) reporter.debug(...params);
2185
- }
2186
- error(...params) {
2187
- for (const reporter of this.#reporters) reporter.error(...params);
2188
- }
2189
- progress(...params) {
2190
- for (const reporter of this.#reporters) reporter.progress(...params);
2191
- }
2192
- async result(result) {
2193
- await Promise.all(this.#reporters.map((reporter) => reporter.result?.(result)));
2194
- }
2195
- get features() {
2196
- return {
2197
- unknownWords: true,
2198
- issueType: true
2199
- };
2200
- }
2201
- async loadReportersAndFinalize(reporters) {
2202
- assert(!this.#finalized, "Cannot change the configuration of a finalized reporter");
2203
- const loaded = await loadReporters(reporters, this.defaultReporter, this.config);
2204
- this.#reporters = [...new Set(loaded)].map((reporter) => finalizeReporter(reporter));
2205
- }
2206
- emitProgressBegin(filename, fileNum, fileCount) {
2207
- this.progress({
2208
- type: "ProgressFileBegin",
2209
- fileNum,
2210
- fileCount,
2211
- filename
2212
- });
2213
- }
2214
- emitProgressComplete(filename, fileNum, fileCount, result) {
2215
- const numIssues = result.issues.filter((issue) => filterFeatureIssues({}, issue, result.reportIssueOptions)).length;
2216
- for (const reporter of this.#reporters) {
2217
- const progress = clean({
2218
- type: "ProgressFileComplete",
2219
- fileNum,
2220
- fileCount,
2221
- filename,
2222
- elapsedTimeMs: result.elapsedTimeMs,
2223
- processed: result.processed,
2224
- skippedReason: result.skippedReason,
2225
- numErrors: numIssues || result.errors,
2226
- cached: result.cached,
2227
- perf: result.perf,
2228
- issues: reporter.features && result.issues,
2229
- reportIssueOptions: reporter.features && result.reportIssueOptions
2230
- });
2231
- reporter.progress(progress);
2232
- }
2233
- result.issues.forEach((issue) => this.issue(issue, result.reportIssueOptions));
2234
- return numIssues;
2235
- }
2236
- };
2237
-
2238
2284
  //#endregion
2239
2285
  //#region src/util/timer.ts
2240
2286
  function getTimeMeasurer() {
@@ -2252,11 +2298,11 @@ function getTimeMeasurer() {
2252
2298
  * @returns
2253
2299
  */
2254
2300
  function indent(str, padding, firstLinePadding = "") {
2255
- let pad$1 = firstLinePadding;
2301
+ let pad = firstLinePadding;
2256
2302
  const lines = [];
2257
2303
  for (const line of str.split("\n")) {
2258
- lines.push(pad$1 + line);
2259
- pad$1 = padding;
2304
+ lines.push(pad + line);
2305
+ pad = padding;
2260
2306
  }
2261
2307
  return lines.join("\n");
2262
2308
  }
@@ -2302,11 +2348,11 @@ function unindentString(str) {
2302
2348
  //#endregion
2303
2349
  //#region src/util/wrap.ts
2304
2350
  const wrapSep = /\s+|(?<=,)|\.(?=\w)/g;
2305
- function wordWrapAnsiText(str, maxWidth, indent$1 = "", sep$1 = wrapSep) {
2351
+ function wordWrapAnsiText(str, maxWidth, indent = "", sep = wrapSep) {
2306
2352
  if (!maxWidth || maxWidth <= 0) return str;
2307
2353
  if (str.length <= maxWidth) return str;
2308
- if (str.includes("\n")) return str.split("\n").map((line$1) => wordWrapAnsiText(line$1, maxWidth, indent$1)).join("\n");
2309
- const fragments = fragmentString(str, sep$1, "sep");
2354
+ if (str.includes("\n")) return str.split("\n").map((line) => wordWrapAnsiText(line, maxWidth, indent)).join("\n");
2355
+ const fragments = fragmentString(str, sep, "sep");
2310
2356
  const lines = [];
2311
2357
  let line = "";
2312
2358
  for (const text of joinFragments(fragments)) {
@@ -2314,7 +2360,7 @@ function wordWrapAnsiText(str, maxWidth, indent$1 = "", sep$1 = wrapSep) {
2314
2360
  const textWidth = ansiWidth(text);
2315
2361
  if (line && lineWidth + textWidth > maxWidth) {
2316
2362
  if (line) lines.push(line);
2317
- line = indent$1 + text.trimStart();
2363
+ line = indent + text.trimStart();
2318
2364
  continue;
2319
2365
  }
2320
2366
  line += text;
@@ -2351,10 +2397,10 @@ async function writeFileOrStream(filename, data) {
2351
2397
  return fs.writeFile(filename, data);
2352
2398
  }
2353
2399
  function writeStream(stream, data) {
2354
- return new Promise((resolve$1, reject) => {
2400
+ return new Promise((resolve, reject) => {
2355
2401
  stream.write(data, (err) => {
2356
2402
  if (err) reject(err);
2357
- else resolve$1();
2403
+ else resolve();
2358
2404
  });
2359
2405
  });
2360
2406
  }
@@ -2427,23 +2473,21 @@ var LinterError = class extends Error {
2427
2473
 
2428
2474
  //#endregion
2429
2475
  //#region src/lint/processFile.ts
2430
- async function processFile(filename, cache, prefetch$1, processFileOptions) {
2431
- if (prefetch$1?.fileResult) return prefetch$1.fileResult;
2432
- const { reporter, cfg, configInfo, userSettings } = processFileOptions;
2476
+ async function processFile(file, cache, prefetch, processFileOptions) {
2477
+ if (prefetch?.fileResult) return prefetch.fileResult;
2478
+ const { filename } = file;
2479
+ const { cfg, configInfo, userSettings } = processFileOptions;
2433
2480
  const getElapsedTimeMs = getTimeMeasurer();
2434
- const reportIssueOptions = prefetch$1?.reportIssueOptions;
2481
+ const reportIssueOptions = prefetch?.reportIssueOptions;
2435
2482
  const cachedResult = await cache.getCachedLintResults(filename);
2436
- if (cachedResult) {
2437
- reporter.debug(`Filename: ${filename}, using cache`);
2438
- return {
2439
- ...cachedResult,
2440
- elapsedTimeMs: getElapsedTimeMs(),
2441
- reportIssueOptions: {
2442
- ...cachedResult.reportIssueOptions,
2443
- ...reportIssueOptions
2444
- }
2445
- };
2446
- }
2483
+ if (cachedResult) return {
2484
+ ...cachedResult,
2485
+ elapsedTimeMs: getElapsedTimeMs(),
2486
+ reportIssueOptions: {
2487
+ ...cachedResult.reportIssueOptions,
2488
+ ...reportIssueOptions
2489
+ }
2490
+ };
2447
2491
  const result = {
2448
2492
  fileInfo: { filename },
2449
2493
  issues: [],
@@ -2451,9 +2495,11 @@ async function processFile(filename, cache, prefetch$1, processFileOptions) {
2451
2495
  errors: 0,
2452
2496
  configErrors: 0,
2453
2497
  elapsedTimeMs: 0,
2454
- reportIssueOptions
2498
+ reportIssueOptions,
2499
+ reportItems: void 0
2455
2500
  };
2456
- const fileInfo = prefetch$1?.fileInfo || await readFileInfo(filename, void 0, true);
2501
+ const reporter = new ReportItemCollector(result);
2502
+ const fileInfo = prefetch?.fileInfo || await readFileInfo(filename, void 0, true);
2457
2503
  if (fileInfo.errorCode) {
2458
2504
  if (fileInfo.errorCode !== "EISDIR" && cfg.options.mustFindFiles) {
2459
2505
  const err = new LinterError(`File not found: "${filename}"`);
@@ -2486,7 +2532,7 @@ async function processFile(filename, cache, prefetch$1, processFileOptions) {
2486
2532
  result.elapsedTimeMs = getElapsedTimeMs();
2487
2533
  const config = spellResult.settingsUsed ?? {};
2488
2534
  result.reportIssueOptions = mergeReportIssueOptions(spellResult.settingsUsed || configInfo.config, reportIssueOptions);
2489
- result.configErrors += reportSpellingResultConfigErrors(spellResult, processFileOptions);
2535
+ result.configErrors += reportSpellingResultConfigErrors(reporter, spellResult, processFileOptions);
2490
2536
  reportCheckResult(result, doc, spellResult, config, processFileOptions);
2491
2537
  const dep = calcDependencies(config);
2492
2538
  await cache.setCachedLintResults(result, dep.files);
@@ -2500,11 +2546,12 @@ async function processFile(filename, cache, prefetch$1, processFileOptions) {
2500
2546
  }
2501
2547
  }
2502
2548
  function reportCheckResult(result, _doc, spellResult, config, processFileOptions) {
2503
- const { configInfo, reporter, verboseLevel, useColor, cfg, chalk: chalk$1 } = processFileOptions;
2549
+ const { configInfo, verboseLevel, useColor, cfg, chalk } = processFileOptions;
2504
2550
  const elapsed = result.elapsedTimeMs || 0;
2505
2551
  const dictionaries = config.dictionaries || [];
2552
+ const reporter = new ReportItemCollector(result);
2506
2553
  if (verboseLevel > 1) {
2507
- const dictsUsed = [...dictionaries].sort().map((name$1) => chalk$1.green(name$1)).join(", ");
2554
+ const dictsUsed = [...dictionaries].sort().map((name) => chalk.green(name)).join(", ");
2508
2555
  const msg = unindent`
2509
2556
  File type: ${config.languageId}, Language: ${config.language}, Issues: ${result.issues.length} ${elapsed.toFixed(2)}ms
2510
2557
  Config file Used: ${relativeToCwd(spellResult.localConfigFilepath || configInfo.source, cfg.root)}
@@ -2513,7 +2560,7 @@ function reportCheckResult(result, _doc, spellResult, config, processFileOptions
2513
2560
  reporter.info(indent(msg, " "), MessageTypes.Info);
2514
2561
  }
2515
2562
  if (cfg.options.debug) {
2516
- const { enabled, language, languageId, dictionaries: dictionaries$1 } = config;
2563
+ const { enabled, language, languageId, dictionaries } = config;
2517
2564
  const msg = unindent`\
2518
2565
  Debug Config: ${formatWithOptions({
2519
2566
  depth: 2,
@@ -2522,7 +2569,7 @@ function reportCheckResult(result, _doc, spellResult, config, processFileOptions
2522
2569
  languageId,
2523
2570
  enabled,
2524
2571
  language,
2525
- dictionaries: dictionaries$1
2572
+ dictionaries
2526
2573
  })}`;
2527
2574
  reporter.debug(msg);
2528
2575
  }
@@ -2531,11 +2578,11 @@ function calcDependencies(config) {
2531
2578
  const { configFiles, dictionaryFiles } = extractDependencies(config);
2532
2579
  return { files: [...configFiles, ...dictionaryFiles] };
2533
2580
  }
2534
- function reportConfigurationErrors(config, processFileOptions) {
2535
- return reportImportErrors(extractImportErrors(config), processFileOptions);
2581
+ function reportConfigurationErrors(reporter, config, processFileOptions) {
2582
+ return reportImportErrors(reporter, extractImportErrors(config), processFileOptions);
2536
2583
  }
2537
- function reportImportErrors(errors, processFileOptions) {
2538
- const { reporter, configErrors } = processFileOptions;
2584
+ function reportImportErrors(reporter, errors, processFileOptions) {
2585
+ const { configErrors } = processFileOptions;
2539
2586
  let count = 0;
2540
2587
  errors.forEach((ref) => {
2541
2588
  const key = ref.error.toString();
@@ -2546,9 +2593,9 @@ function reportImportErrors(errors, processFileOptions) {
2546
2593
  });
2547
2594
  return count;
2548
2595
  }
2549
- function reportSpellingResultConfigErrors(spellResult, processFileOptions) {
2550
- const { reporter, configErrors } = processFileOptions;
2551
- let count = reportImportErrors(spellResult.configErrors || [], processFileOptions);
2596
+ function reportSpellingResultConfigErrors(reporter, spellResult, processFileOptions) {
2597
+ const { configErrors } = processFileOptions;
2598
+ let count = reportImportErrors(reporter, spellResult.configErrors || [], processFileOptions);
2552
2599
  const dictionaryErrors = [...spellResult.dictionaryErrors || []];
2553
2600
  for (const [dictName, dictErrors] of dictionaryErrors) {
2554
2601
  const msg = `Dictionary Error with (${dictName})`;
@@ -2562,8 +2609,8 @@ function reportSpellingResultConfigErrors(spellResult, processFileOptions) {
2562
2609
  }
2563
2610
  return count;
2564
2611
  }
2565
- function countConfigErrors(configInfo, processFileOptions) {
2566
- return reportConfigurationErrors(configInfo.config, processFileOptions);
2612
+ function countConfigErrors(reporter, configInfo, processFileOptions) {
2613
+ return reportConfigurationErrors(reporter, configInfo.config, processFileOptions);
2567
2614
  }
2568
2615
 
2569
2616
  //#endregion
@@ -2574,9 +2621,9 @@ function* prefetchIterable(iterable, size) {
2574
2621
  for (const value of iterable) {
2575
2622
  buffer.push(value);
2576
2623
  if (buffer.length >= size - 1) {
2577
- const value$1 = buffer[0];
2624
+ const value = buffer[0];
2578
2625
  buffer.shift();
2579
- yield value$1;
2626
+ yield value;
2580
2627
  }
2581
2628
  }
2582
2629
  yield* buffer;
@@ -2640,16 +2687,13 @@ function prefetch(fileToProcess, cfg) {
2640
2687
  })
2641
2688
  };
2642
2689
  const reportIssueOptions = extractReporterIssueOptions(cfg.config);
2643
- async function fetch$1() {
2690
+ async function fetch() {
2644
2691
  const getElapsedTimeMs = getTimeMeasurer();
2645
2692
  const cachedResult = await cfg.cache.getCachedLintResults(filename);
2646
- if (cachedResult) {
2647
- cfg.reporter.debug(`Filename: ${filename}, using cache`);
2648
- return { fileResult: {
2649
- ...cachedResult,
2650
- elapsedTimeMs: getElapsedTimeMs()
2651
- } };
2652
- }
2693
+ if (cachedResult) return { fileResult: {
2694
+ ...cachedResult,
2695
+ elapsedTimeMs: getElapsedTimeMs()
2696
+ } };
2653
2697
  const uri = filenameToUri(filename, cfg.root).href;
2654
2698
  const checkResult = await shouldCheckDocument({ uri }, {}, cfg.config);
2655
2699
  if (!checkResult.shouldCheck) return {
@@ -2668,7 +2712,7 @@ function prefetch(fileToProcess, cfg) {
2668
2712
  reportIssueOptions
2669
2713
  };
2670
2714
  }
2671
- const result = fetch$1().catch((e) => toApplicationError(e));
2715
+ const result = fetch().catch((e) => toApplicationError(e));
2672
2716
  return {
2673
2717
  ...fileToProcess,
2674
2718
  result
@@ -2680,14 +2724,12 @@ async function processFiles(files, options) {
2680
2724
  const failFast = options.cfg.options.failFast ?? options.configInfo.config.failFast ?? false;
2681
2725
  const reporter = options.lintReporter;
2682
2726
  const prefetchConfig = {
2683
- reporter,
2684
2727
  root: options.cfg.root,
2685
2728
  maxFileSize: options.cfg.maxFileSize,
2686
2729
  config: options.configInfo.config,
2687
2730
  cache
2688
2731
  };
2689
2732
  const processFileOptionsGeneral = {
2690
- reporter,
2691
2733
  chalk: options.chalk,
2692
2734
  configInfo: options.configInfo,
2693
2735
  cfg: options.cfg,
@@ -2696,11 +2738,11 @@ async function processFiles(files, options) {
2696
2738
  configErrors: options.configErrors,
2697
2739
  userSettings: options.configInfo.config
2698
2740
  };
2699
- function* prefetchFiles(files$1) {
2700
- yield* prefetchIterable(pipe(files$1, opMap$1((file) => prefetch(file, prefetchConfig))), BATCH_FETCH_SIZE);
2741
+ function* prefetchFiles(files) {
2742
+ yield* prefetchIterable(pipe(files, opMap$1((file) => prefetch(file, prefetchConfig))), BATCH_FETCH_SIZE);
2701
2743
  }
2702
- async function* prefetchFilesAsync(files$1) {
2703
- for await (const file of files$1) yield prefetch(file, prefetchConfig);
2744
+ async function* prefetchFilesAsync(files) {
2745
+ for await (const file of files) yield prefetch(file, prefetchConfig);
2704
2746
  }
2705
2747
  const emptyResult = {
2706
2748
  fileInfo: { filename: "" },
@@ -2709,7 +2751,8 @@ async function processFiles(files, options) {
2709
2751
  errors: 0,
2710
2752
  configErrors: 0,
2711
2753
  elapsedTimeMs: 1,
2712
- reportIssueOptions: void 0
2754
+ reportIssueOptions: void 0,
2755
+ reportItems: void 0
2713
2756
  };
2714
2757
  async function processPrefetchFileResult(pf) {
2715
2758
  const { filename, sequence, sequenceSize, result: pFetchResult } = pf;
@@ -2733,7 +2776,7 @@ async function processFiles(files, options) {
2733
2776
  filename,
2734
2777
  sequence,
2735
2778
  sequenceSize,
2736
- result: await processFile(filename, cache, fetchResult, processFileOptionsGeneral)
2779
+ result: await processFile(pf, cache, fetchResult, processFileOptionsGeneral)
2737
2780
  };
2738
2781
  }
2739
2782
  async function* loadAndProcessFiles() {
@@ -2750,8 +2793,9 @@ async function processFiles(files, options) {
2750
2793
  }
2751
2794
  yield* pipe(prefetchIterable(pipe(prefetchFiles(files), opMap$1(async (pf) => processPrefetchFileResult(pf))), BATCH_PROCESS_SIZE));
2752
2795
  }
2753
- for await (const fileP of loadAndProcessFiles()) {
2754
- const { filename, sequence, sequenceSize, result } = fileP;
2796
+ for await (const processed of loadAndProcessFiles()) {
2797
+ const { filename, sequence, sequenceSize, result } = processed;
2798
+ replayReportItems(result, reporter);
2755
2799
  status.files += 1;
2756
2800
  status.cachedFiles = (status.cachedFiles || 0) + (result.cached ? 1 : 0);
2757
2801
  status.skippedFiles = (status.skippedFiles || 0) + (result.processed ? 0 : 1);
@@ -2787,34 +2831,34 @@ function runResult(init = {}) {
2787
2831
  }
2788
2832
 
2789
2833
  //#endregion
2790
- //#region \0@oxc-project+runtime@0.107.0/helpers/usingCtx.js
2834
+ //#region \0@oxc-project+runtime@0.110.0/helpers/usingCtx.js
2791
2835
  function _usingCtx() {
2792
- var r = "function" == typeof SuppressedError ? SuppressedError : function(r$1, e$1) {
2793
- var n$1 = Error();
2794
- return n$1.name = "SuppressedError", n$1.error = r$1, n$1.suppressed = e$1, n$1;
2836
+ var r = "function" == typeof SuppressedError ? SuppressedError : function(r, e) {
2837
+ var n = Error();
2838
+ return n.name = "SuppressedError", n.error = r, n.suppressed = e, n;
2795
2839
  }, e = {}, n = [];
2796
- function using(r$1, e$1) {
2797
- if (null != e$1) {
2798
- if (Object(e$1) !== e$1) throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");
2799
- if (r$1) var o = e$1[Symbol.asyncDispose || Symbol["for"]("Symbol.asyncDispose")];
2800
- if (void 0 === o && (o = e$1[Symbol.dispose || Symbol["for"]("Symbol.dispose")], r$1)) var t = o;
2840
+ function using(r, e) {
2841
+ if (null != e) {
2842
+ if (Object(e) !== e) throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");
2843
+ if (r) var o = e[Symbol.asyncDispose || Symbol["for"]("Symbol.asyncDispose")];
2844
+ if (void 0 === o && (o = e[Symbol.dispose || Symbol["for"]("Symbol.dispose")], r)) var t = o;
2801
2845
  if ("function" != typeof o) throw new TypeError("Object is not disposable.");
2802
- t && (o = function o$1() {
2846
+ t && (o = function o() {
2803
2847
  try {
2804
- t.call(e$1);
2805
- } catch (r$2) {
2806
- return Promise.reject(r$2);
2848
+ t.call(e);
2849
+ } catch (r) {
2850
+ return Promise.reject(r);
2807
2851
  }
2808
2852
  }), n.push({
2809
- v: e$1,
2853
+ v: e,
2810
2854
  d: o,
2811
- a: r$1
2855
+ a: r
2812
2856
  });
2813
- } else r$1 && n.push({
2814
- d: e$1,
2815
- a: r$1
2857
+ } else r && n.push({
2858
+ d: e,
2859
+ a: r
2816
2860
  });
2817
- return e$1;
2861
+ return e;
2818
2862
  }
2819
2863
  return {
2820
2864
  e,
@@ -2826,17 +2870,17 @@ function _usingCtx() {
2826
2870
  for (; o = n.pop();) try {
2827
2871
  if (!o.a && 1 === s) return s = 0, n.push(o), Promise.resolve().then(next);
2828
2872
  if (o.d) {
2829
- var r$1 = o.d.call(o.v);
2830
- if (o.a) return s |= 2, Promise.resolve(r$1).then(next, err);
2873
+ var r = o.d.call(o.v);
2874
+ if (o.a) return s |= 2, Promise.resolve(r).then(next, err);
2831
2875
  } else s |= 1;
2832
- } catch (r$2) {
2833
- return err(r$2);
2876
+ } catch (r) {
2877
+ return err(r);
2834
2878
  }
2835
2879
  if (1 === s) return t !== e ? Promise.reject(t) : Promise.resolve();
2836
2880
  if (t !== e) throw t;
2837
2881
  }
2838
- function err(n$1) {
2839
- return t = t !== e ? new r(n$1, t) : n$1, next();
2882
+ function err(n) {
2883
+ return t = t !== e ? new r(n, t) : n, next();
2840
2884
  }
2841
2885
  return next();
2842
2886
  }
@@ -2889,7 +2933,7 @@ async function runLint(cfg) {
2889
2933
  header(fileGlobs, excludeGlobs);
2890
2934
  checkGlobs(fileGlobs, reporter);
2891
2935
  if (verboseLevel > 1) reporter.info(`Config Files Found:\n ${relativeToCwd(configInfo.source)}\n`, MessageTypes$1.Info);
2892
- const configErrorCount = countConfigErrors(configInfo, processFileOptions);
2936
+ const configErrorCount = countConfigErrors(reporter, configInfo, processFileOptions);
2893
2937
  if (configErrorCount && cfg.options.exitCode !== false && !cfg.options.continueOnError) return runResult({ errors: configErrorCount });
2894
2938
  const { root } = cfg;
2895
2939
  try {
@@ -2938,7 +2982,6 @@ async function runLint(cfg) {
2938
2982
  }
2939
2983
  function getProcessFileOptions(configInfo) {
2940
2984
  return {
2941
- reporter,
2942
2985
  chalk,
2943
2986
  configInfo,
2944
2987
  cfg,
@@ -2950,7 +2993,7 @@ async function runLint(cfg) {
2950
2993
  }
2951
2994
  }
2952
2995
  function checkGlobs(globs, reporter) {
2953
- globs.filter((g) => g.startsWith("'") || g.endsWith("'")).map((glob$2) => chalk.yellow(glob$2)).forEach((glob$2) => reporter.error("Linter", new CheckFailed(`Glob starting or ending with ' (single quote) is not likely to match any files: ${glob$2}.`)));
2996
+ globs.filter((g) => g.startsWith("'") || g.endsWith("'")).map((glob) => chalk.yellow(glob)).forEach((glob) => reporter.error("Linter", new CheckFailed(`Glob starting or ending with ' (single quote) is not likely to match any files: ${glob}.`)));
2954
2997
  }
2955
2998
  async function determineGlobs(configInfo, cfg) {
2956
2999
  const useGitignore = cfg.options.gitignore ?? configInfo.config.useGitignore ?? false;
@@ -3019,22 +3062,22 @@ async function determineFilesToCheck(configInfo, cfg, reporter, globInfo) {
3019
3062
  const absFilename = path$1.resolve(root, filename);
3020
3063
  const r = globMatcherExclude.matchEx(absFilename);
3021
3064
  if (r.matched) {
3022
- const { glob: glob$2, source } = extractGlobSource(r.pattern);
3023
- if (calcVerboseLevel(cfg.options) > 1) reporter.info(`Excluded File: ${path$1.relative(root, absFilename)}; Excluded by ${glob$2} from ${source}`, MessageTypes$1.Info);
3065
+ const { glob, source } = extractGlobSource(r.pattern);
3066
+ if (calcVerboseLevel(cfg.options) > 1) reporter.info(`Excluded File: ${path$1.relative(root, absFilename)}; Excluded by ${glob} from ${source}`, MessageTypes$1.Info);
3024
3067
  }
3025
3068
  return r.matched;
3026
3069
  }
3027
3070
  function filterOutExcludedFilesFn(globMatcherExclude) {
3028
- const excludeInfo = globMatcherExclude.patterns.map(extractGlobSource).map(({ glob: glob$2, source }) => `Glob: ${glob$2} from ${source}`).filter(uniqueFn());
3071
+ const excludeInfo = globMatcherExclude.patterns.map(extractGlobSource).map(({ glob, source }) => `Glob: ${glob} from ${source}`).filter(uniqueFn());
3029
3072
  if (calcVerboseLevel(cfg.options) > 1) reporter.info(`Exclusion Globs: \n ${excludeInfo.join("\n ")}\n`, MessageTypes$1.Info);
3030
3073
  return (filename) => !isExcluded(filename, globMatcherExclude);
3031
3074
  }
3032
3075
  return _determineFilesToCheck();
3033
3076
  }
3034
3077
  function extractGlobSource(g) {
3035
- const { glob: glob$2, rawGlob, source } = g;
3078
+ const { glob, rawGlob, source } = g;
3036
3079
  return {
3037
- glob: rawGlob || glob$2,
3080
+ glob: rawGlob || glob,
3038
3081
  source
3039
3082
  };
3040
3083
  }
@@ -3149,7 +3192,7 @@ var LintRequest = class {
3149
3192
  function mergeFiles(a, b) {
3150
3193
  const files = merge(a, b);
3151
3194
  if (!files) return void 0;
3152
- return [...new Set(files.flatMap((a$1) => a$1.split("\n").map((a$2) => a$2.trim())).filter((a$1) => !!a$1))];
3195
+ return [...new Set(files.flatMap((a) => a.split("\n").map((a) => a.trim())).filter((a) => !!a))];
3153
3196
  }
3154
3197
  function merge(a, b) {
3155
3198
  if (!a) return b;
@@ -3223,8 +3266,8 @@ var SimpleRepl = class {
3223
3266
  this.rl.on("history", (h) => (this._history = h, void 0));
3224
3267
  }
3225
3268
  question(query) {
3226
- return new Promise((resolve$1) => {
3227
- this.rl.question(query, resolve$1);
3269
+ return new Promise((resolve) => {
3270
+ this.rl.question(query, resolve);
3228
3271
  });
3229
3272
  }
3230
3273
  _completer(line) {
@@ -3277,14 +3320,14 @@ function splitList(list) {
3277
3320
  }
3278
3321
  function extractDictionaryLocalesAndFileTypes(config) {
3279
3322
  const map = /* @__PURE__ */ new Map();
3280
- function getDict(name$1) {
3281
- const found = map.get(name$1);
3323
+ function getDict(name) {
3324
+ const found = map.get(name);
3282
3325
  if (found) return found;
3283
3326
  const dict = {
3284
3327
  locales: /* @__PURE__ */ new Set(),
3285
3328
  fileTypes: /* @__PURE__ */ new Set()
3286
3329
  };
3287
- map.set(name$1, dict);
3330
+ map.set(name, dict);
3288
3331
  return dict;
3289
3332
  }
3290
3333
  const languageSettings = config.languageSettings || [];
@@ -3439,4 +3482,4 @@ function parseApplicationFeatureFlags(flags) {
3439
3482
 
3440
3483
  //#endregion
3441
3484
  export { CheckFailed as C, ApplicationError as S, padLeft as _, parseApplicationFeatureFlags as a, pruneAnsiTextStart as b, listDictionaries as c, validateUnitSize as d, unindent as f, tableToLines as g, getReporter as h, lint as i, ReportChoicesAll as l, npmPackage as m, checkText as n, suggestions as o, DEFAULT_CACHE_LOCATION as p, createInit as r, trace as s, IncludeExcludeFlag as t, cvtLinterCliCommandOptionsToLinterCliOptions as u, padWidth as v, console as w, width as x, pruneAnsiTextEnd as y };
3442
- //# sourceMappingURL=application-DaQrXF9X.js.map
3485
+ //# sourceMappingURL=application-DxeSY2Ho.js.map