cspell 9.2.0 → 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 +7 -4
- package/dist/esm/app.d.ts +4 -4
- package/dist/esm/app.js +36 -72
- package/dist/esm/{application-_MFvh02K.js → application-2V_0BiNj.js} +100 -202
- 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
|
@@ -13,10 +13,13 @@ A Spell Checker for Code!
|
|
|
13
13
|
<!--- @@inject: ../../static/sponsor.md --->
|
|
14
14
|
|
|
15
15
|
- [](https://github.com/sponsors/streetsidesoftware)
|
|
16
|
-
- [](https://patreon.com/streetsidesoftware)
|
|
17
16
|
- [](https://www.paypal.com/donate/?hosted_button_id=26LNBP2Q6MKCY)
|
|
18
17
|
- [](https://opencollective.com/cspell)
|
|
19
18
|
|
|
19
|
+
<!---
|
|
20
|
+
- [](https://patreon.com/streetsidesoftware)
|
|
21
|
+
--->
|
|
22
|
+
|
|
20
23
|
<!--- @@inject-end: ../../static/sponsor.md --->
|
|
21
24
|
|
|
22
25
|
## Features
|
|
@@ -437,7 +440,7 @@ const str = 'goedemorgen'; // <- will NOT be flagged as an error.
|
|
|
437
440
|
|
|
438
441
|
### Ignore
|
|
439
442
|
|
|
440
|
-
_Ignore_ allows you
|
|
443
|
+
_Ignore_ allows you to specify a list of words you want to ignore within the document.
|
|
441
444
|
|
|
442
445
|
```javascript
|
|
443
446
|
// cspell:ignore zaallano, wooorrdd
|
|
@@ -645,7 +648,7 @@ export default defineConfig({
|
|
|
645
648
|
// Including "spanish" in the list of dictionaries means both Spanish and English
|
|
646
649
|
// words will be considered correct.
|
|
647
650
|
"dictionaries": ["spanish", "ruby", "corp-terms", "fonts"],
|
|
648
|
-
// Define each dictionary.
|
|
651
|
+
// Define each dictionary. Relative paths are relative to the config file.
|
|
649
652
|
"dictionaryDefinitions": [
|
|
650
653
|
{ "name": "spanish", "path": "./spanish-words.txt"},
|
|
651
654
|
{ "name": "ruby", "path": "./ruby.txt"},
|
|
@@ -713,7 +716,7 @@ The spell checker includes a set of default dictionaries.
|
|
|
713
716
|
- **useCompounds** - allow compound words
|
|
714
717
|
|
|
715
718
|
```javascript
|
|
716
|
-
// Define each dictionary.
|
|
719
|
+
// Define each dictionary. Relative paths are relative to the config file.
|
|
717
720
|
"dictionaryDefinitions": [
|
|
718
721
|
{ "name": "spanish", "path": "./spanish-words.txt"},
|
|
719
722
|
{ "name": "ruby", "path": "./ruby.txt"},
|
package/dist/esm/app.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { LinterCliOptions } from "./options-
|
|
1
|
+
import { i as LinterCliOptions } from "./options-D_a-jMcz.js";
|
|
2
2
|
import { Command } from "commander";
|
|
3
3
|
|
|
4
4
|
//#region src/util/errors.d.ts
|
|
5
5
|
declare class CheckFailed extends Error {
|
|
6
|
-
readonly exitCode:
|
|
6
|
+
readonly exitCode: number;
|
|
7
7
|
constructor(message: string, exitCode?: number);
|
|
8
8
|
}
|
|
9
9
|
declare class ApplicationError extends Error {
|
|
10
|
-
readonly exitCode:
|
|
11
|
-
readonly cause?:
|
|
10
|
+
readonly exitCode: number;
|
|
11
|
+
readonly cause?: Error | undefined;
|
|
12
12
|
constructor(message: string, exitCode?: number, cause?: Error | undefined);
|
|
13
13
|
}
|
|
14
14
|
//#endregion
|
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,10 +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));
|
|
561
|
-
return;
|
|
540
|
+
tableToLines(listGlobalImportsResultToTable((await listGlobalImports()).list)).forEach((line) => console.log(line));
|
|
562
541
|
});
|
|
563
542
|
linkCommand.command("add <dictionaries...>").alias("a").description("Add dictionaries any other settings to the cspell global config.").action(async (dictionaries) => {
|
|
564
543
|
const r = await addPathsToGlobalImports(dictionaries);
|
|
@@ -566,14 +545,12 @@ function commandLink(prog) {
|
|
|
566
545
|
console.log("Adding:");
|
|
567
546
|
tableToLines(table).forEach((line) => console.log(line));
|
|
568
547
|
if (r.error) throw new CheckFailed(r.error, 1);
|
|
569
|
-
return;
|
|
570
548
|
});
|
|
571
549
|
linkCommand.command("remove <paths...>").alias("r").description("Remove matching paths / packages from the global config.").action(async (dictionaries) => {
|
|
572
550
|
const r = await removePathsFromGlobalImports(dictionaries);
|
|
573
551
|
console.log("Removing:");
|
|
574
552
|
if (r.error) throw new CheckFailed(r.error, 1);
|
|
575
553
|
r.removed.map((f) => console.log(f));
|
|
576
|
-
return;
|
|
577
554
|
});
|
|
578
555
|
return linkCommand;
|
|
579
556
|
}
|
|
@@ -699,11 +676,7 @@ function commandLint(prog) {
|
|
|
699
676
|
throw new CheckFailed("outputHelp", 1);
|
|
700
677
|
}
|
|
701
678
|
if (result.errors || mustFindFiles && !result.files) throw new CheckFailed("check failed", 1);
|
|
702
|
-
if (result.issues)
|
|
703
|
-
const exitCode = useExitCode ? 1 : 0;
|
|
704
|
-
throw new CheckFailed("check failed", exitCode);
|
|
705
|
-
}
|
|
706
|
-
return;
|
|
679
|
+
if (result.issues) throw new CheckFailed("check failed", useExitCode ? 1 : 0);
|
|
707
680
|
});
|
|
708
681
|
return spellCheckCommand;
|
|
709
682
|
}
|
|
@@ -788,8 +761,7 @@ function emitSuggestionResult(result, options) {
|
|
|
788
761
|
...s,
|
|
789
762
|
w: handleRtl(s.compoundWord || s.wordAdjustedToMatchCase || s.word)
|
|
790
763
|
}));
|
|
791
|
-
const
|
|
792
|
-
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);
|
|
793
765
|
for (const sug of mappedSugs) {
|
|
794
766
|
const { cost, dictionaries, w } = sug;
|
|
795
767
|
const padding = " ".repeat(padWidth(w, maxWidth$2));
|
|
@@ -880,16 +852,13 @@ function calcTraceResultsReport(word, found, results, options) {
|
|
|
880
852
|
const col = new Intl.Collator();
|
|
881
853
|
results.sort((a, b) => col.compare(a.dictName, b.dictName));
|
|
882
854
|
options.showWordFound && console.log(`${options.prefix || ""}${word}: ${found ? "Found" : "Not Found"}`);
|
|
883
|
-
const header = emitHeader(options.dictionaryPathFormat !== "hide");
|
|
884
|
-
const rows = results.map((r) => emitTraceResult(r, options));
|
|
885
|
-
const t = tableToLines({
|
|
886
|
-
header,
|
|
887
|
-
rows,
|
|
888
|
-
terminalWidth: options.lineWidth || process.stdout.columns || maxWidth,
|
|
889
|
-
deliminator: " "
|
|
890
|
-
});
|
|
891
855
|
return {
|
|
892
|
-
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"),
|
|
893
862
|
errors: emitErrors(results).join("\n")
|
|
894
863
|
};
|
|
895
864
|
}
|
|
@@ -904,15 +873,13 @@ function emitHeader(location) {
|
|
|
904
873
|
}
|
|
905
874
|
function emitTraceResult(r, options) {
|
|
906
875
|
const errors = !!r.errors?.length;
|
|
907
|
-
const
|
|
908
|
-
const cWord = word.replaceAll("+", chalk.yellow("+"));
|
|
876
|
+
const cWord = (r.foundWord || r.word).replaceAll("+", chalk.yellow("+"));
|
|
909
877
|
const sug = r.preferredSuggestions?.map((s) => chalk.yellowBright(s)).join(", ") || "";
|
|
910
878
|
const w = (r.forbidden ? chalk.red(cWord) : chalk.green(cWord)) + (sug ? `->(${sug})` : "");
|
|
911
879
|
const f = calcFoundChar(r);
|
|
912
880
|
const a = r.dictActive ? "*" : " ";
|
|
913
881
|
const dictName = r.dictName.slice(0, colWidthDictionaryName - 1) + a;
|
|
914
|
-
const
|
|
915
|
-
const n = dictColor(dictName);
|
|
882
|
+
const n = (r.dictActive ? chalk.yellowBright : chalk.rgb(200, 128, 50))(dictName);
|
|
916
883
|
const c = colorize(errors ? chalk.red : chalk.white);
|
|
917
884
|
return [
|
|
918
885
|
w,
|
|
@@ -925,8 +892,7 @@ function emitTraceResult(r, options) {
|
|
|
925
892
|
];
|
|
926
893
|
}
|
|
927
894
|
function emitErrors(results) {
|
|
928
|
-
|
|
929
|
-
return errorResults.map((r) => {
|
|
895
|
+
return results.filter((r) => r.errors?.length).map((r) => {
|
|
930
896
|
const errors = r.errors?.map((e) => e.message)?.join("\n ") || "";
|
|
931
897
|
return chalk.bold(r.dictName) + "\n " + chalk.red(errors);
|
|
932
898
|
});
|
|
@@ -966,8 +932,7 @@ function commandTrace(prog) {
|
|
|
966
932
|
for await (const results of trace(words, options)) {
|
|
967
933
|
const byWord = groupBy(results, (r) => r.word);
|
|
968
934
|
for (const split of results.splits) {
|
|
969
|
-
const
|
|
970
|
-
const filtered = filterTraceResults(splitResults, options);
|
|
935
|
+
const filtered = filterTraceResults(byWord.get(split.word) || [], options);
|
|
971
936
|
emitTraceResults(split.word, split.found, filtered, {
|
|
972
937
|
cwd: process.cwd(),
|
|
973
938
|
dictionaryPathFormat,
|
|
@@ -977,8 +942,7 @@ function commandTrace(prog) {
|
|
|
977
942
|
});
|
|
978
943
|
prefix = "\n";
|
|
979
944
|
numFound += results.reduce((n, r) => n + (r.found ? 1 : 0), 0);
|
|
980
|
-
|
|
981
|
-
if (numErrors) {
|
|
945
|
+
if (results.map((r) => r.errors?.length || 0).reduce((n, r) => n + r, 0)) {
|
|
982
946
|
console.error("Dictionary Errors.");
|
|
983
947
|
throw new CheckFailed("dictionary errors", 1);
|
|
984
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,15 +258,13 @@ 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
|
-
const repeatIssues = false;
|
|
277
268
|
const issuesCollection = void 0;
|
|
278
269
|
const errorCollection = [];
|
|
279
270
|
function errorEmitter(message, error) {
|
|
@@ -297,9 +288,7 @@ function getReporter(options, config) {
|
|
|
297
288
|
}
|
|
298
289
|
const cachedFilesText = cachedFiles ? ` (${cachedFiles} from cache)` : "";
|
|
299
290
|
const withErrorsText = errors ? ` with ${errors} error${errors === 1 ? "" : "s"}` : "";
|
|
300
|
-
|
|
301
|
-
const summaryMessage = `CSpell\u003A Files checked: ${files}${cachedFilesText}, Issues found: ${issues$1} in ${numFilesWidthIssuesText}${withErrorsText}.`;
|
|
302
|
-
consoleError(summaryMessage);
|
|
291
|
+
consoleError(`CSpell\u003A Files checked: ${files}${cachedFilesText}, Issues found: ${issues$1} in ${numFilesWithIssues === 1 ? "1 file" : `${numFilesWithIssues} files`}${withErrorsText}.`);
|
|
303
292
|
if (errorCollection?.length && issues$1 > 5) {
|
|
304
293
|
consoleError("-------------------------------------------");
|
|
305
294
|
consoleError("Errors:");
|
|
@@ -377,8 +366,7 @@ function formatIssue(io, templateStr, issue, maxIssueTextWidth) {
|
|
|
377
366
|
$messageColored: messageColored
|
|
378
367
|
};
|
|
379
368
|
const t = templateStr.replaceAll("$messageColored", messageColored);
|
|
380
|
-
|
|
381
|
-
return substitute(chalkTemplate(t), substitutions).trimEnd();
|
|
369
|
+
return substitute(makeTemplate(io.chalk)(t), substitutions).trimEnd();
|
|
382
370
|
}
|
|
383
371
|
function formatSuggestions(io, issue) {
|
|
384
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(", ");
|
|
@@ -389,8 +377,7 @@ function formatQuickFix(io, issue) {
|
|
|
389
377
|
if (!issue.suggestionsEx?.length) return "";
|
|
390
378
|
const preferred = issue.suggestionsEx.filter((sug) => sug.isPreferred).map((sug) => sug.wordAdjustedToMatchCase || sug.word);
|
|
391
379
|
if (!preferred.length) return "";
|
|
392
|
-
|
|
393
|
-
return `fix: (${fixes.join(", ")})`;
|
|
380
|
+
return `fix: (${preferred.map((w) => io.chalk.italic(io.chalk.yellow(w))).join(", ")})`;
|
|
394
381
|
}
|
|
395
382
|
function substitute(text, substitutions) {
|
|
396
383
|
const subs = [];
|
|
@@ -416,16 +403,14 @@ function substitute(text, substitutions) {
|
|
|
416
403
|
i = b;
|
|
417
404
|
return prefix + t;
|
|
418
405
|
}
|
|
419
|
-
|
|
420
|
-
return parts.join("") + text.slice(i);
|
|
406
|
+
return subs.map(sub).join("") + text.slice(i);
|
|
421
407
|
}
|
|
422
408
|
function assertCheckTemplate(template) {
|
|
423
409
|
const r = checkTemplate(template);
|
|
424
410
|
if (r instanceof Error) throw r;
|
|
425
411
|
}
|
|
426
412
|
function checkTemplate(template) {
|
|
427
|
-
const
|
|
428
|
-
const chalkTemplate = makeTemplate(chalk$1);
|
|
413
|
+
const chalkTemplate = makeTemplate(new Chalk());
|
|
429
414
|
const substitutions = {
|
|
430
415
|
$col: "<col>",
|
|
431
416
|
$contextFull: "<contextFull>",
|
|
@@ -443,14 +428,11 @@ function checkTemplate(template) {
|
|
|
443
428
|
$messageColored: "<messageColored>"
|
|
444
429
|
};
|
|
445
430
|
try {
|
|
446
|
-
const
|
|
447
|
-
const result = substitute(t, substitutions);
|
|
448
|
-
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]);
|
|
449
432
|
if (problems.length) throw new Error(`Unresolved template variable${problems.length > 1 ? "s" : ""}: ${problems.map((v) => `'${v}'`).join(", ")}`);
|
|
450
433
|
return true;
|
|
451
434
|
} catch (e) {
|
|
452
|
-
|
|
453
|
-
return new ApplicationError(msg);
|
|
435
|
+
return new ApplicationError(e instanceof Error ? e.message : `${e}`);
|
|
454
436
|
}
|
|
455
437
|
}
|
|
456
438
|
|
|
@@ -459,11 +441,9 @@ function checkTemplate(template) {
|
|
|
459
441
|
async function fileExists(url) {
|
|
460
442
|
if (url.protocol !== "file:") return false;
|
|
461
443
|
try {
|
|
462
|
-
|
|
463
|
-
return stats.isFile();
|
|
444
|
+
return (await promises.stat(url)).isFile();
|
|
464
445
|
} catch (e) {
|
|
465
|
-
|
|
466
|
-
if (err.code === "ENOENT") return false;
|
|
446
|
+
if (toError(e).code === "ENOENT") return false;
|
|
467
447
|
throw e;
|
|
468
448
|
}
|
|
469
449
|
}
|
|
@@ -552,8 +532,7 @@ function addDictionariesToConfigFile(configFile, dictionaries, comment) {
|
|
|
552
532
|
if (!found && comment) configFile.setComment("dictionaries", comment);
|
|
553
533
|
return;
|
|
554
534
|
}
|
|
555
|
-
const
|
|
556
|
-
const dicts = settings.dictionaries || [];
|
|
535
|
+
const dicts = configFile.settings.dictionaries || [];
|
|
557
536
|
const knownDicts = new Set(dicts);
|
|
558
537
|
for (const dict of dictionaries) if (!knownDicts.has(dict)) {
|
|
559
538
|
dicts.push(dict);
|
|
@@ -573,8 +552,7 @@ function applyValuesToConfigFile(config, settings, defaultValues, addComments) {
|
|
|
573
552
|
const oldValue = currentSettings[key];
|
|
574
553
|
const value = newValue ?? oldValue ?? defaultValue;
|
|
575
554
|
if (newValue === void 0 && oldValue !== void 0 || value === void 0) continue;
|
|
576
|
-
|
|
577
|
-
setConfigFieldValue(config, key, value, useComment);
|
|
555
|
+
setConfigFieldValue(config, key, value, addComments && oldValue === void 0 && comment || void 0);
|
|
578
556
|
}
|
|
579
557
|
return config;
|
|
580
558
|
}
|
|
@@ -675,8 +653,7 @@ const defaultConfigYaml = `
|
|
|
675
653
|
`;
|
|
676
654
|
async function configInit(options) {
|
|
677
655
|
const rw = createReaderWriter();
|
|
678
|
-
const
|
|
679
|
-
const configFile = await createConfigFile(rw, url, options);
|
|
656
|
+
const configFile = await createConfigFile(rw, determineFileNameURL(options), options);
|
|
680
657
|
await applyOptionsToConfigFile(configFile, options);
|
|
681
658
|
await fs.mkdir(new URL("./", configFile.url), { recursive: true });
|
|
682
659
|
if (options.stdout) console.stdoutChannel.write(rw.serialize(configFile));
|
|
@@ -789,7 +766,7 @@ const pkgDir = _dirname;
|
|
|
789
766
|
//#endregion
|
|
790
767
|
//#region src/pkgInfo.ts
|
|
791
768
|
const name = "cspell";
|
|
792
|
-
const version$1 = "9.2.
|
|
769
|
+
const version$1 = "9.2.2";
|
|
793
770
|
const engines = { node: ">=20" };
|
|
794
771
|
const npmPackage = {
|
|
795
772
|
name,
|
|
@@ -823,8 +800,7 @@ const defaultExcludeGlobs = ["node_modules/**"];
|
|
|
823
800
|
*/
|
|
824
801
|
async function globP(pattern, options) {
|
|
825
802
|
const cwd = options?.root || options?.cwd || process.cwd();
|
|
826
|
-
const
|
|
827
|
-
const ignore = ignoreRaw?.filter((g) => !g.startsWith("../"));
|
|
803
|
+
const ignore = (typeof options?.ignore === "string" ? [options.ignore] : options?.ignore)?.filter((g) => !g.startsWith("../"));
|
|
828
804
|
const onlyFiles = options?.nodir;
|
|
829
805
|
const dot = options?.dot;
|
|
830
806
|
const patterns = typeof pattern === "string" ? [pattern] : pattern;
|
|
@@ -838,14 +814,11 @@ async function globP(pattern, options) {
|
|
|
838
814
|
expandDirectories: false
|
|
839
815
|
});
|
|
840
816
|
const compare$1 = new Intl.Collator("en").compare;
|
|
841
|
-
|
|
842
|
-
const relativePaths = absolutePaths.map((absFilename) => path$1.relative(cwd, absFilename));
|
|
843
|
-
return relativePaths;
|
|
817
|
+
return (await glob$1(patterns, useOptions)).sort(compare$1).map((absFilename) => path$1.relative(cwd, absFilename));
|
|
844
818
|
}
|
|
845
819
|
function calcGlobs(commandLineExclude) {
|
|
846
|
-
const globs = new Set((commandLineExclude || []).flatMap((glob$2) => glob$2.split(/(?<!\\)\s+/g)).map((g) => g.replaceAll("\\ ", " ")));
|
|
847
820
|
const commandLineExcludes = {
|
|
848
|
-
globs: [...
|
|
821
|
+
globs: [...new Set((commandLineExclude || []).flatMap((glob$2) => glob$2.split(/(?<!\\)\s+/g)).map((g) => g.replaceAll("\\ ", " ")))],
|
|
849
822
|
source: "arguments"
|
|
850
823
|
};
|
|
851
824
|
const defaultExcludes = {
|
|
@@ -855,7 +828,7 @@ function calcGlobs(commandLineExclude) {
|
|
|
855
828
|
return commandLineExcludes.globs.length ? commandLineExcludes : defaultExcludes;
|
|
856
829
|
}
|
|
857
830
|
function extractPatterns(globs) {
|
|
858
|
-
|
|
831
|
+
return globs.reduce((info, g) => {
|
|
859
832
|
const source = g.source;
|
|
860
833
|
const patterns = g.matcher.patternsNormalizedToRoot;
|
|
861
834
|
return [...info, ...patterns.map((glob$2) => ({
|
|
@@ -863,17 +836,15 @@ function extractPatterns(globs) {
|
|
|
863
836
|
source
|
|
864
837
|
}))];
|
|
865
838
|
}, []);
|
|
866
|
-
return r;
|
|
867
839
|
}
|
|
868
840
|
function calcExcludeGlobInfo(root, commandLineExclude) {
|
|
869
841
|
commandLineExclude = typeof commandLineExclude === "string" ? [commandLineExclude] : commandLineExclude;
|
|
870
842
|
const choice = calcGlobs(commandLineExclude);
|
|
871
|
-
const matcher = new GlobMatcher(choice.globs, {
|
|
872
|
-
root,
|
|
873
|
-
dot: true
|
|
874
|
-
});
|
|
875
843
|
return [{
|
|
876
|
-
matcher,
|
|
844
|
+
matcher: new GlobMatcher(choice.globs, {
|
|
845
|
+
root,
|
|
846
|
+
dot: true
|
|
847
|
+
}),
|
|
877
848
|
source: choice.source
|
|
878
849
|
}];
|
|
879
850
|
}
|
|
@@ -883,14 +854,12 @@ function calcExcludeGlobInfo(root, commandLineExclude) {
|
|
|
883
854
|
* @param root - directory to use as the root
|
|
884
855
|
*/
|
|
885
856
|
function buildGlobMatcher(globs, root, isExclude) {
|
|
886
|
-
|
|
887
|
-
const source = typeof g === "string" ? "command line" : void 0;
|
|
857
|
+
return new GlobMatcher(globs.map((g) => {
|
|
888
858
|
return {
|
|
889
|
-
source,
|
|
859
|
+
source: typeof g === "string" ? "command line" : void 0,
|
|
890
860
|
...fileOrGlobToGlob(g, root)
|
|
891
861
|
};
|
|
892
|
-
})
|
|
893
|
-
return new GlobMatcher(withRoots, {
|
|
862
|
+
}), {
|
|
894
863
|
root,
|
|
895
864
|
mode: isExclude ? "exclude" : "include"
|
|
896
865
|
});
|
|
@@ -899,9 +868,7 @@ function extractGlobsFromMatcher(globMatcher) {
|
|
|
899
868
|
return globMatcher.patternsNormalizedToRoot.map((g) => g.glob);
|
|
900
869
|
}
|
|
901
870
|
function normalizeGlobsToRoot(globs, root, isExclude) {
|
|
902
|
-
|
|
903
|
-
const onlyGlobs = globs.filter((g) => typeof g !== "string" || !isPossibleUrlRegExp.test(g));
|
|
904
|
-
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();
|
|
905
872
|
}
|
|
906
873
|
const isPossibleGlobRegExp = /[()*?[{}]/;
|
|
907
874
|
const isPossibleUrlRegExp = /^[\d_a-z-]{3,}:\/\//;
|
|
@@ -924,8 +891,7 @@ async function adjustPossibleDirectory(glob$2, root) {
|
|
|
924
891
|
if (isPossibleUrlRegExp.test(g.glob)) return glob$2;
|
|
925
892
|
const dirPath = path$1.resolve(g.root, g.glob);
|
|
926
893
|
try {
|
|
927
|
-
|
|
928
|
-
if (stat$1.isDirectory()) {
|
|
894
|
+
if ((await promises.stat(dirPath)).isDirectory()) {
|
|
929
895
|
const useGlob = posix.join(posixPath(g.glob), "**");
|
|
930
896
|
return typeof glob$2 === "string" ? useGlob : {
|
|
931
897
|
...glob$2,
|
|
@@ -941,8 +907,7 @@ function posixPath(p) {
|
|
|
941
907
|
return path$1.sep === "\\" ? p.replaceAll("\\", "/") : p;
|
|
942
908
|
}
|
|
943
909
|
async function normalizeFileOrGlobsToRoot(globs, root) {
|
|
944
|
-
|
|
945
|
-
return normalizeGlobsToRoot(adjustedGlobs, root, false);
|
|
910
|
+
return normalizeGlobsToRoot(await Promise.all(globs.map((g) => adjustPossibleDirectory(g, root))), root, false);
|
|
946
911
|
}
|
|
947
912
|
function glob$1(patterns, options) {
|
|
948
913
|
patterns = typeof patterns === "string" ? workaroundPicomatchBug(patterns) : patterns.map((g) => workaroundPicomatchBug(g));
|
|
@@ -1018,8 +983,7 @@ function resolveFilename(filename, cwd) {
|
|
|
1018
983
|
}
|
|
1019
984
|
function readFileInfo(filename, encoding = UTF8, handleNotFound = false) {
|
|
1020
985
|
filename = resolveFilename(filename);
|
|
1021
|
-
|
|
1022
|
-
return pText.then((text) => ({
|
|
986
|
+
return (filename.startsWith(STDINProtocol) ? streamConsumers.text(process.stdin) : readFileText(filename, encoding)).then((text) => ({
|
|
1023
987
|
text,
|
|
1024
988
|
filename
|
|
1025
989
|
}), (e) => {
|
|
@@ -1058,14 +1022,11 @@ const resolveFilenames = asyncMap(resolveFilename);
|
|
|
1058
1022
|
*/
|
|
1059
1023
|
function readFileListFiles(listFiles) {
|
|
1060
1024
|
let useStdin = false;
|
|
1061
|
-
|
|
1025
|
+
return asyncPipe(mergeAsyncIterables(asyncPipe(listFiles.filter((file) => {
|
|
1062
1026
|
const isStdin$1 = file === "stdin";
|
|
1063
1027
|
useStdin = useStdin || isStdin$1;
|
|
1064
1028
|
return !isStdin$1;
|
|
1065
|
-
});
|
|
1066
|
-
const found = asyncPipe(files, asyncMap((file) => readFileListFile(file)), asyncAwait(), asyncFlatten());
|
|
1067
|
-
const stdin = useStdin ? readStdin() : [];
|
|
1068
|
-
return asyncPipe(mergeAsyncIterables(found, stdin), resolveFilenames);
|
|
1029
|
+
}), asyncMap((file) => readFileListFile(file)), asyncAwait(), asyncFlatten()), useStdin ? readStdin() : []), resolveFilenames);
|
|
1069
1030
|
}
|
|
1070
1031
|
/**
|
|
1071
1032
|
* Read a `listFile` and return the containing file paths resolved relative to the `listFile`.
|
|
@@ -1076,9 +1037,7 @@ function readFileListFiles(listFiles) {
|
|
|
1076
1037
|
async function readFileListFile(listFile) {
|
|
1077
1038
|
try {
|
|
1078
1039
|
const relTo = path$1.resolve(path$1.dirname(listFile));
|
|
1079
|
-
|
|
1080
|
-
const lines = content.split("\n").map((a) => a.trim()).filter((a) => !!a).map((file) => path$1.resolve(relTo, file));
|
|
1081
|
-
return lines;
|
|
1040
|
+
return (await readFile(listFile)).split("\n").map((a) => a.trim()).filter((a) => !!a).map((file) => path$1.resolve(relTo, file));
|
|
1082
1041
|
} catch (err) {
|
|
1083
1042
|
throw toApplicationError(err, `Error reading file list from: "${listFile}"`);
|
|
1084
1043
|
}
|
|
@@ -1089,16 +1048,14 @@ function isStdin(filename) {
|
|
|
1089
1048
|
async function isFile(filename) {
|
|
1090
1049
|
if (isStdin(filename)) return true;
|
|
1091
1050
|
try {
|
|
1092
|
-
|
|
1093
|
-
return stat$1.isFile();
|
|
1051
|
+
return (await promises.stat(filename)).isFile();
|
|
1094
1052
|
} catch {
|
|
1095
1053
|
return false;
|
|
1096
1054
|
}
|
|
1097
1055
|
}
|
|
1098
1056
|
async function isDir(filename) {
|
|
1099
1057
|
try {
|
|
1100
|
-
|
|
1101
|
-
return stat$1.isDirectory();
|
|
1058
|
+
return (await promises.stat(filename)).isDirectory();
|
|
1102
1059
|
} catch {
|
|
1103
1060
|
return false;
|
|
1104
1061
|
}
|
|
@@ -1167,15 +1124,13 @@ var FlatCache = class {
|
|
|
1167
1124
|
* @returns
|
|
1168
1125
|
*/
|
|
1169
1126
|
function loadCacheFile(cachefile) {
|
|
1170
|
-
|
|
1171
|
-
return cache.load();
|
|
1127
|
+
return new FlatCache(cachefile).load();
|
|
1172
1128
|
}
|
|
1173
1129
|
|
|
1174
1130
|
//#endregion
|
|
1175
1131
|
//#region src/util/cache/file-entry-cache/file-entry-cache.ts
|
|
1176
1132
|
async function createFromFile$1(cacheFileUrl, useChecksum, currentWorkingDir) {
|
|
1177
|
-
const
|
|
1178
|
-
const fec = new ImplFileEntryCache(cache, useChecksum ?? false, currentWorkingDir);
|
|
1133
|
+
const fec = new ImplFileEntryCache(await loadCacheFile(cacheFileUrl), useChecksum ?? false, currentWorkingDir);
|
|
1179
1134
|
await fec.removeNotFoundFiles();
|
|
1180
1135
|
return fec;
|
|
1181
1136
|
}
|
|
@@ -1318,7 +1273,7 @@ var ImplFileEntryCache = class {
|
|
|
1318
1273
|
} catch (error) {
|
|
1319
1274
|
if (!isNodeError(error) || error.code !== "ENOENT") throw error;
|
|
1320
1275
|
}
|
|
1321
|
-
this.cache.save();
|
|
1276
|
+
await this.cache.save();
|
|
1322
1277
|
}
|
|
1323
1278
|
resolveKeyToFile(entryKey) {
|
|
1324
1279
|
if (this.currentWorkingDir) return path.resolve(this.currentWorkingDir, entryKey);
|
|
@@ -1375,17 +1330,11 @@ var ShallowObjectCollection = class {
|
|
|
1375
1330
|
|
|
1376
1331
|
//#endregion
|
|
1377
1332
|
//#region src/util/cache/DiskCache.ts
|
|
1378
|
-
const
|
|
1333
|
+
const META_DATA_VERSION_SUFFIX = "-1-" + Object.keys({
|
|
1379
1334
|
v: "v",
|
|
1380
1335
|
r: "r",
|
|
1381
1336
|
d: "d"
|
|
1382
|
-
};
|
|
1383
|
-
/**
|
|
1384
|
-
* Meta Data Version is used to detect if the structure of the meta data has changed.
|
|
1385
|
-
* This is used in combination with the Suffix and the version of CSpell.
|
|
1386
|
-
*/
|
|
1387
|
-
const META_DATA_BASE_VERSION = "1";
|
|
1388
|
-
const META_DATA_VERSION_SUFFIX = "-" + META_DATA_BASE_VERSION + "-" + Object.keys(cacheDataKeys).join("|");
|
|
1337
|
+
}).join("|");
|
|
1389
1338
|
/**
|
|
1390
1339
|
* Caches cspell results on disk
|
|
1391
1340
|
*/
|
|
@@ -1412,7 +1361,7 @@ var DiskCache = class {
|
|
|
1412
1361
|
const data = meta?.data;
|
|
1413
1362
|
const result = data?.r;
|
|
1414
1363
|
const versionMatches = this.version === data?.v;
|
|
1415
|
-
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;
|
|
1416
1365
|
const dd = { ...data };
|
|
1417
1366
|
if (dd.d) dd.d = setTreeEntry(this.dependencyCacheTree, dd.d);
|
|
1418
1367
|
dd.r = dd.r && this.normalizeResult(dd.r);
|
|
@@ -1431,12 +1380,11 @@ var DiskCache = class {
|
|
|
1431
1380
|
const fileDescriptor = await this.fileEntryCache.getFileDescriptor(fileInfo.filename);
|
|
1432
1381
|
const meta = fileDescriptor.meta;
|
|
1433
1382
|
if (fileDescriptor.notFound || !meta) return;
|
|
1434
|
-
|
|
1383
|
+
meta.data = this.objectCollection.get({
|
|
1435
1384
|
v: this.version,
|
|
1436
1385
|
r: this.normalizeResult(result),
|
|
1437
1386
|
d: await this.calcDependencyHashes(dependsUponFiles)
|
|
1438
1387
|
});
|
|
1439
|
-
meta.data = data;
|
|
1440
1388
|
}
|
|
1441
1389
|
async reconcile() {
|
|
1442
1390
|
await this.fileEntryCache.reconcile();
|
|
@@ -1538,9 +1486,7 @@ async function getDependencyForUrl(remoteUrl) {
|
|
|
1538
1486
|
}
|
|
1539
1487
|
}
|
|
1540
1488
|
async function createDiskCache(cacheFileLocation, useCheckSum, cspellVersion, useUniversalCache) {
|
|
1541
|
-
|
|
1542
|
-
const cache = new DiskCache(cacheFileLocation, useCheckSum, cspellVersion, useUniversalCache, fileEntryCache);
|
|
1543
|
-
return cache;
|
|
1489
|
+
return new DiskCache(cacheFileLocation, useCheckSum, cspellVersion, useUniversalCache, await createFromFile(cacheFileLocation, useCheckSum, useUniversalCache));
|
|
1544
1490
|
}
|
|
1545
1491
|
function getTreeEntry(tree, keys) {
|
|
1546
1492
|
let r = tree;
|
|
@@ -1634,8 +1580,7 @@ async function calcCacheSettings(config, cacheOptions, root) {
|
|
|
1634
1580
|
}
|
|
1635
1581
|
async function resolveCacheLocation(cacheLocation) {
|
|
1636
1582
|
try {
|
|
1637
|
-
|
|
1638
|
-
if (s.isFile()) return cacheLocation;
|
|
1583
|
+
if ((await stat(cacheLocation)).isFile()) return cacheLocation;
|
|
1639
1584
|
return path.join(cacheLocation, DEFAULT_CACHE_LOCATION);
|
|
1640
1585
|
} catch (err) {
|
|
1641
1586
|
if (isErrorLike(err) && err.code === "ENOENT") return cacheLocation;
|
|
@@ -1656,10 +1601,7 @@ function normalizeVersion(version$2) {
|
|
|
1656
1601
|
//#region src/util/configFileHelper.ts
|
|
1657
1602
|
async function readConfig(configFile, root, stopConfigSearchAt) {
|
|
1658
1603
|
configFile ??= getEnvironmentVariable(environmentKeys.CSPELL_CONFIG_PATH);
|
|
1659
|
-
if (configFile)
|
|
1660
|
-
const cfgFile = typeof configFile === "string" ? await readConfigHandleError(configFile) : configFile;
|
|
1661
|
-
return configFileToConfigInfo(cfgFile);
|
|
1662
|
-
}
|
|
1604
|
+
if (configFile) return configFileToConfigInfo(typeof configFile === "string" ? await readConfigHandleError(configFile) : configFile);
|
|
1663
1605
|
const config = await cspell.searchForConfig(root, { stopSearchAt: stopConfigSearchAt });
|
|
1664
1606
|
const defaultConfigFile = getEnvironmentVariable(environmentKeys.CSPELL_DEFAULT_CONFIG_PATH);
|
|
1665
1607
|
if (!config && defaultConfigFile) {
|
|
@@ -1673,9 +1615,8 @@ async function readConfig(configFile, root, stopConfigSearchAt) {
|
|
|
1673
1615
|
}
|
|
1674
1616
|
async function configFileToConfigInfo(cfgFile) {
|
|
1675
1617
|
const config = await cspell.resolveConfigFileImports(cfgFile);
|
|
1676
|
-
const source = toFilePathOrHref(cfgFile.url);
|
|
1677
1618
|
return {
|
|
1678
|
-
source,
|
|
1619
|
+
source: toFilePathOrHref(cfgFile.url),
|
|
1679
1620
|
config
|
|
1680
1621
|
};
|
|
1681
1622
|
}
|
|
@@ -1739,12 +1680,10 @@ function lineContext(lineText, start, end, contextRange) {
|
|
|
1739
1680
|
const t0 = lineText.slice(left, right);
|
|
1740
1681
|
const tLeft = t0.trimStart();
|
|
1741
1682
|
left = Math.min(left + t0.length - tLeft.length, start);
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
text,
|
|
1683
|
+
return {
|
|
1684
|
+
text: tLeft.trimEnd(),
|
|
1745
1685
|
offset: left
|
|
1746
1686
|
};
|
|
1747
|
-
return context;
|
|
1748
1687
|
}
|
|
1749
1688
|
function extractContext(tdo, contextRange) {
|
|
1750
1689
|
const { line, offset, text } = tdo;
|
|
@@ -1806,13 +1745,12 @@ async function loadReporters(reporters, defaultReporter, config) {
|
|
|
1806
1745
|
}
|
|
1807
1746
|
}
|
|
1808
1747
|
reporters = !reporters || !reporters.length ? ["default"] : [...reporters];
|
|
1809
|
-
|
|
1810
|
-
return loadedReporters.filter((v) => v !== void 0);
|
|
1748
|
+
return (await Promise.all(reporters.map(loadReporter))).filter((v) => v !== void 0);
|
|
1811
1749
|
}
|
|
1812
1750
|
function finalizeReporter(reporter) {
|
|
1813
1751
|
if (!reporter) return void 0;
|
|
1814
1752
|
if (reporterIsFinalized(reporter)) return reporter;
|
|
1815
|
-
|
|
1753
|
+
return {
|
|
1816
1754
|
issue: (...params) => reporter.issue?.(...params),
|
|
1817
1755
|
info: (...params) => reporter.info?.(...params),
|
|
1818
1756
|
debug: (...params) => reporter.debug?.(...params),
|
|
@@ -1821,7 +1759,6 @@ function finalizeReporter(reporter) {
|
|
|
1821
1759
|
result: (...params) => reporter.result?.(...params),
|
|
1822
1760
|
features: reporter.features
|
|
1823
1761
|
};
|
|
1824
|
-
return final;
|
|
1825
1762
|
}
|
|
1826
1763
|
function reporterIsFinalized(reporter) {
|
|
1827
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;
|
|
@@ -1906,8 +1843,7 @@ var LintReporter = class {
|
|
|
1906
1843
|
});
|
|
1907
1844
|
}
|
|
1908
1845
|
emitProgressComplete(filename, fileNum, fileCount, result) {
|
|
1909
|
-
const
|
|
1910
|
-
const numIssues = filteredIssues.length;
|
|
1846
|
+
const numIssues = result.issues.filter((issue) => filterFeatureIssues({}, issue, result.reportIssueOptions)).length;
|
|
1911
1847
|
for (const reporter of this.#reporters) {
|
|
1912
1848
|
const progress = clean({
|
|
1913
1849
|
type: "ProgressFileComplete",
|
|
@@ -1940,14 +1876,12 @@ function getTimeMeasurer() {
|
|
|
1940
1876
|
//#region src/util/writeFile.ts
|
|
1941
1877
|
async function writeFileOrStream(filename, data) {
|
|
1942
1878
|
switch (filename) {
|
|
1943
|
-
case "stdout":
|
|
1879
|
+
case "stdout":
|
|
1944
1880
|
await writeStream(process.stdout, data);
|
|
1945
1881
|
return;
|
|
1946
|
-
|
|
1947
|
-
case "stderr": {
|
|
1882
|
+
case "stderr":
|
|
1948
1883
|
await writeStream(process.stderr, data);
|
|
1949
1884
|
return;
|
|
1950
|
-
}
|
|
1951
1885
|
case "null": return;
|
|
1952
1886
|
}
|
|
1953
1887
|
return fs.writeFile(filename, data);
|
|
@@ -1989,25 +1923,21 @@ async function runLint(cfg) {
|
|
|
1989
1923
|
const cachedResult = await cache.getCachedLintResults(filename);
|
|
1990
1924
|
if (cachedResult) {
|
|
1991
1925
|
reporter.debug(`Filename: ${filename}, using cache`);
|
|
1992
|
-
|
|
1926
|
+
return { fileResult: {
|
|
1993
1927
|
...cachedResult,
|
|
1994
1928
|
elapsedTimeMs: getElapsedTimeMs()
|
|
1995
|
-
};
|
|
1996
|
-
return { fileResult };
|
|
1929
|
+
} };
|
|
1997
1930
|
}
|
|
1998
1931
|
const uri = filenameToUri(filename, cfg.root).href;
|
|
1999
|
-
|
|
2000
|
-
if (!checkResult.shouldCheck) return { skip: true };
|
|
2001
|
-
const fileInfo = await readFileInfo(filename, void 0, true);
|
|
1932
|
+
if (!(await shouldCheckDocument({ uri }, {}, configInfo.config)).shouldCheck) return { skip: true };
|
|
2002
1933
|
return {
|
|
2003
|
-
fileInfo,
|
|
1934
|
+
fileInfo: await readFileInfo(filename, void 0, true),
|
|
2004
1935
|
reportIssueOptions
|
|
2005
1936
|
};
|
|
2006
1937
|
}
|
|
2007
|
-
const result = fetch$1();
|
|
2008
1938
|
return {
|
|
2009
1939
|
filename,
|
|
2010
|
-
result
|
|
1940
|
+
result: fetch$1()
|
|
2011
1941
|
};
|
|
2012
1942
|
}
|
|
2013
1943
|
async function processFile(filename, configInfo, cache, prefetch$1) {
|
|
@@ -2052,13 +1982,12 @@ async function runLint(cfg) {
|
|
|
2052
1982
|
try {
|
|
2053
1983
|
const { showSuggestions: generateSuggestions, validateDirectives, skipValidation } = cfg.options;
|
|
2054
1984
|
const numSuggestions = configInfo.config.numSuggestions ?? 5;
|
|
2055
|
-
const
|
|
1985
|
+
const r = await spellCheckDocument(doc, clean({
|
|
2056
1986
|
generateSuggestions,
|
|
2057
1987
|
numSuggestions,
|
|
2058
1988
|
validateDirectives,
|
|
2059
1989
|
skipValidation
|
|
2060
|
-
});
|
|
2061
|
-
const r = await spellCheckDocument(doc, validateOptions, configInfo.config);
|
|
1990
|
+
}), configInfo.config);
|
|
2062
1991
|
spellResult = r;
|
|
2063
1992
|
result.processed = r.checked;
|
|
2064
1993
|
result.perf = r.perf ? { ...r.perf } : void 0;
|
|
@@ -2135,11 +2064,10 @@ async function runLint(cfg) {
|
|
|
2135
2064
|
elapsedTimeMs: getElapsedTimeMs()
|
|
2136
2065
|
}
|
|
2137
2066
|
};
|
|
2138
|
-
const result = await processFile(filename, configInfo, cache, fetchResult);
|
|
2139
2067
|
return {
|
|
2140
2068
|
filename,
|
|
2141
2069
|
fileNum: index,
|
|
2142
|
-
result
|
|
2070
|
+
result: await processFile(filename, configInfo, cache, fetchResult)
|
|
2143
2071
|
};
|
|
2144
2072
|
}
|
|
2145
2073
|
async function* loadAndProcessFiles() {
|
|
@@ -2180,8 +2108,7 @@ async function runLint(cfg) {
|
|
|
2180
2108
|
count += 1;
|
|
2181
2109
|
reporter.error("Configuration", ref.error);
|
|
2182
2110
|
});
|
|
2183
|
-
|
|
2184
|
-
dictCollection.dictionaries.forEach((dict) => {
|
|
2111
|
+
(await getDictionary(config)).dictionaries.forEach((dict) => {
|
|
2185
2112
|
const dictErrors = dict.getErrors?.() || [];
|
|
2186
2113
|
const msg = `Dictionary Error with (${dict.name})`;
|
|
2187
2114
|
dictErrors.forEach((error) => {
|
|
@@ -2228,8 +2155,7 @@ async function runLint(cfg) {
|
|
|
2228
2155
|
...cfg.options,
|
|
2229
2156
|
version
|
|
2230
2157
|
}, root);
|
|
2231
|
-
const
|
|
2232
|
-
const result = await processFiles(files, configInfo, cacheSettings);
|
|
2158
|
+
const result = await processFiles(await determineFilesToCheck(configInfo, cfg, reporter, globInfo), configInfo, cacheSettings);
|
|
2233
2159
|
if (configErrors$1 && cfg.options.exitCode !== false) result.errors ||= configErrors$1;
|
|
2234
2160
|
return result;
|
|
2235
2161
|
} catch (e) {
|
|
@@ -2263,19 +2189,14 @@ async function determineGlobs(configInfo, cfg) {
|
|
|
2263
2189
|
const cliGlobs = cfg.fileGlobs;
|
|
2264
2190
|
const allGlobs = cliGlobs.length && cliGlobs || cfg.options.filterFiles !== false && configInfo.config.files || [];
|
|
2265
2191
|
const combinedGlobs = await normalizeFileOrGlobsToRoot(allGlobs, cfg.root);
|
|
2266
|
-
const
|
|
2267
|
-
|
|
2268
|
-
const includeGlobs = combinedGlobs.filter((g) => !g.startsWith("!"));
|
|
2269
|
-
const excludeGlobs = [...combinedGlobs.filter((g) => g.startsWith("!")).map((g) => g.slice(1)), ...normalizedExcludes];
|
|
2270
|
-
const fileGlobs = includeGlobs;
|
|
2271
|
-
const appGlobs = {
|
|
2192
|
+
const normalizedExcludes = normalizeGlobsToRoot(extractPatterns(cfg.excludes).map((p) => p.glob), cfg.root, true);
|
|
2193
|
+
return {
|
|
2272
2194
|
allGlobs,
|
|
2273
2195
|
gitIgnore,
|
|
2274
|
-
fileGlobs,
|
|
2275
|
-
excludeGlobs,
|
|
2196
|
+
fileGlobs: combinedGlobs.filter((g) => !g.startsWith("!")),
|
|
2197
|
+
excludeGlobs: [...combinedGlobs.filter((g) => g.startsWith("!")).map((g) => g.slice(1)), ...normalizedExcludes],
|
|
2276
2198
|
normalizedExcludes
|
|
2277
2199
|
};
|
|
2278
|
-
return appGlobs;
|
|
2279
2200
|
}
|
|
2280
2201
|
async function determineFilesToCheck(configInfo, cfg, reporter, globInfo) {
|
|
2281
2202
|
async function _determineFilesToCheck() {
|
|
@@ -2286,16 +2207,14 @@ async function determineFilesToCheck(configInfo, cfg, reporter, globInfo) {
|
|
|
2286
2207
|
const globsToExcludeRaw = [...configInfo.config.ignorePaths || [], ...excludeGlobs];
|
|
2287
2208
|
const globsToExclude = globsToExcludeRaw.filter((g) => !globPattern(g).startsWith("!"));
|
|
2288
2209
|
if (globsToExclude.length !== globsToExcludeRaw.length) {
|
|
2289
|
-
const
|
|
2290
|
-
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(", ")}`;
|
|
2291
2211
|
reporter.info(msg, MessageTypes.Warning);
|
|
2292
2212
|
}
|
|
2293
2213
|
const globMatcher = buildGlobMatcher(globsToExclude, root, true);
|
|
2294
|
-
const ignoreGlobs = extractGlobsFromMatcher(globMatcher);
|
|
2295
2214
|
const globOptions = {
|
|
2296
2215
|
root,
|
|
2297
2216
|
cwd: root,
|
|
2298
|
-
ignore: [...
|
|
2217
|
+
ignore: [...extractGlobsFromMatcher(globMatcher), ...normalizedExcludes],
|
|
2299
2218
|
nodir: true
|
|
2300
2219
|
};
|
|
2301
2220
|
const enableGlobDot = cfg.enableGlobDot ?? configInfo.config.enableGlobDot;
|
|
@@ -2306,8 +2225,7 @@ async function determineFilesToCheck(configInfo, cfg, reporter, globInfo) {
|
|
|
2306
2225
|
const cliFiles = cfg.options.mustFindFiles ? rawCliFiles : rawCliFiles && pipeAsync(rawCliFiles, opFilterAsync(isFile));
|
|
2307
2226
|
const foundFiles = hasFileLists ? concatAsyncIterables(cliFiles, await useFileLists(fileLists, includeFilter)) : cliFiles || await findFiles(fileGlobs, globOptions);
|
|
2308
2227
|
const filtered = gitIgnore ? await gitIgnore.filterOutIgnored(foundFiles) : foundFiles;
|
|
2309
|
-
|
|
2310
|
-
return files;
|
|
2228
|
+
return isAsyncIterable(filtered) ? pipeAsync(filtered, opFilterExcludedFiles) : [...pipe(filtered, opFilterExcludedFiles)];
|
|
2311
2229
|
}
|
|
2312
2230
|
function isExcluded(filename, globMatcherExclude) {
|
|
2313
2231
|
if (isBinaryFile(toFileURL(filename))) return true;
|
|
@@ -2321,8 +2239,7 @@ async function determineFilesToCheck(configInfo, cfg, reporter, globInfo) {
|
|
|
2321
2239
|
return r.matched;
|
|
2322
2240
|
}
|
|
2323
2241
|
function filterOutExcludedFilesFn(globMatcherExclude) {
|
|
2324
|
-
const
|
|
2325
|
-
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());
|
|
2326
2243
|
reporter.info(`Exclusion Globs: \n ${excludeInfo.join("\n ")}\n`, MessageTypes.Info);
|
|
2327
2244
|
return (filename) => !isExcluded(filename, globMatcherExclude);
|
|
2328
2245
|
}
|
|
@@ -2355,12 +2272,11 @@ function getLoggerFromReporter(reporter) {
|
|
|
2355
2272
|
};
|
|
2356
2273
|
const error = (...params) => {
|
|
2357
2274
|
const msg = format(...params);
|
|
2358
|
-
|
|
2275
|
+
reporter.error(msg, {
|
|
2359
2276
|
message: "",
|
|
2360
2277
|
name: "error",
|
|
2361
2278
|
toString: () => ""
|
|
2362
|
-
};
|
|
2363
|
-
reporter.error(msg, err);
|
|
2279
|
+
});
|
|
2364
2280
|
};
|
|
2365
2281
|
const warn = (...params) => {
|
|
2366
2282
|
const msg = format(...params);
|
|
@@ -2382,8 +2298,7 @@ async function generateGitIgnore(roots) {
|
|
|
2382
2298
|
return new GitIgnore(root?.map((p) => path$1.resolve(p)));
|
|
2383
2299
|
}
|
|
2384
2300
|
async function useFileLists(fileListFiles, filterFiles) {
|
|
2385
|
-
|
|
2386
|
-
return pipeAsync(files, opFilter(filterFiles), opFilterAsync(isNotDir));
|
|
2301
|
+
return pipeAsync(readFileListFiles(fileListFiles), opFilter(filterFiles), opFilterAsync(isNotDir));
|
|
2387
2302
|
}
|
|
2388
2303
|
function createIncludeFileFilterFn(includeGlobPatterns, root, dot) {
|
|
2389
2304
|
if (!includeGlobPatterns?.length) return () => true;
|
|
@@ -2403,13 +2318,9 @@ async function* concatAsyncIterables(...iterables) {
|
|
|
2403
2318
|
}
|
|
2404
2319
|
}
|
|
2405
2320
|
async function writeDictionaryLog() {
|
|
2406
|
-
const
|
|
2407
|
-
const
|
|
2408
|
-
|
|
2409
|
-
const lines = _debug.cacheDictionaryGetLog().filter((d) => d.method === "has").map((d) => fields.map((f) => f in d ? `${d[f]}` : "").join(", "));
|
|
2410
|
-
const data = header + lines.join("\n") + "\n";
|
|
2411
|
-
const filename = getEnvironmentVariable("CSPELL_ENABLE_DICTIONARY_LOG_FILE") || "cspell-dictionary-log.csv";
|
|
2412
|
-
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);
|
|
2413
2324
|
}
|
|
2414
2325
|
function globPattern(g) {
|
|
2415
2326
|
return typeof g === "string" ? g : g.glob;
|
|
@@ -2449,11 +2360,10 @@ var LintRequest = class {
|
|
|
2449
2360
|
this.fileLists = (options.fileList ?? options.fileLists) || [];
|
|
2450
2361
|
this.files = mergeFiles(options.file, options.files);
|
|
2451
2362
|
const noConfigSearch = options.configSearch === false ? true : options.configSearch === true ? false : void 0;
|
|
2452
|
-
const dictionaries = [...(options.disableDictionary ?? []).map((d) => `!${d}`), ...(options.dictionary ?? []).map((d) => `!!${d}`)];
|
|
2453
2363
|
const languageSettings = [{
|
|
2454
2364
|
languageId: "*",
|
|
2455
2365
|
locale: "*",
|
|
2456
|
-
dictionaries
|
|
2366
|
+
dictionaries: [...(options.disableDictionary ?? []).map((d) => `!${d}`), ...(options.dictionary ?? []).map((d) => `!!${d}`)]
|
|
2457
2367
|
}];
|
|
2458
2368
|
this.cspellSettingsFromCliOptions = {
|
|
2459
2369
|
...noConfigSearch !== void 0 ? { noConfigSearch } : {},
|
|
@@ -2476,22 +2386,18 @@ function extractUnknownWordsConfig(options) {
|
|
|
2476
2386
|
const config = {};
|
|
2477
2387
|
if (!options.report) return config;
|
|
2478
2388
|
switch (options.report) {
|
|
2479
|
-
case "all":
|
|
2389
|
+
case "all":
|
|
2480
2390
|
config.unknownWords = unknownWordsChoices.ReportAll;
|
|
2481
2391
|
break;
|
|
2482
|
-
|
|
2483
|
-
case "simple": {
|
|
2392
|
+
case "simple":
|
|
2484
2393
|
config.unknownWords = unknownWordsChoices.ReportSimple;
|
|
2485
2394
|
break;
|
|
2486
|
-
|
|
2487
|
-
case "typos": {
|
|
2395
|
+
case "typos":
|
|
2488
2396
|
config.unknownWords = unknownWordsChoices.ReportCommonTypos;
|
|
2489
2397
|
break;
|
|
2490
|
-
|
|
2491
|
-
case "flagged": {
|
|
2398
|
+
case "flagged":
|
|
2492
2399
|
config.unknownWords = unknownWordsChoices.ReportFlagged;
|
|
2493
2400
|
break;
|
|
2494
|
-
}
|
|
2495
2401
|
}
|
|
2496
2402
|
return config;
|
|
2497
2403
|
}
|
|
@@ -2540,8 +2446,7 @@ var SimpleRepl = class {
|
|
|
2540
2446
|
}
|
|
2541
2447
|
_completer(line) {
|
|
2542
2448
|
if (this.completer) return this.completer(line);
|
|
2543
|
-
|
|
2544
|
-
return [hist, line];
|
|
2449
|
+
return [this._history.filter((h) => h.startsWith(line)), line];
|
|
2545
2450
|
}
|
|
2546
2451
|
get history() {
|
|
2547
2452
|
return this._history;
|
|
@@ -2631,8 +2536,7 @@ function extractSpecialDictionaries(config) {
|
|
|
2631
2536
|
}
|
|
2632
2537
|
async function listDictionaries(options) {
|
|
2633
2538
|
const configFile = await readConfig(options.config, void 0);
|
|
2634
|
-
const
|
|
2635
|
-
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);
|
|
2636
2540
|
const useFileType = options.fileType === "text" ? "plaintext" : options.fileType;
|
|
2637
2541
|
if (options.locale) configBase.language = options.locale;
|
|
2638
2542
|
const config = combineTextAndLanguageSettings(configBase, "", useFileType || configBase.languageId || "plaintext");
|
|
@@ -2656,8 +2560,7 @@ async function listDictionaries(options) {
|
|
|
2656
2560
|
}
|
|
2657
2561
|
const dictionaryDefinitions = (config.dictionaryDefinitions || []).filter(filterDicts);
|
|
2658
2562
|
dictionaryDefinitions.sort((a, b) => a.name.localeCompare(b.name));
|
|
2659
|
-
|
|
2660
|
-
return [...specialDicts, ...dictionaryDefinitions.map(toListDictionariesResult)];
|
|
2563
|
+
return [...options.enabled !== false ? extractSpecialDictionaries(config) : [], ...dictionaryDefinitions.map(toListDictionariesResult)];
|
|
2661
2564
|
}
|
|
2662
2565
|
|
|
2663
2566
|
//#endregion
|
|
@@ -2673,11 +2576,10 @@ function lint(fileGlobs, options, reporter) {
|
|
|
2673
2576
|
...useOptions,
|
|
2674
2577
|
console
|
|
2675
2578
|
};
|
|
2676
|
-
|
|
2579
|
+
return runLint(new LintRequest(fileGlobs, useOptions, finalizeReporter(reporter) ?? getReporter({
|
|
2677
2580
|
...useOptions,
|
|
2678
2581
|
fileGlobs
|
|
2679
|
-
}, reporterOptions));
|
|
2680
|
-
return runLint(cfg);
|
|
2582
|
+
}, reporterOptions)));
|
|
2681
2583
|
}
|
|
2682
2584
|
async function* trace(words, options) {
|
|
2683
2585
|
options = fixLegacy(options);
|
|
@@ -2687,8 +2589,7 @@ async function* trace(words, options) {
|
|
|
2687
2589
|
const loadDefault = options.defaultConfiguration ?? configFile.config.loadDefaultConfiguration ?? true;
|
|
2688
2590
|
const additionalSettings = {};
|
|
2689
2591
|
if (options.dictionary) additionalSettings.dictionaries = options.dictionary;
|
|
2690
|
-
|
|
2691
|
-
yield* traceWordsAsync(iWords, config, clean({
|
|
2592
|
+
yield* traceWordsAsync(iWords, mergeSettings(await getDefaultSettings(loadDefault), await getGlobalSettingsAsync(), configFile.config, additionalSettings), clean({
|
|
2692
2593
|
languageId,
|
|
2693
2594
|
locale,
|
|
2694
2595
|
ignoreCase,
|
|
@@ -2731,8 +2632,7 @@ async function* suggestions(words, options) {
|
|
|
2731
2632
|
}
|
|
2732
2633
|
const iWords = options.repl ? pipeAsync(toAsyncIterable(words, simpleRepl()), opTap(tapStart)) : options.useStdin ? pipeAsync(toAsyncIterable(words, readStdin()), opTap(tapStart)) : words.map(mapStart);
|
|
2733
2634
|
try {
|
|
2734
|
-
|
|
2735
|
-
yield* results;
|
|
2635
|
+
yield* pipeAsync(suggestionsForWords(iWords, clean({ ...options }), configFile.config), opMap(mapEnd));
|
|
2736
2636
|
} catch (e) {
|
|
2737
2637
|
if (!(e instanceof SuggestionError)) throw e;
|
|
2738
2638
|
console.error(e.message);
|
|
@@ -2744,18 +2644,16 @@ function createInit(options) {
|
|
|
2744
2644
|
}
|
|
2745
2645
|
function registerApplicationFeatureFlags() {
|
|
2746
2646
|
const ff = getFeatureFlags();
|
|
2747
|
-
|
|
2647
|
+
[{
|
|
2748
2648
|
name: "timer",
|
|
2749
2649
|
description: "Display elapsed time for command."
|
|
2750
|
-
}];
|
|
2751
|
-
flags.forEach((flag) => ff.register(flag));
|
|
2650
|
+
}].forEach((flag) => ff.register(flag));
|
|
2752
2651
|
return ff;
|
|
2753
2652
|
}
|
|
2754
2653
|
function parseApplicationFeatureFlags(flags) {
|
|
2755
|
-
|
|
2756
|
-
return parseFeatureFlags(flags, ff);
|
|
2654
|
+
return parseFeatureFlags(flags, registerApplicationFeatureFlags());
|
|
2757
2655
|
}
|
|
2758
2656
|
|
|
2759
2657
|
//#endregion
|
|
2760
|
-
export {
|
|
2761
|
-
//# 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.
|
|
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
|
}
|