cspell 10.3.5 → 10.4.0-alpha.1
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 +105 -77
- package/dist/esm/app.d.ts +1 -1
- package/dist/esm/app.js +50 -13
- package/dist/esm/{application-094uTsvC.d.ts → application-CFfMlhE_.d.ts} +11 -3
- package/dist/esm/{application-CdcDwTFc.js → application-DRa52DKq.js} +263 -131
- package/dist/esm/application.d.ts +1 -1
- package/dist/esm/application.js +1 -1
- package/dist/esm/index.d.ts +15 -6
- package/dist/esm/index.js +1 -1
- package/dist/esm/{options-DlXe327y.d.ts → options-D5lC3IZu.d.ts} +18 -1
- package/package.json +65 -65
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ Please show your support through one of the following sites:
|
|
|
19
19
|
## Features
|
|
20
20
|
|
|
21
21
|
- Spell Checks Code -- Parses code into words before checking them against the dictionaries.
|
|
22
|
-
- Supports CamelCase,
|
|
22
|
+
- Supports CamelCase, snake_case, and compoundwords naming styles.
|
|
23
23
|
- Self contained -- does not depend upon OS libraries like Hunspell or Aspell. Nor does it depend upon online services.
|
|
24
24
|
- Fast -- checks 1000's of lines of code in seconds.
|
|
25
25
|
- Programming Language Specific Dictionaries -- Has dedicated support for:
|
|
@@ -102,108 +102,130 @@ The `lint` command is used for spell checking files.
|
|
|
102
102
|
cspell lint --help
|
|
103
103
|
```
|
|
104
104
|
|
|
105
|
+
Help, and the tables from `cspell trace` and `cspell dictionaries`, fit the width of your terminal. To use a different
|
|
106
|
+
width, set the `COLUMNS` environment variable:
|
|
107
|
+
|
|
108
|
+
```sh
|
|
109
|
+
COLUMNS=60 cspell lint --help
|
|
110
|
+
```
|
|
111
|
+
|
|
105
112
|
### Options
|
|
106
113
|
|
|
107
114
|
<!--- @@inject: static/help-lint.txt --->
|
|
108
115
|
|
|
109
116
|
```
|
|
110
|
-
Usage: cspell lint [options] [globs...] [file://<path> ...]
|
|
117
|
+
Usage: cspell lint [options] [globs...] [file://<path> ...]
|
|
118
|
+
[stdin[://<path>]]
|
|
111
119
|
|
|
112
120
|
Patterns:
|
|
113
121
|
- [globs...] Glob Patterns
|
|
114
122
|
- [stdin] Read from "stdin" assume text file.
|
|
115
|
-
- [stdin://<path>] Read
|
|
123
|
+
- [stdin://<path>] Read stdin; <path> sets file type and config.
|
|
116
124
|
- [file://<path>] Check the file at <path>
|
|
117
125
|
|
|
118
126
|
Examples:
|
|
119
127
|
cspell . Recursively check all files.
|
|
120
128
|
cspell lint . The same as "cspell ."
|
|
121
|
-
cspell "*.js" Check
|
|
129
|
+
cspell "*.js" Check .js files in this directory
|
|
122
130
|
cspell "**/*.js" Check all .js files recursively
|
|
123
131
|
cspell "src/**/*.js" Only check .js under src
|
|
124
132
|
cspell "**/*.txt" "**/*.js" Check both .js and .txt files.
|
|
125
133
|
cspell "**/*.{txt,js,md}" Check .txt, .js, and .md files.
|
|
126
134
|
cat LICENSE | cspell stdin Check stdin
|
|
127
|
-
cspell stdin://docs/doc.md Check stdin as
|
|
135
|
+
cspell stdin://docs/doc.md Check stdin as "./docs/doc.md"
|
|
128
136
|
|
|
129
137
|
Check spelling
|
|
130
138
|
|
|
131
139
|
Options:
|
|
132
|
-
-c, --config <cspell.json> Configuration file to use. By default
|
|
133
|
-
looks for cspell.json in the
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
140
|
+
-c, --config <cspell.json> Configuration file to use. By default
|
|
141
|
+
cspell looks for cspell.json in the
|
|
142
|
+
current directory.
|
|
143
|
+
--no-config-search Disable automatic searching for
|
|
144
|
+
additional configuration files in
|
|
145
|
+
parent directories. Only the specified
|
|
146
|
+
config file (if any) will be used.
|
|
147
|
+
--stop-config-search-at <dir> Specify a directory at which to stop
|
|
148
|
+
searching for configuration files when
|
|
149
|
+
walking up from the files being
|
|
150
|
+
checked. Useful for limiting config
|
|
151
|
+
inheritance.
|
|
152
|
+
-v, --verbose Display more information about the
|
|
153
|
+
files being checked. Add more than one
|
|
154
|
+
-v for increased verbosity.
|
|
155
|
+
--locale <locale> Set language locales. i.e. "en,fr" for
|
|
156
|
+
English and French, or "en-GB" for
|
|
157
|
+
British English.
|
|
147
158
|
--language-id <file-type> Force programming language for unknown
|
|
148
159
|
extensions. i.e. "php" or "scala"
|
|
149
160
|
--words-only Only output the words not found in the
|
|
150
161
|
dictionaries.
|
|
151
|
-
-u, --unique Only output the first instance of a
|
|
152
|
-
found in the dictionaries.
|
|
153
|
-
-e, --exclude <glob> Exclude files matching the glob
|
|
154
|
-
option can be used
|
|
155
|
-
multiple globs.
|
|
156
|
-
--file-list <path or stdin> Specify a list of files to be spell
|
|
157
|
-
The list is filtered against
|
|
158
|
-
patterns. Note: the
|
|
159
|
-
line.
|
|
160
|
-
--file [file...] Specify files to spell check. They are
|
|
161
|
-
by the [globs...].
|
|
162
|
-
--force-check Force the --file or --file-list
|
|
163
|
-
checked even if it
|
|
162
|
+
-u, --unique Only output the first instance of a
|
|
163
|
+
word not found in the dictionaries.
|
|
164
|
+
-e, --exclude <glob> Exclude files matching the glob
|
|
165
|
+
pattern. This option can be used
|
|
166
|
+
multiple times to add multiple globs.
|
|
167
|
+
--file-list <path or stdin> Specify a list of files to be spell
|
|
168
|
+
checked. The list is filtered against
|
|
169
|
+
the glob file patterns. Note: the
|
|
170
|
+
format is 1 file path per line.
|
|
171
|
+
--file [file...] Specify files to spell check. They are
|
|
172
|
+
filtered by the [globs...].
|
|
173
|
+
--force-check Force the --file or --file-list
|
|
174
|
+
documents to be checked even if it
|
|
175
|
+
would normally be excluded.
|
|
176
|
+
--follow-symlinks Allow checking --file and --file-list
|
|
177
|
+
documents referenced by symbolic links.
|
|
164
178
|
--no-issues Do not show the spelling errors.
|
|
165
179
|
--no-progress Turn off progress messages
|
|
166
180
|
--no-summary Turn off summary message in console.
|
|
167
181
|
-s, --silent Silent mode, suppress error messages.
|
|
168
|
-
--no-exit-code Do not return an exit code if issues
|
|
182
|
+
--no-exit-code Do not return an exit code if issues
|
|
183
|
+
are found.
|
|
169
184
|
--quiet Only show spelling issues or errors.
|
|
170
|
-
--fail-fast Exit after first file with an issue or
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
--
|
|
185
|
+
--fail-fast Exit after first file with an issue or
|
|
186
|
+
error.
|
|
187
|
+
--continue-on-error Continue processing files even if there
|
|
188
|
+
is a configuration error.
|
|
189
|
+
-r, --root <root folder> Root directory, defaults to current
|
|
190
|
+
directory.
|
|
191
|
+
--no-relative Issues are displayed with absolute path
|
|
192
|
+
instead of relative to the root.
|
|
193
|
+
--show-context Show the surrounding text around an
|
|
194
|
+
issue.
|
|
177
195
|
--show-suggestions Show spelling suggestions.
|
|
178
|
-
--no-show-suggestions Do not show spelling suggestions or
|
|
196
|
+
--no-show-suggestions Do not show spelling suggestions or
|
|
197
|
+
fixes.
|
|
179
198
|
--no-must-find-files Do not error if no files are found.
|
|
180
199
|
--cache Use cache to only check changed files.
|
|
181
200
|
--no-cache Do not use cache.
|
|
182
201
|
--cache-reset Reset the cache file.
|
|
183
|
-
--cache-strategy <strategy> Strategy to use for detecting changed
|
|
184
|
-
(choices: "content", "metadata",
|
|
185
|
-
"content")
|
|
186
|
-
--cache-location <path> Path to the cache file or directory.
|
|
187
|
-
".cspellcache")
|
|
188
|
-
--dot Include files and directories starting
|
|
189
|
-
(period) when matching globs.
|
|
190
|
-
--
|
|
191
|
-
.
|
|
202
|
+
--cache-strategy <strategy> Strategy to use for detecting changed
|
|
203
|
+
files. (choices: "content", "metadata",
|
|
204
|
+
default: "content")
|
|
205
|
+
--cache-location <path> Path to the cache file or directory.
|
|
206
|
+
(default: ".cspellcache")
|
|
207
|
+
--dot Include files and directories starting
|
|
208
|
+
with `.` (period) when matching globs.
|
|
209
|
+
--glob-symlinks Follow symbolic links when matching
|
|
210
|
+
globs.
|
|
211
|
+
--gitignore Ignore files matching glob patterns
|
|
212
|
+
found in .gitignore files.
|
|
192
213
|
--no-gitignore Do NOT use .gitignore files.
|
|
193
|
-
--gitignore-root <path> Prevent searching for .gitignore files
|
|
194
|
-
root.
|
|
214
|
+
--gitignore-root <path> Prevent searching for .gitignore files
|
|
215
|
+
past root.
|
|
195
216
|
--validate-directives Validate in-document CSpell directives.
|
|
196
|
-
--max-file-size <size> Prevent checking large files. i.e 1MB,
|
|
197
|
-
1GB
|
|
217
|
+
--max-file-size <size> Prevent checking large files. i.e 1MB,
|
|
218
|
+
50KB, 1GB
|
|
198
219
|
--color Force color.
|
|
199
220
|
--no-color Turn off color.
|
|
200
|
-
--no-default-configuration Do not load the default configuration
|
|
201
|
-
dictionaries.
|
|
221
|
+
--no-default-configuration Do not load the default configuration
|
|
222
|
+
and dictionaries.
|
|
202
223
|
--dictionary <name> Enable a dictionary by name.
|
|
203
224
|
--disable-dictionary <name> Disable a dictionary by name.
|
|
204
225
|
--reporter <module|path> Specify one or more reporters to use.
|
|
205
|
-
--report <level> Set how unknown words are reported
|
|
206
|
-
"all", "simple", "typos",
|
|
226
|
+
--report <level> Set how unknown words are reported
|
|
227
|
+
(choices: "all", "simple", "typos",
|
|
228
|
+
"flagged")
|
|
207
229
|
--issue-template [template] Use a custom issue template. See --help
|
|
208
230
|
--issue-template for details.
|
|
209
231
|
-h, --help display help for command
|
|
@@ -226,7 +248,7 @@ More Examples:
|
|
|
226
248
|
|
|
227
249
|
cspell "/*.md" --no-must-find-files --files $FILES
|
|
228
250
|
Only spell check the "/*.md" files in $FILES,
|
|
229
|
-
where $FILES is a shell variable
|
|
251
|
+
where $FILES is a shell variable containing the list of files.
|
|
230
252
|
|
|
231
253
|
cspell --help --verbose
|
|
232
254
|
Show all options including hidden options.
|
|
@@ -275,26 +297,32 @@ Usage: cspell trace [options] [words...]
|
|
|
275
297
|
Trace words -- Search for words in the configuration and dictionaries.
|
|
276
298
|
|
|
277
299
|
Options:
|
|
278
|
-
-c, --config <cspell.json> Configuration file to use. By default
|
|
279
|
-
looks for cspell.json in the
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
300
|
+
-c, --config <cspell.json> Configuration file to use. By default
|
|
301
|
+
cspell looks for cspell.json in the
|
|
302
|
+
current directory.
|
|
303
|
+
--locale <locale> Set language locales. i.e. "en,fr" for
|
|
304
|
+
English and French, or "en-GB" for British
|
|
305
|
+
English.
|
|
306
|
+
--language-id <language> Use programming language. i.e. "php" or
|
|
307
|
+
"scala".
|
|
283
308
|
--allow-compound-words Turn on allowCompoundWords
|
|
284
309
|
--no-allow-compound-words Turn off allowCompoundWords
|
|
285
|
-
--ignore-case Ignore case and accents when searching for
|
|
286
|
-
--no-ignore-case Do not ignore case and accents when searching for
|
|
310
|
+
--ignore-case Ignore case and accents when searching for
|
|
287
311
|
words.
|
|
288
|
-
--
|
|
289
|
-
|
|
290
|
-
--
|
|
291
|
-
times.
|
|
292
|
-
--dictionary
|
|
293
|
-
|
|
294
|
-
|
|
312
|
+
--no-ignore-case Do not ignore case and accents when
|
|
313
|
+
searching for words.
|
|
314
|
+
--dictionary <name> Enable a dictionary by name. Can be used
|
|
315
|
+
multiple times.
|
|
316
|
+
--no-dictionary <name> Disable a dictionary by name. Can be used
|
|
317
|
+
multiple times.
|
|
318
|
+
--dictionary-path <format> Configure how to display the dictionary
|
|
319
|
+
path. (choices: "hide", "short", "long",
|
|
320
|
+
"full", default: Display most of the
|
|
321
|
+
path.)
|
|
295
322
|
--stdin Read words from stdin.
|
|
296
323
|
--all Show all dictionaries.
|
|
297
|
-
--only-found Show only dictionaries that have the
|
|
324
|
+
--only-found Show only dictionaries that have the
|
|
325
|
+
words.
|
|
298
326
|
--color Force color.
|
|
299
327
|
--no-color Turn off color.
|
|
300
328
|
--no-default-configuration Do not load the default configuration and
|
|
@@ -343,7 +371,7 @@ CSpell needs Node 22 and above.
|
|
|
343
371
|
|
|
344
372
|
## How it works
|
|
345
373
|
|
|
346
|
-
The concept is simple: split camelCase and
|
|
374
|
+
The concept is simple: split camelCase and snake_case words before checking them against a list of known words.
|
|
347
375
|
|
|
348
376
|
- `camelCase` -> `camel case`
|
|
349
377
|
- `HTMLInput` -> `html input`
|
|
@@ -704,7 +732,7 @@ The spell checker includes a set of default dictionaries.
|
|
|
704
732
|
|
|
705
733
|
### General Dictionaries
|
|
706
734
|
|
|
707
|
-
- **
|
|
735
|
+
- **en_US** - Derived from Hunspell US English words.
|
|
708
736
|
- **en-gb** - Derived from Hunspell GB English words.
|
|
709
737
|
- **companies** - List of well known companies
|
|
710
738
|
- **softwareTerms** - Software Terms and concepts like "coroutine", "debounce", "tree", etc.
|
package/dist/esm/app.d.ts
CHANGED
package/dist/esm/app.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as ApplicationError, S as width, T as console, _ as padLeft, a as parseApplicationFeatureFlags, b as pruneAnsiTextEnd, c as listDictionaries, d as validateUnitSize, f as unindent, g as tableToLines, i as lint, l as ReportChoicesAll, m as npmPackage, n as checkText, o as suggestions, p as DEFAULT_CACHE_LOCATION, r as createInit, s as trace, t as IncludeExcludeFlag, u as cvtLinterCliCommandOptionsToLinterCliOptions, v as padWidth, w as CheckFailed, x as pruneAnsiTextStart, y as ansiWidth } from "./application-
|
|
1
|
+
import { C as ApplicationError, S as width, T as console, _ as padLeft, a as parseApplicationFeatureFlags, b as pruneAnsiTextEnd, c as listDictionaries, d as validateUnitSize, f as unindent, g as tableToLines, i as lint, l as ReportChoicesAll, m as npmPackage, n as checkText, o as suggestions, p as DEFAULT_CACHE_LOCATION, r as createInit, s as trace, t as IncludeExcludeFlag, u as cvtLinterCliCommandOptionsToLinterCliOptions, v as padWidth, w as CheckFailed, x as pruneAnsiTextStart, y as ansiWidth } from "./application-DRa52DKq.js";
|
|
2
2
|
import { Link } from "cspell-lib";
|
|
3
3
|
import chalk from "chalk";
|
|
4
4
|
import * as iPath from "node:path";
|
|
@@ -97,6 +97,19 @@ function crOpt(name, description, parseArg, defaultValue) {
|
|
|
97
97
|
return option;
|
|
98
98
|
}
|
|
99
99
|
//#endregion
|
|
100
|
+
//#region src/util/outputWidth.ts
|
|
101
|
+
/**
|
|
102
|
+
* The width to format output for.
|
|
103
|
+
* `COLUMNS` wins when it is a positive integer, otherwise the width of the stream if it has one.
|
|
104
|
+
*/
|
|
105
|
+
function getOutputWidth(stream = process.stdout, env = process.env) {
|
|
106
|
+
return parseColumns(env.COLUMNS) || stream.columns || void 0;
|
|
107
|
+
}
|
|
108
|
+
function parseColumns(value) {
|
|
109
|
+
if (!value || !/^\s*\d+\s*$/.test(value)) return void 0;
|
|
110
|
+
return Number.parseInt(value, 10) || void 0;
|
|
111
|
+
}
|
|
112
|
+
//#endregion
|
|
100
113
|
//#region src/emitters/helpers.ts
|
|
101
114
|
function trimMidPath(s, w, sep) {
|
|
102
115
|
if (s.length <= w) return s;
|
|
@@ -170,7 +183,7 @@ function calcListDictsResultsReport(results, options) {
|
|
|
170
183
|
table: tableToLines({
|
|
171
184
|
header,
|
|
172
185
|
rows,
|
|
173
|
-
terminalWidth: options.lineWidth ||
|
|
186
|
+
terminalWidth: options.lineWidth || getOutputWidth() || maxWidth$1,
|
|
174
187
|
deliminator: " ",
|
|
175
188
|
maxColumnWidths: {
|
|
176
189
|
locales: 12,
|
|
@@ -337,24 +350,25 @@ function commandLink(prog) {
|
|
|
337
350
|
//#endregion
|
|
338
351
|
//#region src/commandLint.ts
|
|
339
352
|
const usage = `\
|
|
340
|
-
[options] [globs...] [file://<path> ...]
|
|
353
|
+
[options] [globs...] [file://<path> ...]
|
|
354
|
+
[stdin[://<path>]]
|
|
341
355
|
|
|
342
356
|
Patterns:
|
|
343
357
|
- [globs...] Glob Patterns
|
|
344
358
|
- [stdin] Read from "stdin" assume text file.
|
|
345
|
-
- [stdin://<path>] Read
|
|
359
|
+
- [stdin://<path>] Read stdin; <path> sets file type and config.
|
|
346
360
|
- [file://<path>] Check the file at <path>
|
|
347
361
|
|
|
348
362
|
Examples:
|
|
349
363
|
cspell . Recursively check all files.
|
|
350
364
|
cspell lint . The same as "cspell ."
|
|
351
|
-
cspell "*.js" Check
|
|
365
|
+
cspell "*.js" Check .js files in this directory
|
|
352
366
|
cspell "**/*.js" Check all .js files recursively
|
|
353
367
|
cspell "src/**/*.js" Only check .js under src
|
|
354
368
|
cspell "**/*.txt" "**/*.js" Check both .js and .txt files.
|
|
355
369
|
cspell "**/*.{txt,js,md}" Check .txt, .js, and .md files.
|
|
356
370
|
cat LICENSE | cspell stdin Check stdin
|
|
357
|
-
cspell stdin://docs/doc.md Check stdin as
|
|
371
|
+
cspell stdin://docs/doc.md Check stdin as "./docs/doc.md"\
|
|
358
372
|
`;
|
|
359
373
|
const advanced = `
|
|
360
374
|
More Examples:
|
|
@@ -375,7 +389,7 @@ More Examples:
|
|
|
375
389
|
|
|
376
390
|
cspell "/*.md" --no-must-find-files --files $FILES
|
|
377
391
|
Only spell check the "/*.md" files in $FILES,
|
|
378
|
-
where $FILES is a shell variable
|
|
392
|
+
where $FILES is a shell variable containing the list of files.
|
|
379
393
|
|
|
380
394
|
cspell --help --verbose
|
|
381
395
|
Show all options including hidden options.
|
|
@@ -386,10 +400,10 @@ References:
|
|
|
386
400
|
`;
|
|
387
401
|
function commandLint(prog, opts) {
|
|
388
402
|
const spellCheckCommand = prog.command("lint", opts);
|
|
389
|
-
spellCheckCommand.description("Check spelling").option("-c, --config <cspell.json>", "Configuration file to use. By default cspell looks for cspell.json in the current directory.").addOption(crOpt("--config-search", "Allow searching for configuration files.", void 0).hideHelp()).option("--no-config-search", "Disable automatic searching for additional configuration files in parent directories. Only the specified config file (if any) will be used.").option("--stop-config-search-at <dir>", "Specify a directory at which to stop searching for configuration files when walking up from the files being checked. Useful for limiting config inheritance.", collect$1).option("-v, --verbose", "Display more information about the files being checked. Add more than one -v for increased verbosity.", increaseVerbosity, 0).option("--locale <locale>", "Set language locales. i.e. \"en,fr\" for English and French, or \"en-GB\" for British English.").option("--language-id <file-type>", "Force programming language for unknown extensions. i.e. \"php\" or \"scala\"").addOption(crOpt("--languageId <file-type>", "Alias of \"--language-id\". Force programming language for unknown extensions. i.e. \"php\" or \"scala\"").hideHelp()).option("--words-only", "Only output the words not found in the dictionaries.").addOption(crOpt("--wordsOnly", "Only output the words not found in the dictionaries.").hideHelp()).option("-u, --unique", "Only output the first instance of a word not found in the dictionaries.").option("-e, --exclude <glob>", "Exclude files matching the glob pattern. This option can be used multiple times to add multiple globs. ", collect$1).option("--file-list <path or stdin>", "Specify a list of files to be spell checked. The list is filtered against the glob file patterns. Note: the format is 1 file path per line.", collect$1).option("--file [file...]", "Specify files to spell check. They are filtered by the [globs...].", collect$1).addOption(crOpt("--files [file...]", "Alias of \"--file\". Files to spell check.", collect$1).hideHelp()).option("--force-check", "Force the --file or --file-list documents to be checked even if it would normally be excluded.").option("--no-issues", "Do not show the spelling errors.").option("--no-progress", "Turn off progress messages").option("--no-summary", "Turn off summary message in console.").option("-s, --silent", "Silent mode, suppress error messages.").option("--no-exit-code", "Do not return an exit code if issues are found.").addOption(crOpt("--quiet", "Only show spelling issues or errors.").implies({
|
|
403
|
+
spellCheckCommand.description("Check spelling").option("-c, --config <cspell.json>", "Configuration file to use. By default cspell looks for cspell.json in the current directory.").addOption(crOpt("--config-search", "Allow searching for configuration files.", void 0).hideHelp()).option("--no-config-search", "Disable automatic searching for additional configuration files in parent directories. Only the specified config file (if any) will be used.").option("--stop-config-search-at <dir>", "Specify a directory at which to stop searching for configuration files when walking up from the files being checked. Useful for limiting config inheritance.", collect$1).option("-v, --verbose", "Display more information about the files being checked. Add more than one -v for increased verbosity.", increaseVerbosity, 0).option("--locale <locale>", "Set language locales. i.e. \"en,fr\" for English and French, or \"en-GB\" for British English.").option("--language-id <file-type>", "Force programming language for unknown extensions. i.e. \"php\" or \"scala\"").addOption(crOpt("--languageId <file-type>", "Alias of \"--language-id\". Force programming language for unknown extensions. i.e. \"php\" or \"scala\"").hideHelp()).option("--words-only", "Only output the words not found in the dictionaries.").addOption(crOpt("--wordsOnly", "Only output the words not found in the dictionaries.").hideHelp()).option("-u, --unique", "Only output the first instance of a word not found in the dictionaries.").option("-e, --exclude <glob>", "Exclude files matching the glob pattern. This option can be used multiple times to add multiple globs. ", collect$1).option("--file-list <path or stdin>", "Specify a list of files to be spell checked. The list is filtered against the glob file patterns. Note: the format is 1 file path per line.", collect$1).option("--file [file...]", "Specify files to spell check. They are filtered by the [globs...].", collect$1).addOption(crOpt("--files [file...]", "Alias of \"--file\". Files to spell check.", collect$1).hideHelp()).option("--force-check", "Force the --file or --file-list documents to be checked even if it would normally be excluded.").option("--follow-symlinks", "Allow checking --file and --file-list documents referenced by symbolic links.").addOption(crOpt("--no-follow-symlinks", "Skip documents referenced by symbolic links.").default(void 0).hideHelp()).option("--no-issues", "Do not show the spelling errors.").option("--no-progress", "Turn off progress messages").option("--no-summary", "Turn off summary message in console.").option("-s, --silent", "Silent mode, suppress error messages.").option("--no-exit-code", "Do not return an exit code if issues are found.").addOption(crOpt("--quiet", "Only show spelling issues or errors.").implies({
|
|
390
404
|
summary: false,
|
|
391
405
|
progress: false
|
|
392
|
-
})).option("--fail-fast", "Exit after first file with an issue or error.").addOption(crOpt("--no-fail-fast", "Process all files even if there is an error.").hideHelp()).option("--continue-on-error", "Continue processing files even if there is a configuration error.").option("-r, --root <root folder>", "Root directory, defaults to current directory.").addOption(crOpt("--relative", "Issues are displayed relative to the root.").default(true).hideHelp()).option("--no-relative", "Issues are displayed with absolute path instead of relative to the root.").option("--show-context", "Show the surrounding text around an issue.").option("--show-suggestions", "Show spelling suggestions.").addOption(crOpt("--no-show-suggestions", "Do not show spelling suggestions or fixes.").default(void 0)).addOption(crOpt("--must-find-files", "Error if no files are found.").default(true).hideHelp()).option("--no-must-find-files", "Do not error if no files are found.").addOption(crOpt("--legacy", "Legacy output").hideHelp()).addOption(crOpt("--local <local>", "Deprecated -- Use: --locale").hideHelp()).option("--cache", "Use cache to only check changed files.").option("--no-cache", "Do not use cache.").option("--cache-reset", "Reset the cache file.").addOption(crOpt("--cache-strategy <strategy>", "Strategy to use for detecting changed files.").choices(["content", "metadata"]).default("content")).option("--cache-location <path>", `Path to the cache file or directory. (default: "${DEFAULT_CACHE_LOCATION}")`).option("--dot", "Include files and directories starting with `.` (period) when matching globs.").option("--gitignore", "Ignore files matching glob patterns found in .gitignore files.").option("--no-gitignore", "Do NOT use .gitignore files.").option("--gitignore-root <path>", "Prevent searching for .gitignore files past root.", collect$1).option("--validate-directives", "Validate in-document CSpell directives.").addOption(crOpt("--no-validate-directives", "Do not validate in-document CSpell directives.").hideHelp()).option("--max-file-size <size>", "Prevent checking large files. i.e 1MB, 50KB, 1GB").addOption(crOpt("--color", "Force color.").default(void 0)).addOption(crOpt("--no-color", "Turn off color.").default(void 0)).addOption(crOpt("--default-configuration", "Load the default configuration and dictionaries.").hideHelp()).addOption(crOpt("--no-default-configuration", "Do not load the default configuration and dictionaries.")).option("--dictionary <name>", "Enable a dictionary by name.", collect$1).addOption(crOpt("--no-dictionary <name>", "Disable a dictionary by name. Can be used multiple times.", prefixCollect("!")).hideHelp()).option("--disable-dictionary <name>", "Disable a dictionary by name.", collect$1).option("--reporter <module|path>", "Specify one or more reporters to use.", collect$1).addOption(crOpt("--report <level>", "Set how unknown words are reported").choices(ReportChoicesAll)).addOption(crOpt("--skip-validation", "Collect and process documents, but do not spell check.").implies({ cache: false }).hideHelp()).addOption(crOpt("--issues-summary-report", "Output a summary of issues found.").hideHelp()).addOption(crOpt("--show-perf-summary", "Output a performance summary report.").hideHelp()).option("--issue-template [template]", "Use a custom issue template. See --help --issue-template for details.").addOption(crOpt("--debug", "Output information useful for debugging cspell.json files.").hideHelp()).usage(usage).addHelpText("after", augmentCommandHelp).arguments("[globs...]").action(action);
|
|
406
|
+
})).option("--fail-fast", "Exit after first file with an issue or error.").addOption(crOpt("--no-fail-fast", "Process all files even if there is an error.").hideHelp()).option("--continue-on-error", "Continue processing files even if there is a configuration error.").option("-r, --root <root folder>", "Root directory, defaults to current directory.").addOption(crOpt("--relative", "Issues are displayed relative to the root.").default(true).hideHelp()).option("--no-relative", "Issues are displayed with absolute path instead of relative to the root.").option("--show-context", "Show the surrounding text around an issue.").option("--show-suggestions", "Show spelling suggestions.").addOption(crOpt("--no-show-suggestions", "Do not show spelling suggestions or fixes.").default(void 0)).addOption(crOpt("--must-find-files", "Error if no files are found.").default(true).hideHelp()).option("--no-must-find-files", "Do not error if no files are found.").addOption(crOpt("--legacy", "Legacy output").hideHelp()).addOption(crOpt("--local <local>", "Deprecated -- Use: --locale").hideHelp()).option("--cache", "Use cache to only check changed files.").option("--no-cache", "Do not use cache.").option("--cache-reset", "Reset the cache file.").addOption(crOpt("--cache-strategy <strategy>", "Strategy to use for detecting changed files.").choices(["content", "metadata"]).default("content")).option("--cache-location <path>", `Path to the cache file or directory. (default: "${DEFAULT_CACHE_LOCATION}")`).option("--dot", "Include files and directories starting with `.` (period) when matching globs.").option("--glob-symlinks", "Follow symbolic links when matching globs.").addOption(crOpt("--no-glob-symlinks", "Do not follow symbolic links when matching globs.").default(void 0).hideHelp()).option("--gitignore", "Ignore files matching glob patterns found in .gitignore files.").option("--no-gitignore", "Do NOT use .gitignore files.").option("--gitignore-root <path>", "Prevent searching for .gitignore files past root.", collect$1).option("--validate-directives", "Validate in-document CSpell directives.").addOption(crOpt("--no-validate-directives", "Do not validate in-document CSpell directives.").hideHelp()).option("--max-file-size <size>", "Prevent checking large files. i.e 1MB, 50KB, 1GB").addOption(crOpt("--color", "Force color.").default(void 0)).addOption(crOpt("--no-color", "Turn off color.").default(void 0)).addOption(crOpt("--default-configuration", "Load the default configuration and dictionaries.").hideHelp()).addOption(crOpt("--no-default-configuration", "Do not load the default configuration and dictionaries.")).option("--dictionary <name>", "Enable a dictionary by name.", collect$1).addOption(crOpt("--no-dictionary <name>", "Disable a dictionary by name. Can be used multiple times.", prefixCollect("!")).hideHelp()).option("--disable-dictionary <name>", "Disable a dictionary by name.", collect$1).option("--reporter <module|path>", "Specify one or more reporters to use.", collect$1).addOption(crOpt("--report <level>", "Set how unknown words are reported").choices(ReportChoicesAll)).addOption(crOpt("--skip-validation", "Collect and process documents, but do not spell check.").implies({ cache: false }).hideHelp()).addOption(crOpt("--issues-summary-report", "Output a summary of issues found.").hideHelp()).addOption(crOpt("--show-perf-summary", "Output a performance summary report.").hideHelp()).option("--issue-template [template]", "Use a custom issue template. See --help --issue-template for details.").addOption(crOpt("--debug", "Output information useful for debugging cspell.json files.").hideHelp()).usage(usage).addHelpText("after", augmentCommandHelp).arguments("[globs...]").action(action);
|
|
393
407
|
return spellCheckCommand;
|
|
394
408
|
}
|
|
395
409
|
async function action(fileGlobs, cliOptions) {
|
|
@@ -408,7 +422,12 @@ async function action(fileGlobs, cliOptions) {
|
|
|
408
422
|
this.outputHelp();
|
|
409
423
|
throw new CheckFailed("outputHelp", 1);
|
|
410
424
|
}
|
|
411
|
-
if (result.errors
|
|
425
|
+
if (result.errors) throw new CheckFailed("check failed", 1);
|
|
426
|
+
const skippedFiles = result.skippedFiles || 0;
|
|
427
|
+
if (mustFindFiles && result.files <= skippedFiles) {
|
|
428
|
+
if (!options.silent) console.error(`No files found to check${skippedFiles ? ` (${skippedFiles} skipped)` : ""}.`);
|
|
429
|
+
throw new CheckFailed("no files found", 1);
|
|
430
|
+
}
|
|
412
431
|
if (result.issues) throw new CheckFailed("check failed", useExitCode ? 1 : 0);
|
|
413
432
|
}
|
|
414
433
|
function helpIssueTemplate(opts) {
|
|
@@ -455,7 +474,7 @@ function augmentCommandHelp(context) {
|
|
|
455
474
|
const showHidden = !!opts.verbose;
|
|
456
475
|
const hiddenHelp = [];
|
|
457
476
|
const help = command.createHelp();
|
|
458
|
-
help.helpWidth =
|
|
477
|
+
help.helpWidth = getOutputWidth() || 80;
|
|
459
478
|
const hiddenOptions = command.options.filter((opt) => opt.hidden && showHidden);
|
|
460
479
|
const flagColWidth = Math.max(...command.options.map((opt) => opt.flags.length), 0);
|
|
461
480
|
for (const options of hiddenOptions) {
|
|
@@ -592,7 +611,7 @@ function calcTraceResultsReport(word, found, results, options) {
|
|
|
592
611
|
table: tableToLines({
|
|
593
612
|
header,
|
|
594
613
|
rows,
|
|
595
|
-
terminalWidth: options.lineWidth ||
|
|
614
|
+
terminalWidth: options.lineWidth || getOutputWidth() || maxWidth,
|
|
596
615
|
deliminator: " "
|
|
597
616
|
}).map((line) => line.trimEnd()).join("\n"),
|
|
598
617
|
errors: emitErrors(results).join("\n")
|
|
@@ -728,9 +747,15 @@ async function run(command, argv) {
|
|
|
728
747
|
const prog = command || program;
|
|
729
748
|
const args = argv || process.argv;
|
|
730
749
|
prog.exitOverride();
|
|
750
|
+
prog.configureOutput({
|
|
751
|
+
getOutHelpWidth: () => getOutputWidth(process.stdout) ?? 80,
|
|
752
|
+
getErrHelpWidth: () => getOutputWidth(process.stderr) ?? 80
|
|
753
|
+
});
|
|
754
|
+
prog.configureHelp({ minWidthToWrap: 20 });
|
|
731
755
|
prog.version(npmPackage.version).description("Spelling Checker for Code").name("cspell");
|
|
732
756
|
if (!satisfies(process.versions.node, npmPackage.engines.node)) throw new ApplicationError(`Unsupported NodeJS version (${process.versions.node}); ${npmPackage.engines.node} is required`);
|
|
733
|
-
addGlobalOptionsToAction(commandLint(prog, { isDefault: true }));
|
|
757
|
+
const lintCommand = addGlobalOptionsToAction(commandLint(prog, { isDefault: true }));
|
|
758
|
+
prog.addHelpText("after", (context) => defaultCommandOptionsHelp(context, lintCommand));
|
|
734
759
|
addGlobalOptionsToAction(commandTrace(prog));
|
|
735
760
|
addGlobalOptionsToAction(commandCheck(prog));
|
|
736
761
|
addGlobalOptionsToAction(commandSuggestion(prog));
|
|
@@ -741,6 +766,18 @@ async function run(command, argv) {
|
|
|
741
766
|
prog.exitOverride();
|
|
742
767
|
await prog.parseAsync(args);
|
|
743
768
|
}
|
|
769
|
+
/**
|
|
770
|
+
* `cspell --help` is answered by the program, not the default command,
|
|
771
|
+
* so list the default command's options here.
|
|
772
|
+
*/
|
|
773
|
+
function defaultCommandOptionsHelp(context, defaultCommand) {
|
|
774
|
+
const helper = defaultCommand.createHelp();
|
|
775
|
+
helper.prepareContext({ helpWidth: getOutputWidth(context.error ? process.stderr : process.stdout) ?? 80 });
|
|
776
|
+
const termWidth = helper.longestOptionTermLength(defaultCommand, helper);
|
|
777
|
+
const items = helper.visibleOptions(defaultCommand).filter((option) => option.long !== "--help").map((option) => helper.formatItem(helper.styleOptionTerm(helper.optionTerm(option)), termWidth, helper.styleOptionDescription(helper.optionDescription(option)), helper));
|
|
778
|
+
const heading = `Options for "${defaultCommand.name()}" (the default command):`;
|
|
779
|
+
return "\n" + helper.formatItemList(heading, items, helper).join("\n");
|
|
780
|
+
}
|
|
744
781
|
//#endregion
|
|
745
782
|
export { ApplicationError, CheckFailed, run };
|
|
746
783
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as SuggestionOptions, i as LinterCliOptions, n as DictionariesOptions, o as TraceOptions, r as LegacyOptions, t as BaseOptions } from "./options-
|
|
1
|
+
import { a as SuggestionOptions, i as LinterCliOptions, n as DictionariesOptions, o as TraceOptions, r as LegacyOptions, t as BaseOptions } from "./options-D5lC3IZu.js";
|
|
2
2
|
import { CheckTextInfo, FeatureFlags, IncludeExcludeFlag, SuggestionsForWordResult, TraceResult, TraceWordResult } from "cspell-lib";
|
|
3
3
|
import { CSpellReporter, RunResult } from "@cspell/cspell-types";
|
|
4
4
|
//#region src/config/options.d.ts
|
|
@@ -106,7 +106,15 @@ interface ListDictionariesResult {
|
|
|
106
106
|
declare function listDictionaries(options: DictionariesOptions): Promise<ListDictionariesResult[]>;
|
|
107
107
|
//#endregion
|
|
108
108
|
//#region src/application.d.mts
|
|
109
|
-
|
|
109
|
+
/**
|
|
110
|
+
* The same shape as `NodeJS.ErrnoException`, declared here so the published types do not need `@types/node`.
|
|
111
|
+
*/
|
|
112
|
+
interface AppError extends Error {
|
|
113
|
+
errno?: number | undefined;
|
|
114
|
+
code?: string | undefined;
|
|
115
|
+
path?: string | undefined;
|
|
116
|
+
syscall?: string | undefined;
|
|
117
|
+
}
|
|
110
118
|
declare function lint(fileGlobs: string[], options: LinterCliOptions, reporter?: CSpellReporter): Promise<RunResult>;
|
|
111
119
|
declare function trace(words: string[], options: TraceOptions): AsyncIterableIterator<TraceWordResult>;
|
|
112
120
|
type CheckTextResult = CheckTextInfo;
|
|
@@ -116,4 +124,4 @@ declare function createInit(options: InitOptions): Promise<void>;
|
|
|
116
124
|
declare function parseApplicationFeatureFlags(flags: string[] | undefined): FeatureFlags;
|
|
117
125
|
//#endregion
|
|
118
126
|
export { checkText as a, parseApplicationFeatureFlags as c, listDictionaries as d, TraceResult as i, suggestions as l, CheckTextResult as n, createInit as o, IncludeExcludeFlag as r, lint as s, AppError as t, trace as u };
|
|
119
|
-
//# sourceMappingURL=application-
|
|
127
|
+
//# sourceMappingURL=application-CFfMlhE_.d.ts.map
|