cspell 6.18.1 → 6.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -89,7 +89,9 @@ cspell lint --help
89
89
 
90
90
  ### Options
91
91
 
92
- ```text
92
+ <!--- @@inject: static/help-lint.txt --->
93
+
94
+ ```
93
95
  Usage: cspell lint [options] [globs...]
94
96
 
95
97
  Check spelling
@@ -97,30 +99,22 @@ Check spelling
97
99
  Options:
98
100
  -c, --config <cspell.json> Configuration file to use. By default cspell
99
101
  looks for cspell.json in the current directory.
100
-
101
102
  -v, --verbose Display more information about the files being
102
103
  checked and the configuration.
103
-
104
104
  --locale <locale> Set language locales. i.e. "en,fr" for English
105
105
  and French, or "en-GB" for British English.
106
-
107
106
  --language-id <language> Force programming language for unknown
108
107
  extensions. i.e. "php" or "scala"
109
-
110
108
  --words-only Only output the words not found in the
111
109
  dictionaries.
112
-
113
110
  -u, --unique Only output the first instance of a word not
114
111
  found in the dictionaries.
115
-
116
112
  -e, --exclude <glob> Exclude files matching the glob pattern. This
117
113
  option can be used multiple times to add
118
114
  multiple globs.
119
-
120
115
  --file-list <path or stdin> Specify a list of files to be spell checked. The
121
116
  list is filtered against the glob file patterns.
122
117
  Note: the format is 1 file path per line.
123
-
124
118
  --no-issues Do not show the spelling errors.
125
119
  --no-progress Turn off progress messages
126
120
  --no-summary Turn off summary message in console.
@@ -131,28 +125,26 @@ Options:
131
125
  --show-context Show the surrounding text around an issue.
132
126
  --show-suggestions Show spelling suggestions.
133
127
  --no-must-find-files Do not error if no files are found.
134
-
135
128
  --cache Use cache to only check changed files.
136
129
  --no-cache Do not use cache.
130
+ --cache-reset Reset the cache file.
137
131
  --cache-strategy <strategy> Strategy to use for detecting changed files.
138
132
  (choices: "metadata", "content")
139
-
140
133
  --cache-location <path> Path to the cache file or directory. (default:
141
134
  ".cspellcache")
142
-
143
135
  --dot Include files and directories starting with `.`
144
136
  (period) when matching globs.
145
-
146
137
  --gitignore Ignore files matching glob patterns found in
147
138
  .gitignore files.
148
-
149
139
  --no-gitignore Do NOT use .gitignore files.
150
-
151
140
  --gitignore-root <path> Prevent searching for .gitignore files past
152
141
  root.
153
-
142
+ --validate-directives Validate in-document CSpell directives.
143
+ --no-validate-directives Do not validate in-document CSpell directives.
154
144
  --no-color Turn off color.
155
145
  --color Force color.
146
+ --no-default-configuration Do not load the default configuration and
147
+ dictionaries.
156
148
  --debug Output information useful for debugging
157
149
  cspell.json files.
158
150
  -h, --help display help for command
@@ -167,6 +159,8 @@ Examples:
167
159
  cat LICENSE | cspell stdin Check stdin
168
160
  ```
169
161
 
162
+ <!--- @@inject-end: static/help-lint.txt --->
163
+
170
164
  ## Command: `check` - Quick Visual Check
171
165
 
172
166
  Do a quick visual check of a file. This is a great way to see which text is included in the check.
@@ -194,6 +188,35 @@ A `!` will appear next to the ones where the word is forbidden.
194
188
 
195
189
  ![image](https://user-images.githubusercontent.com/3740137/129488961-b99dbd2f-7daa-4462-96cd-568e0d4c3c6e.png)
196
190
 
191
+ ### Help `cspell trace --help`
192
+
193
+ <!--- @@inject: static/help-trace.txt --->
194
+
195
+ ```
196
+ Usage: cspell trace [options] [words...]
197
+
198
+ Trace words -- Search for words in the configuration and dictionaries.
199
+
200
+ Options:
201
+ -c, --config <cspell.json> Configuration file to use. By default cspell
202
+ looks for cspell.json in the current directory.
203
+ --locale <locale> Set language locales. i.e. "en,fr" for English
204
+ and French, or "en-GB" for British English.
205
+ --language-id <language> Use programming language. i.e. "php" or "scala"
206
+ --allow-compound-words Turn on allowCompoundWords
207
+ --no-allow-compound-words Turn off allowCompoundWords
208
+ --no-ignore-case Do not ignore case and accents when searching for
209
+ words
210
+ --stdin Read words from stdin.
211
+ --no-color Turn off color.
212
+ --color Force color
213
+ --no-default-configuration Do not load the default configuration and
214
+ dictionaries.
215
+ -h, --help display help for command
216
+ ```
217
+
218
+ <!--- @@inject-end: static/help-trace.txt --->
219
+
197
220
  ## CI/CD Continuous Integration support
198
221
 
199
222
  ### Mega-Linter
@@ -227,7 +250,7 @@ exec git diff --cached --name-only | npx cspell --no-summary --no-progress --no-
227
250
 
228
251
  ## Requirements
229
252
 
230
- cspell needs Node 12 and above.
253
+ cspell needs Node 14 and above.
231
254
 
232
255
  ## How it works
233
256
 
@@ -283,6 +306,7 @@ It is possible to disable / enable the spell checker by adding comments to your
283
306
  - `/* spellchecker: disable */`
284
307
  - `// cspell:disable-line` -- disables checking for the current line.
285
308
  - `/* cspell:disable-next-line */` -- disables checking till the end of the next line.
309
+
286
310
  <!--- cSpell:enable -->
287
311
 
288
312
  #### Enable Checking
@@ -373,9 +397,9 @@ By default the flags `gim` are added if no flags are given.
373
397
 
374
398
  The spell checker works in the following way:
375
399
 
376
- 1. Find all text matching `includeRegExp`
377
- 2. Remove any text matching `ignoreRegExp`
378
- 3. Check the remaining text.
400
+ 1. Find all text matching `includeRegExp`
401
+ 1. Remove any text matching `ignoreRegExp`
402
+ 1. Check the remaining text.
379
403
 
380
404
  #### Exclude Example
381
405
 
@@ -432,7 +456,7 @@ const companyName = 'Lorem ipsum dolor sit amet';
432
456
  ### Exclude patterns
433
457
 
434
458
  - `Urls`<sup>1</sup> -- Matches urls
435
- - `HexValues` -- Matches common hex format like #aaa, 0xfeef, \\u0134
459
+ - `HexValues` -- Matches common hex format like `#aaa`, `0xfeef`, `\u0134`
436
460
  - `Base64`<sup>1</sup> -- matches base64 blocks of text longer than 40 characters.
437
461
  - `Email` -- matches most email addresses.
438
462
 
@@ -495,11 +519,16 @@ Or you can specify a path to a config file with the `--config <path>` argument o
495
519
  ### cspell.json sections
496
520
 
497
521
  - `version` - currently always 0.2 - controls how the settings in the configuration file behave.
522
+
498
523
  - `language` - this specifies the language locale to use in choosing the general dictionary.
499
524
  For example: `"language": "en-GB"` tells cspell to use British English instead of US English.
525
+
500
526
  - `words` - a list of words to be considered correct.
527
+
501
528
  - `flagWords` - a list of words to be always considered incorrect
529
+
502
530
  - `ignoreWords` - a list of words to be ignored (even if they are in the flagWords).
531
+
503
532
  - `ignorePaths` - a list of globs to specify which files are to be ignored.
504
533
 
505
534
  **Example**
@@ -511,9 +540,13 @@ Or you can specify a path to a config file with the `--config <path>` argument o
511
540
  will cause cspell to ignore anything in the `node_modules` directory.
512
541
 
513
542
  - `maxNumberOfProblems` - defaults to **_100_** per file.
543
+
514
544
  - `minWordLength` - defaults to **_4_** - the minimum length of a word before it is checked.
545
+
515
546
  - `allowCompoundWords` - defaults to **_false_**; set to **true** to allow compound words by default.
547
+
516
548
  - `dictionaries` - list of the names of the dictionaries to use. See [Dictionaries](#Dictionaries) below.
549
+
517
550
  - `dictionaryDefinitions` - this list defines any custom dictionaries to use. This is how you can include other languages like Spanish.
518
551
 
519
552
  **Example**
@@ -533,9 +566,12 @@ Or you can specify a path to a config file with the `--config <path>` argument o
533
566
  ```
534
567
 
535
568
  - `ignoreRegExpList` - list of patterns to be ignored
569
+
536
570
  - `includeRegExpList` - _(Advanced)_ limits the text checked to be only that matching the expressions in the list.
571
+
537
572
  - `patterns` - this allows you to define named patterns to be used with
538
573
  `ignoreRegExpList` and `includeRegExpList`.
574
+
539
575
  - `languageSettings` - this allow for per programming language configuration settings. See [LanguageSettings](#LanguageSettings)
540
576
 
541
577
  ## Dictionaries
package/dist/app.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Command } from 'commander';
1
+ import type { Command } from 'commander';
2
2
  export { LinterCliOptions as Options } from './options';
3
3
  export { CheckFailed } from './util/errors';
4
4
  export declare function run(command?: Command, argv?: string[]): Promise<void>;
@@ -1,10 +1,10 @@
1
1
  /// <reference types="node" />
2
2
  import type { CSpellReporter, RunResult } from '@cspell/cspell-types';
3
- import { CheckTextInfo, FeatureFlags, TraceResult } from 'cspell-lib';
4
- import { TimedSuggestionsForWordResult } from './emitters/suggestionsEmitter';
5
- import { BaseOptions, LegacyOptions, LinterCliOptions, SuggestionOptions, TraceOptions } from './options';
6
- export { IncludeExcludeFlag } from 'cspell-lib';
3
+ import type { CheckTextInfo, FeatureFlags, TraceResult } from 'cspell-lib';
4
+ import type { TimedSuggestionsForWordResult } from './emitters/suggestionsEmitter';
5
+ import type { BaseOptions, LegacyOptions, LinterCliOptions, SuggestionOptions, TraceOptions } from './options';
7
6
  export type { TraceResult } from 'cspell-lib';
7
+ export { IncludeExcludeFlag } from 'cspell-lib';
8
8
  export type AppError = NodeJS.ErrnoException;
9
9
  export declare function lint(fileGlobs: string[], options: LinterCliOptions, reporter?: CSpellReporter): Promise<RunResult>;
10
10
  export declare function trace(words: string[], options: TraceOptions): AsyncIterableIterator<TraceResult[]>;
@@ -1,5 +1,5 @@
1
1
  import type { CSpellReporter, Issue } from '@cspell/cspell-types';
2
- import { LinterCliOptions } from './options';
2
+ import type { LinterCliOptions } from './options';
3
3
  export interface ReporterIssue extends Issue {
4
4
  filename: string;
5
5
  }
@@ -22,9 +22,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
25
28
  Object.defineProperty(exports, "__esModule", { value: true });
26
29
  exports.__testing__ = exports.getReporter = void 0;
27
- const chalk = require("chalk");
30
+ const chalk_1 = __importDefault(require("chalk"));
28
31
  const cspell_lib_1 = require("cspell-lib");
29
32
  const path = __importStar(require("path"));
30
33
  const vscode_uri_1 = require("vscode-uri");
@@ -32,7 +35,7 @@ const templateIssue = `{green $filename}:{yellow $row:$col} - $message ({red $te
32
35
  const templateIssueWithSuggestions = `{green $filename}:{yellow $row:$col} - $message ({red $text}) Suggestions: {yellow [$suggestions]}`;
33
36
  const templateIssueWithContext = `{green $filename}:{yellow $row:$col} $padRowCol- $message ({red $text})$padContext -- {gray $contextLeft}{red {underline $text}}{gray $contextRight}`;
34
37
  const templateIssueWithContextWithSuggestions = `{green $filename}:{yellow $row:$col} $padRowCol- $message ({red $text})$padContext -- {gray $contextLeft}{red {underline $text}}{gray $contextRight}\n\t Suggestions: {yellow [$suggestions]}`;
35
- const templateIssueLegacy = `${chalk.green('$filename')}[$row, $col]: $message: ${chalk.red('$text')}`;
38
+ const templateIssueLegacy = `${chalk_1.default.green('$filename')}[$row, $col]: $message: ${chalk_1.default.red('$text')}`;
36
39
  const templateIssueWordsOnly = '$text';
37
40
  function genIssueEmitter(template) {
38
41
  const defaultWidth = 10;
@@ -51,7 +54,7 @@ function errorEmitter(message, error) {
51
54
  if ((0, cspell_lib_1.isSpellingDictionaryLoadError)(error)) {
52
55
  error = error.cause;
53
56
  }
54
- console.error(chalk.red(message), error.toString());
57
+ console.error(chalk_1.default.red(message), error.toString());
55
58
  }
56
59
  function nullEmitter() {
57
60
  /* empty */
@@ -81,21 +84,21 @@ function reportProgressFileBegin(p) {
81
84
  const fc = '' + p.fileCount;
82
85
  const fn = (' '.repeat(fc.length) + p.fileNum).slice(-fc.length);
83
86
  const idx = fn + '/' + fc;
84
- const filename = chalk.gray(relativeFilename(p.filename));
87
+ const filename = chalk_1.default.gray(relativeFilename(p.filename));
85
88
  process.stderr.write(`\r${idx} ${filename}`);
86
89
  }
87
90
  function reportProgressFileComplete(p) {
88
91
  const time = reportTime(p.elapsedTimeMs, !!p.cached);
89
92
  const skipped = p.processed === false ? ' skipped' : '';
90
- const hasErrors = p.numErrors ? chalk.red ` X` : '';
93
+ const hasErrors = p.numErrors ? chalk_1.default.red ` X` : '';
91
94
  console.error(` ${time}${skipped}${hasErrors}`);
92
95
  }
93
96
  function reportTime(elapsedTimeMs, cached) {
94
97
  if (cached)
95
- return chalk.green('cached');
98
+ return chalk_1.default.green('cached');
96
99
  if (elapsedTimeMs === undefined)
97
100
  return '-';
98
- const color = elapsedTimeMs < 1000 ? chalk.white : elapsedTimeMs < 2000 ? chalk.yellow : chalk.redBright;
101
+ const color = elapsedTimeMs < 1000 ? chalk_1.default.white : elapsedTimeMs < 2000 ? chalk_1.default.yellow : chalk_1.default.redBright;
99
102
  return color(elapsedTimeMs.toFixed(2) + 'ms');
100
103
  }
101
104
  function getReporter(options) {
@@ -112,9 +115,9 @@ function getReporter(options) {
112
115
  : templateIssue;
113
116
  const { fileGlobs, silent, summary, issues, progress, verbose, debug } = options;
114
117
  const emitters = {
115
- Debug: !silent && debug ? (s) => console.info(chalk.cyan(s)) : nullEmitter,
116
- Info: !silent && verbose ? (s) => console.info(chalk.yellow(s)) : nullEmitter,
117
- Warning: (s) => console.info(chalk.yellow(s)),
118
+ Debug: !silent && debug ? (s) => console.info(chalk_1.default.cyan(s)) : nullEmitter,
119
+ Info: !silent && verbose ? (s) => console.info(chalk_1.default.yellow(s)) : nullEmitter,
120
+ Warning: (s) => console.info(chalk_1.default.yellow(s)),
118
121
  };
119
122
  function infoEmitter(message, msgType) {
120
123
  emitters[msgType]?.(message);
@@ -180,12 +183,12 @@ function formatIssue(templateStr, issue, maxIssueTextWidth) {
180
183
  $uri: uri,
181
184
  };
182
185
  const t = template(templateStr.replace(/\$message/g, message));
183
- return substitute(chalk(t), substitutions);
186
+ return substitute((0, chalk_1.default)(t), substitutions);
184
187
  }
185
188
  function formatSuggestions(issue) {
186
189
  if (issue.suggestionsEx) {
187
190
  return issue.suggestionsEx
188
- .map((sug) => (sug.isPreferred ? chalk.italic(chalk.bold(sug.word)) + '*' : sug.word))
191
+ .map((sug) => (sug.isPreferred ? chalk_1.default.italic(chalk_1.default.bold(sug.word)) + '*' : sug.word))
189
192
  .join(', ');
190
193
  }
191
194
  if (issue.suggestions) {
@@ -1,3 +1,3 @@
1
- import { Command } from 'commander';
1
+ import type { Command } from 'commander';
2
2
  export declare function commandCheck(prog: Command): Command;
3
3
  //# sourceMappingURL=commandCheck.d.ts.map
@@ -22,13 +22,16 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
25
28
  Object.defineProperty(exports, "__esModule", { value: true });
26
29
  exports.commandCheck = void 0;
30
+ const chalk_1 = __importDefault(require("chalk"));
27
31
  const commander_1 = require("commander");
28
32
  const App = __importStar(require("./application"));
29
33
  const application_1 = require("./application");
30
34
  const errors_1 = require("./util/errors");
31
- const chalk = require("chalk");
32
35
  function commandCheck(prog) {
33
36
  return prog
34
37
  .command('check <files...>')
@@ -44,16 +47,16 @@ function commandCheck(prog) {
44
47
  App.parseApplicationFeatureFlags(options.flag);
45
48
  let issueCount = 0;
46
49
  for (const filename of files) {
47
- console.log(chalk.yellowBright(`Check file: ${filename}`));
50
+ console.log(chalk_1.default.yellowBright(`Check file: ${filename}`));
48
51
  console.log();
49
52
  try {
50
53
  const result = await (0, application_1.checkText)(filename, options);
51
54
  for (const item of result.items) {
52
55
  const fn = item.flagIE === App.IncludeExcludeFlag.EXCLUDE
53
- ? chalk.gray
56
+ ? chalk_1.default.gray
54
57
  : item.isError
55
- ? chalk.red
56
- : chalk.whiteBright;
58
+ ? chalk_1.default.red
59
+ : chalk_1.default.whiteBright;
57
60
  const t = fn(item.text);
58
61
  process.stdout.write(t);
59
62
  issueCount += item.isError ? 1 : 0;
@@ -1,3 +1,3 @@
1
- import { Command } from 'commander';
1
+ import type { Command } from 'commander';
2
2
  export declare function commandLink(prog: Command): Command;
3
3
  //# sourceMappingURL=commandLink.d.ts.map
@@ -1,3 +1,3 @@
1
- import { Command } from 'commander';
1
+ import type { Command } from 'commander';
2
2
  export declare function commandLint(prog: Command): Command;
3
3
  //# sourceMappingURL=commandLint.d.ts.map
@@ -1,3 +1,3 @@
1
- import { Command } from 'commander';
1
+ import type { Command } from 'commander';
2
2
  export declare function commandSuggestion(prog: Command): Command;
3
3
  //# sourceMappingURL=commandSuggestion.d.ts.map
@@ -56,7 +56,7 @@ function commandSuggestion(prog) {
56
56
  .option('--num-suggestions <number>', 'Number of suggestions', asNumber, 8)
57
57
  .option('--no-include-ties', 'Force the number of suggested to be limited, by not including suggestions that have the same edit cost.')
58
58
  .option('--stdin', 'Use stdin for input.')
59
- .addOption(new commander_1.Option('--repl', 'REPL interface for looking up suggestions.').hideHelp())
59
+ .addOption(new commander_1.Option('--repl', 'REPL interface for looking up suggestions.'))
60
60
  .option('-v, --verbose', 'Show detailed output.', count, 0)
61
61
  .option('-d, --dictionary <dictionary name>', 'Use the dictionary specified. Only dictionaries specified will be used.', collect)
62
62
  .option('--dictionaries <dictionary names...>', 'Use the dictionaries specified. Only dictionaries specified will be used.')
@@ -1,3 +1,3 @@
1
- import { Command } from 'commander';
1
+ import type { Command } from 'commander';
2
2
  export declare function commandTrace(prog: Command): Command;
3
3
  //# sourceMappingURL=commandTrace.d.ts.map
@@ -1,7 +1,10 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.emitSuggestionResult = void 0;
4
- const chalk = require("chalk");
7
+ const chalk_1 = __importDefault(require("chalk"));
5
8
  const util_1 = require("../util/util");
6
9
  const regExpRTL = /([\u0591-\u07FF\uFB1D-\uFDFD\uFE70-\uFEFC י]+)/g;
7
10
  function reverseRtlText(s) {
@@ -12,10 +15,10 @@ function emitSuggestionResult(result, options) {
12
15
  const { verbose, output = console } = options;
13
16
  const elapsed = verbose && verbose > 1 && result.elapsedTimeMs ? ` ${result.elapsedTimeMs.toFixed(2)} ms` : '';
14
17
  const rWord = reverseRtlText(word);
15
- const wordEx = rWord !== word ? ` (${chalk.yellow(rWord)})` : '';
16
- output.log((word ? chalk.yellow(word) + wordEx : chalk.yellow('<empty>')) + ':' + elapsed);
18
+ const wordEx = rWord !== word ? ` (${chalk_1.default.yellow(rWord)})` : '';
19
+ output.log((word ? chalk_1.default.yellow(word) + wordEx : chalk_1.default.yellow('<empty>')) + ':' + elapsed);
17
20
  if (!suggestions.length) {
18
- console.log(chalk.yellow(' <no suggestions>'));
21
+ console.log(chalk_1.default.yellow(' <no suggestions>'));
19
22
  return;
20
23
  }
21
24
  function handleRtl(word) {
@@ -30,16 +33,16 @@ function emitSuggestionResult(result, options) {
30
33
  const { cost, dictionaries, w } = sug;
31
34
  const padding = ' '.repeat((0, util_1.padWidth)(w, maxWidth));
32
35
  const forbid = sug.forbidden && sug.isPreferred
33
- ? chalk.red('*')
36
+ ? chalk_1.default.red('*')
34
37
  : sug.forbidden
35
- ? chalk.red('X')
38
+ ? chalk_1.default.red('X')
36
39
  : sug.isPreferred
37
- ? chalk.yellow('*')
40
+ ? chalk_1.default.yellow('*')
38
41
  : ' ';
39
- const ignore = sug.noSuggest ? chalk.yellow('N') : ' ';
42
+ const ignore = sug.noSuggest ? chalk_1.default.yellow('N') : ' ';
40
43
  const strCost = (0, util_1.padLeft)(cost.toString(10), 4);
41
- const dicts = dictionaries.map((n) => chalk.gray(n)).join(', ');
42
- output.log(` - ${formatWord(w, sug)}${padding} ${forbid}${ignore} - ${chalk.yellow(strCost)} ${dicts}`);
44
+ const dicts = dictionaries.map((n) => chalk_1.default.gray(n)).join(', ');
45
+ output.log(` - ${formatWord(w, sug)}${padding} ${forbid}${ignore} - ${chalk_1.default.yellow(strCost)} ${dicts}`);
43
46
  }
44
47
  }
45
48
  else {
@@ -51,13 +54,13 @@ function emitSuggestionResult(result, options) {
51
54
  }
52
55
  exports.emitSuggestionResult = emitSuggestionResult;
53
56
  function formatWord(word, r) {
54
- return r.forbidden || r.noSuggest ? chalk.gray(chalk.strikethrough(word)) : word;
57
+ return r.forbidden || r.noSuggest ? chalk_1.default.gray(chalk_1.default.strikethrough(word)) : word;
55
58
  }
56
59
  function formatWordSingle(s) {
57
60
  let word = formatWord(s.word, s);
58
- word = s.forbidden ? word + chalk.red(' X') : word;
59
- word = s.noSuggest ? word + chalk.yellow(' Not suggested.') : word;
60
- word = s.isPreferred ? chalk.yellow(word + ' *') : word;
61
+ word = s.forbidden ? word + chalk_1.default.red(' X') : word;
62
+ word = s.noSuggest ? word + chalk_1.default.yellow(' Not suggested.') : word;
63
+ word = s.isPreferred ? chalk_1.default.yellow(word + ' *') : word;
61
64
  return word;
62
65
  }
63
66
  //# sourceMappingURL=suggestionsEmitter.js.map
@@ -1,4 +1,4 @@
1
- import { TraceResult } from '../application';
1
+ import type { TraceResult } from '../application';
2
2
  export interface EmitTraceOptions {
3
3
  /** current working directory */
4
4
  cwd: string;
@@ -27,10 +27,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.emitTraceResults = void 0;
30
+ const chalk_1 = __importDefault(require("chalk"));
30
31
  const Path = __importStar(require("path"));
31
32
  const strip_ansi_1 = __importDefault(require("strip-ansi"));
32
33
  const util_1 = require("../util/util");
33
- const chalk = require("chalk");
34
34
  const colWidthDictionaryName = 20;
35
35
  function emitTraceResults(results, options) {
36
36
  const maxWordLength = results
@@ -54,28 +54,28 @@ function emitHeader(colWidths) {
54
54
  (0, util_1.pad)('Dictionary', colWidths.dictName),
55
55
  (0, util_1.pad)('Dictionary Location', 30),
56
56
  ];
57
- console.log(chalk.underline(line.join(' ').slice(0, colWidths.terminalWidth)));
57
+ console.log(chalk_1.default.underline(line.join(' ').slice(0, colWidths.terminalWidth)));
58
58
  }
59
59
  function emitTraceResult(r, colWidths, options) {
60
60
  const { word: wordColWidth, terminalWidth, dictName: widthName } = colWidths;
61
61
  const errors = r.errors?.map((e) => e.message)?.join('\n\t') || '';
62
62
  const word = (0, util_1.pad)(r.foundWord || r.word, wordColWidth);
63
- const cWord = word.replace(/[+]/g, chalk.yellow('+'));
64
- const w = r.forbidden ? chalk.red(cWord) : chalk.green(cWord);
63
+ const cWord = word.replace(/[+]/g, chalk_1.default.yellow('+'));
64
+ const w = r.forbidden ? chalk_1.default.red(cWord) : chalk_1.default.green(cWord);
65
65
  const f = calcFoundChar(r);
66
66
  const a = r.dictActive ? '*' : ' ';
67
67
  const dictName = (0, util_1.pad)(r.dictName.slice(0, widthName - 1) + a, widthName);
68
- const dictColor = r.dictActive ? chalk.yellowBright : chalk.rgb(200, 128, 50);
68
+ const dictColor = r.dictActive ? chalk_1.default.yellowBright : chalk_1.default.rgb(200, 128, 50);
69
69
  const n = dictColor(dictName);
70
70
  const info = [w, f, n].join(' ') + ' ';
71
71
  const used = (0, util_1.width)((0, strip_ansi_1.default)(info));
72
72
  const widthSrc = terminalWidth - used;
73
- const c = errors ? chalk.red : chalk.white;
73
+ const c = errors ? chalk_1.default.red : chalk_1.default.white;
74
74
  const s = c(formatDictionaryLocation(r.dictSource, widthSrc, options.cwd));
75
75
  const line = info + s;
76
76
  console.log(line);
77
77
  if (errors) {
78
- console.error('\t' + chalk.red(errors));
78
+ console.error('\t' + chalk_1.default.red(errors));
79
79
  }
80
80
  }
81
81
  function trimMid(s, w) {
@@ -89,11 +89,11 @@ function trimMid(s, w) {
89
89
  }
90
90
  function calcFoundChar(r) {
91
91
  const errors = r.errors?.map((e) => e.message)?.join('\n\t') || '';
92
- let color = chalk.dim;
93
- color = r.found ? chalk.whiteBright : color;
94
- color = r.forbidden ? chalk.red : color;
95
- color = r.noSuggest ? chalk.yellowBright : color;
96
- color = errors ? chalk.red : color;
92
+ let color = chalk_1.default.dim;
93
+ color = r.found ? chalk_1.default.whiteBright : color;
94
+ color = r.forbidden ? chalk_1.default.red : color;
95
+ color = r.noSuggest ? chalk_1.default.yellowBright : color;
96
+ color = errors ? chalk_1.default.red : color;
97
97
  let char = '-';
98
98
  char = r.found ? '*' : char;
99
99
  char = r.forbidden ? '!' : char;
@@ -1,4 +1,4 @@
1
- import { FeatureFlags } from 'cspell-lib';
1
+ import type { FeatureFlags } from 'cspell-lib';
2
2
  export declare function getFeatureFlags(): FeatureFlags;
3
3
  export declare function parseFeatureFlags(flags: string[] | undefined, featureFlags?: FeatureFlags): FeatureFlags;
4
4
  //# sourceMappingURL=featureFlags.d.ts.map
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export * from '@cspell/cspell-types';
2
1
  export * from './application';
3
- export type { BaseOptions, LinterCliOptions as CSpellApplicationOptions, TraceOptions } from './options';
4
2
  export { getReporter as getDefaultReporter } from './cli-reporter';
3
+ export type { BaseOptions, LinterCliOptions as CSpellApplicationOptions, TraceOptions } from './options';
4
+ export * from '@cspell/cspell-types';
5
5
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -15,8 +15,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.getDefaultReporter = void 0;
18
- __exportStar(require("@cspell/cspell-types"), exports);
19
18
  __exportStar(require("./application"), exports);
20
19
  var cli_reporter_1 = require("./cli-reporter");
21
20
  Object.defineProperty(exports, "getDefaultReporter", { enumerable: true, get: function () { return cli_reporter_1.getReporter; } });
21
+ __exportStar(require("@cspell/cspell-types"), exports);
22
22
  //# sourceMappingURL=index.js.map
package/dist/link.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Link } from 'cspell-lib';
2
- import { Table } from './util/table';
2
+ import type { Table } from './util/table';
3
3
  export declare const listGlobalImports: typeof Link.listGlobalImports;
4
4
  export declare const addPathsToGlobalImports: typeof Link.addPathsToGlobalImports;
5
5
  export declare const removePathsFromGlobalImports: typeof Link.removePathsFromGlobalImports;
package/dist/link.js CHANGED
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.addPathsToGlobalImportsResultToTable = exports.listGlobalImportsResultToTable = exports.removePathsFromGlobalImports = exports.addPathsToGlobalImports = exports.listGlobalImports = void 0;
7
- const cspell_lib_1 = require("cspell-lib");
8
7
  const chalk_1 = __importDefault(require("chalk"));
8
+ const cspell_lib_1 = require("cspell-lib");
9
9
  exports.listGlobalImports = cspell_lib_1.Link.listGlobalImports;
10
10
  exports.addPathsToGlobalImports = cspell_lib_1.Link.addPathsToGlobalImports;
11
11
  exports.removePathsFromGlobalImports = cspell_lib_1.Link.removePathsFromGlobalImports;
@@ -1,6 +1,6 @@
1
1
  import type { CSpellReporter, Issue } from '@cspell/cspell-types';
2
- import { LinterOptions } from '../options';
3
- import { GlobSrcInfo } from '../util/glob';
2
+ import type { LinterOptions } from '../options';
3
+ import type { GlobSrcInfo } from '../util/glob';
4
4
  interface Deprecated {
5
5
  fileLists?: LinterOptions['fileList'];
6
6
  }
@@ -1,4 +1,4 @@
1
1
  import type { RunResult } from '@cspell/cspell-types';
2
- import { LintRequest } from './LintRequest';
2
+ import type { LintRequest } from './LintRequest';
3
3
  export declare function runLint(cfg: LintRequest): Promise<RunResult>;
4
4
  //# sourceMappingURL=lint.d.ts.map
package/dist/lint/lint.js CHANGED
@@ -22,16 +22,21 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
25
28
  Object.defineProperty(exports, "__esModule", { value: true });
26
29
  exports.runLint = void 0;
27
30
  const cspell_pipe_1 = require("@cspell/cspell-pipe");
28
31
  const cspell_types_1 = require("@cspell/cspell-types");
32
+ const chalk_1 = __importDefault(require("chalk"));
29
33
  const cspell_gitignore_1 = require("cspell-gitignore");
30
34
  const cspell_glob_1 = require("cspell-glob");
31
35
  const cspell = __importStar(require("cspell-lib"));
32
36
  const path = __importStar(require("path"));
33
37
  const util_1 = require("util");
34
38
  const vscode_uri_1 = require("vscode-uri");
39
+ const featureFlags_1 = require("../featureFlags");
35
40
  const cache_1 = require("../util/cache");
36
41
  const errors_1 = require("../util/errors");
37
42
  const fileHelper_1 = require("../util/fileHelper");
@@ -39,8 +44,6 @@ const glob_1 = require("../util/glob");
39
44
  const reporters_1 = require("../util/reporters");
40
45
  const timer_1 = require("../util/timer");
41
46
  const util = __importStar(require("../util/util"));
42
- const chalk = require("chalk");
43
- const featureFlags_1 = require("../featureFlags");
44
47
  // eslint-disable-next-line @typescript-eslint/no-var-requires
45
48
  const npmPackage = require('../../package.json');
46
49
  const version = npmPackage.version;
@@ -229,7 +232,7 @@ async function runLint(cfg) {
229
232
  return runResult();
230
233
  }
231
234
  header(fileGlobs, excludeGlobs);
232
- checkGlobs(cfg.fileGlobs, reporter);
235
+ checkGlobs(fileGlobs, reporter);
233
236
  reporter.info(`Config Files Found:\n ${configInfo.source}\n`, cspell_types_1.MessageTypes.Info);
234
237
  const configErrors = await countConfigErrors(configInfo);
235
238
  if (configErrors)
@@ -266,7 +269,7 @@ exports.runLint = runLint;
266
269
  function checkGlobs(globs, reporter) {
267
270
  globs
268
271
  .filter((g) => g.startsWith("'") || g.endsWith("'"))
269
- .map((glob) => chalk.yellow(glob))
272
+ .map((glob) => chalk_1.default.yellow(glob))
270
273
  .forEach((glob) => reporter.error('Linter', new errors_1.CheckFailed(`Glob starting or ending with ' (single quote) is not likely to match any files: ${glob}.`)));
271
274
  }
272
275
  async function determineGlobs(configInfo, cfg) {
@@ -275,7 +278,7 @@ async function determineGlobs(configInfo, cfg) {
275
278
  const gitIgnore = useGitignore ? await generateGitIgnore(gitignoreRoots) : undefined;
276
279
  const cliGlobs = cfg.fileGlobs;
277
280
  const allGlobs = cliGlobs.length ? cliGlobs : configInfo.config.files || [];
278
- const combinedGlobs = (0, glob_1.normalizeGlobsToRoot)(allGlobs, cfg.root, false);
281
+ const combinedGlobs = await (0, glob_1.normalizeFileOrGlobsToRoot)(allGlobs, cfg.root);
279
282
  const cliExcludeGlobs = (0, glob_1.extractPatterns)(cfg.excludes).map((p) => p.glob);
280
283
  const normalizedExcludes = (0, glob_1.normalizeGlobsToRoot)(cliExcludeGlobs, cfg.root, true);
281
284
  const includeGlobs = combinedGlobs.filter((g) => !g.startsWith('!'));
@@ -1,3 +1,3 @@
1
- export { helpers as asyncHelpers, operators as asyncOperators, pipeAsync as asyncPipe, toArray as asyncIterableToArray, toAsyncIterable as mergeAsyncIterables, } from '@cspell/cspell-pipe';
1
+ export { helpers as asyncHelpers, toArray as asyncIterableToArray, operators as asyncOperators, pipeAsync as asyncPipe, toAsyncIterable as mergeAsyncIterables, } from '@cspell/cspell-pipe';
2
2
  export declare const asyncMap: typeof import("@cspell/cspell-pipe/operators").opMapAsync, asyncFilter: typeof import("@cspell/cspell-pipe/operators").opFilterAsync, asyncAwait: typeof import("@cspell/cspell-pipe").opAwaitAsync, asyncFlatten: typeof import("@cspell/cspell-pipe/operators").opFlattenAsync;
3
3
  //# sourceMappingURL=async.d.ts.map
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.asyncFlatten = exports.asyncAwait = exports.asyncFilter = exports.asyncMap = exports.mergeAsyncIterables = exports.asyncIterableToArray = exports.asyncPipe = exports.asyncOperators = exports.asyncHelpers = void 0;
3
+ exports.asyncFlatten = exports.asyncAwait = exports.asyncFilter = exports.asyncMap = exports.mergeAsyncIterables = exports.asyncPipe = exports.asyncOperators = exports.asyncIterableToArray = exports.asyncHelpers = void 0;
4
4
  const cspell_pipe_1 = require("@cspell/cspell-pipe");
5
5
  var cspell_pipe_2 = require("@cspell/cspell-pipe");
6
6
  Object.defineProperty(exports, "asyncHelpers", { enumerable: true, get: function () { return cspell_pipe_2.helpers; } });
7
+ Object.defineProperty(exports, "asyncIterableToArray", { enumerable: true, get: function () { return cspell_pipe_2.toArray; } });
7
8
  Object.defineProperty(exports, "asyncOperators", { enumerable: true, get: function () { return cspell_pipe_2.operators; } });
8
9
  Object.defineProperty(exports, "asyncPipe", { enumerable: true, get: function () { return cspell_pipe_2.pipeAsync; } });
9
- Object.defineProperty(exports, "asyncIterableToArray", { enumerable: true, get: function () { return cspell_pipe_2.toArray; } });
10
10
  Object.defineProperty(exports, "mergeAsyncIterables", { enumerable: true, get: function () { return cspell_pipe_2.toAsyncIterable; } });
11
11
  exports.asyncMap = cspell_pipe_1.operators.opMapAsync, exports.asyncFilter = cspell_pipe_1.operators.opFilterAsync, exports.asyncAwait = cspell_pipe_1.operators.opAwaitAsync, exports.asyncFlatten = cspell_pipe_1.operators.opFlattenAsync;
12
12
  //# sourceMappingURL=async.js.map
@@ -1,4 +1,4 @@
1
- import { FileResult } from '../../util/fileHelper';
1
+ import type { FileResult } from '../../util/fileHelper';
2
2
  export interface CSpellLintResultCache {
3
3
  /**
4
4
  * Retrieve cached lint results for a given file name, if present in the cache.
@@ -1,4 +1,4 @@
1
- import type { CacheStrategy, CacheFormat } from '@cspell/cspell-types';
1
+ import type { CacheFormat, CacheStrategy } from '@cspell/cspell-types';
2
2
  export interface CacheOptions {
3
3
  /**
4
4
  * The version of `cspell` that made the cache entry.
@@ -1,6 +1,6 @@
1
1
  import type { FileResult } from '../../util/fileHelper';
2
2
  import type { CSpellLintResultCache } from './CSpellLintResultCache';
3
- import { FileDescriptor } from './fileEntryCache';
3
+ import type { FileDescriptor } from './fileEntryCache';
4
4
  export type CachedFileResult = Omit<FileResult, 'fileInfo' | 'elapsedTimeMs' | 'cached'>;
5
5
  /**
6
6
  * This is the data cached.
@@ -1,6 +1,6 @@
1
- import { CacheSettings, CSpellSettings } from '@cspell/cspell-types';
2
- import { CacheOptions } from '.';
3
- import { CSpellLintResultCache } from './CSpellLintResultCache';
1
+ import type { CacheSettings, CSpellSettings } from '@cspell/cspell-types';
2
+ import type { CacheOptions } from './CacheOptions';
3
+ import type { CSpellLintResultCache } from './CSpellLintResultCache';
4
4
  export declare const DEFAULT_CACHE_LOCATION = ".cspellcache";
5
5
  export interface CreateCacheSettings extends Required<CacheSettings> {
6
6
  /**
@@ -28,8 +28,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.normalizePath = exports.createFromFile = void 0;
30
30
  const file_entry_cache = __importStar(require("file-entry-cache"));
31
- const path = __importStar(require("path"));
32
31
  const fs = __importStar(require("fs-extra"));
32
+ const path = __importStar(require("path"));
33
33
  function createFromFile(pathToCache, useCheckSum, useRelative) {
34
34
  const absPathToCache = path.resolve(pathToCache);
35
35
  const relDir = path.dirname(absPathToCache);
@@ -1,4 +1,4 @@
1
- export { createCache, calcCacheSettings, DEFAULT_CACHE_LOCATION, type CreateCacheSettings } from './createCache';
2
- export type { CSpellLintResultCache } from './CSpellLintResultCache';
3
1
  export type { CacheOptions } from './CacheOptions';
2
+ export { type CreateCacheSettings, calcCacheSettings, createCache, DEFAULT_CACHE_LOCATION } from './createCache';
3
+ export type { CSpellLintResultCache } from './CSpellLintResultCache';
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DEFAULT_CACHE_LOCATION = exports.calcCacheSettings = exports.createCache = void 0;
3
+ exports.DEFAULT_CACHE_LOCATION = exports.createCache = exports.calcCacheSettings = void 0;
4
4
  var createCache_1 = require("./createCache");
5
- Object.defineProperty(exports, "createCache", { enumerable: true, get: function () { return createCache_1.createCache; } });
6
5
  Object.defineProperty(exports, "calcCacheSettings", { enumerable: true, get: function () { return createCache_1.calcCacheSettings; } });
6
+ Object.defineProperty(exports, "createCache", { enumerable: true, get: function () { return createCache_1.createCache; } });
7
7
  Object.defineProperty(exports, "DEFAULT_CACHE_LOCATION", { enumerable: true, get: function () { return createCache_1.DEFAULT_CACHE_LOCATION; } });
8
8
  //# sourceMappingURL=index.js.map
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" />
2
- import { CSpellUserSettings, Document, Issue } from 'cspell-lib';
3
- import { GlobOptions } from './glob';
2
+ import type { CSpellUserSettings, Document, Issue } from 'cspell-lib';
3
+ import type { GlobOptions } from './glob';
4
4
  export interface ConfigInfo {
5
5
  source: string;
6
6
  config: CSpellUserSettings;
@@ -1,5 +1,6 @@
1
1
  import type { CSpellUserSettings, Glob } from '@cspell/cspell-types';
2
- import { GlobMatcher, GlobPatternWithRoot } from 'cspell-glob';
2
+ import type { GlobPatternWithRoot } from 'cspell-glob';
3
+ import { GlobMatcher } from 'cspell-glob';
3
4
  /**
4
5
  * This is a subset of IOptions from 'glob'.
5
6
  */
@@ -8,7 +9,7 @@ export interface GlobOptions {
8
9
  root?: string | undefined;
9
10
  dot?: boolean | undefined;
10
11
  nodir?: boolean | undefined;
11
- ignore?: string | ReadonlyArray<string> | undefined;
12
+ ignore?: string | Array<string> | undefined;
12
13
  }
13
14
  /**
14
15
  *
@@ -39,5 +40,6 @@ export declare function extractGlobExcludesFromConfig(root: string, source: stri
39
40
  export declare function buildGlobMatcher(globs: Glob[], root: string, isExclude: boolean): GlobMatcher;
40
41
  export declare function extractGlobsFromMatcher(globMatcher: GlobMatcher): string[];
41
42
  export declare function normalizeGlobsToRoot(globs: Glob[], root: string, isExclude: boolean): string[];
43
+ export declare function normalizeFileOrGlobsToRoot(globs: Glob[], root: string): Promise<string[]>;
42
44
  export {};
43
45
  //# sourceMappingURL=glob.d.ts.map
package/dist/util/glob.js CHANGED
@@ -26,62 +26,33 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.normalizeGlobsToRoot = exports.extractGlobsFromMatcher = exports.buildGlobMatcher = exports.extractGlobExcludesFromConfig = exports.calcExcludeGlobInfo = exports.extractPatterns = exports.calcGlobs = exports.globP = void 0;
29
+ exports.normalizeFileOrGlobsToRoot = exports.normalizeGlobsToRoot = exports.extractGlobsFromMatcher = exports.buildGlobMatcher = exports.extractGlobExcludesFromConfig = exports.calcExcludeGlobInfo = exports.extractPatterns = exports.calcGlobs = exports.globP = void 0;
30
30
  const cspell_glob_1 = require("cspell-glob");
31
- const glob_1 = __importDefault(require("glob"));
31
+ const fast_glob_1 = __importDefault(require("fast-glob"));
32
+ const fs_1 = require("fs");
32
33
  const path = __importStar(require("path"));
34
+ const path_1 = require("path");
33
35
  const defaultExcludeGlobs = ['node_modules/**'];
34
- // Note this is to allow experimenting with using a single glob
35
- const useJoinPatterns = process.env['CSPELL_SINGLE_GLOB'];
36
36
  /**
37
37
  *
38
38
  * @param pattern - glob patterns and NOT file paths. It can be a file path turned into a glob.
39
39
  * @param options - search options.
40
40
  */
41
41
  async function globP(pattern, options) {
42
- const root = options?.root || process.cwd();
43
- const opts = options || { root };
44
- const rawPatterns = typeof pattern === 'string' ? [pattern] : pattern;
45
- const normPatterns = useJoinPatterns ? joinPatterns(rawPatterns) : rawPatterns;
46
- const globPState = {
47
- options: { ...opts, root },
48
- };
49
- const globResults = normPatterns.map(async (pat) => {
50
- globPState.options = { ...opts, root: root, cwd: root };
51
- const absolutePaths = (await _globP(pat, globPState)).map((filename) => path.resolve(root, filename));
52
- const relativeToRoot = absolutePaths.map((absFilename) => path.relative(root, absFilename));
53
- return relativeToRoot;
54
- });
55
- const results = new Set(flatten(await Promise.all(globResults)));
56
- return [...results];
42
+ const cwd = options?.root || options?.cwd || process.cwd();
43
+ const ignore = typeof options?.ignore === 'string' ? [options.ignore] : options?.ignore;
44
+ const onlyFiles = options?.nodir;
45
+ const dot = options?.dot;
46
+ const patterns = typeof pattern === 'string' ? [pattern] : pattern;
47
+ const useOptions = { cwd, onlyFiles, dot, ignore, absolute: true, followSymbolicLinks: false };
48
+ const compare = new Intl.Collator('en').compare;
49
+ const absolutePaths = (await (0, fast_glob_1.default)(patterns, useOptions)).sort(compare);
50
+ const relativePaths = absolutePaths.map((absFilename) => path.relative(cwd, absFilename));
51
+ return relativePaths;
57
52
  }
58
53
  exports.globP = globP;
59
- function joinPatterns(globs) {
60
- return globs.length <= 1 ? globs : [`{${globs.join(',')}}`];
61
- }
62
- function _globP(pattern, state) {
63
- if (!pattern) {
64
- return Promise.resolve([]);
65
- }
66
- return new Promise((resolve, reject) => {
67
- const cb = (err, matches) => {
68
- if (err) {
69
- reject(err);
70
- }
71
- resolve(matches);
72
- };
73
- const options = { ...(state.glob || {}), ...state.options };
74
- state.glob = (0, glob_1.default)(pattern, options, cb);
75
- });
76
- }
77
54
  function calcGlobs(commandLineExclude) {
78
- const globs = (commandLineExclude || [])
79
- .map((glob) => glob.split(/(?<!\\)\s+/g))
80
- .map((globs) => globs.map((g) => g.replace(/\\ /g, ' ')))
81
- .reduce((s, globs) => {
82
- globs.forEach((g) => s.add(g));
83
- return s;
84
- }, new Set());
55
+ const globs = new Set((commandLineExclude || []).flatMap((glob) => glob.split(/(?<!\\)\s+/g)).map((g) => g.replace(/\\ /g, ' ')));
85
56
  const commandLineExcludes = {
86
57
  globs: [...globs],
87
58
  source: 'arguments',
@@ -143,14 +114,48 @@ function normalizeGlobsToRoot(globs, root, isExclude) {
143
114
  return extractGlobsFromMatcher(buildGlobMatcher(globs, root, isExclude));
144
115
  }
145
116
  exports.normalizeGlobsToRoot = normalizeGlobsToRoot;
146
- function* flatten(src) {
147
- for (const item of src) {
148
- if (Array.isArray(item)) {
149
- yield* item;
117
+ const isPossibleGlobRegExp = /[*{}()?[]/;
118
+ /**
119
+ * If a 'glob' is a path to a directory, then append `**` so that
120
+ * directory searches work.
121
+ * @param glob - a glob, file, or directory
122
+ * @param root - root to use.
123
+ * @returns `**` is appended directories.
124
+ */
125
+ async function adjustPossibleDirectory(glob, root) {
126
+ const g = typeof glob === 'string'
127
+ ? {
128
+ glob,
129
+ root,
150
130
  }
151
- else {
152
- yield item;
131
+ : {
132
+ glob: glob.glob,
133
+ root: glob.root ?? root,
134
+ };
135
+ // Do not ask the file system to look up obvious glob patterns.
136
+ if (isPossibleGlobRegExp.test(g.glob)) {
137
+ return glob;
138
+ }
139
+ const dirPath = path.resolve(g.root, g.glob);
140
+ try {
141
+ const stat = await fs_1.promises.stat(dirPath);
142
+ if (stat.isDirectory()) {
143
+ const useGlob = path_1.posix.join(posixPath(g.glob), '**');
144
+ return typeof glob === 'string' ? useGlob : { ...glob, glob: useGlob };
153
145
  }
154
146
  }
147
+ catch (e) {
148
+ // it was not possible to access the dirPath, no problem, just let the file glob search look for it.
149
+ return glob;
150
+ }
151
+ return glob;
152
+ }
153
+ function posixPath(p) {
154
+ return path.sep === '\\' ? p.replace(/\\/g, '/') : p;
155
+ }
156
+ async function normalizeFileOrGlobsToRoot(globs, root) {
157
+ const adjustedGlobs = await Promise.all(globs.map((g) => adjustPossibleDirectory(g, root)));
158
+ return normalizeGlobsToRoot(adjustedGlobs, root, false);
155
159
  }
160
+ exports.normalizeFileOrGlobsToRoot = normalizeFileOrGlobsToRoot;
156
161
  //# sourceMappingURL=glob.js.map
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.decorateRowWith = exports.tableToLines = void 0;
7
- const strip_ansi_1 = __importDefault(require("strip-ansi"));
8
7
  const chalk_1 = __importDefault(require("chalk"));
8
+ const strip_ansi_1 = __importDefault(require("strip-ansi"));
9
9
  function tableToLines(table, deliminator) {
10
10
  deliminator = deliminator || table.deliminator || ' | ';
11
11
  const columnWidths = [];
@@ -3,7 +3,13 @@ type FilterFn<T> = (_v: T) => boolean;
3
3
  export declare function uniqueFilterFnGenerator<T>(): FilterFn<T>;
4
4
  export declare function uniqueFilterFnGenerator<T, U>(extractFn: (v: T) => U): FilterFn<T>;
5
5
  export declare function unique<T>(src: T[]): T[];
6
- export declare function clean<T extends object>(src: T): T;
6
+ /**
7
+ * Make all properties in T required
8
+ */
9
+ type RemoveUndefined<T extends object> = {
10
+ [P in keyof T]: T[P] extends undefined ? never : T[P];
11
+ };
12
+ export declare function clean<T extends object>(src: T): RemoveUndefined<T>;
7
13
  export declare function padWidth(s: string, target: number): number;
8
14
  export declare function pad(s: string, w: number): string;
9
15
  export declare function padLeft(s: string, w: number): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cspell",
3
- "version": "6.18.1",
3
+ "version": "6.19.0",
4
4
  "description": "A Spelling Checker for Code!",
5
5
  "funding": "https://github.com/streetsidesoftware/cspell?sponsor=1",
6
6
  "main": "dist/index.js",
@@ -35,17 +35,21 @@
35
35
  "!**/*.map"
36
36
  ],
37
37
  "scripts": {
38
- "clean": "rimraf dist coverage .tsbuildinfo",
38
+ "clean": "shx rm -rf dist coverage .tsbuildinfo",
39
39
  "build": "pnpm run compile && pnpm run build-api",
40
40
  "build-api": "rollup -c rollup.config.mjs",
41
41
  "build-dev": "tsc -p tsconfig.dev.json",
42
+ "build:readme": "pnpm build:readme:help",
43
+ "build:readme:help": "pnpm build:readme:help:lint && pnpm build:readme:help:trace && inject-markdown README.md && prettier -w README.md",
44
+ "build:readme:help:lint": "./bin.js lint --help > static/help-lint.txt",
45
+ "build:readme:help:trace": "./bin.js trace --help > static/help-trace.txt",
42
46
  "clean-build": "pnpm run clean && pnpm run build",
43
47
  "compile": "tsc -p .",
44
48
  "watch": "tsc --watch -p .",
45
49
  "coverage": "jest --coverage",
46
50
  "test-watch": "jest --watch",
47
51
  "prepublishOnly": "pnpm run clean-build",
48
- "test": "jest",
52
+ "test": "jest --maxWorkers=1",
49
53
  "test:update-snapshot": "jest --updateSnapshot"
50
54
  },
51
55
  "repository": {
@@ -70,17 +74,17 @@
70
74
  },
71
75
  "homepage": "https://streetsidesoftware.github.io/cspell/",
72
76
  "dependencies": {
73
- "@cspell/cspell-pipe": "6.18.1",
77
+ "@cspell/cspell-pipe": "6.19.0",
74
78
  "chalk": "^4.1.2",
75
- "commander": "^9.4.1",
76
- "cspell-gitignore": "6.18.1",
77
- "cspell-glob": "6.18.1",
78
- "cspell-lib": "6.18.1",
79
+ "commander": "^9.5.0",
80
+ "cspell-gitignore": "6.19.0",
81
+ "cspell-glob": "6.19.0",
82
+ "cspell-lib": "6.19.0",
83
+ "fast-glob": "^3.2.12",
79
84
  "fast-json-stable-stringify": "^2.1.0",
80
85
  "file-entry-cache": "^6.0.1",
81
86
  "fs-extra": "^11.1.0",
82
87
  "get-stdin": "^8.0.0",
83
- "glob": "^8.0.3",
84
88
  "imurmurhash": "^0.1.4",
85
89
  "semver": "^7.3.8",
86
90
  "strip-ansi": "^6.0.1",
@@ -90,8 +94,8 @@
90
94
  "node": ">=14"
91
95
  },
92
96
  "devDependencies": {
93
- "@cspell/cspell-json-reporter": "6.18.1",
94
- "@cspell/cspell-types": "6.18.1",
97
+ "@cspell/cspell-json-reporter": "6.19.0",
98
+ "@cspell/cspell-types": "6.19.0",
95
99
  "@types/file-entry-cache": "^5.0.2",
96
100
  "@types/fs-extra": "^9.0.13",
97
101
  "@types/glob": "^8.0.0",
@@ -102,9 +106,8 @@
102
106
  "jest": "^29.3.1",
103
107
  "micromatch": "^4.0.5",
104
108
  "minimatch": "^5.1.2",
105
- "rimraf": "^3.0.2",
106
- "rollup": "^3.9.0",
107
- "rollup-plugin-dts": "^5.1.0"
109
+ "rollup": "^3.10.0",
110
+ "rollup-plugin-dts": "^5.1.1"
108
111
  },
109
- "gitHead": "2570a9bb03e68864d30ed8024786b3b2eeddab2b"
112
+ "gitHead": "f643f0cd6384905618dbca950bd65a39a77dc028"
110
113
  }