cspell 9.0.2 → 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.
Files changed (69) hide show
  1. package/README.md +78 -59
  2. package/dist/esm/app.mjs +4 -15
  3. package/dist/esm/application.d.mts +3 -1
  4. package/dist/esm/application.mjs +14 -6
  5. package/dist/esm/cli-reporter.js +2 -1
  6. package/dist/esm/commandConfig.d.ts +3 -0
  7. package/dist/esm/commandConfig.js +18 -0
  8. package/dist/esm/commandDictionaries.d.ts +3 -0
  9. package/dist/esm/commandDictionaries.js +40 -0
  10. package/dist/esm/commandHelpers.d.ts +18 -0
  11. package/dist/esm/commandHelpers.js +30 -0
  12. package/dist/esm/commandInit.d.ts +3 -0
  13. package/dist/esm/commandInit.js +25 -0
  14. package/dist/esm/commandLint.js +13 -26
  15. package/dist/esm/commandTrace.js +2 -0
  16. package/dist/esm/config/adjustConfig.d.ts +7 -0
  17. package/dist/esm/config/adjustConfig.js +137 -0
  18. package/dist/esm/config/config.d.ts +5 -0
  19. package/dist/esm/config/config.js +18 -0
  20. package/dist/esm/config/configInit.d.ts +3 -0
  21. package/dist/esm/config/configInit.js +104 -0
  22. package/dist/esm/config/constants.d.ts +17 -0
  23. package/dist/esm/config/constants.js +23 -0
  24. package/dist/esm/config/index.d.ts +3 -0
  25. package/dist/esm/config/index.js +2 -0
  26. package/dist/esm/config/options.d.ts +62 -0
  27. package/dist/esm/config/options.js +2 -0
  28. package/dist/esm/config/updateConfig.d.ts +3 -0
  29. package/dist/esm/config/updateConfig.js +2 -0
  30. package/dist/esm/dictionaries/index.d.ts +3 -0
  31. package/dist/esm/dictionaries/index.js +2 -0
  32. package/dist/esm/dictionaries/listDictionaries.d.ts +33 -0
  33. package/dist/esm/dictionaries/listDictionaries.js +131 -0
  34. package/dist/esm/emitters/dictionaryListEmitter.d.ts +19 -0
  35. package/dist/esm/emitters/dictionaryListEmitter.js +82 -0
  36. package/dist/esm/emitters/helpers.d.ts +14 -0
  37. package/dist/esm/emitters/helpers.js +67 -0
  38. package/dist/esm/emitters/traceEmitter.d.ts +1 -10
  39. package/dist/esm/emitters/traceEmitter.js +1 -69
  40. package/dist/esm/lint/LintRequest.d.ts +3 -2
  41. package/dist/esm/lint/LintRequest.js +41 -5
  42. package/dist/esm/lint/index.d.ts +1 -1
  43. package/dist/esm/lint/index.js +1 -1
  44. package/dist/esm/lint/lint.js +28 -66
  45. package/dist/esm/options.d.ts +101 -4
  46. package/dist/esm/options.js +1 -0
  47. package/dist/esm/pkgInfo.d.ts +1 -1
  48. package/dist/esm/pkgInfo.js +1 -1
  49. package/dist/esm/util/InMemoryReporter.d.ts +10 -7
  50. package/dist/esm/util/InMemoryReporter.js +20 -13
  51. package/dist/esm/util/LintFileResult.d.ts +14 -0
  52. package/dist/esm/util/LintFileResult.js +2 -0
  53. package/dist/esm/util/cache/CSpellLintResultCache.d.ts +3 -3
  54. package/dist/esm/util/cache/DiskCache.d.ts +4 -4
  55. package/dist/esm/util/configFileHelper.d.ts +1 -1
  56. package/dist/esm/util/configFileHelper.js +2 -2
  57. package/dist/esm/util/extractContext.d.ts +5 -0
  58. package/dist/esm/util/extractContext.js +75 -0
  59. package/dist/esm/util/fileHelper.d.ts +2 -11
  60. package/dist/esm/util/fileHelper.js +9 -1
  61. package/dist/esm/util/pad.d.ts +16 -0
  62. package/dist/esm/util/pad.js +61 -1
  63. package/dist/esm/util/reporters.d.ts +21 -5
  64. package/dist/esm/util/reporters.js +178 -31
  65. package/dist/esm/util/table.d.ts +31 -4
  66. package/dist/esm/util/table.js +76 -16
  67. package/dist/esm/util/util.d.ts +5 -0
  68. package/dist/esm/util/util.js +5 -0
  69. package/package.json +14 -13
package/README.md CHANGED
@@ -132,65 +132,79 @@ Examples:
132
132
  Check spelling
133
133
 
134
134
  Options:
135
- -c, --config <cspell.json> Configuration file to use. By default cspell
136
- looks for cspell.json in the current directory.
137
- -v, --verbose Display more information about the files being
138
- checked and the configuration.
139
- --locale <locale> Set language locales. i.e. "en,fr" for English
140
- and French, or "en-GB" for British English.
141
- --language-id <file-type> Force programming language for unknown
142
- extensions. i.e. "php" or "scala"
143
- --words-only Only output the words not found in the
144
- dictionaries.
145
- -u, --unique Only output the first instance of a word not
146
- found in the dictionaries.
147
- -e, --exclude <glob> Exclude files matching the glob pattern. This
148
- option can be used multiple times to add multiple
149
- globs.
150
- --file-list <path or stdin> Specify a list of files to be spell checked. The
151
- list is filtered against the glob file patterns.
152
- Note: the format is 1 file path per line.
153
- --file [file...] Specify files to spell check. They are filtered
154
- by the [globs...].
155
- --no-issues Do not show the spelling errors.
156
- --no-progress Turn off progress messages
157
- --no-summary Turn off summary message in console.
158
- -s, --silent Silent mode, suppress error messages.
159
- --no-exit-code Do not return an exit code if issues are found.
160
- --quiet Only show spelling issues or errors.
161
- --fail-fast Exit after first file with an issue or error.
162
- -r, --root <root folder> Root directory, defaults to current directory.
163
- --no-relative Issues are displayed with absolute path instead
164
- of relative to the root.
165
- --show-context Show the surrounding text around an issue.
166
- --show-suggestions Show spelling suggestions.
167
- --no-show-suggestions Do not show spelling suggestions or fixes.
168
- --no-must-find-files Do not error if no files are found.
169
- --cache Use cache to only check changed files.
170
- --no-cache Do not use cache.
171
- --cache-reset Reset the cache file.
172
- --cache-strategy <strategy> Strategy to use for detecting changed files.
173
- (choices: "content", "metadata", default:
174
- "content")
175
- --cache-location <path> Path to the cache file or directory. (default:
176
- ".cspellcache")
177
- --dot Include files and directories starting with `.`
178
- (period) when matching globs.
179
- --gitignore Ignore files matching glob patterns found in
180
- .gitignore files.
181
- --no-gitignore Do NOT use .gitignore files.
182
- --gitignore-root <path> Prevent searching for .gitignore files past root.
183
- --validate-directives Validate in-document CSpell directives.
184
- --color Force color.
185
- --no-color Turn off color.
186
- --no-default-configuration Do not load the default configuration and
187
- dictionaries.
188
- --debug Output information useful for debugging
189
- cspell.json files.
190
- --reporter <module|path> Specify one or more reporters to use.
191
- --issue-template [template] Use a custom issue template. See --help
192
- --issue-template for details.
193
- -h, --help display help for command
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
@@ -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 reporterOptions = { ...options, console };
19
- const cfg = new LintRequest(fileGlobs, options, finalizeReporter(reporter) ?? getReporter({ ...options, fileGlobs }, reporterOptions));
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 config = mergeSettings(await getDefaultSettings(loadDefault), await getGlobalSettingsAsync(), configFile.config);
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 Promise.reject();
86
+ export function createInit(options) {
87
+ return configInit(options);
80
88
  }
81
89
  function registerApplicationFeatureFlags() {
82
90
  const ff = getFeatureFlags();
@@ -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,3 @@
1
+ import type { Command } from 'commander';
2
+ export declare function commandInit(prog: Command): Command;
3
+ //# sourceMappingURL=commandConfig.d.ts.map
@@ -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,3 @@
1
+ import type { Command } from 'commander';
2
+ export declare function commandDictionaries(prog: Command): Command;
3
+ //# sourceMappingURL=commandDictionaries.d.ts.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,3 @@
1
+ import type { Command } from 'commander';
2
+ export declare function commandInit(prog: Command): Command;
3
+ //# sourceMappingURL=commandInit.d.ts.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
@@ -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('--debug', 'Output information useful for debugging cspell.json files.')
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
@@ -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