cspell 9.2.1 → 9.2.2
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/README.md +3 -3
- package/dist/esm/app.d.ts +1 -1
- package/dist/esm/app.js +36 -68
- package/dist/esm/{application-BZlf5spr.js → application-2V_0BiNj.js} +94 -189
- package/dist/esm/{application-D8WjsMdV.d.ts → application-DDngbSV7.d.ts} +3 -3
- package/dist/esm/application.d.ts +2 -2
- package/dist/esm/application.js +1 -1
- package/dist/esm/index.d.ts +2 -6
- package/dist/esm/index.js +1 -1
- package/dist/esm/{options-ChaXtdFn.d.ts → options-D_a-jMcz.d.ts} +2 -2
- package/package.json +19 -19
package/README.md
CHANGED
|
@@ -440,7 +440,7 @@ const str = 'goedemorgen'; // <- will NOT be flagged as an error.
|
|
|
440
440
|
|
|
441
441
|
### Ignore
|
|
442
442
|
|
|
443
|
-
_Ignore_ allows you
|
|
443
|
+
_Ignore_ allows you to specify a list of words you want to ignore within the document.
|
|
444
444
|
|
|
445
445
|
```javascript
|
|
446
446
|
// cspell:ignore zaallano, wooorrdd
|
|
@@ -648,7 +648,7 @@ export default defineConfig({
|
|
|
648
648
|
// Including "spanish" in the list of dictionaries means both Spanish and English
|
|
649
649
|
// words will be considered correct.
|
|
650
650
|
"dictionaries": ["spanish", "ruby", "corp-terms", "fonts"],
|
|
651
|
-
// Define each dictionary.
|
|
651
|
+
// Define each dictionary. Relative paths are relative to the config file.
|
|
652
652
|
"dictionaryDefinitions": [
|
|
653
653
|
{ "name": "spanish", "path": "./spanish-words.txt"},
|
|
654
654
|
{ "name": "ruby", "path": "./ruby.txt"},
|
|
@@ -716,7 +716,7 @@ The spell checker includes a set of default dictionaries.
|
|
|
716
716
|
- **useCompounds** - allow compound words
|
|
717
717
|
|
|
718
718
|
```javascript
|
|
719
|
-
// Define each dictionary.
|
|
719
|
+
// Define each dictionary. Relative paths are relative to the config file.
|
|
720
720
|
"dictionaryDefinitions": [
|
|
721
721
|
{ "name": "spanish", "path": "./spanish-words.txt"},
|
|
722
722
|
{ "name": "ruby", "path": "./ruby.txt"},
|
package/dist/esm/app.d.ts
CHANGED
package/dist/esm/app.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as parseApplicationFeatureFlags, c as listDictionaries, d as npmPackage, h as console, i as lint, l as ReportChoicesAll, m as CheckFailed, n as checkText, o as suggestions, p as ApplicationError, r as createInit, s as trace, t as IncludeExcludeFlag, u as DEFAULT_CACHE_LOCATION } from "./application-2V_0BiNj.js";
|
|
2
2
|
import { Option, program } from "commander";
|
|
3
3
|
import { satisfies } from "semver";
|
|
4
4
|
import chalk from "chalk";
|
|
@@ -19,8 +19,7 @@ function commandCheck(prog) {
|
|
|
19
19
|
try {
|
|
20
20
|
const result = await checkText(filename, options);
|
|
21
21
|
for (const item of result.items) {
|
|
22
|
-
const
|
|
23
|
-
const t = fn(item.text);
|
|
22
|
+
const t = (item.flagIE === IncludeExcludeFlag.EXCLUDE ? chalk.gray : item.isError ? chalk.red : chalk.whiteBright)(item.text);
|
|
24
23
|
process.stdout.write(t);
|
|
25
24
|
issueCount += item.isError ? 1 : 0;
|
|
26
25
|
}
|
|
@@ -31,10 +30,7 @@ function commandCheck(prog) {
|
|
|
31
30
|
}
|
|
32
31
|
console.log();
|
|
33
32
|
}
|
|
34
|
-
if (issueCount)
|
|
35
|
-
const exitCode = useExitCode ?? true ? 1 : 0;
|
|
36
|
-
throw new CheckFailed("Issues found", exitCode);
|
|
37
|
-
}
|
|
33
|
+
if (issueCount) throw new CheckFailed("Issues found", useExitCode ?? true ? 1 : 0);
|
|
38
34
|
});
|
|
39
35
|
}
|
|
40
36
|
|
|
@@ -102,8 +98,7 @@ function pruneTextEnd(str, maxWidth$2, pad$1 = "…") {
|
|
|
102
98
|
if (!maxWidth$2 || maxWidth$2 <= 0) return str;
|
|
103
99
|
if (str.length <= maxWidth$2) return str;
|
|
104
100
|
if (isAnsiString(str)) return pruneAnsiTextEnd(str, maxWidth$2, pad$1);
|
|
105
|
-
const
|
|
106
|
-
const maxWidthWithPad = maxWidth$2 - padWidth$1;
|
|
101
|
+
const maxWidthWithPad = maxWidth$2 - width(pad$1);
|
|
107
102
|
const letters = [...str];
|
|
108
103
|
let len = 0;
|
|
109
104
|
for (let i = 0; i < letters.length; i++) {
|
|
@@ -127,8 +122,7 @@ function pruneTextEnd(str, maxWidth$2, pad$1 = "…") {
|
|
|
127
122
|
function pruneTextStart(str, maxWidth$2, pad$1 = "…") {
|
|
128
123
|
if (!maxWidth$2 || maxWidth$2 <= 0) return str;
|
|
129
124
|
if (str.length <= maxWidth$2) return str;
|
|
130
|
-
const
|
|
131
|
-
const maxWidthWithPad = maxWidth$2 - padWidth$1;
|
|
125
|
+
const maxWidthWithPad = maxWidth$2 - width(pad$1);
|
|
132
126
|
const letters = [...str];
|
|
133
127
|
let len = 0;
|
|
134
128
|
for (let i = letters.length - 1; i >= 1; i--) {
|
|
@@ -176,8 +170,7 @@ function pruneAnsiTextEnd(str, maxWidth$2, pad$1 = "…") {
|
|
|
176
170
|
if (ansiWidth(str) <= maxWidth$2) return str;
|
|
177
171
|
const padWidth$1 = ansiWidth(pad$1);
|
|
178
172
|
const fragments = parseAnsiStr(str);
|
|
179
|
-
|
|
180
|
-
let remaining = maxWidthWithPad;
|
|
173
|
+
let remaining = maxWidth$2 - padWidth$1;
|
|
181
174
|
for (const frag of fragments) {
|
|
182
175
|
if (frag.type !== "text") continue;
|
|
183
176
|
if (remaining <= 0) {
|
|
@@ -207,8 +200,7 @@ function pruneAnsiTextStart(str, maxWidth$2, pad$1 = "…") {
|
|
|
207
200
|
if (ansiWidth(str) <= maxWidth$2) return str;
|
|
208
201
|
const padWidth$1 = ansiWidth(pad$1);
|
|
209
202
|
const fragments = parseAnsiStr(str);
|
|
210
|
-
|
|
211
|
-
let remaining = maxWidthWithPad;
|
|
203
|
+
let remaining = maxWidth$2 - padWidth$1;
|
|
212
204
|
for (const frag of fragments.reverse()) {
|
|
213
205
|
if (frag.type !== "text") continue;
|
|
214
206
|
if (remaining <= 0) {
|
|
@@ -242,8 +234,7 @@ function tableToLines(table, deliminator) {
|
|
|
242
234
|
function getCellFromRow(row, col) {
|
|
243
235
|
if (!row) return void 0;
|
|
244
236
|
if (Array.isArray(row)) return row[col];
|
|
245
|
-
|
|
246
|
-
return row[fieldName];
|
|
237
|
+
return row[columnFieldNames[col]];
|
|
247
238
|
}
|
|
248
239
|
function rowToCells(row) {
|
|
249
240
|
if (Array.isArray(row)) return row;
|
|
@@ -368,14 +359,10 @@ function formatDictionaryLocation(dictSource, maxWidth$2, { cwd, dictionaryPathF
|
|
|
368
359
|
const idxNodeModule = relPath.lastIndexOf("node_modules");
|
|
369
360
|
const isNodeModule = idxNodeModule >= 0;
|
|
370
361
|
if (format$1 === "hide") return "";
|
|
371
|
-
if (format$1 === "short")
|
|
372
|
-
const prefix = isNodeModule ? "[node_modules]/" : relPath.startsWith(".." + iPath$1.sep + "..") ? "…/" : relPath.startsWith(".." + iPath$1.sep) ? "../" : "";
|
|
373
|
-
return prefix + iPath$1.basename(dictSource);
|
|
374
|
-
}
|
|
362
|
+
if (format$1 === "short") return (isNodeModule ? "[node_modules]/" : relPath.startsWith(".." + iPath$1.sep + "..") ? "…/" : relPath.startsWith(".." + iPath$1.sep) ? "../" : "") + iPath$1.basename(dictSource);
|
|
375
363
|
if (format$1 === "full") return dictSource;
|
|
376
364
|
relPath = isNodeModule ? relPath.slice(idxNodeModule) : relPath;
|
|
377
|
-
|
|
378
|
-
return trimMidPath(usePath, maxWidth$2, iPath$1.sep);
|
|
365
|
+
return trimMidPath(relPath.length < dictSource.length ? relPath : dictSource, maxWidth$2, iPath$1.sep);
|
|
379
366
|
}
|
|
380
367
|
|
|
381
368
|
//#endregion
|
|
@@ -394,20 +381,17 @@ function calcListDictsResultsReport(results, options) {
|
|
|
394
381
|
else if (options.color === false) chalk.level = 0;
|
|
395
382
|
const col = new Intl.Collator();
|
|
396
383
|
results.sort((a, b) => col.compare(a.name, b.name));
|
|
397
|
-
const header = calcHeaders(options);
|
|
398
|
-
const rows = results.map((r) => dictTableRowToTableRow(emitDictResult(r, options)));
|
|
399
|
-
const t = tableToLines({
|
|
400
|
-
header,
|
|
401
|
-
rows,
|
|
402
|
-
terminalWidth: options.lineWidth || process.stdout.columns || maxWidth$1,
|
|
403
|
-
deliminator: " ",
|
|
404
|
-
maxColumnWidths: {
|
|
405
|
-
locales: 12,
|
|
406
|
-
fileTypes: 40
|
|
407
|
-
}
|
|
408
|
-
});
|
|
409
384
|
return {
|
|
410
|
-
table:
|
|
385
|
+
table: tableToLines({
|
|
386
|
+
header: calcHeaders(options),
|
|
387
|
+
rows: results.map((r) => dictTableRowToTableRow(emitDictResult(r, options))),
|
|
388
|
+
terminalWidth: options.lineWidth || process.stdout.columns || maxWidth$1,
|
|
389
|
+
deliminator: " ",
|
|
390
|
+
maxColumnWidths: {
|
|
391
|
+
locales: 12,
|
|
392
|
+
fileTypes: 40
|
|
393
|
+
}
|
|
394
|
+
}).map((line) => line.trimEnd()).join("\n"),
|
|
411
395
|
errors: ""
|
|
412
396
|
};
|
|
413
397
|
}
|
|
@@ -484,8 +468,7 @@ function commandDictionaries(prog) {
|
|
|
484
468
|
]).default("long", "Display most of the path.")).addOption(crOpt("--enabled", "Show only enabled dictionaries.").default(void 0)).addOption(crOpt("--no-enabled", "Do not show enabled dictionaries.")).option("--locale <locale>", "Set language locales. i.e. \"en,fr\" for English and French, or \"en-GB\" for British English.").option("--file-type <fileType>", "File type to use. i.e. \"html\", \"golang\", or \"javascript\".").option("--no-show-location", "Do not show the location of the dictionary.").option("--show-file-types", "Show the file types supported by the dictionary.", false).addOption(crOpt("--no-show-file-types", "Do not show the file types supported by the dictionary.").hideHelp()).option("--show-locales", "Show the language locales supported by the dictionary.", false).addOption(crOpt("--no-show-locales", "Do not show the locales supported by the dictionary.").hideHelp()).addOption(crOpt("--color", "Force color.").default(void 0)).addOption(crOpt("--no-color", "Turn off color.").default(void 0)).addOption(crOpt("--default-configuration", "Load the default configuration and dictionaries.").hideHelp()).addOption(crOpt("--no-default-configuration", "Do not load the default configuration and dictionaries.")).action(async (options) => {
|
|
485
469
|
const dictionaryPathFormat = isDictionaryPathFormat(options.pathFormat) ? options.pathFormat : "long";
|
|
486
470
|
const useColor = canUseColor(options.color);
|
|
487
|
-
|
|
488
|
-
emitListDictionariesResults(listResult, {
|
|
471
|
+
emitListDictionariesResults(await listDictionaries(options), {
|
|
489
472
|
cwd: process.cwd(),
|
|
490
473
|
dictionaryPathFormat,
|
|
491
474
|
color: useColor,
|
|
@@ -497,7 +480,7 @@ function commandDictionaries(prog) {
|
|
|
497
480
|
//#endregion
|
|
498
481
|
//#region src/commandInit.ts
|
|
499
482
|
function commandInit(prog) {
|
|
500
|
-
|
|
483
|
+
return prog.command("init").description("Initialize a CSpell configuration file.").addOption(crOpt("-c, --config <path>", "Path to the CSpell configuration file. Conflicts with --output and --format.").conflicts(["output", "format"])).option("-o, --output <path>", "Define where to write file.").addOption(crOpt("--format <format>", "Define the format of the file.").choices([
|
|
501
484
|
"yaml",
|
|
502
485
|
"yml",
|
|
503
486
|
"json",
|
|
@@ -505,7 +488,6 @@ function commandInit(prog) {
|
|
|
505
488
|
]).default("yaml")).option("--import <path|package>", "Import a configuration file or dictionary package.", collect).option("--locale <locale>", "Define the locale to use when spell checking (e.g., en, en-US, de).").addOption(crOpt("--dictionary <dictionary>", "Enable a dictionary. Can be used multiple times.", collect).default(void 0)).addOption(crOpt("--comments", "Add comments to the config file.").default(void 0).hideHelp()).option("--no-comments", "Do not add comments to the config file.").addOption(crOpt("--remove-comments", "Remove all comments from the config file.").implies({ comments: false })).option("--no-schema", "Do not add the schema reference to the config file.").option("--stdout", "Write the configuration to stdout instead of a file.").action((options) => {
|
|
506
489
|
return createInit(options);
|
|
507
490
|
});
|
|
508
|
-
return command;
|
|
509
491
|
}
|
|
510
492
|
|
|
511
493
|
//#endregion
|
|
@@ -555,9 +537,7 @@ function addPathsToGlobalImportsResultToTable(results) {
|
|
|
555
537
|
function commandLink(prog) {
|
|
556
538
|
const linkCommand = prog.command("link").description("Link dictionaries and other settings to the cspell global config.");
|
|
557
539
|
linkCommand.command("list", { isDefault: true }).alias("ls").description("List currently linked configurations.").action(async () => {
|
|
558
|
-
|
|
559
|
-
const table = listGlobalImportsResultToTable(imports.list);
|
|
560
|
-
tableToLines(table).forEach((line) => console.log(line));
|
|
540
|
+
tableToLines(listGlobalImportsResultToTable((await listGlobalImports()).list)).forEach((line) => console.log(line));
|
|
561
541
|
});
|
|
562
542
|
linkCommand.command("add <dictionaries...>").alias("a").description("Add dictionaries any other settings to the cspell global config.").action(async (dictionaries) => {
|
|
563
543
|
const r = await addPathsToGlobalImports(dictionaries);
|
|
@@ -696,10 +676,7 @@ function commandLint(prog) {
|
|
|
696
676
|
throw new CheckFailed("outputHelp", 1);
|
|
697
677
|
}
|
|
698
678
|
if (result.errors || mustFindFiles && !result.files) throw new CheckFailed("check failed", 1);
|
|
699
|
-
if (result.issues)
|
|
700
|
-
const exitCode = useExitCode ? 1 : 0;
|
|
701
|
-
throw new CheckFailed("check failed", exitCode);
|
|
702
|
-
}
|
|
679
|
+
if (result.issues) throw new CheckFailed("check failed", useExitCode ? 1 : 0);
|
|
703
680
|
});
|
|
704
681
|
return spellCheckCommand;
|
|
705
682
|
}
|
|
@@ -784,8 +761,7 @@ function emitSuggestionResult(result, options) {
|
|
|
784
761
|
...s,
|
|
785
762
|
w: handleRtl(s.compoundWord || s.wordAdjustedToMatchCase || s.word)
|
|
786
763
|
}));
|
|
787
|
-
const
|
|
788
|
-
const maxWidth$2 = sugWidths.reduce((max, len) => Math.max(max, len), 0);
|
|
764
|
+
const maxWidth$2 = mappedSugs.map((s) => width(s.w)).reduce((max, len) => Math.max(max, len), 0);
|
|
789
765
|
for (const sug of mappedSugs) {
|
|
790
766
|
const { cost, dictionaries, w } = sug;
|
|
791
767
|
const padding = " ".repeat(padWidth(w, maxWidth$2));
|
|
@@ -876,16 +852,13 @@ function calcTraceResultsReport(word, found, results, options) {
|
|
|
876
852
|
const col = new Intl.Collator();
|
|
877
853
|
results.sort((a, b) => col.compare(a.dictName, b.dictName));
|
|
878
854
|
options.showWordFound && console.log(`${options.prefix || ""}${word}: ${found ? "Found" : "Not Found"}`);
|
|
879
|
-
const header = emitHeader(options.dictionaryPathFormat !== "hide");
|
|
880
|
-
const rows = results.map((r) => emitTraceResult(r, options));
|
|
881
|
-
const t = tableToLines({
|
|
882
|
-
header,
|
|
883
|
-
rows,
|
|
884
|
-
terminalWidth: options.lineWidth || process.stdout.columns || maxWidth,
|
|
885
|
-
deliminator: " "
|
|
886
|
-
});
|
|
887
855
|
return {
|
|
888
|
-
table:
|
|
856
|
+
table: tableToLines({
|
|
857
|
+
header: emitHeader(options.dictionaryPathFormat !== "hide"),
|
|
858
|
+
rows: results.map((r) => emitTraceResult(r, options)),
|
|
859
|
+
terminalWidth: options.lineWidth || process.stdout.columns || maxWidth,
|
|
860
|
+
deliminator: " "
|
|
861
|
+
}).map((line) => line.trimEnd()).join("\n"),
|
|
889
862
|
errors: emitErrors(results).join("\n")
|
|
890
863
|
};
|
|
891
864
|
}
|
|
@@ -900,15 +873,13 @@ function emitHeader(location) {
|
|
|
900
873
|
}
|
|
901
874
|
function emitTraceResult(r, options) {
|
|
902
875
|
const errors = !!r.errors?.length;
|
|
903
|
-
const
|
|
904
|
-
const cWord = word.replaceAll("+", chalk.yellow("+"));
|
|
876
|
+
const cWord = (r.foundWord || r.word).replaceAll("+", chalk.yellow("+"));
|
|
905
877
|
const sug = r.preferredSuggestions?.map((s) => chalk.yellowBright(s)).join(", ") || "";
|
|
906
878
|
const w = (r.forbidden ? chalk.red(cWord) : chalk.green(cWord)) + (sug ? `->(${sug})` : "");
|
|
907
879
|
const f = calcFoundChar(r);
|
|
908
880
|
const a = r.dictActive ? "*" : " ";
|
|
909
881
|
const dictName = r.dictName.slice(0, colWidthDictionaryName - 1) + a;
|
|
910
|
-
const
|
|
911
|
-
const n = dictColor(dictName);
|
|
882
|
+
const n = (r.dictActive ? chalk.yellowBright : chalk.rgb(200, 128, 50))(dictName);
|
|
912
883
|
const c = colorize(errors ? chalk.red : chalk.white);
|
|
913
884
|
return [
|
|
914
885
|
w,
|
|
@@ -921,8 +892,7 @@ function emitTraceResult(r, options) {
|
|
|
921
892
|
];
|
|
922
893
|
}
|
|
923
894
|
function emitErrors(results) {
|
|
924
|
-
|
|
925
|
-
return errorResults.map((r) => {
|
|
895
|
+
return results.filter((r) => r.errors?.length).map((r) => {
|
|
926
896
|
const errors = r.errors?.map((e) => e.message)?.join("\n ") || "";
|
|
927
897
|
return chalk.bold(r.dictName) + "\n " + chalk.red(errors);
|
|
928
898
|
});
|
|
@@ -962,8 +932,7 @@ function commandTrace(prog) {
|
|
|
962
932
|
for await (const results of trace(words, options)) {
|
|
963
933
|
const byWord = groupBy(results, (r) => r.word);
|
|
964
934
|
for (const split of results.splits) {
|
|
965
|
-
const
|
|
966
|
-
const filtered = filterTraceResults(splitResults, options);
|
|
935
|
+
const filtered = filterTraceResults(byWord.get(split.word) || [], options);
|
|
967
936
|
emitTraceResults(split.word, split.found, filtered, {
|
|
968
937
|
cwd: process.cwd(),
|
|
969
938
|
dictionaryPathFormat,
|
|
@@ -973,8 +942,7 @@ function commandTrace(prog) {
|
|
|
973
942
|
});
|
|
974
943
|
prefix = "\n";
|
|
975
944
|
numFound += results.reduce((n, r) => n + (r.found ? 1 : 0), 0);
|
|
976
|
-
|
|
977
|
-
if (numErrors) {
|
|
945
|
+
if (results.map((r) => r.errors?.length || 0).reduce((n, r) => n + r, 0)) {
|
|
978
946
|
console.error("Dictionary Errors.");
|
|
979
947
|
throw new CheckFailed("dictionary errors", 1);
|
|
980
948
|
}
|
|
@@ -53,8 +53,7 @@ var Console = class {
|
|
|
53
53
|
};
|
|
54
54
|
const console = new Console();
|
|
55
55
|
function getColorLevel(stream) {
|
|
56
|
-
|
|
57
|
-
switch (depth) {
|
|
56
|
+
switch (stream.getColorDepth?.() || 0) {
|
|
58
57
|
case 1: return 1;
|
|
59
58
|
case 4: return 2;
|
|
60
59
|
case 24: return 3;
|
|
@@ -105,8 +104,7 @@ function isError(e) {
|
|
|
105
104
|
function isErrorLike(e) {
|
|
106
105
|
if (e instanceof Error) return true;
|
|
107
106
|
if (!e || typeof e !== "object") return false;
|
|
108
|
-
|
|
109
|
-
return typeof ex.message === "string";
|
|
107
|
+
return typeof e.message === "string";
|
|
110
108
|
}
|
|
111
109
|
function toApplicationError(e, message) {
|
|
112
110
|
if (e instanceof ApplicationError && !message) return e;
|
|
@@ -185,12 +183,9 @@ function reportProgress(io, p, cwdURL, options) {
|
|
|
185
183
|
}
|
|
186
184
|
function determineFilename(io, p, cwd) {
|
|
187
185
|
const fc = "" + p.fileCount;
|
|
188
|
-
const fn = (" ".repeat(fc.length) + p.fileNum).slice(-fc.length);
|
|
189
|
-
const idx = fn + "/" + fc;
|
|
190
|
-
const filename = io.chalk.gray(relativeUriFilename(p.filename, cwd));
|
|
191
186
|
return {
|
|
192
|
-
idx,
|
|
193
|
-
filename
|
|
187
|
+
idx: (" ".repeat(fc.length) + p.fileNum).slice(-fc.length) + "/" + fc,
|
|
188
|
+
filename: io.chalk.gray(relativeUriFilename(p.filename, cwd))
|
|
194
189
|
};
|
|
195
190
|
}
|
|
196
191
|
function reportProgressFileBegin(io, p, cwdURL) {
|
|
@@ -206,16 +201,14 @@ function reportProgressFileComplete(io, p, cwd, options) {
|
|
|
206
201
|
const time = reportTime(io, p.elapsedTimeMs, !!p.cached);
|
|
207
202
|
const skipped = p.processed === false ? " skipped" : "";
|
|
208
203
|
const hasErrors = p.numErrors ? io.chalk.red` X` : "";
|
|
209
|
-
const
|
|
210
|
-
const msg = `${idx} ${filename} ${time}${skipped}${hasErrors}${newLine || "\r"}`;
|
|
204
|
+
const msg = `${idx} ${filename} ${time}${skipped}${hasErrors}${(skipped && (verbose || debug) || hasErrors || isSlow(p.elapsedTimeMs) || io.getColorLevel() < 1 ? "\n" : "") || "\r"}`;
|
|
211
205
|
io.write(msg);
|
|
212
206
|
}
|
|
213
207
|
function reportTime(io, elapsedTimeMs, cached) {
|
|
214
208
|
if (cached) return io.chalk.green("cached");
|
|
215
209
|
if (elapsedTimeMs === void 0) return "-";
|
|
216
210
|
const slow = isSlow(elapsedTimeMs);
|
|
217
|
-
|
|
218
|
-
return color(elapsedTimeMs.toFixed(2) + "ms");
|
|
211
|
+
return (!slow ? io.chalk.white : slow === 1 ? io.chalk.yellow : io.chalk.redBright)(elapsedTimeMs.toFixed(2) + "ms");
|
|
219
212
|
}
|
|
220
213
|
function isSlow(elapsedTmeMs) {
|
|
221
214
|
if (!elapsedTmeMs || elapsedTmeMs < 1e3) return 0;
|
|
@@ -265,12 +258,11 @@ function getReporter(options, config) {
|
|
|
265
258
|
return (i) => {
|
|
266
259
|
const fullFilename = i.uri ? toFilePathOrHref(toFileURL(i.uri, rootURL)) : "";
|
|
267
260
|
const filename = i.uri ? fnFilename(i.uri) : "";
|
|
268
|
-
|
|
261
|
+
fn({
|
|
269
262
|
...i,
|
|
270
263
|
filename,
|
|
271
264
|
fullFilename
|
|
272
|
-
};
|
|
273
|
-
fn(r);
|
|
265
|
+
});
|
|
274
266
|
};
|
|
275
267
|
}
|
|
276
268
|
const issuesCollection = void 0;
|
|
@@ -296,9 +288,7 @@ function getReporter(options, config) {
|
|
|
296
288
|
}
|
|
297
289
|
const cachedFilesText = cachedFiles ? ` (${cachedFiles} from cache)` : "";
|
|
298
290
|
const withErrorsText = errors ? ` with ${errors} error${errors === 1 ? "" : "s"}` : "";
|
|
299
|
-
|
|
300
|
-
const summaryMessage = `CSpell\u003A Files checked: ${files}${cachedFilesText}, Issues found: ${issues$1} in ${numFilesWidthIssuesText}${withErrorsText}.`;
|
|
301
|
-
consoleError(summaryMessage);
|
|
291
|
+
consoleError(`CSpell\u003A Files checked: ${files}${cachedFilesText}, Issues found: ${issues$1} in ${numFilesWithIssues === 1 ? "1 file" : `${numFilesWithIssues} files`}${withErrorsText}.`);
|
|
302
292
|
if (errorCollection?.length && issues$1 > 5) {
|
|
303
293
|
consoleError("-------------------------------------------");
|
|
304
294
|
consoleError("Errors:");
|
|
@@ -376,8 +366,7 @@ function formatIssue(io, templateStr, issue, maxIssueTextWidth) {
|
|
|
376
366
|
$messageColored: messageColored
|
|
377
367
|
};
|
|
378
368
|
const t = templateStr.replaceAll("$messageColored", messageColored);
|
|
379
|
-
|
|
380
|
-
return substitute(chalkTemplate(t), substitutions).trimEnd();
|
|
369
|
+
return substitute(makeTemplate(io.chalk)(t), substitutions).trimEnd();
|
|
381
370
|
}
|
|
382
371
|
function formatSuggestions(io, issue) {
|
|
383
372
|
if (issue.suggestionsEx) return issue.suggestionsEx.map((sug) => sug.isPreferred ? io.chalk.italic(io.chalk.bold(sug.wordAdjustedToMatchCase || sug.word)) + "*" : sug.wordAdjustedToMatchCase || sug.word).join(", ");
|
|
@@ -388,8 +377,7 @@ function formatQuickFix(io, issue) {
|
|
|
388
377
|
if (!issue.suggestionsEx?.length) return "";
|
|
389
378
|
const preferred = issue.suggestionsEx.filter((sug) => sug.isPreferred).map((sug) => sug.wordAdjustedToMatchCase || sug.word);
|
|
390
379
|
if (!preferred.length) return "";
|
|
391
|
-
|
|
392
|
-
return `fix: (${fixes.join(", ")})`;
|
|
380
|
+
return `fix: (${preferred.map((w) => io.chalk.italic(io.chalk.yellow(w))).join(", ")})`;
|
|
393
381
|
}
|
|
394
382
|
function substitute(text, substitutions) {
|
|
395
383
|
const subs = [];
|
|
@@ -415,16 +403,14 @@ function substitute(text, substitutions) {
|
|
|
415
403
|
i = b;
|
|
416
404
|
return prefix + t;
|
|
417
405
|
}
|
|
418
|
-
|
|
419
|
-
return parts.join("") + text.slice(i);
|
|
406
|
+
return subs.map(sub).join("") + text.slice(i);
|
|
420
407
|
}
|
|
421
408
|
function assertCheckTemplate(template) {
|
|
422
409
|
const r = checkTemplate(template);
|
|
423
410
|
if (r instanceof Error) throw r;
|
|
424
411
|
}
|
|
425
412
|
function checkTemplate(template) {
|
|
426
|
-
const
|
|
427
|
-
const chalkTemplate = makeTemplate(chalk$1);
|
|
413
|
+
const chalkTemplate = makeTemplate(new Chalk());
|
|
428
414
|
const substitutions = {
|
|
429
415
|
$col: "<col>",
|
|
430
416
|
$contextFull: "<contextFull>",
|
|
@@ -442,14 +428,11 @@ function checkTemplate(template) {
|
|
|
442
428
|
$messageColored: "<messageColored>"
|
|
443
429
|
};
|
|
444
430
|
try {
|
|
445
|
-
const
|
|
446
|
-
const result = substitute(t, substitutions);
|
|
447
|
-
const problems = [...result.matchAll(/\$[a-z]+/gi)].map((m) => m[0]);
|
|
431
|
+
const problems = [...substitute(chalkTemplate(template), substitutions).matchAll(/\$[a-z]+/gi)].map((m) => m[0]);
|
|
448
432
|
if (problems.length) throw new Error(`Unresolved template variable${problems.length > 1 ? "s" : ""}: ${problems.map((v) => `'${v}'`).join(", ")}`);
|
|
449
433
|
return true;
|
|
450
434
|
} catch (e) {
|
|
451
|
-
|
|
452
|
-
return new ApplicationError(msg);
|
|
435
|
+
return new ApplicationError(e instanceof Error ? e.message : `${e}`);
|
|
453
436
|
}
|
|
454
437
|
}
|
|
455
438
|
|
|
@@ -458,11 +441,9 @@ function checkTemplate(template) {
|
|
|
458
441
|
async function fileExists(url) {
|
|
459
442
|
if (url.protocol !== "file:") return false;
|
|
460
443
|
try {
|
|
461
|
-
|
|
462
|
-
return stats.isFile();
|
|
444
|
+
return (await promises.stat(url)).isFile();
|
|
463
445
|
} catch (e) {
|
|
464
|
-
|
|
465
|
-
if (err.code === "ENOENT") return false;
|
|
446
|
+
if (toError(e).code === "ENOENT") return false;
|
|
466
447
|
throw e;
|
|
467
448
|
}
|
|
468
449
|
}
|
|
@@ -551,8 +532,7 @@ function addDictionariesToConfigFile(configFile, dictionaries, comment) {
|
|
|
551
532
|
if (!found && comment) configFile.setComment("dictionaries", comment);
|
|
552
533
|
return;
|
|
553
534
|
}
|
|
554
|
-
const
|
|
555
|
-
const dicts = settings.dictionaries || [];
|
|
535
|
+
const dicts = configFile.settings.dictionaries || [];
|
|
556
536
|
const knownDicts = new Set(dicts);
|
|
557
537
|
for (const dict of dictionaries) if (!knownDicts.has(dict)) {
|
|
558
538
|
dicts.push(dict);
|
|
@@ -572,8 +552,7 @@ function applyValuesToConfigFile(config, settings, defaultValues, addComments) {
|
|
|
572
552
|
const oldValue = currentSettings[key];
|
|
573
553
|
const value = newValue ?? oldValue ?? defaultValue;
|
|
574
554
|
if (newValue === void 0 && oldValue !== void 0 || value === void 0) continue;
|
|
575
|
-
|
|
576
|
-
setConfigFieldValue(config, key, value, useComment);
|
|
555
|
+
setConfigFieldValue(config, key, value, addComments && oldValue === void 0 && comment || void 0);
|
|
577
556
|
}
|
|
578
557
|
return config;
|
|
579
558
|
}
|
|
@@ -674,8 +653,7 @@ const defaultConfigYaml = `
|
|
|
674
653
|
`;
|
|
675
654
|
async function configInit(options) {
|
|
676
655
|
const rw = createReaderWriter();
|
|
677
|
-
const
|
|
678
|
-
const configFile = await createConfigFile(rw, url, options);
|
|
656
|
+
const configFile = await createConfigFile(rw, determineFileNameURL(options), options);
|
|
679
657
|
await applyOptionsToConfigFile(configFile, options);
|
|
680
658
|
await fs.mkdir(new URL("./", configFile.url), { recursive: true });
|
|
681
659
|
if (options.stdout) console.stdoutChannel.write(rw.serialize(configFile));
|
|
@@ -788,7 +766,7 @@ const pkgDir = _dirname;
|
|
|
788
766
|
//#endregion
|
|
789
767
|
//#region src/pkgInfo.ts
|
|
790
768
|
const name = "cspell";
|
|
791
|
-
const version$1 = "9.2.
|
|
769
|
+
const version$1 = "9.2.2";
|
|
792
770
|
const engines = { node: ">=20" };
|
|
793
771
|
const npmPackage = {
|
|
794
772
|
name,
|
|
@@ -822,8 +800,7 @@ const defaultExcludeGlobs = ["node_modules/**"];
|
|
|
822
800
|
*/
|
|
823
801
|
async function globP(pattern, options) {
|
|
824
802
|
const cwd = options?.root || options?.cwd || process.cwd();
|
|
825
|
-
const
|
|
826
|
-
const ignore = ignoreRaw?.filter((g) => !g.startsWith("../"));
|
|
803
|
+
const ignore = (typeof options?.ignore === "string" ? [options.ignore] : options?.ignore)?.filter((g) => !g.startsWith("../"));
|
|
827
804
|
const onlyFiles = options?.nodir;
|
|
828
805
|
const dot = options?.dot;
|
|
829
806
|
const patterns = typeof pattern === "string" ? [pattern] : pattern;
|
|
@@ -837,14 +814,11 @@ async function globP(pattern, options) {
|
|
|
837
814
|
expandDirectories: false
|
|
838
815
|
});
|
|
839
816
|
const compare$1 = new Intl.Collator("en").compare;
|
|
840
|
-
|
|
841
|
-
const relativePaths = absolutePaths.map((absFilename) => path$1.relative(cwd, absFilename));
|
|
842
|
-
return relativePaths;
|
|
817
|
+
return (await glob$1(patterns, useOptions)).sort(compare$1).map((absFilename) => path$1.relative(cwd, absFilename));
|
|
843
818
|
}
|
|
844
819
|
function calcGlobs(commandLineExclude) {
|
|
845
|
-
const globs = new Set((commandLineExclude || []).flatMap((glob$2) => glob$2.split(/(?<!\\)\s+/g)).map((g) => g.replaceAll("\\ ", " ")));
|
|
846
820
|
const commandLineExcludes = {
|
|
847
|
-
globs: [...
|
|
821
|
+
globs: [...new Set((commandLineExclude || []).flatMap((glob$2) => glob$2.split(/(?<!\\)\s+/g)).map((g) => g.replaceAll("\\ ", " ")))],
|
|
848
822
|
source: "arguments"
|
|
849
823
|
};
|
|
850
824
|
const defaultExcludes = {
|
|
@@ -854,7 +828,7 @@ function calcGlobs(commandLineExclude) {
|
|
|
854
828
|
return commandLineExcludes.globs.length ? commandLineExcludes : defaultExcludes;
|
|
855
829
|
}
|
|
856
830
|
function extractPatterns(globs) {
|
|
857
|
-
|
|
831
|
+
return globs.reduce((info, g) => {
|
|
858
832
|
const source = g.source;
|
|
859
833
|
const patterns = g.matcher.patternsNormalizedToRoot;
|
|
860
834
|
return [...info, ...patterns.map((glob$2) => ({
|
|
@@ -862,17 +836,15 @@ function extractPatterns(globs) {
|
|
|
862
836
|
source
|
|
863
837
|
}))];
|
|
864
838
|
}, []);
|
|
865
|
-
return r;
|
|
866
839
|
}
|
|
867
840
|
function calcExcludeGlobInfo(root, commandLineExclude) {
|
|
868
841
|
commandLineExclude = typeof commandLineExclude === "string" ? [commandLineExclude] : commandLineExclude;
|
|
869
842
|
const choice = calcGlobs(commandLineExclude);
|
|
870
|
-
const matcher = new GlobMatcher(choice.globs, {
|
|
871
|
-
root,
|
|
872
|
-
dot: true
|
|
873
|
-
});
|
|
874
843
|
return [{
|
|
875
|
-
matcher,
|
|
844
|
+
matcher: new GlobMatcher(choice.globs, {
|
|
845
|
+
root,
|
|
846
|
+
dot: true
|
|
847
|
+
}),
|
|
876
848
|
source: choice.source
|
|
877
849
|
}];
|
|
878
850
|
}
|
|
@@ -882,14 +854,12 @@ function calcExcludeGlobInfo(root, commandLineExclude) {
|
|
|
882
854
|
* @param root - directory to use as the root
|
|
883
855
|
*/
|
|
884
856
|
function buildGlobMatcher(globs, root, isExclude) {
|
|
885
|
-
|
|
886
|
-
const source = typeof g === "string" ? "command line" : void 0;
|
|
857
|
+
return new GlobMatcher(globs.map((g) => {
|
|
887
858
|
return {
|
|
888
|
-
source,
|
|
859
|
+
source: typeof g === "string" ? "command line" : void 0,
|
|
889
860
|
...fileOrGlobToGlob(g, root)
|
|
890
861
|
};
|
|
891
|
-
})
|
|
892
|
-
return new GlobMatcher(withRoots, {
|
|
862
|
+
}), {
|
|
893
863
|
root,
|
|
894
864
|
mode: isExclude ? "exclude" : "include"
|
|
895
865
|
});
|
|
@@ -898,9 +868,7 @@ function extractGlobsFromMatcher(globMatcher) {
|
|
|
898
868
|
return globMatcher.patternsNormalizedToRoot.map((g) => g.glob);
|
|
899
869
|
}
|
|
900
870
|
function normalizeGlobsToRoot(globs, root, isExclude) {
|
|
901
|
-
|
|
902
|
-
const onlyGlobs = globs.filter((g) => typeof g !== "string" || !isPossibleUrlRegExp.test(g));
|
|
903
|
-
return [urls, extractGlobsFromMatcher(buildGlobMatcher(onlyGlobs, root, isExclude))].flat();
|
|
871
|
+
return [globs.filter((g) => typeof g === "string" && isPossibleUrlRegExp.test(g)), extractGlobsFromMatcher(buildGlobMatcher(globs.filter((g) => typeof g !== "string" || !isPossibleUrlRegExp.test(g)), root, isExclude))].flat();
|
|
904
872
|
}
|
|
905
873
|
const isPossibleGlobRegExp = /[()*?[{}]/;
|
|
906
874
|
const isPossibleUrlRegExp = /^[\d_a-z-]{3,}:\/\//;
|
|
@@ -923,8 +891,7 @@ async function adjustPossibleDirectory(glob$2, root) {
|
|
|
923
891
|
if (isPossibleUrlRegExp.test(g.glob)) return glob$2;
|
|
924
892
|
const dirPath = path$1.resolve(g.root, g.glob);
|
|
925
893
|
try {
|
|
926
|
-
|
|
927
|
-
if (stat$1.isDirectory()) {
|
|
894
|
+
if ((await promises.stat(dirPath)).isDirectory()) {
|
|
928
895
|
const useGlob = posix.join(posixPath(g.glob), "**");
|
|
929
896
|
return typeof glob$2 === "string" ? useGlob : {
|
|
930
897
|
...glob$2,
|
|
@@ -940,8 +907,7 @@ function posixPath(p) {
|
|
|
940
907
|
return path$1.sep === "\\" ? p.replaceAll("\\", "/") : p;
|
|
941
908
|
}
|
|
942
909
|
async function normalizeFileOrGlobsToRoot(globs, root) {
|
|
943
|
-
|
|
944
|
-
return normalizeGlobsToRoot(adjustedGlobs, root, false);
|
|
910
|
+
return normalizeGlobsToRoot(await Promise.all(globs.map((g) => adjustPossibleDirectory(g, root))), root, false);
|
|
945
911
|
}
|
|
946
912
|
function glob$1(patterns, options) {
|
|
947
913
|
patterns = typeof patterns === "string" ? workaroundPicomatchBug(patterns) : patterns.map((g) => workaroundPicomatchBug(g));
|
|
@@ -1017,8 +983,7 @@ function resolveFilename(filename, cwd) {
|
|
|
1017
983
|
}
|
|
1018
984
|
function readFileInfo(filename, encoding = UTF8, handleNotFound = false) {
|
|
1019
985
|
filename = resolveFilename(filename);
|
|
1020
|
-
|
|
1021
|
-
return pText.then((text) => ({
|
|
986
|
+
return (filename.startsWith(STDINProtocol) ? streamConsumers.text(process.stdin) : readFileText(filename, encoding)).then((text) => ({
|
|
1022
987
|
text,
|
|
1023
988
|
filename
|
|
1024
989
|
}), (e) => {
|
|
@@ -1057,14 +1022,11 @@ const resolveFilenames = asyncMap(resolveFilename);
|
|
|
1057
1022
|
*/
|
|
1058
1023
|
function readFileListFiles(listFiles) {
|
|
1059
1024
|
let useStdin = false;
|
|
1060
|
-
|
|
1025
|
+
return asyncPipe(mergeAsyncIterables(asyncPipe(listFiles.filter((file) => {
|
|
1061
1026
|
const isStdin$1 = file === "stdin";
|
|
1062
1027
|
useStdin = useStdin || isStdin$1;
|
|
1063
1028
|
return !isStdin$1;
|
|
1064
|
-
});
|
|
1065
|
-
const found = asyncPipe(files, asyncMap((file) => readFileListFile(file)), asyncAwait(), asyncFlatten());
|
|
1066
|
-
const stdin = useStdin ? readStdin() : [];
|
|
1067
|
-
return asyncPipe(mergeAsyncIterables(found, stdin), resolveFilenames);
|
|
1029
|
+
}), asyncMap((file) => readFileListFile(file)), asyncAwait(), asyncFlatten()), useStdin ? readStdin() : []), resolveFilenames);
|
|
1068
1030
|
}
|
|
1069
1031
|
/**
|
|
1070
1032
|
* Read a `listFile` and return the containing file paths resolved relative to the `listFile`.
|
|
@@ -1075,9 +1037,7 @@ function readFileListFiles(listFiles) {
|
|
|
1075
1037
|
async function readFileListFile(listFile) {
|
|
1076
1038
|
try {
|
|
1077
1039
|
const relTo = path$1.resolve(path$1.dirname(listFile));
|
|
1078
|
-
|
|
1079
|
-
const lines = content.split("\n").map((a) => a.trim()).filter((a) => !!a).map((file) => path$1.resolve(relTo, file));
|
|
1080
|
-
return lines;
|
|
1040
|
+
return (await readFile(listFile)).split("\n").map((a) => a.trim()).filter((a) => !!a).map((file) => path$1.resolve(relTo, file));
|
|
1081
1041
|
} catch (err) {
|
|
1082
1042
|
throw toApplicationError(err, `Error reading file list from: "${listFile}"`);
|
|
1083
1043
|
}
|
|
@@ -1088,16 +1048,14 @@ function isStdin(filename) {
|
|
|
1088
1048
|
async function isFile(filename) {
|
|
1089
1049
|
if (isStdin(filename)) return true;
|
|
1090
1050
|
try {
|
|
1091
|
-
|
|
1092
|
-
return stat$1.isFile();
|
|
1051
|
+
return (await promises.stat(filename)).isFile();
|
|
1093
1052
|
} catch {
|
|
1094
1053
|
return false;
|
|
1095
1054
|
}
|
|
1096
1055
|
}
|
|
1097
1056
|
async function isDir(filename) {
|
|
1098
1057
|
try {
|
|
1099
|
-
|
|
1100
|
-
return stat$1.isDirectory();
|
|
1058
|
+
return (await promises.stat(filename)).isDirectory();
|
|
1101
1059
|
} catch {
|
|
1102
1060
|
return false;
|
|
1103
1061
|
}
|
|
@@ -1166,15 +1124,13 @@ var FlatCache = class {
|
|
|
1166
1124
|
* @returns
|
|
1167
1125
|
*/
|
|
1168
1126
|
function loadCacheFile(cachefile) {
|
|
1169
|
-
|
|
1170
|
-
return cache.load();
|
|
1127
|
+
return new FlatCache(cachefile).load();
|
|
1171
1128
|
}
|
|
1172
1129
|
|
|
1173
1130
|
//#endregion
|
|
1174
1131
|
//#region src/util/cache/file-entry-cache/file-entry-cache.ts
|
|
1175
1132
|
async function createFromFile$1(cacheFileUrl, useChecksum, currentWorkingDir) {
|
|
1176
|
-
const
|
|
1177
|
-
const fec = new ImplFileEntryCache(cache, useChecksum ?? false, currentWorkingDir);
|
|
1133
|
+
const fec = new ImplFileEntryCache(await loadCacheFile(cacheFileUrl), useChecksum ?? false, currentWorkingDir);
|
|
1178
1134
|
await fec.removeNotFoundFiles();
|
|
1179
1135
|
return fec;
|
|
1180
1136
|
}
|
|
@@ -1317,7 +1273,7 @@ var ImplFileEntryCache = class {
|
|
|
1317
1273
|
} catch (error) {
|
|
1318
1274
|
if (!isNodeError(error) || error.code !== "ENOENT") throw error;
|
|
1319
1275
|
}
|
|
1320
|
-
this.cache.save();
|
|
1276
|
+
await this.cache.save();
|
|
1321
1277
|
}
|
|
1322
1278
|
resolveKeyToFile(entryKey) {
|
|
1323
1279
|
if (this.currentWorkingDir) return path.resolve(this.currentWorkingDir, entryKey);
|
|
@@ -1374,17 +1330,11 @@ var ShallowObjectCollection = class {
|
|
|
1374
1330
|
|
|
1375
1331
|
//#endregion
|
|
1376
1332
|
//#region src/util/cache/DiskCache.ts
|
|
1377
|
-
const
|
|
1333
|
+
const META_DATA_VERSION_SUFFIX = "-1-" + Object.keys({
|
|
1378
1334
|
v: "v",
|
|
1379
1335
|
r: "r",
|
|
1380
1336
|
d: "d"
|
|
1381
|
-
};
|
|
1382
|
-
/**
|
|
1383
|
-
* Meta Data Version is used to detect if the structure of the meta data has changed.
|
|
1384
|
-
* This is used in combination with the Suffix and the version of CSpell.
|
|
1385
|
-
*/
|
|
1386
|
-
const META_DATA_BASE_VERSION = "1";
|
|
1387
|
-
const META_DATA_VERSION_SUFFIX = "-" + META_DATA_BASE_VERSION + "-" + Object.keys(cacheDataKeys).join("|");
|
|
1337
|
+
}).join("|");
|
|
1388
1338
|
/**
|
|
1389
1339
|
* Caches cspell results on disk
|
|
1390
1340
|
*/
|
|
@@ -1411,7 +1361,7 @@ var DiskCache = class {
|
|
|
1411
1361
|
const data = meta?.data;
|
|
1412
1362
|
const result = data?.r;
|
|
1413
1363
|
const versionMatches = this.version === data?.v;
|
|
1414
|
-
if (fileDescriptor.notFound || fileDescriptor.changed || !meta || !result || !versionMatches || !await this.checkDependencies(data.d)) return
|
|
1364
|
+
if (fileDescriptor.notFound || fileDescriptor.changed || !meta || !result || !versionMatches || !await this.checkDependencies(data.d)) return;
|
|
1415
1365
|
const dd = { ...data };
|
|
1416
1366
|
if (dd.d) dd.d = setTreeEntry(this.dependencyCacheTree, dd.d);
|
|
1417
1367
|
dd.r = dd.r && this.normalizeResult(dd.r);
|
|
@@ -1430,12 +1380,11 @@ var DiskCache = class {
|
|
|
1430
1380
|
const fileDescriptor = await this.fileEntryCache.getFileDescriptor(fileInfo.filename);
|
|
1431
1381
|
const meta = fileDescriptor.meta;
|
|
1432
1382
|
if (fileDescriptor.notFound || !meta) return;
|
|
1433
|
-
|
|
1383
|
+
meta.data = this.objectCollection.get({
|
|
1434
1384
|
v: this.version,
|
|
1435
1385
|
r: this.normalizeResult(result),
|
|
1436
1386
|
d: await this.calcDependencyHashes(dependsUponFiles)
|
|
1437
1387
|
});
|
|
1438
|
-
meta.data = data;
|
|
1439
1388
|
}
|
|
1440
1389
|
async reconcile() {
|
|
1441
1390
|
await this.fileEntryCache.reconcile();
|
|
@@ -1537,9 +1486,7 @@ async function getDependencyForUrl(remoteUrl) {
|
|
|
1537
1486
|
}
|
|
1538
1487
|
}
|
|
1539
1488
|
async function createDiskCache(cacheFileLocation, useCheckSum, cspellVersion, useUniversalCache) {
|
|
1540
|
-
|
|
1541
|
-
const cache = new DiskCache(cacheFileLocation, useCheckSum, cspellVersion, useUniversalCache, fileEntryCache);
|
|
1542
|
-
return cache;
|
|
1489
|
+
return new DiskCache(cacheFileLocation, useCheckSum, cspellVersion, useUniversalCache, await createFromFile(cacheFileLocation, useCheckSum, useUniversalCache));
|
|
1543
1490
|
}
|
|
1544
1491
|
function getTreeEntry(tree, keys) {
|
|
1545
1492
|
let r = tree;
|
|
@@ -1633,8 +1580,7 @@ async function calcCacheSettings(config, cacheOptions, root) {
|
|
|
1633
1580
|
}
|
|
1634
1581
|
async function resolveCacheLocation(cacheLocation) {
|
|
1635
1582
|
try {
|
|
1636
|
-
|
|
1637
|
-
if (s.isFile()) return cacheLocation;
|
|
1583
|
+
if ((await stat(cacheLocation)).isFile()) return cacheLocation;
|
|
1638
1584
|
return path.join(cacheLocation, DEFAULT_CACHE_LOCATION);
|
|
1639
1585
|
} catch (err) {
|
|
1640
1586
|
if (isErrorLike(err) && err.code === "ENOENT") return cacheLocation;
|
|
@@ -1655,10 +1601,7 @@ function normalizeVersion(version$2) {
|
|
|
1655
1601
|
//#region src/util/configFileHelper.ts
|
|
1656
1602
|
async function readConfig(configFile, root, stopConfigSearchAt) {
|
|
1657
1603
|
configFile ??= getEnvironmentVariable(environmentKeys.CSPELL_CONFIG_PATH);
|
|
1658
|
-
if (configFile)
|
|
1659
|
-
const cfgFile = typeof configFile === "string" ? await readConfigHandleError(configFile) : configFile;
|
|
1660
|
-
return configFileToConfigInfo(cfgFile);
|
|
1661
|
-
}
|
|
1604
|
+
if (configFile) return configFileToConfigInfo(typeof configFile === "string" ? await readConfigHandleError(configFile) : configFile);
|
|
1662
1605
|
const config = await cspell.searchForConfig(root, { stopSearchAt: stopConfigSearchAt });
|
|
1663
1606
|
const defaultConfigFile = getEnvironmentVariable(environmentKeys.CSPELL_DEFAULT_CONFIG_PATH);
|
|
1664
1607
|
if (!config && defaultConfigFile) {
|
|
@@ -1672,9 +1615,8 @@ async function readConfig(configFile, root, stopConfigSearchAt) {
|
|
|
1672
1615
|
}
|
|
1673
1616
|
async function configFileToConfigInfo(cfgFile) {
|
|
1674
1617
|
const config = await cspell.resolveConfigFileImports(cfgFile);
|
|
1675
|
-
const source = toFilePathOrHref(cfgFile.url);
|
|
1676
1618
|
return {
|
|
1677
|
-
source,
|
|
1619
|
+
source: toFilePathOrHref(cfgFile.url),
|
|
1678
1620
|
config
|
|
1679
1621
|
};
|
|
1680
1622
|
}
|
|
@@ -1738,12 +1680,10 @@ function lineContext(lineText, start, end, contextRange) {
|
|
|
1738
1680
|
const t0 = lineText.slice(left, right);
|
|
1739
1681
|
const tLeft = t0.trimStart();
|
|
1740
1682
|
left = Math.min(left + t0.length - tLeft.length, start);
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
text,
|
|
1683
|
+
return {
|
|
1684
|
+
text: tLeft.trimEnd(),
|
|
1744
1685
|
offset: left
|
|
1745
1686
|
};
|
|
1746
|
-
return context;
|
|
1747
1687
|
}
|
|
1748
1688
|
function extractContext(tdo, contextRange) {
|
|
1749
1689
|
const { line, offset, text } = tdo;
|
|
@@ -1805,13 +1745,12 @@ async function loadReporters(reporters, defaultReporter, config) {
|
|
|
1805
1745
|
}
|
|
1806
1746
|
}
|
|
1807
1747
|
reporters = !reporters || !reporters.length ? ["default"] : [...reporters];
|
|
1808
|
-
|
|
1809
|
-
return loadedReporters.filter((v) => v !== void 0);
|
|
1748
|
+
return (await Promise.all(reporters.map(loadReporter))).filter((v) => v !== void 0);
|
|
1810
1749
|
}
|
|
1811
1750
|
function finalizeReporter(reporter) {
|
|
1812
1751
|
if (!reporter) return void 0;
|
|
1813
1752
|
if (reporterIsFinalized(reporter)) return reporter;
|
|
1814
|
-
|
|
1753
|
+
return {
|
|
1815
1754
|
issue: (...params) => reporter.issue?.(...params),
|
|
1816
1755
|
info: (...params) => reporter.info?.(...params),
|
|
1817
1756
|
debug: (...params) => reporter.debug?.(...params),
|
|
@@ -1820,7 +1759,6 @@ function finalizeReporter(reporter) {
|
|
|
1820
1759
|
result: (...params) => reporter.result?.(...params),
|
|
1821
1760
|
features: reporter.features
|
|
1822
1761
|
};
|
|
1823
|
-
return final;
|
|
1824
1762
|
}
|
|
1825
1763
|
function reporterIsFinalized(reporter) {
|
|
1826
1764
|
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;
|
|
@@ -1905,8 +1843,7 @@ var LintReporter = class {
|
|
|
1905
1843
|
});
|
|
1906
1844
|
}
|
|
1907
1845
|
emitProgressComplete(filename, fileNum, fileCount, result) {
|
|
1908
|
-
const
|
|
1909
|
-
const numIssues = filteredIssues.length;
|
|
1846
|
+
const numIssues = result.issues.filter((issue) => filterFeatureIssues({}, issue, result.reportIssueOptions)).length;
|
|
1910
1847
|
for (const reporter of this.#reporters) {
|
|
1911
1848
|
const progress = clean({
|
|
1912
1849
|
type: "ProgressFileComplete",
|
|
@@ -1986,25 +1923,21 @@ async function runLint(cfg) {
|
|
|
1986
1923
|
const cachedResult = await cache.getCachedLintResults(filename);
|
|
1987
1924
|
if (cachedResult) {
|
|
1988
1925
|
reporter.debug(`Filename: ${filename}, using cache`);
|
|
1989
|
-
|
|
1926
|
+
return { fileResult: {
|
|
1990
1927
|
...cachedResult,
|
|
1991
1928
|
elapsedTimeMs: getElapsedTimeMs()
|
|
1992
|
-
};
|
|
1993
|
-
return { fileResult };
|
|
1929
|
+
} };
|
|
1994
1930
|
}
|
|
1995
1931
|
const uri = filenameToUri(filename, cfg.root).href;
|
|
1996
|
-
|
|
1997
|
-
if (!checkResult.shouldCheck) return { skip: true };
|
|
1998
|
-
const fileInfo = await readFileInfo(filename, void 0, true);
|
|
1932
|
+
if (!(await shouldCheckDocument({ uri }, {}, configInfo.config)).shouldCheck) return { skip: true };
|
|
1999
1933
|
return {
|
|
2000
|
-
fileInfo,
|
|
1934
|
+
fileInfo: await readFileInfo(filename, void 0, true),
|
|
2001
1935
|
reportIssueOptions
|
|
2002
1936
|
};
|
|
2003
1937
|
}
|
|
2004
|
-
const result = fetch$1();
|
|
2005
1938
|
return {
|
|
2006
1939
|
filename,
|
|
2007
|
-
result
|
|
1940
|
+
result: fetch$1()
|
|
2008
1941
|
};
|
|
2009
1942
|
}
|
|
2010
1943
|
async function processFile(filename, configInfo, cache, prefetch$1) {
|
|
@@ -2049,13 +1982,12 @@ async function runLint(cfg) {
|
|
|
2049
1982
|
try {
|
|
2050
1983
|
const { showSuggestions: generateSuggestions, validateDirectives, skipValidation } = cfg.options;
|
|
2051
1984
|
const numSuggestions = configInfo.config.numSuggestions ?? 5;
|
|
2052
|
-
const
|
|
1985
|
+
const r = await spellCheckDocument(doc, clean({
|
|
2053
1986
|
generateSuggestions,
|
|
2054
1987
|
numSuggestions,
|
|
2055
1988
|
validateDirectives,
|
|
2056
1989
|
skipValidation
|
|
2057
|
-
});
|
|
2058
|
-
const r = await spellCheckDocument(doc, validateOptions, configInfo.config);
|
|
1990
|
+
}), configInfo.config);
|
|
2059
1991
|
spellResult = r;
|
|
2060
1992
|
result.processed = r.checked;
|
|
2061
1993
|
result.perf = r.perf ? { ...r.perf } : void 0;
|
|
@@ -2132,11 +2064,10 @@ async function runLint(cfg) {
|
|
|
2132
2064
|
elapsedTimeMs: getElapsedTimeMs()
|
|
2133
2065
|
}
|
|
2134
2066
|
};
|
|
2135
|
-
const result = await processFile(filename, configInfo, cache, fetchResult);
|
|
2136
2067
|
return {
|
|
2137
2068
|
filename,
|
|
2138
2069
|
fileNum: index,
|
|
2139
|
-
result
|
|
2070
|
+
result: await processFile(filename, configInfo, cache, fetchResult)
|
|
2140
2071
|
};
|
|
2141
2072
|
}
|
|
2142
2073
|
async function* loadAndProcessFiles() {
|
|
@@ -2177,8 +2108,7 @@ async function runLint(cfg) {
|
|
|
2177
2108
|
count += 1;
|
|
2178
2109
|
reporter.error("Configuration", ref.error);
|
|
2179
2110
|
});
|
|
2180
|
-
|
|
2181
|
-
dictCollection.dictionaries.forEach((dict) => {
|
|
2111
|
+
(await getDictionary(config)).dictionaries.forEach((dict) => {
|
|
2182
2112
|
const dictErrors = dict.getErrors?.() || [];
|
|
2183
2113
|
const msg = `Dictionary Error with (${dict.name})`;
|
|
2184
2114
|
dictErrors.forEach((error) => {
|
|
@@ -2225,8 +2155,7 @@ async function runLint(cfg) {
|
|
|
2225
2155
|
...cfg.options,
|
|
2226
2156
|
version
|
|
2227
2157
|
}, root);
|
|
2228
|
-
const
|
|
2229
|
-
const result = await processFiles(files, configInfo, cacheSettings);
|
|
2158
|
+
const result = await processFiles(await determineFilesToCheck(configInfo, cfg, reporter, globInfo), configInfo, cacheSettings);
|
|
2230
2159
|
if (configErrors$1 && cfg.options.exitCode !== false) result.errors ||= configErrors$1;
|
|
2231
2160
|
return result;
|
|
2232
2161
|
} catch (e) {
|
|
@@ -2260,19 +2189,14 @@ async function determineGlobs(configInfo, cfg) {
|
|
|
2260
2189
|
const cliGlobs = cfg.fileGlobs;
|
|
2261
2190
|
const allGlobs = cliGlobs.length && cliGlobs || cfg.options.filterFiles !== false && configInfo.config.files || [];
|
|
2262
2191
|
const combinedGlobs = await normalizeFileOrGlobsToRoot(allGlobs, cfg.root);
|
|
2263
|
-
const
|
|
2264
|
-
|
|
2265
|
-
const includeGlobs = combinedGlobs.filter((g) => !g.startsWith("!"));
|
|
2266
|
-
const excludeGlobs = [...combinedGlobs.filter((g) => g.startsWith("!")).map((g) => g.slice(1)), ...normalizedExcludes];
|
|
2267
|
-
const fileGlobs = includeGlobs;
|
|
2268
|
-
const appGlobs = {
|
|
2192
|
+
const normalizedExcludes = normalizeGlobsToRoot(extractPatterns(cfg.excludes).map((p) => p.glob), cfg.root, true);
|
|
2193
|
+
return {
|
|
2269
2194
|
allGlobs,
|
|
2270
2195
|
gitIgnore,
|
|
2271
|
-
fileGlobs,
|
|
2272
|
-
excludeGlobs,
|
|
2196
|
+
fileGlobs: combinedGlobs.filter((g) => !g.startsWith("!")),
|
|
2197
|
+
excludeGlobs: [...combinedGlobs.filter((g) => g.startsWith("!")).map((g) => g.slice(1)), ...normalizedExcludes],
|
|
2273
2198
|
normalizedExcludes
|
|
2274
2199
|
};
|
|
2275
|
-
return appGlobs;
|
|
2276
2200
|
}
|
|
2277
2201
|
async function determineFilesToCheck(configInfo, cfg, reporter, globInfo) {
|
|
2278
2202
|
async function _determineFilesToCheck() {
|
|
@@ -2283,16 +2207,14 @@ async function determineFilesToCheck(configInfo, cfg, reporter, globInfo) {
|
|
|
2283
2207
|
const globsToExcludeRaw = [...configInfo.config.ignorePaths || [], ...excludeGlobs];
|
|
2284
2208
|
const globsToExclude = globsToExcludeRaw.filter((g) => !globPattern(g).startsWith("!"));
|
|
2285
2209
|
if (globsToExclude.length !== globsToExcludeRaw.length) {
|
|
2286
|
-
const
|
|
2287
|
-
const msg = `Negative glob exclusions are not supported: ${globs.join(", ")}`;
|
|
2210
|
+
const msg = `Negative glob exclusions are not supported: ${globsToExcludeRaw.map((g) => globPattern(g)).filter((g) => g.startsWith("!")).join(", ")}`;
|
|
2288
2211
|
reporter.info(msg, MessageTypes.Warning);
|
|
2289
2212
|
}
|
|
2290
2213
|
const globMatcher = buildGlobMatcher(globsToExclude, root, true);
|
|
2291
|
-
const ignoreGlobs = extractGlobsFromMatcher(globMatcher);
|
|
2292
2214
|
const globOptions = {
|
|
2293
2215
|
root,
|
|
2294
2216
|
cwd: root,
|
|
2295
|
-
ignore: [...
|
|
2217
|
+
ignore: [...extractGlobsFromMatcher(globMatcher), ...normalizedExcludes],
|
|
2296
2218
|
nodir: true
|
|
2297
2219
|
};
|
|
2298
2220
|
const enableGlobDot = cfg.enableGlobDot ?? configInfo.config.enableGlobDot;
|
|
@@ -2303,8 +2225,7 @@ async function determineFilesToCheck(configInfo, cfg, reporter, globInfo) {
|
|
|
2303
2225
|
const cliFiles = cfg.options.mustFindFiles ? rawCliFiles : rawCliFiles && pipeAsync(rawCliFiles, opFilterAsync(isFile));
|
|
2304
2226
|
const foundFiles = hasFileLists ? concatAsyncIterables(cliFiles, await useFileLists(fileLists, includeFilter)) : cliFiles || await findFiles(fileGlobs, globOptions);
|
|
2305
2227
|
const filtered = gitIgnore ? await gitIgnore.filterOutIgnored(foundFiles) : foundFiles;
|
|
2306
|
-
|
|
2307
|
-
return files;
|
|
2228
|
+
return isAsyncIterable(filtered) ? pipeAsync(filtered, opFilterExcludedFiles) : [...pipe(filtered, opFilterExcludedFiles)];
|
|
2308
2229
|
}
|
|
2309
2230
|
function isExcluded(filename, globMatcherExclude) {
|
|
2310
2231
|
if (isBinaryFile(toFileURL(filename))) return true;
|
|
@@ -2318,8 +2239,7 @@ async function determineFilesToCheck(configInfo, cfg, reporter, globInfo) {
|
|
|
2318
2239
|
return r.matched;
|
|
2319
2240
|
}
|
|
2320
2241
|
function filterOutExcludedFilesFn(globMatcherExclude) {
|
|
2321
|
-
const
|
|
2322
|
-
const excludeInfo = patterns.map(extractGlobSource).map(({ glob: glob$2, source }) => `Glob: ${glob$2} from ${source}`).filter(uniqueFn());
|
|
2242
|
+
const excludeInfo = globMatcherExclude.patterns.map(extractGlobSource).map(({ glob: glob$2, source }) => `Glob: ${glob$2} from ${source}`).filter(uniqueFn());
|
|
2323
2243
|
reporter.info(`Exclusion Globs: \n ${excludeInfo.join("\n ")}\n`, MessageTypes.Info);
|
|
2324
2244
|
return (filename) => !isExcluded(filename, globMatcherExclude);
|
|
2325
2245
|
}
|
|
@@ -2352,12 +2272,11 @@ function getLoggerFromReporter(reporter) {
|
|
|
2352
2272
|
};
|
|
2353
2273
|
const error = (...params) => {
|
|
2354
2274
|
const msg = format(...params);
|
|
2355
|
-
|
|
2275
|
+
reporter.error(msg, {
|
|
2356
2276
|
message: "",
|
|
2357
2277
|
name: "error",
|
|
2358
2278
|
toString: () => ""
|
|
2359
|
-
};
|
|
2360
|
-
reporter.error(msg, err);
|
|
2279
|
+
});
|
|
2361
2280
|
};
|
|
2362
2281
|
const warn = (...params) => {
|
|
2363
2282
|
const msg = format(...params);
|
|
@@ -2379,8 +2298,7 @@ async function generateGitIgnore(roots) {
|
|
|
2379
2298
|
return new GitIgnore(root?.map((p) => path$1.resolve(p)));
|
|
2380
2299
|
}
|
|
2381
2300
|
async function useFileLists(fileListFiles, filterFiles) {
|
|
2382
|
-
|
|
2383
|
-
return pipeAsync(files, opFilter(filterFiles), opFilterAsync(isNotDir));
|
|
2301
|
+
return pipeAsync(readFileListFiles(fileListFiles), opFilter(filterFiles), opFilterAsync(isNotDir));
|
|
2384
2302
|
}
|
|
2385
2303
|
function createIncludeFileFilterFn(includeGlobPatterns, root, dot) {
|
|
2386
2304
|
if (!includeGlobPatterns?.length) return () => true;
|
|
@@ -2400,13 +2318,9 @@ async function* concatAsyncIterables(...iterables) {
|
|
|
2400
2318
|
}
|
|
2401
2319
|
}
|
|
2402
2320
|
async function writeDictionaryLog() {
|
|
2403
|
-
const
|
|
2404
|
-
const
|
|
2405
|
-
|
|
2406
|
-
const lines = _debug.cacheDictionaryGetLog().filter((d) => d.method === "has").map((d) => fields.map((f) => f in d ? `${d[f]}` : "").join(", "));
|
|
2407
|
-
const data = header + lines.join("\n") + "\n";
|
|
2408
|
-
const filename = getEnvironmentVariable("CSPELL_ENABLE_DICTIONARY_LOG_FILE") || "cspell-dictionary-log.csv";
|
|
2409
|
-
await writeFileOrStream(filename, data);
|
|
2321
|
+
const fields = (getEnvironmentVariable("CSPELL_ENABLE_DICTIONARY_LOG_FIELDS") || "time, word, value").split(",").map((f) => f.trim());
|
|
2322
|
+
const data = fields.join(", ") + "\n" + _debug.cacheDictionaryGetLog().filter((d) => d.method === "has").map((d) => fields.map((f) => f in d ? `${d[f]}` : "").join(", ")).join("\n") + "\n";
|
|
2323
|
+
await writeFileOrStream(getEnvironmentVariable("CSPELL_ENABLE_DICTIONARY_LOG_FILE") || "cspell-dictionary-log.csv", data);
|
|
2410
2324
|
}
|
|
2411
2325
|
function globPattern(g) {
|
|
2412
2326
|
return typeof g === "string" ? g : g.glob;
|
|
@@ -2446,11 +2360,10 @@ var LintRequest = class {
|
|
|
2446
2360
|
this.fileLists = (options.fileList ?? options.fileLists) || [];
|
|
2447
2361
|
this.files = mergeFiles(options.file, options.files);
|
|
2448
2362
|
const noConfigSearch = options.configSearch === false ? true : options.configSearch === true ? false : void 0;
|
|
2449
|
-
const dictionaries = [...(options.disableDictionary ?? []).map((d) => `!${d}`), ...(options.dictionary ?? []).map((d) => `!!${d}`)];
|
|
2450
2363
|
const languageSettings = [{
|
|
2451
2364
|
languageId: "*",
|
|
2452
2365
|
locale: "*",
|
|
2453
|
-
dictionaries
|
|
2366
|
+
dictionaries: [...(options.disableDictionary ?? []).map((d) => `!${d}`), ...(options.dictionary ?? []).map((d) => `!!${d}`)]
|
|
2454
2367
|
}];
|
|
2455
2368
|
this.cspellSettingsFromCliOptions = {
|
|
2456
2369
|
...noConfigSearch !== void 0 ? { noConfigSearch } : {},
|
|
@@ -2533,8 +2446,7 @@ var SimpleRepl = class {
|
|
|
2533
2446
|
}
|
|
2534
2447
|
_completer(line) {
|
|
2535
2448
|
if (this.completer) return this.completer(line);
|
|
2536
|
-
|
|
2537
|
-
return [hist, line];
|
|
2449
|
+
return [this._history.filter((h) => h.startsWith(line)), line];
|
|
2538
2450
|
}
|
|
2539
2451
|
get history() {
|
|
2540
2452
|
return this._history;
|
|
@@ -2624,8 +2536,7 @@ function extractSpecialDictionaries(config) {
|
|
|
2624
2536
|
}
|
|
2625
2537
|
async function listDictionaries(options) {
|
|
2626
2538
|
const configFile = await readConfig(options.config, void 0);
|
|
2627
|
-
const
|
|
2628
|
-
const configBase = mergeSettings(await getDefaultSettings(loadDefault), await getGlobalSettingsAsync(), configFile.config);
|
|
2539
|
+
const configBase = mergeSettings(await getDefaultSettings(options.defaultConfiguration ?? configFile.config.loadDefaultConfiguration ?? true), await getGlobalSettingsAsync(), configFile.config);
|
|
2629
2540
|
const useFileType = options.fileType === "text" ? "plaintext" : options.fileType;
|
|
2630
2541
|
if (options.locale) configBase.language = options.locale;
|
|
2631
2542
|
const config = combineTextAndLanguageSettings(configBase, "", useFileType || configBase.languageId || "plaintext");
|
|
@@ -2649,8 +2560,7 @@ async function listDictionaries(options) {
|
|
|
2649
2560
|
}
|
|
2650
2561
|
const dictionaryDefinitions = (config.dictionaryDefinitions || []).filter(filterDicts);
|
|
2651
2562
|
dictionaryDefinitions.sort((a, b) => a.name.localeCompare(b.name));
|
|
2652
|
-
|
|
2653
|
-
return [...specialDicts, ...dictionaryDefinitions.map(toListDictionariesResult)];
|
|
2563
|
+
return [...options.enabled !== false ? extractSpecialDictionaries(config) : [], ...dictionaryDefinitions.map(toListDictionariesResult)];
|
|
2654
2564
|
}
|
|
2655
2565
|
|
|
2656
2566
|
//#endregion
|
|
@@ -2666,11 +2576,10 @@ function lint(fileGlobs, options, reporter) {
|
|
|
2666
2576
|
...useOptions,
|
|
2667
2577
|
console
|
|
2668
2578
|
};
|
|
2669
|
-
|
|
2579
|
+
return runLint(new LintRequest(fileGlobs, useOptions, finalizeReporter(reporter) ?? getReporter({
|
|
2670
2580
|
...useOptions,
|
|
2671
2581
|
fileGlobs
|
|
2672
|
-
}, reporterOptions));
|
|
2673
|
-
return runLint(cfg);
|
|
2582
|
+
}, reporterOptions)));
|
|
2674
2583
|
}
|
|
2675
2584
|
async function* trace(words, options) {
|
|
2676
2585
|
options = fixLegacy(options);
|
|
@@ -2680,8 +2589,7 @@ async function* trace(words, options) {
|
|
|
2680
2589
|
const loadDefault = options.defaultConfiguration ?? configFile.config.loadDefaultConfiguration ?? true;
|
|
2681
2590
|
const additionalSettings = {};
|
|
2682
2591
|
if (options.dictionary) additionalSettings.dictionaries = options.dictionary;
|
|
2683
|
-
|
|
2684
|
-
yield* traceWordsAsync(iWords, config, clean({
|
|
2592
|
+
yield* traceWordsAsync(iWords, mergeSettings(await getDefaultSettings(loadDefault), await getGlobalSettingsAsync(), configFile.config, additionalSettings), clean({
|
|
2685
2593
|
languageId,
|
|
2686
2594
|
locale,
|
|
2687
2595
|
ignoreCase,
|
|
@@ -2724,8 +2632,7 @@ async function* suggestions(words, options) {
|
|
|
2724
2632
|
}
|
|
2725
2633
|
const iWords = options.repl ? pipeAsync(toAsyncIterable(words, simpleRepl()), opTap(tapStart)) : options.useStdin ? pipeAsync(toAsyncIterable(words, readStdin()), opTap(tapStart)) : words.map(mapStart);
|
|
2726
2634
|
try {
|
|
2727
|
-
|
|
2728
|
-
yield* results;
|
|
2635
|
+
yield* pipeAsync(suggestionsForWords(iWords, clean({ ...options }), configFile.config), opMap(mapEnd));
|
|
2729
2636
|
} catch (e) {
|
|
2730
2637
|
if (!(e instanceof SuggestionError)) throw e;
|
|
2731
2638
|
console.error(e.message);
|
|
@@ -2737,18 +2644,16 @@ function createInit(options) {
|
|
|
2737
2644
|
}
|
|
2738
2645
|
function registerApplicationFeatureFlags() {
|
|
2739
2646
|
const ff = getFeatureFlags();
|
|
2740
|
-
|
|
2647
|
+
[{
|
|
2741
2648
|
name: "timer",
|
|
2742
2649
|
description: "Display elapsed time for command."
|
|
2743
|
-
}];
|
|
2744
|
-
flags.forEach((flag) => ff.register(flag));
|
|
2650
|
+
}].forEach((flag) => ff.register(flag));
|
|
2745
2651
|
return ff;
|
|
2746
2652
|
}
|
|
2747
2653
|
function parseApplicationFeatureFlags(flags) {
|
|
2748
|
-
|
|
2749
|
-
return parseFeatureFlags(flags, ff);
|
|
2654
|
+
return parseFeatureFlags(flags, registerApplicationFeatureFlags());
|
|
2750
2655
|
}
|
|
2751
2656
|
|
|
2752
2657
|
//#endregion
|
|
2753
|
-
export {
|
|
2754
|
-
//# sourceMappingURL=application-
|
|
2658
|
+
export { parseApplicationFeatureFlags as a, listDictionaries as c, npmPackage as d, getReporter as f, console as h, lint as i, ReportChoicesAll as l, CheckFailed as m, checkText as n, suggestions as o, ApplicationError as p, createInit as r, trace as s, IncludeExcludeFlag as t, DEFAULT_CACHE_LOCATION as u };
|
|
2659
|
+
//# sourceMappingURL=application-2V_0BiNj.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as SuggestionOptions, i as LinterCliOptions, n as DictionariesOptions, o as TraceOptions, r as LegacyOptions, t as BaseOptions } from "./options-D_a-jMcz.js";
|
|
2
2
|
import { CheckTextInfo, FeatureFlags, IncludeExcludeFlag, SuggestionsForWordResult, TraceResult, TraceWordResult } from "cspell-lib";
|
|
3
3
|
import { CSpellReporter, RunResult } from "@cspell/cspell-types";
|
|
4
4
|
|
|
@@ -112,5 +112,5 @@ declare function suggestions(words: string[], options: SuggestionOptions): Async
|
|
|
112
112
|
declare function createInit(options: InitOptions): Promise<void>;
|
|
113
113
|
declare function parseApplicationFeatureFlags(flags: string[] | undefined): FeatureFlags;
|
|
114
114
|
//#endregion
|
|
115
|
-
export {
|
|
116
|
-
//# sourceMappingURL=application-
|
|
115
|
+
export { checkText as a, parseApplicationFeatureFlags as c, listDictionaries as d, TraceResult as i, suggestions as l, CheckTextResult as n, createInit as o, IncludeExcludeFlag as r, lint as s, AppError as t, trace as u };
|
|
116
|
+
//# sourceMappingURL=application-DDngbSV7.d.ts.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "./options-
|
|
2
|
-
import {
|
|
1
|
+
import "./options-D_a-jMcz.js";
|
|
2
|
+
import { a as checkText, c as parseApplicationFeatureFlags, d as listDictionaries, i as TraceResult, l as suggestions, n as CheckTextResult, o as createInit, r as IncludeExcludeFlag, s as lint, t as AppError, u as trace } from "./application-DDngbSV7.js";
|
|
3
3
|
export { AppError, CheckTextResult, IncludeExcludeFlag, TraceResult, checkText, createInit, lint, listDictionaries, parseApplicationFeatureFlags, suggestions, trace };
|
package/dist/esm/application.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as parseApplicationFeatureFlags, c as listDictionaries, i as lint, n as checkText, o as suggestions, r as createInit, s as trace, t as IncludeExcludeFlag } from "./application-2V_0BiNj.js";
|
|
2
2
|
|
|
3
3
|
export { IncludeExcludeFlag, checkText, createInit, lint, listDictionaries, parseApplicationFeatureFlags, suggestions, trace };
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { i as LinterCliOptions, o as TraceOptions, t as BaseOptions } from "./options-D_a-jMcz.js";
|
|
2
|
+
import { a as checkText, c as parseApplicationFeatureFlags, d as listDictionaries, i as TraceResult, l as suggestions, n as CheckTextResult, o as createInit, r as IncludeExcludeFlag, s as lint, t as AppError, u as trace } from "./application-DDngbSV7.js";
|
|
3
3
|
import "chalk";
|
|
4
4
|
import { CSpellReporter, CSpellSettings, ReporterConfiguration, RunResult } from "@cspell/cspell-types";
|
|
5
5
|
import { WriteStream } from "node:tty";
|
|
@@ -40,10 +40,6 @@ interface CSpellReporterModule {
|
|
|
40
40
|
//#endregion
|
|
41
41
|
//#region src/util/reporters.d.ts
|
|
42
42
|
type FinalizedReporter = Required<CSpellReporter>;
|
|
43
|
-
/**
|
|
44
|
-
* Loads reporter modules configured in cspell config file
|
|
45
|
-
*/
|
|
46
|
-
|
|
47
43
|
//#endregion
|
|
48
44
|
//#region src/cli-reporter.d.ts
|
|
49
45
|
interface ReporterOptions extends Pick<LinterCliOptions, "color" | "debug" | "issues" | "issuesSummaryReport" | "legacy" | "progress" | "relative" | "root" | "showContext" | "showPerfSummary" | "showSuggestions" | "silent" | "summary" | "verbose" | "wordsOnly"> {
|
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as parseApplicationFeatureFlags, c as listDictionaries, f as getReporter, i as lint, n as checkText, o as suggestions, r as createInit, s as trace, t as IncludeExcludeFlag } from "./application-2V_0BiNj.js";
|
|
2
2
|
|
|
3
3
|
export * from "@cspell/cspell-types"
|
|
4
4
|
|
|
@@ -383,5 +383,5 @@ interface CSpellConfigFile {
|
|
|
383
383
|
settings: CSpellSettings;
|
|
384
384
|
}
|
|
385
385
|
//#endregion
|
|
386
|
-
export {
|
|
387
|
-
//# sourceMappingURL=options-
|
|
386
|
+
export { SuggestionOptions as a, LinterCliOptions as i, DictionariesOptions as n, TraceOptions as o, LegacyOptions as r, BaseOptions as t };
|
|
387
|
+
//# sourceMappingURL=options-D_a-jMcz.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cspell",
|
|
3
|
-
"version": "9.2.
|
|
3
|
+
"version": "9.2.2",
|
|
4
4
|
"description": "A Spelling Checker for Code!",
|
|
5
5
|
"funding": "https://github.com/streetsidesoftware/cspell?sponsor=1",
|
|
6
6
|
"bin": {
|
|
@@ -83,24 +83,24 @@
|
|
|
83
83
|
},
|
|
84
84
|
"homepage": "https://cspell.org/",
|
|
85
85
|
"dependencies": {
|
|
86
|
-
"@cspell/cspell-json-reporter": "9.2.
|
|
87
|
-
"@cspell/cspell-pipe": "9.2.
|
|
88
|
-
"@cspell/cspell-types": "9.2.
|
|
89
|
-
"@cspell/dynamic-import": "9.2.
|
|
90
|
-
"@cspell/url": "9.2.
|
|
91
|
-
"chalk": "^5.6.
|
|
92
|
-
"chalk-template": "^1.1.
|
|
93
|
-
"commander": "^14.0.
|
|
94
|
-
"cspell-config-lib": "9.2.
|
|
95
|
-
"cspell-dictionary": "9.2.
|
|
96
|
-
"cspell-gitignore": "9.2.
|
|
97
|
-
"cspell-glob": "9.2.
|
|
98
|
-
"cspell-io": "9.2.
|
|
99
|
-
"cspell-lib": "9.2.
|
|
86
|
+
"@cspell/cspell-json-reporter": "9.2.2",
|
|
87
|
+
"@cspell/cspell-pipe": "9.2.2",
|
|
88
|
+
"@cspell/cspell-types": "9.2.2",
|
|
89
|
+
"@cspell/dynamic-import": "9.2.2",
|
|
90
|
+
"@cspell/url": "9.2.2",
|
|
91
|
+
"chalk": "^5.6.2",
|
|
92
|
+
"chalk-template": "^1.1.2",
|
|
93
|
+
"commander": "^14.0.1",
|
|
94
|
+
"cspell-config-lib": "9.2.2",
|
|
95
|
+
"cspell-dictionary": "9.2.2",
|
|
96
|
+
"cspell-gitignore": "9.2.2",
|
|
97
|
+
"cspell-glob": "9.2.2",
|
|
98
|
+
"cspell-io": "9.2.2",
|
|
99
|
+
"cspell-lib": "9.2.2",
|
|
100
100
|
"fast-json-stable-stringify": "^2.1.0",
|
|
101
101
|
"flatted": "^3.3.3",
|
|
102
|
-
"semver": "^7.7.
|
|
103
|
-
"tinyglobby": "^0.2.
|
|
102
|
+
"semver": "^7.7.3",
|
|
103
|
+
"tinyglobby": "^0.2.15"
|
|
104
104
|
},
|
|
105
105
|
"engines": {
|
|
106
106
|
"node": ">=20"
|
|
@@ -108,9 +108,9 @@
|
|
|
108
108
|
"devDependencies": {
|
|
109
109
|
"@types/glob": "^8.1.0",
|
|
110
110
|
"@types/micromatch": "^4.0.9",
|
|
111
|
-
"@types/semver": "^7.7.
|
|
111
|
+
"@types/semver": "^7.7.1",
|
|
112
112
|
"micromatch": "^4.0.8",
|
|
113
113
|
"minimatch": "^9.0.5"
|
|
114
114
|
},
|
|
115
|
-
"gitHead": "
|
|
115
|
+
"gitHead": "594a58399cb9dad07cbb1d9cef6f2adb87560dd7"
|
|
116
116
|
}
|