cspell 9.6.3 → 9.7.0
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/cjs/commonJsApi.cjs +1 -0
- package/dist/esm/app.js +18 -6
- package/dist/esm/application.d.ts +17 -3
- package/dist/esm/application.js +96 -2
- package/dist/esm/{application-5MjpInZh.d.ts → index-BObT-HkR.d.ts} +8 -15
- package/dist/esm/index.d.ts +2 -1
- package/dist/esm/index.js +2 -1
- package/dist/esm/{application-DxeSY2Ho.js → listDictionaries-DRQ2BGn_.js} +23 -103
- package/package.json +17 -17
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/cjs/commonJsApi.cjs
CHANGED
package/dist/esm/app.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as width, D as ansiWidth, E as padWidth, M as CheckFailed, N as console, O as pruneAnsiTextEnd, T as padLeft, i as cvtLinterCliCommandOptionsToLinterCliOptions, j as ApplicationError, k as pruneAnsiTextStart, l as validateUnitSize, p as DEFAULT_CACHE_LOCATION, r as ReportChoicesAll, t as listDictionaries, u as unindent, v as npmPackage, w as tableToLines } from "./listDictionaries-DRQ2BGn_.js";
|
|
2
|
+
import { IncludeExcludeFlag, checkText, createInit, lint, parseApplicationFeatureFlags, suggestions, trace } from "./application.js";
|
|
2
3
|
import { Link } from "cspell-lib";
|
|
3
4
|
import chalk from "chalk";
|
|
4
5
|
import * as iPath from "node:path";
|
|
@@ -45,6 +46,17 @@ function collect$1(value, previous) {
|
|
|
45
46
|
return previous ? [...previous, ...values] : values;
|
|
46
47
|
}
|
|
47
48
|
/**
|
|
49
|
+
* Collects string values into an array, prefixing each value with the given prefix.
|
|
50
|
+
* @param prefix the prefix to add to each value.
|
|
51
|
+
* @returns a function that collects values with the given prefix.
|
|
52
|
+
*/
|
|
53
|
+
function prefixCollect(prefix) {
|
|
54
|
+
return (value, previous) => {
|
|
55
|
+
const values = (Array.isArray(value) ? value : [value]).map((v) => prefix + v);
|
|
56
|
+
return previous ? [...previous, ...values] : values;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
48
60
|
* Create Option - a helper function to create a commander option.
|
|
49
61
|
* @param name - the name of the option
|
|
50
62
|
* @param description - the description of the option
|
|
@@ -153,9 +165,9 @@ function calcHeaders(options) {
|
|
|
153
165
|
return headers;
|
|
154
166
|
}
|
|
155
167
|
function emitDictResult(r, options) {
|
|
156
|
-
const a = r.enabled ? "*" : " ";
|
|
168
|
+
const a = (r.blocked ? chalk.redBright("!") : "") + (r.enabled ? "*" : " ");
|
|
157
169
|
const dictColor = r.enabled ? chalk.yellowBright : chalk.rgb(200, 128, 50);
|
|
158
|
-
const n = (width) => dictColor(pruneAnsiTextEnd(r.name, width && width - a
|
|
170
|
+
const n = (width) => dictColor(pruneAnsiTextEnd(r.name, width && width - ansiWidth(a)) + a);
|
|
159
171
|
const c = colorize$1(chalk.white);
|
|
160
172
|
const locales = (width) => c(pruneAnsiTextEnd(r.locales?.join(",") || "", width));
|
|
161
173
|
const fileTypes = (width) => c(pruneAnsiTextEnd(r.fileTypes?.join(",") || "", width));
|
|
@@ -357,7 +369,7 @@ function commandLint(prog, opts) {
|
|
|
357
369
|
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
370
|
summary: false,
|
|
359
371
|
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);
|
|
372
|
+
})).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
373
|
return spellCheckCommand;
|
|
362
374
|
}
|
|
363
375
|
async function action(fileGlobs, cliOptions) {
|
|
@@ -580,7 +592,7 @@ function emitTraceResult(r, options) {
|
|
|
580
592
|
const sug = r.preferredSuggestions?.map((s) => chalk.yellowBright(s)).join(", ") || "";
|
|
581
593
|
const w = (r.forbidden ? chalk.red(cWord) : chalk.green(cWord)) + (sug ? `->(${sug})` : "");
|
|
582
594
|
const f = calcFoundChar(r);
|
|
583
|
-
const a = r.dictActive ? "*" : " ";
|
|
595
|
+
const a = (r.dictBlocked ? chalk.redBright("!") : "") + (r.dictActive ? "*" : " ");
|
|
584
596
|
const dictName = r.dictName.slice(0, colWidthDictionaryName - 1) + a;
|
|
585
597
|
const n = (r.dictActive ? chalk.yellowBright : chalk.rgb(200, 128, 50))(dictName);
|
|
586
598
|
const c = colorize(errors ? chalk.red : chalk.white);
|
|
@@ -621,7 +633,7 @@ function colorize(fn) {
|
|
|
621
633
|
//#endregion
|
|
622
634
|
//#region src/commandTrace.ts
|
|
623
635
|
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([
|
|
636
|
+
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
637
|
"hide",
|
|
626
638
|
"short",
|
|
627
639
|
"long",
|
|
@@ -1,3 +1,17 @@
|
|
|
1
|
-
import "./options-CeDseSxu.js";
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { a as SuggestionOptions, i as LinterCliOptions, o as TraceOptions, r as LegacyOptions, t as BaseOptions } from "./options-CeDseSxu.js";
|
|
2
|
+
import { n as TimedSuggestionsForWordResult, r as InitOptions, t as listDictionaries } from "./index-BObT-HkR.js";
|
|
3
|
+
import { CheckTextInfo, FeatureFlags, IncludeExcludeFlag, TraceResult, TraceWordResult } from "cspell-lib";
|
|
4
|
+
import { CSpellReporter, RunResult } from "@cspell/cspell-types";
|
|
5
|
+
|
|
6
|
+
//#region src/application.d.mts
|
|
7
|
+
type AppError = NodeJS.ErrnoException;
|
|
8
|
+
declare function lint(fileGlobs: string[], options: LinterCliOptions, reporter?: CSpellReporter): Promise<RunResult>;
|
|
9
|
+
declare function trace(words: string[], options: TraceOptions): AsyncIterableIterator<TraceWordResult>;
|
|
10
|
+
type CheckTextResult = CheckTextInfo;
|
|
11
|
+
declare function checkText(filename: string, options: BaseOptions & LegacyOptions): Promise<CheckTextResult>;
|
|
12
|
+
declare function suggestions(words: string[], options: SuggestionOptions): AsyncIterable<TimedSuggestionsForWordResult>;
|
|
13
|
+
declare function createInit(options: InitOptions): Promise<void>;
|
|
14
|
+
declare function parseApplicationFeatureFlags(flags: string[] | undefined): FeatureFlags;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { AppError, CheckTextResult, IncludeExcludeFlag, type TraceResult, checkText, createInit, lint, listDictionaries, parseApplicationFeatureFlags, suggestions, trace };
|
|
17
|
+
//# sourceMappingURL=application.d.ts.map
|
package/dist/esm/application.js
CHANGED
|
@@ -1,3 +1,97 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { C as clean, N as console, S as getReporter, _ as finalizeReporter, a as fixLegacy, b as parseFeatureFlags, c as runLint, d as getTimeMeasurer, f as readConfig, g as readStdin, h as readFileInfo, m as fileInfoToDocument, n as simpleRepl, o as LintRequest, s as extractUnknownWordsConfig, t as listDictionaries, x as configInit, y as getFeatureFlags } from "./listDictionaries-DRQ2BGn_.js";
|
|
2
|
+
import { opMap, opTap, pipeAsync, toAsyncIterable } from "@cspell/cspell-pipe";
|
|
3
|
+
import { IncludeExcludeFlag, SuggestionError, checkTextDocument, getDefaultSettings, getGlobalSettingsAsync, mergeSettings, suggestionsForWords, traceWordsAsync } from "cspell-lib";
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
//#region src/application.mts
|
|
6
|
+
function lint(fileGlobs, options, reporter) {
|
|
7
|
+
options = fixLegacy(options);
|
|
8
|
+
const unknownWordsConfig = extractUnknownWordsConfig(options);
|
|
9
|
+
const useOptions = {
|
|
10
|
+
...options,
|
|
11
|
+
...unknownWordsConfig
|
|
12
|
+
};
|
|
13
|
+
const reporterOptions = {
|
|
14
|
+
...useOptions,
|
|
15
|
+
console
|
|
16
|
+
};
|
|
17
|
+
return runLint(new LintRequest(fileGlobs, useOptions, finalizeReporter(reporter) ?? getReporter({
|
|
18
|
+
...useOptions,
|
|
19
|
+
fileGlobs
|
|
20
|
+
}, reporterOptions)));
|
|
21
|
+
}
|
|
22
|
+
async function* trace(words, options) {
|
|
23
|
+
options = fixLegacy(options);
|
|
24
|
+
const iWords = options.stdin ? toAsyncIterable(words, readStdin()) : words;
|
|
25
|
+
const { languageId, locale, allowCompoundWords, ignoreCase } = options;
|
|
26
|
+
const configFile = await readConfig(options.config, void 0);
|
|
27
|
+
const loadDefault = options.defaultConfiguration ?? configFile.config.loadDefaultConfiguration ?? true;
|
|
28
|
+
const additionalSettings = {};
|
|
29
|
+
if (options.dictionary) additionalSettings.dictionaries = options.dictionary;
|
|
30
|
+
yield* traceWordsAsync(iWords, mergeSettings(await getDefaultSettings(loadDefault), await getGlobalSettingsAsync(), configFile.config, additionalSettings), clean({
|
|
31
|
+
languageId,
|
|
32
|
+
locale,
|
|
33
|
+
ignoreCase,
|
|
34
|
+
allowCompoundWords
|
|
35
|
+
}));
|
|
36
|
+
}
|
|
37
|
+
async function checkText(filename, options) {
|
|
38
|
+
options = fixLegacy(options);
|
|
39
|
+
const fileInfo = await readFileInfo(filename);
|
|
40
|
+
const { locale, languageId, validateDirectives } = options;
|
|
41
|
+
const doc = fileInfoToDocument(fileInfo, languageId, locale);
|
|
42
|
+
const checkOptions = {
|
|
43
|
+
configFile: options.config,
|
|
44
|
+
validateDirectives
|
|
45
|
+
};
|
|
46
|
+
const settingsFromCommandLine = clean({
|
|
47
|
+
languageId,
|
|
48
|
+
language: locale,
|
|
49
|
+
loadDefaultConfiguration: options.defaultConfiguration
|
|
50
|
+
});
|
|
51
|
+
return checkTextDocument(doc, clean({ ...checkOptions }), settingsFromCommandLine);
|
|
52
|
+
}
|
|
53
|
+
async function* suggestions(words, options) {
|
|
54
|
+
options = fixLegacy(options);
|
|
55
|
+
const configFile = await readConfig(options.config, void 0);
|
|
56
|
+
let timer;
|
|
57
|
+
function tapStart() {
|
|
58
|
+
timer = getTimeMeasurer();
|
|
59
|
+
}
|
|
60
|
+
function mapStart(v) {
|
|
61
|
+
tapStart();
|
|
62
|
+
return v;
|
|
63
|
+
}
|
|
64
|
+
function mapEnd(v) {
|
|
65
|
+
const elapsedTimeMs = timer?.();
|
|
66
|
+
return elapsedTimeMs ? {
|
|
67
|
+
...v,
|
|
68
|
+
elapsedTimeMs
|
|
69
|
+
} : v;
|
|
70
|
+
}
|
|
71
|
+
const iWords = options.repl ? pipeAsync(toAsyncIterable(words, simpleRepl()), opTap(tapStart)) : options.useStdin ? pipeAsync(toAsyncIterable(words, readStdin()), opTap(tapStart)) : words.map(mapStart);
|
|
72
|
+
try {
|
|
73
|
+
yield* pipeAsync(suggestionsForWords(iWords, clean({ ...options }), configFile.config), opMap(mapEnd));
|
|
74
|
+
} catch (e) {
|
|
75
|
+
if (!(e instanceof SuggestionError)) throw e;
|
|
76
|
+
console.error(e.message);
|
|
77
|
+
process.exitCode = 1;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function createInit(options) {
|
|
81
|
+
return configInit(options);
|
|
82
|
+
}
|
|
83
|
+
function registerApplicationFeatureFlags() {
|
|
84
|
+
const ff = getFeatureFlags();
|
|
85
|
+
[{
|
|
86
|
+
name: "timer",
|
|
87
|
+
description: "Display elapsed time for command."
|
|
88
|
+
}].forEach((flag) => ff.register(flag));
|
|
89
|
+
return ff;
|
|
90
|
+
}
|
|
91
|
+
function parseApplicationFeatureFlags(flags) {
|
|
92
|
+
return parseFeatureFlags(flags, registerApplicationFeatureFlags());
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
//#endregion
|
|
96
|
+
export { IncludeExcludeFlag, checkText, createInit, lint, listDictionaries, parseApplicationFeatureFlags, suggestions, trace };
|
|
97
|
+
//# sourceMappingURL=application.js.map
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { CSpellReporter, RunResult } from "@cspell/cspell-types";
|
|
1
|
+
import { n as DictionariesOptions } from "./options-CeDseSxu.js";
|
|
2
|
+
import { SuggestionsForWordResult } from "cspell-lib";
|
|
4
3
|
|
|
5
4
|
//#region src/config/options.d.ts
|
|
6
5
|
interface BaseConfigOptions {
|
|
@@ -88,6 +87,10 @@ interface ListDictionariesResult {
|
|
|
88
87
|
*/
|
|
89
88
|
enabled: boolean;
|
|
90
89
|
/**
|
|
90
|
+
* True if the dictionary is blocked.
|
|
91
|
+
*/
|
|
92
|
+
blocked: boolean;
|
|
93
|
+
/**
|
|
91
94
|
* The inline dictionaries supported by the dictionary.
|
|
92
95
|
*/
|
|
93
96
|
inline?: string[] | undefined;
|
|
@@ -102,15 +105,5 @@ interface ListDictionariesResult {
|
|
|
102
105
|
}
|
|
103
106
|
declare function listDictionaries(options: DictionariesOptions): Promise<ListDictionariesResult[]>;
|
|
104
107
|
//#endregion
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
declare function lint(fileGlobs: string[], options: LinterCliOptions, reporter?: CSpellReporter): Promise<RunResult>;
|
|
108
|
-
declare function trace(words: string[], options: TraceOptions): AsyncIterableIterator<TraceWordResult>;
|
|
109
|
-
type CheckTextResult = CheckTextInfo;
|
|
110
|
-
declare function checkText(filename: string, options: BaseOptions & LegacyOptions): Promise<CheckTextResult>;
|
|
111
|
-
declare function suggestions(words: string[], options: SuggestionOptions): AsyncIterable<TimedSuggestionsForWordResult>;
|
|
112
|
-
declare function createInit(options: InitOptions): Promise<void>;
|
|
113
|
-
declare function parseApplicationFeatureFlags(flags: string[] | undefined): FeatureFlags;
|
|
114
|
-
//#endregion
|
|
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-5MjpInZh.d.ts.map
|
|
108
|
+
export { TimedSuggestionsForWordResult as n, InitOptions as r, listDictionaries as t };
|
|
109
|
+
//# sourceMappingURL=index-BObT-HkR.d.ts.map
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { i as LinterCliOptions, o as TraceOptions, s as FinalizedReporter, t as BaseOptions } from "./options-CeDseSxu.js";
|
|
2
|
-
import {
|
|
2
|
+
import { t as listDictionaries } from "./index-BObT-HkR.js";
|
|
3
|
+
import { AppError, CheckTextResult, IncludeExcludeFlag, TraceResult, checkText, createInit, lint, parseApplicationFeatureFlags, suggestions, trace } from "./application.js";
|
|
3
4
|
import "chalk";
|
|
4
5
|
import { CSpellReporter, ReporterConfiguration } from "@cspell/cspell-types";
|
|
5
6
|
import { WriteStream } from "node:tty";
|
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { S as getReporter, t as listDictionaries } from "./listDictionaries-DRQ2BGn_.js";
|
|
2
|
+
import { IncludeExcludeFlag, checkText, createInit, lint, parseApplicationFeatureFlags, suggestions, trace } from "./application.js";
|
|
2
3
|
|
|
3
4
|
export * from "@cspell/cspell-types"
|
|
4
5
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
|
-
import { isAsyncIterable, opFilter,
|
|
2
|
+
import { isAsyncIterable, opFilter, operators, pipeAsync, pipeAsync as asyncPipe, toAsyncIterable as mergeAsyncIterables } from "@cspell/cspell-pipe";
|
|
3
3
|
import * as cspell from "cspell-lib";
|
|
4
|
-
import { ENV_CSPELL_GLOB_ROOT,
|
|
4
|
+
import { ENV_CSPELL_GLOB_ROOT, MessageTypes, Text, combineTextAndLanguageSettings, createDictionaryReferenceCollection, createPerfTimer, extractDependencies, extractImportErrors, fileToDocument, getDefaultSettings, getGlobalSettingsAsync, getSystemFeatureFlags, isBinaryFile, isSpellingDictionaryLoadError, mergeSettings, setLogger, shouldCheckDocument, spellCheckDocument } from "cspell-lib";
|
|
5
5
|
import assert from "node:assert";
|
|
6
6
|
import { format, formatWithOptions, stripVTControlCharacters } from "node:util";
|
|
7
7
|
import { isUrlLike, toFileDirURL, toFilePathOrHref, toFileURL, urlRelative } from "@cspell/url";
|
|
@@ -1201,7 +1201,7 @@ const pkgDir = _dirname;
|
|
|
1201
1201
|
//#endregion
|
|
1202
1202
|
//#region src/pkgInfo.ts
|
|
1203
1203
|
const name = "cspell";
|
|
1204
|
-
const version$1 = "9.
|
|
1204
|
+
const version$1 = "9.7.0";
|
|
1205
1205
|
const engines = { node: ">=20.18" };
|
|
1206
1206
|
const npmPackage = {
|
|
1207
1207
|
name,
|
|
@@ -2831,7 +2831,7 @@ function runResult(init = {}) {
|
|
|
2831
2831
|
}
|
|
2832
2832
|
|
|
2833
2833
|
//#endregion
|
|
2834
|
-
//#region \0@oxc-project+runtime@0.
|
|
2834
|
+
//#region \0@oxc-project+runtime@0.112.0/helpers/usingCtx.js
|
|
2835
2835
|
function _usingCtx() {
|
|
2836
2836
|
var r = "function" == typeof SuppressedError ? SuppressedError : function(r, e) {
|
|
2837
2837
|
var n = Error();
|
|
@@ -3295,22 +3295,26 @@ const inlineDictionaries = {
|
|
|
3295
3295
|
"[words]": {
|
|
3296
3296
|
name: "[words]",
|
|
3297
3297
|
description: "List of words to be included in the spell check.",
|
|
3298
|
-
enabled: true
|
|
3298
|
+
enabled: true,
|
|
3299
|
+
blocked: false
|
|
3299
3300
|
},
|
|
3300
3301
|
"[flagWords]": {
|
|
3301
3302
|
name: "[flagWords]",
|
|
3302
3303
|
description: "List of words to be flagged as incorrect.",
|
|
3303
|
-
enabled: true
|
|
3304
|
+
enabled: true,
|
|
3305
|
+
blocked: false
|
|
3304
3306
|
},
|
|
3305
3307
|
"[ignoreWords]": {
|
|
3306
3308
|
name: "[ignoreWords]",
|
|
3307
3309
|
description: "List of words to be ignored in the spell check.",
|
|
3308
|
-
enabled: true
|
|
3310
|
+
enabled: true,
|
|
3311
|
+
blocked: false
|
|
3309
3312
|
},
|
|
3310
3313
|
"[suggestWords]": {
|
|
3311
3314
|
name: "[suggestWords]",
|
|
3312
3315
|
description: "List of spelling suggestions for words.",
|
|
3313
|
-
enabled: true
|
|
3316
|
+
enabled: true,
|
|
3317
|
+
blocked: false
|
|
3314
3318
|
}
|
|
3315
3319
|
};
|
|
3316
3320
|
function splitList(list) {
|
|
@@ -3366,14 +3370,21 @@ async function listDictionaries(options) {
|
|
|
3366
3370
|
const useFileType = options.fileType === "text" ? "plaintext" : options.fileType;
|
|
3367
3371
|
if (options.locale) configBase.language = options.locale;
|
|
3368
3372
|
const config = combineTextAndLanguageSettings(configBase, "", useFileType || configBase.languageId || "plaintext");
|
|
3369
|
-
const
|
|
3370
|
-
const
|
|
3373
|
+
const dictRefs = createDictionaryReferenceCollection(config.dictionaries || []);
|
|
3374
|
+
const allDictionaries = [...dictRefs.enabled(), ...dictRefs.blocked()];
|
|
3375
|
+
const dictionaryLocalesAndFileTypes = extractDictionaryLocalesAndFileTypes({
|
|
3376
|
+
...config,
|
|
3377
|
+
dictionaries: allDictionaries
|
|
3378
|
+
});
|
|
3379
|
+
const enabledDictionaries = new Set(dictRefs.enabled());
|
|
3380
|
+
const blockedDictionaries = new Set(dictRefs.blocked());
|
|
3371
3381
|
function toListDictionariesResult(dict) {
|
|
3372
3382
|
const inline = extractInlineDictionaries(dict);
|
|
3373
3383
|
return {
|
|
3374
3384
|
name: dict.name,
|
|
3375
3385
|
description: dict.description,
|
|
3376
3386
|
enabled: enabledDictionaries.has(dict.name),
|
|
3387
|
+
blocked: blockedDictionaries.has(dict.name),
|
|
3377
3388
|
path: dict.path,
|
|
3378
3389
|
inline,
|
|
3379
3390
|
locales: [...dictionaryLocalesAndFileTypes.get(dict.name)?.locales || []].sort(),
|
|
@@ -3390,96 +3401,5 @@ async function listDictionaries(options) {
|
|
|
3390
3401
|
}
|
|
3391
3402
|
|
|
3392
3403
|
//#endregion
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
options = fixLegacy(options);
|
|
3396
|
-
const unknownWordsConfig = extractUnknownWordsConfig(options);
|
|
3397
|
-
const useOptions = {
|
|
3398
|
-
...options,
|
|
3399
|
-
...unknownWordsConfig
|
|
3400
|
-
};
|
|
3401
|
-
const reporterOptions = {
|
|
3402
|
-
...useOptions,
|
|
3403
|
-
console
|
|
3404
|
-
};
|
|
3405
|
-
return runLint(new LintRequest(fileGlobs, useOptions, finalizeReporter(reporter) ?? getReporter({
|
|
3406
|
-
...useOptions,
|
|
3407
|
-
fileGlobs
|
|
3408
|
-
}, reporterOptions)));
|
|
3409
|
-
}
|
|
3410
|
-
async function* trace(words, options) {
|
|
3411
|
-
options = fixLegacy(options);
|
|
3412
|
-
const iWords = options.stdin ? toAsyncIterable(words, readStdin()) : words;
|
|
3413
|
-
const { languageId, locale, allowCompoundWords, ignoreCase } = options;
|
|
3414
|
-
const configFile = await readConfig(options.config, void 0);
|
|
3415
|
-
const loadDefault = options.defaultConfiguration ?? configFile.config.loadDefaultConfiguration ?? true;
|
|
3416
|
-
const additionalSettings = {};
|
|
3417
|
-
if (options.dictionary) additionalSettings.dictionaries = options.dictionary;
|
|
3418
|
-
yield* traceWordsAsync(iWords, mergeSettings(await getDefaultSettings(loadDefault), await getGlobalSettingsAsync(), configFile.config, additionalSettings), clean({
|
|
3419
|
-
languageId,
|
|
3420
|
-
locale,
|
|
3421
|
-
ignoreCase,
|
|
3422
|
-
allowCompoundWords
|
|
3423
|
-
}));
|
|
3424
|
-
}
|
|
3425
|
-
async function checkText(filename, options) {
|
|
3426
|
-
options = fixLegacy(options);
|
|
3427
|
-
const fileInfo = await readFileInfo(filename);
|
|
3428
|
-
const { locale, languageId, validateDirectives } = options;
|
|
3429
|
-
const doc = fileInfoToDocument(fileInfo, languageId, locale);
|
|
3430
|
-
const checkOptions = {
|
|
3431
|
-
configFile: options.config,
|
|
3432
|
-
validateDirectives
|
|
3433
|
-
};
|
|
3434
|
-
const settingsFromCommandLine = clean({
|
|
3435
|
-
languageId,
|
|
3436
|
-
language: locale,
|
|
3437
|
-
loadDefaultConfiguration: options.defaultConfiguration
|
|
3438
|
-
});
|
|
3439
|
-
return checkTextDocument(doc, clean({ ...checkOptions }), settingsFromCommandLine);
|
|
3440
|
-
}
|
|
3441
|
-
async function* suggestions(words, options) {
|
|
3442
|
-
options = fixLegacy(options);
|
|
3443
|
-
const configFile = await readConfig(options.config, void 0);
|
|
3444
|
-
let timer;
|
|
3445
|
-
function tapStart() {
|
|
3446
|
-
timer = getTimeMeasurer();
|
|
3447
|
-
}
|
|
3448
|
-
function mapStart(v) {
|
|
3449
|
-
tapStart();
|
|
3450
|
-
return v;
|
|
3451
|
-
}
|
|
3452
|
-
function mapEnd(v) {
|
|
3453
|
-
const elapsedTimeMs = timer?.();
|
|
3454
|
-
return elapsedTimeMs ? {
|
|
3455
|
-
...v,
|
|
3456
|
-
elapsedTimeMs
|
|
3457
|
-
} : v;
|
|
3458
|
-
}
|
|
3459
|
-
const iWords = options.repl ? pipeAsync(toAsyncIterable(words, simpleRepl()), opTap(tapStart)) : options.useStdin ? pipeAsync(toAsyncIterable(words, readStdin()), opTap(tapStart)) : words.map(mapStart);
|
|
3460
|
-
try {
|
|
3461
|
-
yield* pipeAsync(suggestionsForWords(iWords, clean({ ...options }), configFile.config), opMap(mapEnd));
|
|
3462
|
-
} catch (e) {
|
|
3463
|
-
if (!(e instanceof SuggestionError)) throw e;
|
|
3464
|
-
console.error(e.message);
|
|
3465
|
-
process.exitCode = 1;
|
|
3466
|
-
}
|
|
3467
|
-
}
|
|
3468
|
-
function createInit(options) {
|
|
3469
|
-
return configInit(options);
|
|
3470
|
-
}
|
|
3471
|
-
function registerApplicationFeatureFlags() {
|
|
3472
|
-
const ff = getFeatureFlags();
|
|
3473
|
-
[{
|
|
3474
|
-
name: "timer",
|
|
3475
|
-
description: "Display elapsed time for command."
|
|
3476
|
-
}].forEach((flag) => ff.register(flag));
|
|
3477
|
-
return ff;
|
|
3478
|
-
}
|
|
3479
|
-
function parseApplicationFeatureFlags(flags) {
|
|
3480
|
-
return parseFeatureFlags(flags, registerApplicationFeatureFlags());
|
|
3481
|
-
}
|
|
3482
|
-
|
|
3483
|
-
//#endregion
|
|
3484
|
-
export { CheckFailed as C, ApplicationError as S, padLeft as _, parseApplicationFeatureFlags as a, pruneAnsiTextStart as b, listDictionaries as c, validateUnitSize as d, unindent as f, tableToLines as g, getReporter as h, lint as i, ReportChoicesAll as l, npmPackage as m, checkText as n, suggestions as o, DEFAULT_CACHE_LOCATION as p, createInit as r, trace as s, IncludeExcludeFlag as t, cvtLinterCliCommandOptionsToLinterCliOptions as u, padWidth as v, console as w, width as x, pruneAnsiTextEnd as y };
|
|
3485
|
-
//# sourceMappingURL=application-DxeSY2Ho.js.map
|
|
3404
|
+
export { width as A, clean as C, ansiWidth as D, padWidth as E, CheckFailed as M, console as N, pruneAnsiTextEnd as O, getReporter as S, padLeft as T, finalizeReporter as _, fixLegacy as a, parseFeatureFlags as b, runLint as c, getTimeMeasurer as d, readConfig as f, readStdin as g, readFileInfo as h, cvtLinterCliCommandOptionsToLinterCliOptions as i, ApplicationError as j, pruneAnsiTextStart as k, validateUnitSize as l, fileInfoToDocument as m, simpleRepl as n, LintRequest as o, DEFAULT_CACHE_LOCATION as p, ReportChoicesAll as r, extractUnknownWordsConfig as s, listDictionaries as t, unindent as u, npmPackage as v, tableToLines as w, configInit as x, getFeatureFlags as y };
|
|
3405
|
+
//# sourceMappingURL=listDictionaries-DRQ2BGn_.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cspell",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.7.0",
|
|
4
4
|
"description": "A Spelling Checker for Code!",
|
|
5
5
|
"funding": "https://github.com/streetsidesoftware/cspell?sponsor=1",
|
|
6
6
|
"bin": {
|
|
@@ -86,26 +86,26 @@
|
|
|
86
86
|
},
|
|
87
87
|
"homepage": "https://cspell.org/",
|
|
88
88
|
"dependencies": {
|
|
89
|
-
"@cspell/cspell-json-reporter": "9.
|
|
90
|
-
"@cspell/cspell-performance-monitor": "9.
|
|
91
|
-
"@cspell/cspell-pipe": "9.
|
|
92
|
-
"@cspell/cspell-types": "9.
|
|
93
|
-
"@cspell/cspell-worker": "9.
|
|
94
|
-
"@cspell/dynamic-import": "9.
|
|
95
|
-
"@cspell/url": "9.
|
|
89
|
+
"@cspell/cspell-json-reporter": "9.7.0",
|
|
90
|
+
"@cspell/cspell-performance-monitor": "9.7.0",
|
|
91
|
+
"@cspell/cspell-pipe": "9.7.0",
|
|
92
|
+
"@cspell/cspell-types": "9.7.0",
|
|
93
|
+
"@cspell/cspell-worker": "9.7.0",
|
|
94
|
+
"@cspell/dynamic-import": "9.7.0",
|
|
95
|
+
"@cspell/url": "9.7.0",
|
|
96
96
|
"ansi-regex": "^6.2.2",
|
|
97
97
|
"chalk": "^5.6.2",
|
|
98
98
|
"chalk-template": "^1.1.2",
|
|
99
99
|
"commander": "^14.0.3",
|
|
100
|
-
"cspell-config-lib": "9.
|
|
101
|
-
"cspell-dictionary": "9.
|
|
102
|
-
"cspell-gitignore": "9.
|
|
103
|
-
"cspell-glob": "9.
|
|
104
|
-
"cspell-io": "9.
|
|
105
|
-
"cspell-lib": "9.
|
|
100
|
+
"cspell-config-lib": "9.7.0",
|
|
101
|
+
"cspell-dictionary": "9.7.0",
|
|
102
|
+
"cspell-gitignore": "9.7.0",
|
|
103
|
+
"cspell-glob": "9.7.0",
|
|
104
|
+
"cspell-io": "9.7.0",
|
|
105
|
+
"cspell-lib": "9.7.0",
|
|
106
106
|
"fast-json-stable-stringify": "^2.1.0",
|
|
107
107
|
"flatted": "^3.3.3",
|
|
108
|
-
"semver": "^7.7.
|
|
108
|
+
"semver": "^7.7.4",
|
|
109
109
|
"tinyglobby": "^0.2.15"
|
|
110
110
|
},
|
|
111
111
|
"engines": {
|
|
@@ -115,7 +115,7 @@
|
|
|
115
115
|
"@types/micromatch": "^4.0.10",
|
|
116
116
|
"@types/semver": "^7.7.1",
|
|
117
117
|
"micromatch": "^4.0.8",
|
|
118
|
-
"minimatch": "^9.0.
|
|
118
|
+
"minimatch": "^9.0.6"
|
|
119
119
|
},
|
|
120
|
-
"gitHead": "
|
|
120
|
+
"gitHead": "48f64e0bd95b39011af6dc80cd8ae4d519511f73"
|
|
121
121
|
}
|