cspell 9.6.2 → 9.6.4
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 +2 -0
- package/dist/esm/app.d.ts +1 -1
- package/dist/esm/app.js +39 -28
- package/dist/esm/{application-BBOBF62T.js → application-DYABxs7R.js} +425 -371
- package/dist/esm/{application-Ce_s5c1d.d.ts → application-i4vvz7Jf.d.ts} +6 -2
- package/dist/esm/application.d.ts +2 -2
- package/dist/esm/application.js +1 -1
- package/dist/esm/index.d.ts +3 -6
- package/dist/esm/index.js +1 -1
- package/dist/esm/{options-D_PtlSKK.d.ts → options-CeDseSxu.d.ts} +6 -3
- package/package.json +16 -16
package/README.md
CHANGED
|
@@ -291,6 +291,8 @@ Options:
|
|
|
291
291
|
words.
|
|
292
292
|
--dictionary <name> Enable a dictionary by name. Can be used multiple
|
|
293
293
|
times.
|
|
294
|
+
--no-dictionary <name> Disable a dictionary by name. Can be used multiple
|
|
295
|
+
times.
|
|
294
296
|
--dictionary-path <format> Configure how to display the dictionary path.
|
|
295
297
|
(choices: "hide", "short", "long", "full",
|
|
296
298
|
default: Display most of the path.)
|
package/dist/esm/app.d.ts
CHANGED
package/dist/esm/app.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as
|
|
1
|
+
import { C as ApplicationError, S as width, T as console, _ as padLeft, a as parseApplicationFeatureFlags, b as pruneAnsiTextEnd, c as listDictionaries, d as validateUnitSize, f as unindent, g as tableToLines, i as lint, l as ReportChoicesAll, m as npmPackage, n as checkText, o as suggestions, p as DEFAULT_CACHE_LOCATION, r as createInit, s as trace, t as IncludeExcludeFlag, u as cvtLinterCliCommandOptionsToLinterCliOptions, v as padWidth, w as CheckFailed, x as pruneAnsiTextStart, y as ansiWidth } from "./application-DYABxs7R.js";
|
|
2
2
|
import { Link } from "cspell-lib";
|
|
3
3
|
import chalk from "chalk";
|
|
4
4
|
import * as iPath from "node:path";
|
|
@@ -45,6 +45,17 @@ function collect$1(value, previous) {
|
|
|
45
45
|
return previous ? [...previous, ...values] : values;
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
48
|
+
* Collects string values into an array, prefixing each value with the given prefix.
|
|
49
|
+
* @param prefix the prefix to add to each value.
|
|
50
|
+
* @returns a function that collects values with the given prefix.
|
|
51
|
+
*/
|
|
52
|
+
function prefixCollect(prefix) {
|
|
53
|
+
return (value, previous) => {
|
|
54
|
+
const values = (Array.isArray(value) ? value : [value]).map((v) => prefix + v);
|
|
55
|
+
return previous ? [...previous, ...values] : values;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
48
59
|
* Create Option - a helper function to create a commander option.
|
|
49
60
|
* @param name - the name of the option
|
|
50
61
|
* @param description - the description of the option
|
|
@@ -61,16 +72,16 @@ function crOpt(name, description, parseArg, defaultValue) {
|
|
|
61
72
|
|
|
62
73
|
//#endregion
|
|
63
74
|
//#region src/emitters/helpers.ts
|
|
64
|
-
function trimMidPath(s, w, sep
|
|
75
|
+
function trimMidPath(s, w, sep) {
|
|
65
76
|
if (s.length <= w) return s;
|
|
66
|
-
const parts = s.split(sep
|
|
77
|
+
const parts = s.split(sep);
|
|
67
78
|
if (parts[parts.length - 1].length > w) return trimMid(s, w);
|
|
68
|
-
function join(left
|
|
79
|
+
function join(left, right) {
|
|
69
80
|
return [
|
|
70
|
-
...parts.slice(0, left
|
|
81
|
+
...parts.slice(0, left),
|
|
71
82
|
"…",
|
|
72
|
-
...parts.slice(right
|
|
73
|
-
].join(sep
|
|
83
|
+
...parts.slice(right)
|
|
84
|
+
].join(sep);
|
|
74
85
|
}
|
|
75
86
|
let left = 0, right = parts.length, last = "";
|
|
76
87
|
for (let i = 0; i < parts.length; ++i) {
|
|
@@ -101,15 +112,15 @@ function trimMid(s, w) {
|
|
|
101
112
|
const r = Math.ceil((w - 1) / 2);
|
|
102
113
|
return s.slice(0, l) + "…" + s.slice(-r);
|
|
103
114
|
}
|
|
104
|
-
function formatDictionaryLocation(dictSource, maxWidth
|
|
105
|
-
let relPath = cwd ? iPath
|
|
115
|
+
function formatDictionaryLocation(dictSource, maxWidth, { cwd, dictionaryPathFormat: format, iPath }) {
|
|
116
|
+
let relPath = cwd ? iPath.relative(cwd, dictSource) : dictSource;
|
|
106
117
|
const idxNodeModule = relPath.lastIndexOf("node_modules");
|
|
107
118
|
const isNodeModule = idxNodeModule >= 0;
|
|
108
119
|
if (format === "hide") return "";
|
|
109
|
-
if (format === "short") return (isNodeModule ? "[node_modules]/" : relPath.startsWith(".." + iPath
|
|
120
|
+
if (format === "short") return (isNodeModule ? "[node_modules]/" : relPath.startsWith(".." + iPath.sep + "..") ? "…/" : relPath.startsWith(".." + iPath.sep) ? "../" : "") + iPath.basename(dictSource);
|
|
110
121
|
if (format === "full") return dictSource;
|
|
111
122
|
relPath = isNodeModule ? relPath.slice(idxNodeModule) : relPath;
|
|
112
|
-
return trimMidPath(relPath.length < dictSource.length ? relPath : dictSource, maxWidth
|
|
123
|
+
return trimMidPath(relPath.length < dictSource.length ? relPath : dictSource, maxWidth, iPath.sep);
|
|
113
124
|
}
|
|
114
125
|
|
|
115
126
|
//#endregion
|
|
@@ -153,12 +164,12 @@ function calcHeaders(options) {
|
|
|
153
164
|
return headers;
|
|
154
165
|
}
|
|
155
166
|
function emitDictResult(r, options) {
|
|
156
|
-
const a = r.enabled ? "*" : " ";
|
|
167
|
+
const a = (r.blocked ? chalk.redBright("!") : "") + (r.enabled ? "*" : " ");
|
|
157
168
|
const dictColor = r.enabled ? chalk.yellowBright : chalk.rgb(200, 128, 50);
|
|
158
|
-
const n = (width
|
|
169
|
+
const n = (width) => dictColor(pruneAnsiTextEnd(r.name, width && width - ansiWidth(a)) + a);
|
|
159
170
|
const c = colorize$1(chalk.white);
|
|
160
|
-
const locales = (width
|
|
161
|
-
const fileTypes = (width
|
|
171
|
+
const locales = (width) => c(pruneAnsiTextEnd(r.locales?.join(",") || "", width));
|
|
172
|
+
const fileTypes = (width) => c(pruneAnsiTextEnd(r.fileTypes?.join(",") || "", width));
|
|
162
173
|
if (!r.path) return {
|
|
163
174
|
name: n,
|
|
164
175
|
location: c(r.inline?.join(", ") || ""),
|
|
@@ -357,7 +368,7 @@ function commandLint(prog, opts) {
|
|
|
357
368
|
spellCheckCommand.description("Check spelling").option("-c, --config <cspell.json>", "Configuration file to use. By default cspell looks for cspell.json in the current directory.").addOption(crOpt("--config-search", "Allow searching for configuration files.", void 0).hideHelp()).option("--no-config-search", "Disable automatic searching for additional configuration files in parent directories. Only the specified config file (if any) will be used.").option("--stop-config-search-at <dir>", "Specify a directory at which to stop searching for configuration files when walking up from the files being checked. Useful for limiting config inheritance.", collect$1).option("-v, --verbose", "Display more information about the files being checked. Add more than one -v for increased verbosity.", increaseVerbosity, 0).option("--locale <locale>", "Set language locales. i.e. \"en,fr\" for English and French, or \"en-GB\" for British English.").option("--language-id <file-type>", "Force programming language for unknown extensions. i.e. \"php\" or \"scala\"").addOption(crOpt("--languageId <file-type>", "Alias of \"--language-id\". Force programming language for unknown extensions. i.e. \"php\" or \"scala\"").hideHelp()).option("--words-only", "Only output the words not found in the dictionaries.").addOption(crOpt("--wordsOnly", "Only output the words not found in the dictionaries.").hideHelp()).option("-u, --unique", "Only output the first instance of a word not found in the dictionaries.").option("-e, --exclude <glob>", "Exclude files matching the glob pattern. This option can be used multiple times to add multiple globs. ", collect$1).option("--file-list <path or stdin>", "Specify a list of files to be spell checked. The list is filtered against the glob file patterns. Note: the format is 1 file path per line.", collect$1).option("--file [file...]", "Specify files to spell check. They are filtered by the [globs...].", collect$1).addOption(crOpt("--files [file...]", "Alias of \"--file\". Files to spell check.", collect$1).hideHelp()).option("--no-issues", "Do not show the spelling errors.").option("--no-progress", "Turn off progress messages").option("--no-summary", "Turn off summary message in console.").option("-s, --silent", "Silent mode, suppress error messages.").option("--no-exit-code", "Do not return an exit code if issues are found.").addOption(crOpt("--quiet", "Only show spelling issues or errors.").implies({
|
|
358
369
|
summary: false,
|
|
359
370
|
progress: false
|
|
360
|
-
})).option("--fail-fast", "Exit after first file with an issue or error.").addOption(crOpt("--no-fail-fast", "Process all files even if there is an error.").hideHelp()).option("--continue-on-error", "Continue processing files even if there is a configuration error.").option("-r, --root <root folder>", "Root directory, defaults to current directory.").addOption(crOpt("--relative", "Issues are displayed relative to the root.").default(true).hideHelp()).option("--no-relative", "Issues are displayed with absolute path instead of relative to the root.").option("--show-context", "Show the surrounding text around an issue.").option("--show-suggestions", "Show spelling suggestions.").addOption(crOpt("--no-show-suggestions", "Do not show spelling suggestions or fixes.").default(void 0)).addOption(crOpt("--must-find-files", "Error if no files are found.").default(true).hideHelp()).option("--no-must-find-files", "Do not error if no files are found.").addOption(crOpt("--legacy", "Legacy output").hideHelp()).addOption(crOpt("--local <local>", "Deprecated -- Use: --locale").hideHelp()).option("--cache", "Use cache to only check changed files.").option("--no-cache", "Do not use cache.").option("--cache-reset", "Reset the cache file.").addOption(crOpt("--cache-strategy <strategy>", "Strategy to use for detecting changed files.").choices(["content", "metadata"]).default("content")).option("--cache-location <path>", `Path to the cache file or directory. (default: "${DEFAULT_CACHE_LOCATION}")`).option("--dot", "Include files and directories starting with `.` (period) when matching globs.").option("--gitignore", "Ignore files matching glob patterns found in .gitignore files.").option("--no-gitignore", "Do NOT use .gitignore files.").option("--gitignore-root <path>", "Prevent searching for .gitignore files past root.", collect$1).option("--validate-directives", "Validate in-document CSpell directives.").addOption(crOpt("--no-validate-directives", "Do not validate in-document CSpell directives.").hideHelp()).option("--max-file-size <size>", "Prevent checking large files. i.e 1MB, 50KB, 1GB").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.")).option("--dictionary <name>", "Enable a dictionary by name.", collect$1).option("--disable-dictionary <name>", "Disable a dictionary by name.", collect$1).option("--reporter <module|path>", "Specify one or more reporters to use.", collect$1).addOption(crOpt("--report <level>", "Set how unknown words are reported").choices(ReportChoicesAll)).addOption(crOpt("--skip-validation", "Collect and process documents, but do not spell check.").implies({ cache: false }).hideHelp()).addOption(crOpt("--issues-summary-report", "Output a summary of issues found.").hideHelp()).addOption(crOpt("--show-perf-summary", "Output a performance summary report.").hideHelp()).option("--issue-template [template]", "Use a custom issue template. See --help --issue-template for details.").addOption(crOpt("--debug", "Output information useful for debugging cspell.json files.").hideHelp()).usage(usage).addHelpText("after", augmentCommandHelp).arguments("[globs...]").action(action);
|
|
371
|
+
})).option("--fail-fast", "Exit after first file with an issue or error.").addOption(crOpt("--no-fail-fast", "Process all files even if there is an error.").hideHelp()).option("--continue-on-error", "Continue processing files even if there is a configuration error.").option("-r, --root <root folder>", "Root directory, defaults to current directory.").addOption(crOpt("--relative", "Issues are displayed relative to the root.").default(true).hideHelp()).option("--no-relative", "Issues are displayed with absolute path instead of relative to the root.").option("--show-context", "Show the surrounding text around an issue.").option("--show-suggestions", "Show spelling suggestions.").addOption(crOpt("--no-show-suggestions", "Do not show spelling suggestions or fixes.").default(void 0)).addOption(crOpt("--must-find-files", "Error if no files are found.").default(true).hideHelp()).option("--no-must-find-files", "Do not error if no files are found.").addOption(crOpt("--legacy", "Legacy output").hideHelp()).addOption(crOpt("--local <local>", "Deprecated -- Use: --locale").hideHelp()).option("--cache", "Use cache to only check changed files.").option("--no-cache", "Do not use cache.").option("--cache-reset", "Reset the cache file.").addOption(crOpt("--cache-strategy <strategy>", "Strategy to use for detecting changed files.").choices(["content", "metadata"]).default("content")).option("--cache-location <path>", `Path to the cache file or directory. (default: "${DEFAULT_CACHE_LOCATION}")`).option("--dot", "Include files and directories starting with `.` (period) when matching globs.").option("--gitignore", "Ignore files matching glob patterns found in .gitignore files.").option("--no-gitignore", "Do NOT use .gitignore files.").option("--gitignore-root <path>", "Prevent searching for .gitignore files past root.", collect$1).option("--validate-directives", "Validate in-document CSpell directives.").addOption(crOpt("--no-validate-directives", "Do not validate in-document CSpell directives.").hideHelp()).option("--max-file-size <size>", "Prevent checking large files. i.e 1MB, 50KB, 1GB").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.")).option("--dictionary <name>", "Enable a dictionary by name.", collect$1).addOption(crOpt("--no-dictionary <name>", "Disable a dictionary by name. Can be used multiple times.", prefixCollect("!")).hideHelp()).option("--disable-dictionary <name>", "Disable a dictionary by name.", collect$1).option("--reporter <module|path>", "Specify one or more reporters to use.", collect$1).addOption(crOpt("--report <level>", "Set how unknown words are reported").choices(ReportChoicesAll)).addOption(crOpt("--skip-validation", "Collect and process documents, but do not spell check.").implies({ cache: false }).hideHelp()).addOption(crOpt("--issues-summary-report", "Output a summary of issues found.").hideHelp()).addOption(crOpt("--show-perf-summary", "Output a performance summary report.").hideHelp()).option("--issue-template [template]", "Use a custom issue template. See --help --issue-template for details.").addOption(crOpt("--debug", "Output information useful for debugging cspell.json files.").hideHelp()).usage(usage).addHelpText("after", augmentCommandHelp).arguments("[globs...]").action(action);
|
|
361
372
|
return spellCheckCommand;
|
|
362
373
|
}
|
|
363
374
|
async function action(fileGlobs, cliOptions) {
|
|
@@ -442,32 +453,32 @@ function increaseVerbosity(_dummyValue, previous) {
|
|
|
442
453
|
//#region src/emitters/suggestionsEmitter.ts
|
|
443
454
|
const regExpRTL = /([ \u0591-\u07FF\uFB1D-\uFDFD\uFE70-\uFEFC]+)/g;
|
|
444
455
|
function reverseRtlText(s) {
|
|
445
|
-
return s.replaceAll(regExpRTL, (s
|
|
456
|
+
return s.replaceAll(regExpRTL, (s) => [...s].reverse().join(""));
|
|
446
457
|
}
|
|
447
458
|
function emitSuggestionResult(result, options) {
|
|
448
|
-
const { word, suggestions
|
|
459
|
+
const { word, suggestions } = result;
|
|
449
460
|
const { verbose, output = console } = options;
|
|
450
461
|
const elapsed = verbose && verbose > 1 && result.elapsedTimeMs ? ` ${result.elapsedTimeMs.toFixed(2)} ms` : "";
|
|
451
462
|
const rWord = reverseRtlText(word);
|
|
452
463
|
const wordEx = rWord !== word ? ` (${chalk.yellow(rWord)})` : "";
|
|
453
464
|
output.log((word ? chalk.yellow(word) + wordEx : chalk.yellow("<empty>")) + ":" + elapsed);
|
|
454
|
-
if (!suggestions
|
|
465
|
+
if (!suggestions.length) {
|
|
455
466
|
console.log(chalk.yellow(" <no suggestions>"));
|
|
456
467
|
return;
|
|
457
468
|
}
|
|
458
|
-
function handleRtl(word
|
|
459
|
-
const r = reverseRtlText(word
|
|
460
|
-
return r === word
|
|
469
|
+
function handleRtl(word) {
|
|
470
|
+
const r = reverseRtlText(word);
|
|
471
|
+
return r === word ? word : `${word} (${r})`;
|
|
461
472
|
}
|
|
462
473
|
if (verbose) {
|
|
463
|
-
const mappedSugs = suggestions
|
|
474
|
+
const mappedSugs = suggestions.map((s) => ({
|
|
464
475
|
...s,
|
|
465
476
|
w: handleRtl(s.compoundWord || s.wordAdjustedToMatchCase || s.word)
|
|
466
477
|
}));
|
|
467
|
-
const maxWidth
|
|
478
|
+
const maxWidth = mappedSugs.map((s) => width(s.w)).reduce((max, len) => Math.max(max, len), 0);
|
|
468
479
|
for (const sug of mappedSugs) {
|
|
469
480
|
const { cost, dictionaries, w } = sug;
|
|
470
|
-
const padding = " ".repeat(padWidth(w, maxWidth
|
|
481
|
+
const padding = " ".repeat(padWidth(w, maxWidth));
|
|
471
482
|
const forbid = sug.forbidden && sug.isPreferred ? chalk.red("*") : sug.forbidden ? chalk.red("X") : sug.isPreferred ? chalk.yellow("*") : " ";
|
|
472
483
|
const ignore = sug.noSuggest ? chalk.yellow("N") : " ";
|
|
473
484
|
const strCost = padLeft(cost.toString(10), 4);
|
|
@@ -475,7 +486,7 @@ function emitSuggestionResult(result, options) {
|
|
|
475
486
|
output.log(` - ${formatWord(w, sug)}${padding} ${forbid}${ignore} - ${chalk.yellow(strCost)} ${dicts}`);
|
|
476
487
|
}
|
|
477
488
|
} else {
|
|
478
|
-
const mappedSugs = suggestions
|
|
489
|
+
const mappedSugs = suggestions.map((s) => ({
|
|
479
490
|
...s,
|
|
480
491
|
word: handleRtl(s.wordAdjustedToMatchCase || s.word)
|
|
481
492
|
}));
|
|
@@ -580,7 +591,7 @@ function emitTraceResult(r, options) {
|
|
|
580
591
|
const sug = r.preferredSuggestions?.map((s) => chalk.yellowBright(s)).join(", ") || "";
|
|
581
592
|
const w = (r.forbidden ? chalk.red(cWord) : chalk.green(cWord)) + (sug ? `->(${sug})` : "");
|
|
582
593
|
const f = calcFoundChar(r);
|
|
583
|
-
const a = r.dictActive ? "*" : " ";
|
|
594
|
+
const a = (r.dictBlocked ? chalk.redBright("!") : "") + (r.dictActive ? "*" : " ");
|
|
584
595
|
const dictName = r.dictName.slice(0, colWidthDictionaryName - 1) + a;
|
|
585
596
|
const n = (r.dictActive ? chalk.yellowBright : chalk.rgb(200, 128, 50))(dictName);
|
|
586
597
|
const c = colorize(errors ? chalk.red : chalk.white);
|
|
@@ -621,7 +632,7 @@ function colorize(fn) {
|
|
|
621
632
|
//#endregion
|
|
622
633
|
//#region src/commandTrace.ts
|
|
623
634
|
function commandTrace(prog) {
|
|
624
|
-
return prog.command("trace").description(`Trace words -- Search for words in the configuration and dictionaries.`).option("-c, --config <cspell.json>", "Configuration file to use. By default cspell looks for cspell.json in the current directory.").option("--locale <locale>", "Set language locales. i.e. \"en,fr\" for English and French, or \"en-GB\" for British English.").option("--language-id <language>", "Use programming language. i.e. \"php\" or \"scala\".").addOption(new Option("--languageId <language>", "Use programming language. i.e. \"php\" or \"scala\".").hideHelp()).option("--allow-compound-words", "Turn on allowCompoundWords").addOption(new Option("--allowCompoundWords", "Turn on allowCompoundWords.").hideHelp()).option("--no-allow-compound-words", "Turn off allowCompoundWords").option("--ignore-case", "Ignore case and accents when searching for words.").option("--no-ignore-case", "Do not ignore case and accents when searching for words.").option("--dictionary <name>", "Enable a dictionary by name. Can be used multiple times.", collect$1).addOption(new Option("--dictionary-path <format>", "Configure how to display the dictionary path.").choices([
|
|
635
|
+
return prog.command("trace").description(`Trace words -- Search for words in the configuration and dictionaries.`).option("-c, --config <cspell.json>", "Configuration file to use. By default cspell looks for cspell.json in the current directory.").option("--locale <locale>", "Set language locales. i.e. \"en,fr\" for English and French, or \"en-GB\" for British English.").option("--language-id <language>", "Use programming language. i.e. \"php\" or \"scala\".").addOption(new Option("--languageId <language>", "Use programming language. i.e. \"php\" or \"scala\".").hideHelp()).option("--allow-compound-words", "Turn on allowCompoundWords").addOption(new Option("--allowCompoundWords", "Turn on allowCompoundWords.").hideHelp()).option("--no-allow-compound-words", "Turn off allowCompoundWords").option("--ignore-case", "Ignore case and accents when searching for words.").option("--no-ignore-case", "Do not ignore case and accents when searching for words.").option("--dictionary <name>", "Enable a dictionary by name. Can be used multiple times.", collect$1).option("--no-dictionary <name>", "Disable a dictionary by name. Can be used multiple times.", prefixCollect("!")).addOption(new Option("--dictionary-path <format>", "Configure how to display the dictionary path.").choices([
|
|
625
636
|
"hide",
|
|
626
637
|
"short",
|
|
627
638
|
"long",
|