cspell 9.1.2 → 9.1.5
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 +29 -21
- package/bin.mjs +1 -1
- package/dist/esm/app.d.ts +19 -0
- package/dist/esm/app.js +1033 -0
- package/dist/esm/application-D-NwS6qb.js +2573 -0
- package/dist/esm/application-DbOQYm56.d.ts +116 -0
- package/dist/esm/application.d.ts +3 -0
- package/dist/esm/application.js +3 -0
- package/dist/esm/index.d.ts +55 -0
- package/dist/esm/index.js +5 -0
- package/dist/esm/options-ChaXtdFn.d.ts +387 -0
- package/package.json +27 -25
- package/dist/esm/app.d.mts +0 -5
- package/dist/esm/app.mjs +0 -34
- package/dist/esm/application.d.mts +0 -17
- package/dist/esm/application.mjs +0 -99
- package/dist/esm/cli-reporter.d.ts +0 -38
- package/dist/esm/cli-reporter.js +0 -386
- package/dist/esm/commandCheck.d.ts +0 -3
- package/dist/esm/commandCheck.js +0 -52
- package/dist/esm/commandConfig.d.ts +0 -3
- package/dist/esm/commandConfig.js +0 -18
- package/dist/esm/commandDictionaries.d.ts +0 -3
- package/dist/esm/commandDictionaries.js +0 -40
- package/dist/esm/commandHelpers.d.ts +0 -18
- package/dist/esm/commandHelpers.js +0 -30
- package/dist/esm/commandInit.d.ts +0 -3
- package/dist/esm/commandInit.js +0 -25
- package/dist/esm/commandLink.d.ts +0 -3
- package/dist/esm/commandLink.js +0 -48
- package/dist/esm/commandLint.d.ts +0 -3
- package/dist/esm/commandLint.js +0 -226
- package/dist/esm/commandSuggestion.d.ts +0 -3
- package/dist/esm/commandSuggestion.js +0 -61
- package/dist/esm/commandTrace.d.ts +0 -3
- package/dist/esm/commandTrace.js +0 -91
- package/dist/esm/config/adjustConfig.d.ts +0 -7
- package/dist/esm/config/adjustConfig.js +0 -137
- package/dist/esm/config/config.d.ts +0 -5
- package/dist/esm/config/config.js +0 -18
- package/dist/esm/config/configInit.d.ts +0 -3
- package/dist/esm/config/configInit.js +0 -104
- package/dist/esm/config/constants.d.ts +0 -17
- package/dist/esm/config/constants.js +0 -23
- package/dist/esm/config/index.d.ts +0 -3
- package/dist/esm/config/index.js +0 -2
- package/dist/esm/config/options.d.ts +0 -62
- package/dist/esm/config/options.js +0 -2
- package/dist/esm/config/updateConfig.d.ts +0 -3
- package/dist/esm/config/updateConfig.js +0 -2
- package/dist/esm/console.d.ts +0 -25
- package/dist/esm/console.js +0 -53
- package/dist/esm/dictionaries/index.d.ts +0 -3
- package/dist/esm/dictionaries/index.js +0 -2
- package/dist/esm/dictionaries/listDictionaries.d.ts +0 -33
- package/dist/esm/dictionaries/listDictionaries.js +0 -131
- package/dist/esm/dirname.d.ts +0 -2
- package/dist/esm/dirname.js +0 -13
- package/dist/esm/emitters/DictionaryPathFormat.d.ts +0 -3
- package/dist/esm/emitters/DictionaryPathFormat.js +0 -12
- package/dist/esm/emitters/dictionaryListEmitter.d.ts +0 -19
- package/dist/esm/emitters/dictionaryListEmitter.js +0 -82
- package/dist/esm/emitters/helpers.d.ts +0 -14
- package/dist/esm/emitters/helpers.js +0 -67
- package/dist/esm/emitters/suggestionsEmitter.d.ts +0 -13
- package/dist/esm/emitters/suggestionsEmitter.js +0 -79
- package/dist/esm/emitters/traceEmitter.d.ts +0 -19
- package/dist/esm/emitters/traceEmitter.js +0 -87
- package/dist/esm/environment.d.ts +0 -39
- package/dist/esm/environment.js +0 -30
- package/dist/esm/featureFlags/featureFlags.d.ts +0 -4
- package/dist/esm/featureFlags/featureFlags.js +0 -21
- package/dist/esm/featureFlags/index.d.ts +0 -2
- package/dist/esm/featureFlags/index.js +0 -2
- package/dist/esm/index.d.mts +0 -6
- package/dist/esm/index.mjs +0 -4
- package/dist/esm/link.d.ts +0 -8
- package/dist/esm/link.js +0 -39
- package/dist/esm/lint/LintRequest.d.ts +0 -26
- package/dist/esm/lint/LintRequest.js +0 -83
- package/dist/esm/lint/index.d.ts +0 -3
- package/dist/esm/lint/index.js +0 -3
- package/dist/esm/lint/lint.d.ts +0 -8
- package/dist/esm/lint/lint.js +0 -515
- package/dist/esm/models.d.ts +0 -15
- package/dist/esm/models.js +0 -2
- package/dist/esm/options.d.ts +0 -353
- package/dist/esm/options.js +0 -9
- package/dist/esm/pkgInfo.d.ts +0 -14
- package/dist/esm/pkgInfo.js +0 -7
- package/dist/esm/repl/index.d.ts +0 -18
- package/dist/esm/repl/index.js +0 -52
- package/dist/esm/util/InMemoryReporter.d.ts +0 -31
- package/dist/esm/util/InMemoryReporter.js +0 -49
- package/dist/esm/util/LintFileResult.d.ts +0 -14
- package/dist/esm/util/LintFileResult.js +0 -2
- package/dist/esm/util/async.d.ts +0 -3
- package/dist/esm/util/async.js +0 -4
- package/dist/esm/util/cache/CSpellLintResultCache.d.ts +0 -20
- package/dist/esm/util/cache/CSpellLintResultCache.js +0 -2
- package/dist/esm/util/cache/CacheOptions.d.ts +0 -34
- package/dist/esm/util/cache/CacheOptions.js +0 -2
- package/dist/esm/util/cache/DiskCache.d.ts +0 -63
- package/dist/esm/util/cache/DiskCache.js +0 -214
- package/dist/esm/util/cache/DummyCache.d.ts +0 -11
- package/dist/esm/util/cache/DummyCache.js +0 -18
- package/dist/esm/util/cache/ObjectCollection.d.ts +0 -17
- package/dist/esm/util/cache/ObjectCollection.js +0 -127
- package/dist/esm/util/cache/createCache.d.ts +0 -31
- package/dist/esm/util/cache/createCache.js +0 -69
- package/dist/esm/util/cache/file-entry-cache.d.mts +0 -4
- package/dist/esm/util/cache/file-entry-cache.mjs +0 -5
- package/dist/esm/util/cache/fileEntryCache.d.ts +0 -9
- package/dist/esm/util/cache/fileEntryCache.js +0 -79
- package/dist/esm/util/cache/index.d.ts +0 -4
- package/dist/esm/util/cache/index.js +0 -2
- package/dist/esm/util/canUseColor.d.ts +0 -2
- package/dist/esm/util/canUseColor.js +0 -10
- package/dist/esm/util/configFileHelper.d.ts +0 -15
- package/dist/esm/util/configFileHelper.js +0 -43
- package/dist/esm/util/constants.d.ts +0 -6
- package/dist/esm/util/constants.js +0 -6
- package/dist/esm/util/errors.d.ts +0 -24
- package/dist/esm/util/errors.js +0 -60
- package/dist/esm/util/extractContext.d.ts +0 -5
- package/dist/esm/util/extractContext.js +0 -75
- package/dist/esm/util/fileHelper.d.ts +0 -44
- package/dist/esm/util/fileHelper.js +0 -165
- package/dist/esm/util/glob.d.ts +0 -45
- package/dist/esm/util/glob.js +0 -147
- package/dist/esm/util/pad.d.ts +0 -45
- package/dist/esm/util/pad.js +0 -191
- package/dist/esm/util/prefetch.d.ts +0 -2
- package/dist/esm/util/prefetch.js +0 -15
- package/dist/esm/util/reporters.d.ts +0 -30
- package/dist/esm/util/reporters.js +0 -209
- package/dist/esm/util/stdin.d.ts +0 -2
- package/dist/esm/util/stdin.js +0 -5
- package/dist/esm/util/stdinUrl.d.ts +0 -9
- package/dist/esm/util/stdinUrl.js +0 -26
- package/dist/esm/util/table.d.ts +0 -41
- package/dist/esm/util/table.js +0 -115
- package/dist/esm/util/timer.d.ts +0 -4
- package/dist/esm/util/timer.js +0 -9
- package/dist/esm/util/types.d.ts +0 -7
- package/dist/esm/util/types.js +0 -5
- package/dist/esm/util/unindent.d.ts +0 -14
- package/dist/esm/util/unindent.js +0 -55
- package/dist/esm/util/util.d.ts +0 -14
- package/dist/esm/util/util.js +0 -30
- package/dist/esm/util/writeFile.d.ts +0 -3
- package/dist/esm/util/writeFile.js +0 -30
|
@@ -1,40 +0,0 @@
|
|
|
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
|
|
@@ -1,18 +0,0 @@
|
|
|
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
|
|
@@ -1,30 +0,0 @@
|
|
|
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
|
package/dist/esm/commandInit.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
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/commandLink.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { console } from './console.js';
|
|
2
|
-
import { addPathsToGlobalImports, addPathsToGlobalImportsResultToTable, listGlobalImports, listGlobalImportsResultToTable, removePathsFromGlobalImports, } from './link.js';
|
|
3
|
-
import { CheckFailed } from './util/errors.js';
|
|
4
|
-
import { tableToLines } from './util/table.js';
|
|
5
|
-
export function commandLink(prog) {
|
|
6
|
-
const linkCommand = prog
|
|
7
|
-
.command('link')
|
|
8
|
-
.description('Link dictionaries and other settings to the cspell global config.');
|
|
9
|
-
linkCommand
|
|
10
|
-
.command('list', { isDefault: true })
|
|
11
|
-
.alias('ls')
|
|
12
|
-
.description('List currently linked configurations.')
|
|
13
|
-
.action(async () => {
|
|
14
|
-
const imports = await listGlobalImports();
|
|
15
|
-
const table = listGlobalImportsResultToTable(imports.list);
|
|
16
|
-
tableToLines(table).forEach((line) => console.log(line));
|
|
17
|
-
return;
|
|
18
|
-
});
|
|
19
|
-
linkCommand
|
|
20
|
-
.command('add <dictionaries...>')
|
|
21
|
-
.alias('a')
|
|
22
|
-
.description('Add dictionaries any other settings to the cspell global config.')
|
|
23
|
-
.action(async (dictionaries) => {
|
|
24
|
-
const r = await addPathsToGlobalImports(dictionaries);
|
|
25
|
-
const table = addPathsToGlobalImportsResultToTable(r);
|
|
26
|
-
console.log('Adding:');
|
|
27
|
-
tableToLines(table).forEach((line) => console.log(line));
|
|
28
|
-
if (r.error) {
|
|
29
|
-
throw new CheckFailed(r.error, 1);
|
|
30
|
-
}
|
|
31
|
-
return;
|
|
32
|
-
});
|
|
33
|
-
linkCommand
|
|
34
|
-
.command('remove <paths...>')
|
|
35
|
-
.alias('r')
|
|
36
|
-
.description('Remove matching paths / packages from the global config.')
|
|
37
|
-
.action(async (dictionaries) => {
|
|
38
|
-
const r = await removePathsFromGlobalImports(dictionaries);
|
|
39
|
-
console.log('Removing:');
|
|
40
|
-
if (r.error) {
|
|
41
|
-
throw new CheckFailed(r.error, 1);
|
|
42
|
-
}
|
|
43
|
-
r.removed.map((f) => console.log(f));
|
|
44
|
-
return;
|
|
45
|
-
});
|
|
46
|
-
return linkCommand;
|
|
47
|
-
}
|
|
48
|
-
//# sourceMappingURL=commandLink.js.map
|
package/dist/esm/commandLint.js
DELETED
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
import * as App from './application.mjs';
|
|
2
|
-
import { collect, crOpt } from './commandHelpers.js';
|
|
3
|
-
import { ReportChoicesAll } from './options.js';
|
|
4
|
-
import { DEFAULT_CACHE_LOCATION } from './util/cache/index.js';
|
|
5
|
-
import { canUseColor } from './util/canUseColor.js';
|
|
6
|
-
import { CheckFailed } from './util/errors.js';
|
|
7
|
-
import { unindent } from './util/unindent.js';
|
|
8
|
-
// interface InitOptions extends Options {}
|
|
9
|
-
const usage = `\
|
|
10
|
-
[options] [globs...] [file://<path> ...] [stdin[://<path>]]
|
|
11
|
-
|
|
12
|
-
Patterns:
|
|
13
|
-
- [globs...] Glob Patterns
|
|
14
|
-
- [stdin] Read from "stdin" assume text file.
|
|
15
|
-
- [stdin://<path>] Read from "stdin", use <path> for file type and config.
|
|
16
|
-
- [file://<path>] Check the file at <path>
|
|
17
|
-
|
|
18
|
-
Examples:
|
|
19
|
-
cspell . Recursively check all files.
|
|
20
|
-
cspell lint . The same as "cspell ."
|
|
21
|
-
cspell "*.js" Check all .js files in the current directory
|
|
22
|
-
cspell "**/*.js" Check all .js files recursively
|
|
23
|
-
cspell "src/**/*.js" Only check .js under src
|
|
24
|
-
cspell "**/*.txt" "**/*.js" Check both .js and .txt files.
|
|
25
|
-
cspell "**/*.{txt,js,md}" Check .txt, .js, and .md files.
|
|
26
|
-
cat LICENSE | cspell stdin Check stdin
|
|
27
|
-
cspell stdin://docs/doc.md Check stdin as if it was "./docs/doc.md"\
|
|
28
|
-
`;
|
|
29
|
-
const advanced = `
|
|
30
|
-
More Examples:
|
|
31
|
-
|
|
32
|
-
cspell "**/*.js" --reporter @cspell/cspell-json-reporter
|
|
33
|
-
This will spell check all ".js" files recursively and use
|
|
34
|
-
"@cspell/cspell-json-reporter".
|
|
35
|
-
|
|
36
|
-
cspell . --reporter default
|
|
37
|
-
This will force the default reporter to be used overriding
|
|
38
|
-
any reporters defined in the configuration.
|
|
39
|
-
|
|
40
|
-
cspell . --reporter ./<path>/reporter.cjs
|
|
41
|
-
Use a custom reporter. See API for details.
|
|
42
|
-
|
|
43
|
-
cspell "*.md" --exclude CHANGELOG.md --files README.md CHANGELOG.md
|
|
44
|
-
Spell check only check "README.md" but NOT "CHANGELOG.md".
|
|
45
|
-
|
|
46
|
-
cspell "/*.md" --no-must-find-files --files $FILES
|
|
47
|
-
Only spell check the "/*.md" files in $FILES,
|
|
48
|
-
where $FILES is a shell variable that contains the list of files.
|
|
49
|
-
|
|
50
|
-
cspell --help --verbose
|
|
51
|
-
Show all options including hidden options.
|
|
52
|
-
|
|
53
|
-
References:
|
|
54
|
-
https://cspell.org
|
|
55
|
-
https://github.com/streetsidesoftware/cspell
|
|
56
|
-
`;
|
|
57
|
-
export function commandLint(prog) {
|
|
58
|
-
const spellCheckCommand = prog.command('lint', { isDefault: true });
|
|
59
|
-
spellCheckCommand
|
|
60
|
-
.description('Check spelling')
|
|
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)
|
|
65
|
-
.option('-v, --verbose', 'Display more information about the files being checked and the configuration.')
|
|
66
|
-
.option('--locale <locale>', 'Set language locales. i.e. "en,fr" for English and French, or "en-GB" for British English.')
|
|
67
|
-
.option('--language-id <file-type>', 'Force programming language for unknown extensions. i.e. "php" or "scala"')
|
|
68
|
-
.addOption(crOpt('--languageId <file-type>', 'Alias of "--language-id". Force programming language for unknown extensions. i.e. "php" or "scala"').hideHelp())
|
|
69
|
-
.option('--words-only', 'Only output the words not found in the dictionaries.')
|
|
70
|
-
.addOption(crOpt('--wordsOnly', 'Only output the words not found in the dictionaries.').hideHelp())
|
|
71
|
-
.option('-u, --unique', 'Only output the first instance of a word not found in the dictionaries.')
|
|
72
|
-
.option('-e, --exclude <glob>', 'Exclude files matching the glob pattern. This option can be used multiple times to add multiple globs. ', collect)
|
|
73
|
-
// .option('--include <glob>', 'Include files matching the glob pattern. This option can be used multiple times.', collect)
|
|
74
|
-
.option('--file-list <path or stdin>', 'Specify a list of files to be spell checked.' +
|
|
75
|
-
' The list is filtered against the glob file patterns.' +
|
|
76
|
-
' Note: the format is 1 file path per line.', collect)
|
|
77
|
-
.option('--file [file...]', 'Specify files to spell check. They are filtered by the [globs...].', collect)
|
|
78
|
-
.addOption(crOpt('--files [file...]', 'Alias of "--file". Files to spell check.', collect).hideHelp())
|
|
79
|
-
.option('--no-issues', 'Do not show the spelling errors.')
|
|
80
|
-
.option('--no-progress', 'Turn off progress messages')
|
|
81
|
-
.option('--no-summary', 'Turn off summary message in console.')
|
|
82
|
-
.option('-s, --silent', 'Silent mode, suppress error messages.')
|
|
83
|
-
.option('--no-exit-code', 'Do not return an exit code if issues are found.')
|
|
84
|
-
.addOption(crOpt('--quiet', 'Only show spelling issues or errors.').implies({
|
|
85
|
-
summary: false,
|
|
86
|
-
progress: false,
|
|
87
|
-
}))
|
|
88
|
-
.option('--fail-fast', 'Exit after first file with an issue or error.')
|
|
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.')
|
|
91
|
-
.option('-r, --root <root folder>', 'Root directory, defaults to current directory.')
|
|
92
|
-
.addOption(crOpt('--relative', 'Issues are displayed relative to the root.').default(true).hideHelp())
|
|
93
|
-
.option('--no-relative', 'Issues are displayed with absolute path instead of relative to the root.')
|
|
94
|
-
.option('--show-context', 'Show the surrounding text around an issue.')
|
|
95
|
-
.option('--show-suggestions', 'Show spelling suggestions.')
|
|
96
|
-
.addOption(crOpt('--no-show-suggestions', 'Do not show spelling suggestions or fixes.').default(undefined))
|
|
97
|
-
.addOption(crOpt('--must-find-files', 'Error if no files are found.').default(true).hideHelp())
|
|
98
|
-
.option('--no-must-find-files', 'Do not error if no files are found.')
|
|
99
|
-
// The --filter-files option is still under design review.
|
|
100
|
-
// .option('--filter-files', 'Use the `files` configuration to filter files found.')
|
|
101
|
-
// .option(
|
|
102
|
-
// '--no-filter-files',
|
|
103
|
-
// 'Do NOT use the `files` configuration to filter files (Only applies to --files options).',
|
|
104
|
-
// )
|
|
105
|
-
// The following options are planned features
|
|
106
|
-
// .option('-w, --watch', 'Watch for any changes to the matching files and report any errors')
|
|
107
|
-
// .option('--force', 'Force the exit value to always be 0')
|
|
108
|
-
.addOption(crOpt('--legacy', 'Legacy output').hideHelp())
|
|
109
|
-
.addOption(crOpt('--local <local>', 'Deprecated -- Use: --locale').hideHelp())
|
|
110
|
-
.option('--cache', 'Use cache to only check changed files.')
|
|
111
|
-
.option('--no-cache', 'Do not use cache.')
|
|
112
|
-
.option('--cache-reset', 'Reset the cache file.')
|
|
113
|
-
.addOption(crOpt('--cache-strategy <strategy>', 'Strategy to use for detecting changed files.')
|
|
114
|
-
.choices(['content', 'metadata'])
|
|
115
|
-
.default('content'))
|
|
116
|
-
.option('--cache-location <path>', `Path to the cache file or directory. (default: "${DEFAULT_CACHE_LOCATION}")`)
|
|
117
|
-
.option('--dot', 'Include files and directories starting with `.` (period) when matching globs.')
|
|
118
|
-
.option('--gitignore', 'Ignore files matching glob patterns found in .gitignore files.')
|
|
119
|
-
.option('--no-gitignore', 'Do NOT use .gitignore files.')
|
|
120
|
-
.option('--gitignore-root <path>', 'Prevent searching for .gitignore files past root.', collect)
|
|
121
|
-
.option('--validate-directives', 'Validate in-document CSpell directives.')
|
|
122
|
-
.addOption(crOpt('--no-validate-directives', 'Do not validate in-document CSpell directives.').hideHelp())
|
|
123
|
-
.addOption(crOpt('--color', 'Force color.').default(undefined))
|
|
124
|
-
.addOption(crOpt('--no-color', 'Turn off color.').default(undefined))
|
|
125
|
-
.addOption(crOpt('--default-configuration', 'Load the default configuration and dictionaries.').hideHelp())
|
|
126
|
-
.addOption(crOpt('--no-default-configuration', 'Do not load the default configuration and dictionaries.'))
|
|
127
|
-
.option('--dictionary <name>', 'Enable a dictionary by name.', collect)
|
|
128
|
-
.option('--disable-dictionary <name>', 'Disable a dictionary by name.', collect)
|
|
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))
|
|
131
|
-
.addOption(crOpt('--skip-validation', 'Collect and process documents, but do not spell check.')
|
|
132
|
-
.implies({ cache: false })
|
|
133
|
-
.hideHelp())
|
|
134
|
-
.addOption(crOpt('--issues-summary-report', 'Output a summary of issues found.').hideHelp())
|
|
135
|
-
.addOption(crOpt('--show-perf-summary', 'Output a performance summary report.').hideHelp())
|
|
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())
|
|
138
|
-
// Planned options
|
|
139
|
-
// .option('--import', 'Import a configuration file.', collect)
|
|
140
|
-
.usage(usage)
|
|
141
|
-
.addHelpText('after', augmentCommandHelp)
|
|
142
|
-
.arguments('[globs...]')
|
|
143
|
-
.action(async (fileGlobs, options) => {
|
|
144
|
-
// console.error('lint: %o', { fileGlobs, options });
|
|
145
|
-
const useExitCode = options.exitCode ?? true;
|
|
146
|
-
if (options.skipValidation) {
|
|
147
|
-
options.cache = false;
|
|
148
|
-
}
|
|
149
|
-
options.color ??= canUseColor(options.color);
|
|
150
|
-
App.parseApplicationFeatureFlags(options.flag);
|
|
151
|
-
const { mustFindFiles, fileList, files, file } = options;
|
|
152
|
-
const result = await App.lint(fileGlobs, options);
|
|
153
|
-
if (!fileGlobs.length && !result.files && !result.errors && !fileList && !files?.length && !file?.length) {
|
|
154
|
-
spellCheckCommand.outputHelp();
|
|
155
|
-
throw new CheckFailed('outputHelp', 1);
|
|
156
|
-
}
|
|
157
|
-
if (result.errors || (mustFindFiles && !result.files)) {
|
|
158
|
-
throw new CheckFailed('check failed', 1);
|
|
159
|
-
}
|
|
160
|
-
if (result.issues) {
|
|
161
|
-
const exitCode = useExitCode ? 1 : 0;
|
|
162
|
-
throw new CheckFailed('check failed', exitCode);
|
|
163
|
-
}
|
|
164
|
-
return;
|
|
165
|
-
});
|
|
166
|
-
return spellCheckCommand;
|
|
167
|
-
}
|
|
168
|
-
function helpIssueTemplate(opts) {
|
|
169
|
-
if (!('issueTemplate' in opts))
|
|
170
|
-
return '';
|
|
171
|
-
return unindent `
|
|
172
|
-
Issue Template:
|
|
173
|
-
Use "--issue-template" to set the template to use when reporting issues.
|
|
174
|
-
|
|
175
|
-
The template is a string that can contain the following placeholders:
|
|
176
|
-
- $filename - the file name
|
|
177
|
-
- $col - the column number
|
|
178
|
-
- $row - the row number
|
|
179
|
-
- $text - the word that is misspelled
|
|
180
|
-
- $message - the issues message: "unknown word", "word is misspelled", etc.
|
|
181
|
-
- $messageColored - the issues message with color based upon the message type.
|
|
182
|
-
- $uri - the URI of the file
|
|
183
|
-
- $suggestions - suggestions for the misspelled word (if requested)
|
|
184
|
-
- $quickFix - possible quick fixes for the misspelled word.
|
|
185
|
-
- $contextFull - the full context of the misspelled word.
|
|
186
|
-
- $contextLeft - the context to the left of the misspelled word.
|
|
187
|
-
- $contextRight - the context to the right of the misspelled word.
|
|
188
|
-
|
|
189
|
-
Color is supported using the following template pattern:
|
|
190
|
-
- \`{<style[.style]> <text>}\` - where \`<style>\` is a style name and \`<text>\` is the text to style.
|
|
191
|
-
|
|
192
|
-
Styles
|
|
193
|
-
- \`bold\`, \`italic\`, \`underline\`, \`strikethrough\`, \`dim\`, \`inverse\`
|
|
194
|
-
- \`black\`, \`red\`, \`green\`, \`yellow\`, \`blue\`, \`magenta\`, \`cyan\`, \`white\`
|
|
195
|
-
|
|
196
|
-
Example:
|
|
197
|
-
--issue-template '{green $filename}:{yellow $row}:{yellow $col} $message {red $text} $quickFix {dim $suggestions}'
|
|
198
|
-
`;
|
|
199
|
-
}
|
|
200
|
-
/**
|
|
201
|
-
* Add additional help text to the command.
|
|
202
|
-
* When the verbose flag is set, show the hidden options.
|
|
203
|
-
* @param context
|
|
204
|
-
* @returns
|
|
205
|
-
*/
|
|
206
|
-
function augmentCommandHelp(context) {
|
|
207
|
-
const output = [];
|
|
208
|
-
const command = context.command;
|
|
209
|
-
const opts = command.opts();
|
|
210
|
-
const showHidden = !!opts.verbose;
|
|
211
|
-
const hiddenHelp = [];
|
|
212
|
-
const help = command.createHelp();
|
|
213
|
-
help.helpWidth = process.stdout.columns || 80;
|
|
214
|
-
const hiddenOptions = command.options.filter((opt) => opt.hidden && showHidden);
|
|
215
|
-
const flagColWidth = Math.max(...command.options.map((opt) => opt.flags.length), 0);
|
|
216
|
-
// const indent = flagColWidth + 4;
|
|
217
|
-
for (const options of hiddenOptions) {
|
|
218
|
-
if (!hiddenHelp.length) {
|
|
219
|
-
hiddenHelp.push('\nHidden Options:');
|
|
220
|
-
}
|
|
221
|
-
hiddenHelp.push(help.formatItem(options.flags, flagColWidth, options.description, help));
|
|
222
|
-
}
|
|
223
|
-
output.push(...hiddenHelp, advanced);
|
|
224
|
-
return helpIssueTemplate(opts) + output.join('\n');
|
|
225
|
-
}
|
|
226
|
-
//# sourceMappingURL=commandLint.js.map
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { Option as CommanderOption } from 'commander';
|
|
2
|
-
import * as App from './application.mjs';
|
|
3
|
-
import { emitSuggestionResult } from './emitters/suggestionsEmitter.js';
|
|
4
|
-
import { CheckFailed } from './util/errors.js';
|
|
5
|
-
function collect(value, previous) {
|
|
6
|
-
value = value.replace(/^=/, '');
|
|
7
|
-
if (!previous) {
|
|
8
|
-
return [value];
|
|
9
|
-
}
|
|
10
|
-
return [...previous, value];
|
|
11
|
-
}
|
|
12
|
-
function count(_, previous) {
|
|
13
|
-
return (previous || 0) + 1;
|
|
14
|
-
}
|
|
15
|
-
function asNumber(value, prev) {
|
|
16
|
-
return Number.parseInt(value, 10) ?? prev;
|
|
17
|
-
}
|
|
18
|
-
export function commandSuggestion(prog) {
|
|
19
|
-
const suggestionCommand = prog.command('suggestions');
|
|
20
|
-
suggestionCommand
|
|
21
|
-
.aliases(['sug', 'suggest'])
|
|
22
|
-
.description('Spelling Suggestions for words.')
|
|
23
|
-
.option('-c, --config <cspell.json>', 'Configuration file to use. By default cspell looks for cspell.json in the current directory.')
|
|
24
|
-
.option('--locale <locale>', 'Set language locales. i.e. "en,fr" for English and French, or "en-GB" for British English.')
|
|
25
|
-
.option('--language-id <language>', 'Use programming language. i.e. "php" or "scala".')
|
|
26
|
-
.addOption(new CommanderOption('--languageId <language>', 'Use programming language. i.e. "php" or "scala".').hideHelp())
|
|
27
|
-
.option('-s, --no-strict', 'Ignore case and accents when searching for words.')
|
|
28
|
-
.option('--ignore-case', 'Alias of --no-strict.')
|
|
29
|
-
.option('--num-changes <number>', 'Number of changes allowed to a word', asNumber, 4)
|
|
30
|
-
.option('--num-suggestions <number>', 'Number of suggestions', asNumber, 8)
|
|
31
|
-
.option('--no-include-ties', 'Force the number of suggested to be limited, by not including suggestions that have the same edit cost.')
|
|
32
|
-
.option('--stdin', 'Use stdin for input.')
|
|
33
|
-
.addOption(new CommanderOption('--repl', 'REPL interface for looking up suggestions.'))
|
|
34
|
-
.option('-v, --verbose', 'Show detailed output.', count, 0)
|
|
35
|
-
.option('-d, --dictionary <dictionary name>', 'Use the dictionary specified. Only dictionaries specified will be used.', collect)
|
|
36
|
-
.option('--dictionaries <dictionary names...>', 'Use the dictionaries specified. Only dictionaries specified will be used.')
|
|
37
|
-
.option('--no-color', 'Turn off color.')
|
|
38
|
-
.option('--color', 'Force color')
|
|
39
|
-
.arguments('[words...]')
|
|
40
|
-
.action(async (words, options) => {
|
|
41
|
-
App.parseApplicationFeatureFlags(options.flag);
|
|
42
|
-
options.useStdin = options.stdin;
|
|
43
|
-
options.dictionaries = mergeArrays(options.dictionaries, options.dictionary);
|
|
44
|
-
if (!words.length && !options.useStdin && !options.repl) {
|
|
45
|
-
suggestionCommand.outputHelp();
|
|
46
|
-
throw new CheckFailed('outputHelp', 1);
|
|
47
|
-
}
|
|
48
|
-
for await (const r of App.suggestions(words, options)) {
|
|
49
|
-
emitSuggestionResult(r, options);
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
return suggestionCommand;
|
|
53
|
-
}
|
|
54
|
-
function mergeArrays(a, b) {
|
|
55
|
-
if (a === undefined)
|
|
56
|
-
return b;
|
|
57
|
-
if (b === undefined)
|
|
58
|
-
return a;
|
|
59
|
-
return [...a, ...b];
|
|
60
|
-
}
|
|
61
|
-
//# sourceMappingURL=commandSuggestion.js.map
|
package/dist/esm/commandTrace.js
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { Option as CommanderOption } from 'commander';
|
|
2
|
-
import * as App from './application.mjs';
|
|
3
|
-
import { collect } from './commandHelpers.js';
|
|
4
|
-
import { console } from './console.js';
|
|
5
|
-
import { isDictionaryPathFormat } from './emitters/DictionaryPathFormat.js';
|
|
6
|
-
import { emitTraceResults } from './emitters/traceEmitter.js';
|
|
7
|
-
import { canUseColor } from './util/canUseColor.js';
|
|
8
|
-
import { CheckFailed } from './util/errors.js';
|
|
9
|
-
export function commandTrace(prog) {
|
|
10
|
-
return prog
|
|
11
|
-
.command('trace')
|
|
12
|
-
.description(`Trace words -- Search for words in the configuration and dictionaries.`)
|
|
13
|
-
.option('-c, --config <cspell.json>', 'Configuration file to use. By default cspell looks for cspell.json in the current directory.')
|
|
14
|
-
.option('--locale <locale>', 'Set language locales. i.e. "en,fr" for English and French, or "en-GB" for British English.')
|
|
15
|
-
.option('--language-id <language>', 'Use programming language. i.e. "php" or "scala".')
|
|
16
|
-
.addOption(new CommanderOption('--languageId <language>', 'Use programming language. i.e. "php" or "scala".').hideHelp())
|
|
17
|
-
.option('--allow-compound-words', 'Turn on allowCompoundWords')
|
|
18
|
-
.addOption(new CommanderOption('--allowCompoundWords', 'Turn on allowCompoundWords.').hideHelp())
|
|
19
|
-
.option('--no-allow-compound-words', 'Turn off allowCompoundWords')
|
|
20
|
-
.option('--ignore-case', 'Ignore case and accents when searching for words.')
|
|
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)
|
|
23
|
-
.addOption(new CommanderOption('--dictionary-path <format>', 'Configure how to display the dictionary path.')
|
|
24
|
-
.choices(['hide', 'short', 'long', 'full'])
|
|
25
|
-
.default('long', 'Display most of the path.'))
|
|
26
|
-
.option('--stdin', 'Read words from stdin.')
|
|
27
|
-
.option('--all', 'Show all dictionaries.')
|
|
28
|
-
.addOption(new CommanderOption('--only-found', 'Show only dictionaries that have the words.').conflicts('all'))
|
|
29
|
-
.addOption(new CommanderOption('--color', 'Force color.').default(undefined))
|
|
30
|
-
.addOption(new CommanderOption('--no-color', 'Turn off color.').default(undefined))
|
|
31
|
-
.addOption(new CommanderOption('--default-configuration', 'Load the default configuration and dictionaries.').hideHelp())
|
|
32
|
-
.addOption(new CommanderOption('--no-default-configuration', 'Do not load the default configuration and dictionaries.'))
|
|
33
|
-
.arguments('[words...]')
|
|
34
|
-
.action(async (words, options) => {
|
|
35
|
-
App.parseApplicationFeatureFlags(options.flag);
|
|
36
|
-
let numFound = 0;
|
|
37
|
-
const dictionaryPathFormat = isDictionaryPathFormat(options.dictionaryPath)
|
|
38
|
-
? options.dictionaryPath
|
|
39
|
-
: 'long';
|
|
40
|
-
let prefix = '';
|
|
41
|
-
const useColor = canUseColor(options.color);
|
|
42
|
-
for await (const results of App.trace(words, options)) {
|
|
43
|
-
const byWord = groupBy(results, (r) => r.word);
|
|
44
|
-
for (const split of results.splits) {
|
|
45
|
-
const splitResults = byWord.get(split.word) || [];
|
|
46
|
-
const filtered = filterTraceResults(splitResults, options);
|
|
47
|
-
emitTraceResults(split.word, split.found, filtered, {
|
|
48
|
-
cwd: process.cwd(),
|
|
49
|
-
dictionaryPathFormat,
|
|
50
|
-
prefix,
|
|
51
|
-
showWordFound: results.splits.length > 1,
|
|
52
|
-
color: useColor,
|
|
53
|
-
});
|
|
54
|
-
prefix = '\n';
|
|
55
|
-
numFound += results.reduce((n, r) => n + (r.found ? 1 : 0), 0);
|
|
56
|
-
const numErrors = results.map((r) => r.errors?.length || 0).reduce((n, r) => n + r, 0);
|
|
57
|
-
if (numErrors) {
|
|
58
|
-
console.error('Dictionary Errors.');
|
|
59
|
-
throw new CheckFailed('dictionary errors', 1);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
if (!numFound) {
|
|
64
|
-
console.error('No matches found');
|
|
65
|
-
throw new CheckFailed('no matches', 1);
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
function filterTraceResults(results, options) {
|
|
70
|
-
if (options.all)
|
|
71
|
-
return results;
|
|
72
|
-
return results.filter((r) => filterTraceResult(r, options.onlyFound));
|
|
73
|
-
}
|
|
74
|
-
function filterTraceResult(result, onlyFound) {
|
|
75
|
-
return (result.found ||
|
|
76
|
-
result.forbidden ||
|
|
77
|
-
result.noSuggest ||
|
|
78
|
-
!!result.preferredSuggestions ||
|
|
79
|
-
(!onlyFound && result.dictActive));
|
|
80
|
-
}
|
|
81
|
-
function groupBy(items, key) {
|
|
82
|
-
const map = new Map();
|
|
83
|
-
for (const item of items) {
|
|
84
|
-
const k = key(item);
|
|
85
|
-
const a = map.get(k) || [];
|
|
86
|
-
a.push(item);
|
|
87
|
-
map.set(k, a);
|
|
88
|
-
}
|
|
89
|
-
return map;
|
|
90
|
-
}
|
|
91
|
-
//# sourceMappingURL=commandTrace.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
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
|