cspell 9.0.1 → 9.1.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 +78 -59
- package/dist/esm/app.mjs +4 -15
- package/dist/esm/application.d.mts +3 -1
- package/dist/esm/application.mjs +14 -6
- package/dist/esm/cli-reporter.js +2 -1
- package/dist/esm/commandConfig.d.ts +3 -0
- package/dist/esm/commandConfig.js +18 -0
- package/dist/esm/commandDictionaries.d.ts +3 -0
- package/dist/esm/commandDictionaries.js +40 -0
- package/dist/esm/commandHelpers.d.ts +18 -0
- package/dist/esm/commandHelpers.js +30 -0
- package/dist/esm/commandInit.d.ts +3 -0
- package/dist/esm/commandInit.js +25 -0
- package/dist/esm/commandLint.js +13 -26
- package/dist/esm/commandTrace.js +2 -0
- package/dist/esm/config/adjustConfig.d.ts +7 -0
- package/dist/esm/config/adjustConfig.js +137 -0
- package/dist/esm/config/config.d.ts +5 -0
- package/dist/esm/config/config.js +18 -0
- package/dist/esm/config/configInit.d.ts +3 -0
- package/dist/esm/config/configInit.js +104 -0
- package/dist/esm/config/constants.d.ts +17 -0
- package/dist/esm/config/constants.js +23 -0
- package/dist/esm/config/index.d.ts +3 -0
- package/dist/esm/config/index.js +2 -0
- package/dist/esm/config/options.d.ts +62 -0
- package/dist/esm/config/options.js +2 -0
- package/dist/esm/config/updateConfig.d.ts +3 -0
- package/dist/esm/config/updateConfig.js +2 -0
- package/dist/esm/dictionaries/index.d.ts +3 -0
- package/dist/esm/dictionaries/index.js +2 -0
- package/dist/esm/dictionaries/listDictionaries.d.ts +33 -0
- package/dist/esm/dictionaries/listDictionaries.js +131 -0
- package/dist/esm/emitters/dictionaryListEmitter.d.ts +19 -0
- package/dist/esm/emitters/dictionaryListEmitter.js +82 -0
- package/dist/esm/emitters/helpers.d.ts +14 -0
- package/dist/esm/emitters/helpers.js +67 -0
- package/dist/esm/emitters/traceEmitter.d.ts +1 -10
- package/dist/esm/emitters/traceEmitter.js +1 -69
- package/dist/esm/lint/LintRequest.d.ts +3 -2
- package/dist/esm/lint/LintRequest.js +41 -5
- package/dist/esm/lint/index.d.ts +1 -1
- package/dist/esm/lint/index.js +1 -1
- package/dist/esm/lint/lint.js +28 -66
- package/dist/esm/options.d.ts +101 -4
- package/dist/esm/options.js +1 -0
- package/dist/esm/pkgInfo.d.ts +1 -1
- package/dist/esm/pkgInfo.js +1 -1
- package/dist/esm/util/InMemoryReporter.d.ts +10 -7
- package/dist/esm/util/InMemoryReporter.js +20 -13
- package/dist/esm/util/LintFileResult.d.ts +14 -0
- package/dist/esm/util/LintFileResult.js +2 -0
- package/dist/esm/util/cache/CSpellLintResultCache.d.ts +3 -3
- package/dist/esm/util/cache/DiskCache.d.ts +4 -4
- package/dist/esm/util/configFileHelper.d.ts +1 -1
- package/dist/esm/util/configFileHelper.js +2 -2
- package/dist/esm/util/extractContext.d.ts +5 -0
- package/dist/esm/util/extractContext.js +75 -0
- package/dist/esm/util/fileHelper.d.ts +2 -11
- package/dist/esm/util/fileHelper.js +9 -1
- package/dist/esm/util/pad.d.ts +16 -0
- package/dist/esm/util/pad.js +61 -1
- package/dist/esm/util/reporters.d.ts +21 -5
- package/dist/esm/util/reporters.js +178 -31
- package/dist/esm/util/table.d.ts +31 -4
- package/dist/esm/util/table.js +76 -16
- package/dist/esm/util/util.d.ts +5 -0
- package/dist/esm/util/util.js +5 -0
- package/package.json +16 -15
package/README.md
CHANGED
|
@@ -132,65 +132,79 @@ Examples:
|
|
|
132
132
|
Check spelling
|
|
133
133
|
|
|
134
134
|
Options:
|
|
135
|
-
-c, --config <cspell.json>
|
|
136
|
-
|
|
137
|
-
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
--
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
--
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
--
|
|
166
|
-
--
|
|
167
|
-
|
|
168
|
-
--no-
|
|
169
|
-
--
|
|
170
|
-
--
|
|
171
|
-
--
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
--
|
|
178
|
-
|
|
179
|
-
--
|
|
180
|
-
|
|
181
|
-
--no-
|
|
182
|
-
--
|
|
183
|
-
--
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
--
|
|
187
|
-
|
|
188
|
-
--
|
|
189
|
-
|
|
190
|
-
--
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
-
|
|
135
|
+
-c, --config <cspell.json> Configuration file to use. By default cspell
|
|
136
|
+
looks for cspell.json in the current directory.
|
|
137
|
+
--no-config-search Disable automatic searching for additional
|
|
138
|
+
configuration files in parent directories. Only
|
|
139
|
+
the specified config file (if any) will be
|
|
140
|
+
used.
|
|
141
|
+
--stop-config-search-at <dir> Specify a directory at which to stop searching
|
|
142
|
+
for configuration files when walking up from
|
|
143
|
+
the files being checked. Useful for limiting
|
|
144
|
+
config inheritance.
|
|
145
|
+
-v, --verbose Display more information about the files being
|
|
146
|
+
checked and the configuration.
|
|
147
|
+
--locale <locale> Set language locales. i.e. "en,fr" for English
|
|
148
|
+
and French, or "en-GB" for British English.
|
|
149
|
+
--language-id <file-type> Force programming language for unknown
|
|
150
|
+
extensions. i.e. "php" or "scala"
|
|
151
|
+
--words-only Only output the words not found in the
|
|
152
|
+
dictionaries.
|
|
153
|
+
-u, --unique Only output the first instance of a word not
|
|
154
|
+
found in the dictionaries.
|
|
155
|
+
-e, --exclude <glob> Exclude files matching the glob pattern. This
|
|
156
|
+
option can be used multiple times to add
|
|
157
|
+
multiple globs.
|
|
158
|
+
--file-list <path or stdin> Specify a list of files to be spell checked.
|
|
159
|
+
The list is filtered against the glob file
|
|
160
|
+
patterns. Note: the format is 1 file path per
|
|
161
|
+
line.
|
|
162
|
+
--file [file...] Specify files to spell check. They are filtered
|
|
163
|
+
by the [globs...].
|
|
164
|
+
--no-issues Do not show the spelling errors.
|
|
165
|
+
--no-progress Turn off progress messages
|
|
166
|
+
--no-summary Turn off summary message in console.
|
|
167
|
+
-s, --silent Silent mode, suppress error messages.
|
|
168
|
+
--no-exit-code Do not return an exit code if issues are found.
|
|
169
|
+
--quiet Only show spelling issues or errors.
|
|
170
|
+
--fail-fast Exit after first file with an issue or error.
|
|
171
|
+
--continue-on-error Continue processing files even if there is a
|
|
172
|
+
configuration error.
|
|
173
|
+
-r, --root <root folder> Root directory, defaults to current directory.
|
|
174
|
+
--no-relative Issues are displayed with absolute path instead
|
|
175
|
+
of relative to the root.
|
|
176
|
+
--show-context Show the surrounding text around an issue.
|
|
177
|
+
--show-suggestions Show spelling suggestions.
|
|
178
|
+
--no-show-suggestions Do not show spelling suggestions or fixes.
|
|
179
|
+
--no-must-find-files Do not error if no files are found.
|
|
180
|
+
--cache Use cache to only check changed files.
|
|
181
|
+
--no-cache Do not use cache.
|
|
182
|
+
--cache-reset Reset the cache file.
|
|
183
|
+
--cache-strategy <strategy> Strategy to use for detecting changed files.
|
|
184
|
+
(choices: "content", "metadata", default:
|
|
185
|
+
"content")
|
|
186
|
+
--cache-location <path> Path to the cache file or directory. (default:
|
|
187
|
+
".cspellcache")
|
|
188
|
+
--dot Include files and directories starting with `.`
|
|
189
|
+
(period) when matching globs.
|
|
190
|
+
--gitignore Ignore files matching glob patterns found in
|
|
191
|
+
.gitignore files.
|
|
192
|
+
--no-gitignore Do NOT use .gitignore files.
|
|
193
|
+
--gitignore-root <path> Prevent searching for .gitignore files past
|
|
194
|
+
root.
|
|
195
|
+
--validate-directives Validate in-document CSpell directives.
|
|
196
|
+
--color Force color.
|
|
197
|
+
--no-color Turn off color.
|
|
198
|
+
--no-default-configuration Do not load the default configuration and
|
|
199
|
+
dictionaries.
|
|
200
|
+
--dictionary <name> Enable a dictionary by name.
|
|
201
|
+
--disable-dictionary <name> Disable a dictionary by name.
|
|
202
|
+
--reporter <module|path> Specify one or more reporters to use.
|
|
203
|
+
--report <level> Set how unknown words are reported (choices:
|
|
204
|
+
"all", "simple", "typos", "flagged")
|
|
205
|
+
--issue-template [template] Use a custom issue template. See --help
|
|
206
|
+
--issue-template for details.
|
|
207
|
+
-h, --help display help for command
|
|
194
208
|
|
|
195
209
|
More Examples:
|
|
196
210
|
|
|
@@ -212,6 +226,9 @@ More Examples:
|
|
|
212
226
|
Only spell check the "/*.md" files in $FILES,
|
|
213
227
|
where $FILES is a shell variable that contains the list of files.
|
|
214
228
|
|
|
229
|
+
cspell --help --verbose
|
|
230
|
+
Show all options including hidden options.
|
|
231
|
+
|
|
215
232
|
References:
|
|
216
233
|
https://cspell.org
|
|
217
234
|
https://github.com/streetsidesoftware/cspell
|
|
@@ -266,6 +283,8 @@ Options:
|
|
|
266
283
|
--ignore-case Ignore case and accents when searching for words.
|
|
267
284
|
--no-ignore-case Do not ignore case and accents when searching for
|
|
268
285
|
words.
|
|
286
|
+
--dictionary <name> Enable a dictionary by name. Can be used multiple
|
|
287
|
+
times.
|
|
269
288
|
--dictionary-path <format> Configure how to display the dictionary path.
|
|
270
289
|
(choices: "hide", "short", "long", "full",
|
|
271
290
|
default: Display most of the path.)
|
package/dist/esm/app.mjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Option as CommanderOption, program } from 'commander';
|
|
2
2
|
import { satisfies as semverSatisfies } from 'semver';
|
|
3
3
|
import { commandCheck } from './commandCheck.js';
|
|
4
|
+
import { commandDictionaries } from './commandDictionaries.js';
|
|
5
|
+
import { commandInit } from './commandInit.js';
|
|
4
6
|
import { commandLink } from './commandLink.js';
|
|
5
7
|
import { commandLint } from './commandLint.js';
|
|
6
8
|
import { commandSuggestion } from './commandSuggestion.js';
|
|
@@ -23,22 +25,9 @@ export async function run(command, argv) {
|
|
|
23
25
|
commandTrace(prog).addOption(optionFlags);
|
|
24
26
|
commandCheck(prog).addOption(optionFlags);
|
|
25
27
|
commandSuggestion(prog).addOption(optionFlags);
|
|
28
|
+
commandInit(prog).addOption(optionFlags);
|
|
26
29
|
commandLink(prog);
|
|
27
|
-
|
|
28
|
-
program
|
|
29
|
-
.command('init')
|
|
30
|
-
.description('(Alpha) Initialize a cspell.json file.')
|
|
31
|
-
.option('-o, --output <cspell.json>', 'define where to write file.')
|
|
32
|
-
.option('--extends <cspell.json>', 'extend an existing cspell.json file.')
|
|
33
|
-
.action((options: InitOptions) => {
|
|
34
|
-
showHelp = false;
|
|
35
|
-
CSpellApplication.createInit(options).then(
|
|
36
|
-
() => process.exit(0),
|
|
37
|
-
() => process.exit(1)
|
|
38
|
-
);
|
|
39
|
-
console.log('Init');
|
|
40
|
-
});
|
|
41
|
-
*/
|
|
30
|
+
commandDictionaries(prog);
|
|
42
31
|
prog.exitOverride();
|
|
43
32
|
await prog.parseAsync(args);
|
|
44
33
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { CSpellReporter, RunResult } from '@cspell/cspell-types';
|
|
2
2
|
import type { CheckTextInfo, FeatureFlags, TraceWordResult } from 'cspell-lib';
|
|
3
|
+
import { type InitOptions } from './config/index.js';
|
|
3
4
|
import type { TimedSuggestionsForWordResult } from './emitters/suggestionsEmitter.js';
|
|
4
5
|
import type { BaseOptions, LegacyOptions, LinterCliOptions, SuggestionOptions, TraceOptions } from './options.js';
|
|
6
|
+
export { listDictionaries } from './dictionaries/index.js';
|
|
5
7
|
export type { TraceResult } from 'cspell-lib';
|
|
6
8
|
export { IncludeExcludeFlag } from 'cspell-lib';
|
|
7
9
|
export type AppError = NodeJS.ErrnoException;
|
|
@@ -10,6 +12,6 @@ export declare function trace(words: string[], options: TraceOptions): AsyncIter
|
|
|
10
12
|
export type CheckTextResult = CheckTextInfo;
|
|
11
13
|
export declare function checkText(filename: string, options: BaseOptions & LegacyOptions): Promise<CheckTextResult>;
|
|
12
14
|
export declare function suggestions(words: string[], options: SuggestionOptions): AsyncIterable<TimedSuggestionsForWordResult>;
|
|
13
|
-
export declare function createInit(): Promise<void>;
|
|
15
|
+
export declare function createInit(options: InitOptions): Promise<void>;
|
|
14
16
|
export declare function parseApplicationFeatureFlags(flags: string[] | undefined): FeatureFlags;
|
|
15
17
|
//# sourceMappingURL=application.d.mts.map
|
package/dist/esm/application.mjs
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { opMap, opTap, pipeAsync, toAsyncIterable } from '@cspell/cspell-pipe';
|
|
2
2
|
import { checkTextDocument, getDefaultSettings, getGlobalSettingsAsync, mergeSettings, SuggestionError, suggestionsForWords, traceWordsAsync, } from 'cspell-lib';
|
|
3
3
|
import { getReporter } from './cli-reporter.js';
|
|
4
|
+
import { configInit } from './config/index.js';
|
|
4
5
|
import { console } from './console.js';
|
|
5
6
|
import { getFeatureFlags, parseFeatureFlags } from './featureFlags/index.js';
|
|
6
|
-
import { LintRequest, runLint } from './lint/index.js';
|
|
7
|
+
import { extractUnknownWordsConfig, LintRequest, runLint } from './lint/index.js';
|
|
7
8
|
import { fixLegacy } from './options.js';
|
|
8
9
|
import { simpleRepl } from './repl/index.js';
|
|
9
10
|
import { readConfig } from './util/configFileHelper.js';
|
|
@@ -12,11 +13,14 @@ import { finalizeReporter } from './util/reporters.js';
|
|
|
12
13
|
import { readStdin } from './util/stdin.js';
|
|
13
14
|
import { getTimeMeasurer } from './util/timer.js';
|
|
14
15
|
import * as util from './util/util.js';
|
|
16
|
+
export { listDictionaries } from './dictionaries/index.js';
|
|
15
17
|
export { IncludeExcludeFlag } from 'cspell-lib';
|
|
16
18
|
export function lint(fileGlobs, options, reporter) {
|
|
17
19
|
options = fixLegacy(options);
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
+
const unknownWordsConfig = extractUnknownWordsConfig(options);
|
|
21
|
+
const useOptions = { ...options, ...unknownWordsConfig };
|
|
22
|
+
const reporterOptions = { ...useOptions, console };
|
|
23
|
+
const cfg = new LintRequest(fileGlobs, useOptions, finalizeReporter(reporter) ?? getReporter({ ...useOptions, fileGlobs }, reporterOptions));
|
|
20
24
|
return runLint(cfg);
|
|
21
25
|
}
|
|
22
26
|
export async function* trace(words, options) {
|
|
@@ -25,7 +29,11 @@ export async function* trace(words, options) {
|
|
|
25
29
|
const { languageId, locale, allowCompoundWords, ignoreCase } = options;
|
|
26
30
|
const configFile = await readConfig(options.config, undefined);
|
|
27
31
|
const loadDefault = options.defaultConfiguration ?? configFile.config.loadDefaultConfiguration ?? true;
|
|
28
|
-
const
|
|
32
|
+
const additionalSettings = {};
|
|
33
|
+
if (options.dictionary) {
|
|
34
|
+
additionalSettings.dictionaries = options.dictionary;
|
|
35
|
+
}
|
|
36
|
+
const config = mergeSettings(await getDefaultSettings(loadDefault), await getGlobalSettingsAsync(), configFile.config, additionalSettings);
|
|
29
37
|
yield* traceWordsAsync(iWords, config, util.clean({ languageId, locale, ignoreCase, allowCompoundWords }));
|
|
30
38
|
}
|
|
31
39
|
export async function checkText(filename, options) {
|
|
@@ -75,8 +83,8 @@ export async function* suggestions(words, options) {
|
|
|
75
83
|
process.exitCode = 1;
|
|
76
84
|
}
|
|
77
85
|
}
|
|
78
|
-
export function createInit() {
|
|
79
|
-
return
|
|
86
|
+
export function createInit(options) {
|
|
87
|
+
return configInit(options);
|
|
80
88
|
}
|
|
81
89
|
function registerApplicationFeatureFlags() {
|
|
82
90
|
const ff = getFeatureFlags();
|
package/dist/esm/cli-reporter.js
CHANGED
|
@@ -254,13 +254,14 @@ export function getReporter(options, config) {
|
|
|
254
254
|
debug: emitters.Debug,
|
|
255
255
|
progress,
|
|
256
256
|
result: !silent && summary ? resultEmitter : nullEmitter,
|
|
257
|
+
features: undefined,
|
|
257
258
|
};
|
|
258
259
|
}
|
|
259
260
|
function formatIssue(io, templateStr, issue, maxIssueTextWidth) {
|
|
260
261
|
function clean(t) {
|
|
261
262
|
return t.replace(/\s+/, ' ');
|
|
262
263
|
}
|
|
263
|
-
const { uri = '', filename, row, col, text, context, offset } = issue;
|
|
264
|
+
const { uri = '', filename, row, col, text, context = issue.line, offset } = issue;
|
|
264
265
|
const contextLeft = clean(context.text.slice(0, offset - context.offset));
|
|
265
266
|
const contextRight = clean(context.text.slice(offset + text.length - context.offset));
|
|
266
267
|
const contextFull = clean(context.text);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { collect, crOpt } from './commandHelpers.js';
|
|
2
|
+
import { updateConfig } from './config/updateConfig.js';
|
|
3
|
+
export function commandInit(prog) {
|
|
4
|
+
const command = prog
|
|
5
|
+
.command('config')
|
|
6
|
+
.description('Update a CSpell configuration file.')
|
|
7
|
+
.option('-c, --config <path>', 'Path to the CSpell configuration file.')
|
|
8
|
+
.option('--import <path|package>', 'Import a configuration file or dictionary package.', collect)
|
|
9
|
+
.option('--locale <locale>', 'Define the locale to use when spell checking (e.g., en, en-US, de).')
|
|
10
|
+
.addOption(crOpt('--dictionary <dictionary>', 'Enable a dictionary.', collect).default(undefined))
|
|
11
|
+
.addOption(crOpt('--comments', 'Add comments to the config file.').default(undefined).hideHelp())
|
|
12
|
+
.option('--no-comments', 'Do not add comments to the config file.')
|
|
13
|
+
.action((options) => {
|
|
14
|
+
return updateConfig(options);
|
|
15
|
+
});
|
|
16
|
+
return command;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=commandConfig.js.map
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as App from './application.mjs';
|
|
2
|
+
import { crOpt } from './commandHelpers.js';
|
|
3
|
+
import { emitListDictionariesResults } from './emitters/dictionaryListEmitter.js';
|
|
4
|
+
import { isDictionaryPathFormat } from './emitters/DictionaryPathFormat.js';
|
|
5
|
+
import { canUseColor } from './util/canUseColor.js';
|
|
6
|
+
// interface InitOptions extends Options {}
|
|
7
|
+
export function commandDictionaries(prog) {
|
|
8
|
+
return prog
|
|
9
|
+
.command('dictionaries')
|
|
10
|
+
.description(`List dictionaries`)
|
|
11
|
+
.option('-c, --config <cspell.json>', 'Configuration file to use. By default cspell looks for cspell.json in the current directory.')
|
|
12
|
+
.addOption(crOpt('--path-format <format>', 'Configure how to display the dictionary path.')
|
|
13
|
+
.choices(['hide', 'short', 'long', 'full'])
|
|
14
|
+
.default('long', 'Display most of the path.'))
|
|
15
|
+
.addOption(crOpt('--enabled', 'Show only enabled dictionaries.').default(undefined))
|
|
16
|
+
.addOption(crOpt('--no-enabled', 'Do not show enabled dictionaries.'))
|
|
17
|
+
.option('--locale <locale>', 'Set language locales. i.e. "en,fr" for English and French, or "en-GB" for British English.')
|
|
18
|
+
.option('--file-type <fileType>', 'File type to use. i.e. "html", "golang", or "javascript".')
|
|
19
|
+
.option('--no-show-location', 'Do not show the location of the dictionary.')
|
|
20
|
+
.option('--show-file-types', 'Show the file types supported by the dictionary.', false)
|
|
21
|
+
.addOption(crOpt('--no-show-file-types', 'Do not show the file types supported by the dictionary.').hideHelp())
|
|
22
|
+
.option('--show-locales', 'Show the language locales supported by the dictionary.', false)
|
|
23
|
+
.addOption(crOpt('--no-show-locales', 'Do not show the locales supported by the dictionary.').hideHelp())
|
|
24
|
+
.addOption(crOpt('--color', 'Force color.').default(undefined))
|
|
25
|
+
.addOption(crOpt('--no-color', 'Turn off color.').default(undefined))
|
|
26
|
+
.addOption(crOpt('--default-configuration', 'Load the default configuration and dictionaries.').hideHelp())
|
|
27
|
+
.addOption(crOpt('--no-default-configuration', 'Do not load the default configuration and dictionaries.'))
|
|
28
|
+
.action(async (options) => {
|
|
29
|
+
const dictionaryPathFormat = isDictionaryPathFormat(options.pathFormat) ? options.pathFormat : 'long';
|
|
30
|
+
const useColor = canUseColor(options.color);
|
|
31
|
+
const listResult = await App.listDictionaries(options);
|
|
32
|
+
emitListDictionariesResults(listResult, {
|
|
33
|
+
cwd: process.cwd(),
|
|
34
|
+
dictionaryPathFormat,
|
|
35
|
+
color: useColor,
|
|
36
|
+
options,
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=commandDictionaries.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Option as CommanderOption } from 'commander';
|
|
2
|
+
/**
|
|
3
|
+
* Collects string values into an array.
|
|
4
|
+
* @param value the new value(s) to collect.
|
|
5
|
+
* @param previous the previous values.
|
|
6
|
+
* @returns the new values appended to the previous values.
|
|
7
|
+
*/
|
|
8
|
+
export declare function collect(value: string | string[], previous: string[] | undefined): string[];
|
|
9
|
+
/**
|
|
10
|
+
* Create Option - a helper function to create a commander option.
|
|
11
|
+
* @param name - the name of the option
|
|
12
|
+
* @param description - the description of the option
|
|
13
|
+
* @param parseArg - optional function to parse the argument
|
|
14
|
+
* @param defaultValue - optional default value
|
|
15
|
+
* @returns CommanderOption
|
|
16
|
+
*/
|
|
17
|
+
export declare function crOpt<T>(name: string, description: string, parseArg?: (value: string, previous: T) => T, defaultValue?: T): CommanderOption;
|
|
18
|
+
//# sourceMappingURL=commandHelpers.d.ts.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Option as CommanderOption } from 'commander';
|
|
2
|
+
/**
|
|
3
|
+
* Collects string values into an array.
|
|
4
|
+
* @param value the new value(s) to collect.
|
|
5
|
+
* @param previous the previous values.
|
|
6
|
+
* @returns the new values appended to the previous values.
|
|
7
|
+
*/
|
|
8
|
+
export function collect(value, previous) {
|
|
9
|
+
const values = Array.isArray(value) ? value : [value];
|
|
10
|
+
return previous ? [...previous, ...values] : values;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Create Option - a helper function to create a commander option.
|
|
14
|
+
* @param name - the name of the option
|
|
15
|
+
* @param description - the description of the option
|
|
16
|
+
* @param parseArg - optional function to parse the argument
|
|
17
|
+
* @param defaultValue - optional default value
|
|
18
|
+
* @returns CommanderOption
|
|
19
|
+
*/
|
|
20
|
+
export function crOpt(name, description, parseArg, defaultValue) {
|
|
21
|
+
const option = new CommanderOption(name, description);
|
|
22
|
+
if (parseArg) {
|
|
23
|
+
option.argParser(parseArg);
|
|
24
|
+
}
|
|
25
|
+
if (defaultValue !== undefined) {
|
|
26
|
+
option.default(defaultValue);
|
|
27
|
+
}
|
|
28
|
+
return option;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=commandHelpers.js.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createInit } from './application.mjs';
|
|
2
|
+
import { collect, crOpt } from './commandHelpers.js';
|
|
3
|
+
export function commandInit(prog) {
|
|
4
|
+
const command = prog
|
|
5
|
+
.command('init')
|
|
6
|
+
.description('Initialize a CSpell configuration file.')
|
|
7
|
+
.addOption(crOpt('-c, --config <path>', 'Path to the CSpell configuration file. Conflicts with --output and --format.').conflicts(['output', 'format']))
|
|
8
|
+
.option('-o, --output <path>', 'Define where to write file.')
|
|
9
|
+
.addOption(crOpt('--format <format>', 'Define the format of the file.')
|
|
10
|
+
.choices(['yaml', 'yml', 'json', 'jsonc'])
|
|
11
|
+
.default('yaml'))
|
|
12
|
+
.option('--import <path|package>', 'Import a configuration file or dictionary package.', collect)
|
|
13
|
+
.option('--locale <locale>', 'Define the locale to use when spell checking (e.g., en, en-US, de).')
|
|
14
|
+
.addOption(crOpt('--dictionary <dictionary>', 'Enable a dictionary. Can be used multiple times.', collect).default(undefined))
|
|
15
|
+
.addOption(crOpt('--comments', 'Add comments to the config file.').default(undefined).hideHelp())
|
|
16
|
+
.option('--no-comments', 'Do not add comments to the config file.')
|
|
17
|
+
.addOption(crOpt('--remove-comments', 'Remove all comments from the config file.').implies({ comments: false }))
|
|
18
|
+
.option('--no-schema', 'Do not add the schema reference to the config file.')
|
|
19
|
+
.option('--stdout', 'Write the configuration to stdout instead of a file.')
|
|
20
|
+
.action((options) => {
|
|
21
|
+
return createInit(options);
|
|
22
|
+
});
|
|
23
|
+
return command;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=commandInit.js.map
|
package/dist/esm/commandLint.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Option as CommanderOption } from 'commander';
|
|
2
1
|
import * as App from './application.mjs';
|
|
2
|
+
import { collect, crOpt } from './commandHelpers.js';
|
|
3
|
+
import { ReportChoicesAll } from './options.js';
|
|
3
4
|
import { DEFAULT_CACHE_LOCATION } from './util/cache/index.js';
|
|
4
5
|
import { canUseColor } from './util/canUseColor.js';
|
|
5
6
|
import { CheckFailed } from './util/errors.js';
|
|
@@ -46,19 +47,21 @@ More Examples:
|
|
|
46
47
|
Only spell check the "/*.md" files in $FILES,
|
|
47
48
|
where $FILES is a shell variable that contains the list of files.
|
|
48
49
|
|
|
50
|
+
cspell --help --verbose
|
|
51
|
+
Show all options including hidden options.
|
|
52
|
+
|
|
49
53
|
References:
|
|
50
54
|
https://cspell.org
|
|
51
55
|
https://github.com/streetsidesoftware/cspell
|
|
52
56
|
`;
|
|
53
|
-
function collect(value, previous) {
|
|
54
|
-
const values = Array.isArray(value) ? value : [value];
|
|
55
|
-
return previous ? [...previous, ...values] : values;
|
|
56
|
-
}
|
|
57
57
|
export function commandLint(prog) {
|
|
58
58
|
const spellCheckCommand = prog.command('lint', { isDefault: true });
|
|
59
59
|
spellCheckCommand
|
|
60
60
|
.description('Check spelling')
|
|
61
61
|
.option('-c, --config <cspell.json>', 'Configuration file to use. By default cspell looks for cspell.json in the current directory.')
|
|
62
|
+
.addOption(crOpt('--config-search', 'Allow searching for configuration files.', undefined).hideHelp())
|
|
63
|
+
.option('--no-config-search', 'Disable automatic searching for additional configuration files in parent directories. Only the specified config file (if any) will be used.')
|
|
64
|
+
.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)
|
|
62
65
|
.option('-v, --verbose', 'Display more information about the files being checked and the configuration.')
|
|
63
66
|
.option('--locale <locale>', 'Set language locales. i.e. "en,fr" for English and French, or "en-GB" for British English.')
|
|
64
67
|
.option('--language-id <file-type>', 'Force programming language for unknown extensions. i.e. "php" or "scala"')
|
|
@@ -84,6 +87,7 @@ export function commandLint(prog) {
|
|
|
84
87
|
}))
|
|
85
88
|
.option('--fail-fast', 'Exit after first file with an issue or error.')
|
|
86
89
|
.addOption(crOpt('--no-fail-fast', 'Process all files even if there is an error.').hideHelp())
|
|
90
|
+
.option('--continue-on-error', 'Continue processing files even if there is a configuration error.')
|
|
87
91
|
.option('-r, --root <root folder>', 'Root directory, defaults to current directory.')
|
|
88
92
|
.addOption(crOpt('--relative', 'Issues are displayed relative to the root.').default(true).hideHelp())
|
|
89
93
|
.option('--no-relative', 'Issues are displayed with absolute path instead of relative to the root.')
|
|
@@ -120,17 +124,18 @@ export function commandLint(prog) {
|
|
|
120
124
|
.addOption(crOpt('--no-color', 'Turn off color.').default(undefined))
|
|
121
125
|
.addOption(crOpt('--default-configuration', 'Load the default configuration and dictionaries.').hideHelp())
|
|
122
126
|
.addOption(crOpt('--no-default-configuration', 'Do not load the default configuration and dictionaries.'))
|
|
123
|
-
.option('--
|
|
127
|
+
.option('--dictionary <name>', 'Enable a dictionary by name.', collect)
|
|
128
|
+
.option('--disable-dictionary <name>', 'Disable a dictionary by name.', collect)
|
|
124
129
|
.option('--reporter <module|path>', 'Specify one or more reporters to use.', collect)
|
|
130
|
+
.addOption(crOpt('--report <level>', 'Set how unknown words are reported').choices(ReportChoicesAll))
|
|
125
131
|
.addOption(crOpt('--skip-validation', 'Collect and process documents, but do not spell check.')
|
|
126
132
|
.implies({ cache: false })
|
|
127
133
|
.hideHelp())
|
|
128
134
|
.addOption(crOpt('--issues-summary-report', 'Output a summary of issues found.').hideHelp())
|
|
129
135
|
.addOption(crOpt('--show-perf-summary', 'Output a performance summary report.').hideHelp())
|
|
130
136
|
.option('--issue-template [template]', 'Use a custom issue template. See --help --issue-template for details.')
|
|
137
|
+
.addOption(crOpt('--debug', 'Output information useful for debugging cspell.json files.').hideHelp())
|
|
131
138
|
// Planned options
|
|
132
|
-
// .option('--dictionary <dictionary name>', 'Enable a dictionary by name.', collect)
|
|
133
|
-
// .option('--no-dictionary <dictionary name>', 'Disable a dictionary by name.', collect)
|
|
134
139
|
// .option('--import', 'Import a configuration file.', collect)
|
|
135
140
|
.usage(usage)
|
|
136
141
|
.addHelpText('after', augmentCommandHelp)
|
|
@@ -218,22 +223,4 @@ function augmentCommandHelp(context) {
|
|
|
218
223
|
output.push(...hiddenHelp, advanced);
|
|
219
224
|
return helpIssueTemplate(opts) + output.join('\n');
|
|
220
225
|
}
|
|
221
|
-
/**
|
|
222
|
-
* Create Option - a helper function to create a commander option.
|
|
223
|
-
* @param name - the name of the option
|
|
224
|
-
* @param description - the description of the option
|
|
225
|
-
* @param parseArg - optional function to parse the argument
|
|
226
|
-
* @param defaultValue - optional default value
|
|
227
|
-
* @returns CommanderOption
|
|
228
|
-
*/
|
|
229
|
-
function crOpt(name, description, parseArg, defaultValue) {
|
|
230
|
-
const option = new CommanderOption(name, description);
|
|
231
|
-
if (parseArg) {
|
|
232
|
-
option.argParser(parseArg);
|
|
233
|
-
}
|
|
234
|
-
if (defaultValue !== undefined) {
|
|
235
|
-
option.default(defaultValue);
|
|
236
|
-
}
|
|
237
|
-
return option;
|
|
238
|
-
}
|
|
239
226
|
//# sourceMappingURL=commandLint.js.map
|
package/dist/esm/commandTrace.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Option as CommanderOption } from 'commander';
|
|
2
2
|
import * as App from './application.mjs';
|
|
3
|
+
import { collect } from './commandHelpers.js';
|
|
3
4
|
import { console } from './console.js';
|
|
4
5
|
import { isDictionaryPathFormat } from './emitters/DictionaryPathFormat.js';
|
|
5
6
|
import { emitTraceResults } from './emitters/traceEmitter.js';
|
|
@@ -18,6 +19,7 @@ export function commandTrace(prog) {
|
|
|
18
19
|
.option('--no-allow-compound-words', 'Turn off allowCompoundWords')
|
|
19
20
|
.option('--ignore-case', 'Ignore case and accents when searching for words.')
|
|
20
21
|
.option('--no-ignore-case', 'Do not ignore case and accents when searching for words.')
|
|
22
|
+
.option('--dictionary <name>', 'Enable a dictionary by name. Can be used multiple times.', collect)
|
|
21
23
|
.addOption(new CommanderOption('--dictionary-path <format>', 'Configure how to display the dictionary path.')
|
|
22
24
|
.choices(['hide', 'short', 'long', 'full'])
|
|
23
25
|
.default('long', 'Display most of the path.'))
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CSpellSettings } from '@cspell/cspell-types';
|
|
2
|
+
import { CSpellConfigFile } from 'cspell-config-lib';
|
|
3
|
+
export declare function resolveImports(configFile: CSpellConfigFile, imports: string[]): Promise<string[]>;
|
|
4
|
+
export declare function addImportsToConfigFile(configFile: CSpellConfigFile, imports: string[], comment: string | undefined): Promise<void>;
|
|
5
|
+
export declare function setConfigFieldValue<K extends keyof CSpellSettings>(configFile: CSpellConfigFile, key: K, value: CSpellSettings[K], comment?: string | undefined): void;
|
|
6
|
+
export declare function addDictionariesToConfigFile(configFile: CSpellConfigFile, dictionaries: string[], comment?: string | undefined): void;
|
|
7
|
+
//# sourceMappingURL=adjustConfig.d.ts.map
|