cspell 7.0.0-alpha.1 → 7.0.1-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/dist/esm/application.d.mts +1 -1
  2. package/dist/esm/cli-reporter.mjs +2 -1
  3. package/dist/esm/util/constants.d.mts +1 -1
  4. package/dist/esm/util/fileHelper.d.mts +1 -1
  5. package/dist/lib/file-entry-cache.cjs +3 -2
  6. package/dist/lib/file-entry-cache.d.cts +2 -2
  7. package/dist/lib/pkgInfo.cjs +3 -25
  8. package/package.json +31 -36
  9. package/bin.js +0 -16
  10. package/dist/cjs/app.d.ts +0 -5
  11. package/dist/cjs/app.js +0 -50
  12. package/dist/cjs/application.d.ts +0 -16
  13. package/dist/cjs/application.js +0 -121
  14. package/dist/cjs/cli-reporter.d.ts +0 -16
  15. package/dist/cjs/cli-reporter.js +0 -247
  16. package/dist/cjs/commandCheck.d.ts +0 -3
  17. package/dist/cjs/commandCheck.js +0 -78
  18. package/dist/cjs/commandLink.d.ts +0 -3
  19. package/dist/cjs/commandLink.js +0 -51
  20. package/dist/cjs/commandLint.d.ts +0 -3
  21. package/dist/cjs/commandLint.js +0 -150
  22. package/dist/cjs/commandSuggestion.d.ts +0 -3
  23. package/dist/cjs/commandSuggestion.js +0 -88
  24. package/dist/cjs/commandTrace.d.ts +0 -3
  25. package/dist/cjs/commandTrace.js +0 -87
  26. package/dist/cjs/emitters/DictionaryPathFormat.d.ts +0 -3
  27. package/dist/cjs/emitters/DictionaryPathFormat.js +0 -16
  28. package/dist/cjs/emitters/suggestionsEmitter.d.ts +0 -13
  29. package/dist/cjs/emitters/suggestionsEmitter.js +0 -84
  30. package/dist/cjs/emitters/traceEmitter.d.ts +0 -21
  31. package/dist/cjs/emitters/traceEmitter.js +0 -171
  32. package/dist/cjs/featureFlags/featureFlags.d.ts +0 -4
  33. package/dist/cjs/featureFlags/featureFlags.js +0 -25
  34. package/dist/cjs/featureFlags/index.d.ts +0 -2
  35. package/dist/cjs/featureFlags/index.js +0 -7
  36. package/dist/cjs/index.d.ts +0 -5
  37. package/dist/cjs/index.js +0 -22
  38. package/dist/cjs/link.d.ts +0 -8
  39. package/dist/cjs/link.js +0 -47
  40. package/dist/cjs/lint/LintRequest.d.ts +0 -23
  41. package/dist/cjs/lint/LintRequest.js +0 -48
  42. package/dist/cjs/lint/index.d.ts +0 -3
  43. package/dist/cjs/lint/index.js +0 -8
  44. package/dist/cjs/lint/lint.d.ts +0 -4
  45. package/dist/cjs/lint/lint.js +0 -499
  46. package/dist/cjs/options.d.ts +0 -178
  47. package/dist/cjs/options.js +0 -12
  48. package/dist/cjs/repl/index.d.ts +0 -18
  49. package/dist/cjs/repl/index.js +0 -75
  50. package/dist/cjs/util/InMemoryReporter.d.ts +0 -28
  51. package/dist/cjs/util/InMemoryReporter.js +0 -47
  52. package/dist/cjs/util/async.d.ts +0 -3
  53. package/dist/cjs/util/async.js +0 -12
  54. package/dist/cjs/util/cache/CSpellLintResultCache.d.ts +0 -20
  55. package/dist/cjs/util/cache/CSpellLintResultCache.js +0 -3
  56. package/dist/cjs/util/cache/CacheOptions.d.ts +0 -34
  57. package/dist/cjs/util/cache/CacheOptions.js +0 -3
  58. package/dist/cjs/util/cache/DiskCache.d.ts +0 -63
  59. package/dist/cjs/util/cache/DiskCache.js +0 -237
  60. package/dist/cjs/util/cache/DummyCache.d.ts +0 -11
  61. package/dist/cjs/util/cache/DummyCache.js +0 -22
  62. package/dist/cjs/util/cache/ObjectCollection.d.ts +0 -17
  63. package/dist/cjs/util/cache/ObjectCollection.js +0 -136
  64. package/dist/cjs/util/cache/createCache.d.ts +0 -31
  65. package/dist/cjs/util/cache/createCache.js +0 -77
  66. package/dist/cjs/util/cache/fileEntryCache.d.ts +0 -9
  67. package/dist/cjs/util/cache/fileEntryCache.js +0 -107
  68. package/dist/cjs/util/cache/index.d.ts +0 -4
  69. package/dist/cjs/util/cache/index.js +0 -8
  70. package/dist/cjs/util/constants.d.ts +0 -6
  71. package/dist/cjs/util/constants.js +0 -8
  72. package/dist/cjs/util/errors.d.ts +0 -23
  73. package/dist/cjs/util/errors.js +0 -60
  74. package/dist/cjs/util/fileHelper.d.ts +0 -63
  75. package/dist/cjs/util/fileHelper.js +0 -226
  76. package/dist/cjs/util/glob.d.ts +0 -45
  77. package/dist/cjs/util/glob.js +0 -175
  78. package/dist/cjs/util/prefetch.d.ts +0 -2
  79. package/dist/cjs/util/prefetch.js +0 -23
  80. package/dist/cjs/util/reporters.d.ts +0 -14
  81. package/dist/cjs/util/reporters.js +0 -68
  82. package/dist/cjs/util/stdin.d.ts +0 -2
  83. package/dist/cjs/util/stdin.js +0 -32
  84. package/dist/cjs/util/table.d.ts +0 -10
  85. package/dist/cjs/util/table.js +0 -40
  86. package/dist/cjs/util/timer.d.ts +0 -8
  87. package/dist/cjs/util/timer.js +0 -17
  88. package/dist/cjs/util/types.d.ts +0 -7
  89. package/dist/cjs/util/types.js +0 -6
  90. package/dist/cjs/util/util.d.ts +0 -13
  91. package/dist/cjs/util/util.js +0 -55
@@ -1,247 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.__testing__ = exports.getReporter = void 0;
30
- const chalk_1 = __importDefault(require("chalk"));
31
- const cspell_lib_1 = require("cspell-lib");
32
- const path = __importStar(require("path"));
33
- const uri_cjs_1 = require("../lib/uri.cjs");
34
- const templateIssue = `{green $filename}:{yellow $row:$col} - $message ({red $text}) $quickFix`;
35
- const templateIssueNoFix = `{green $filename}:{yellow $row:$col} - $message ({red $text})`;
36
- const templateIssueWithSuggestions = `{green $filename}:{yellow $row:$col} - $message ({red $text}) Suggestions: {yellow [$suggestions]}`;
37
- const templateIssueWithContext = `{green $filename}:{yellow $row:$col} $padRowCol- $message ({red $text})$padContext -- {gray $contextLeft}{red {underline $text}}{gray $contextRight}`;
38
- const templateIssueWithContextWithSuggestions = `{green $filename}:{yellow $row:$col} $padRowCol- $message ({red $text})$padContext -- {gray $contextLeft}{red {underline $text}}{gray $contextRight}\n\t Suggestions: {yellow [$suggestions]}`;
39
- const templateIssueLegacy = `${chalk_1.default.green('$filename')}[$row, $col]: $message: ${chalk_1.default.red('$text')}`;
40
- const templateIssueWordsOnly = '$text';
41
- function genIssueEmitter(template) {
42
- const defaultWidth = 10;
43
- let maxWidth = defaultWidth;
44
- let uri;
45
- return function issueEmitter(issue) {
46
- if (uri !== issue.uri) {
47
- maxWidth = defaultWidth;
48
- uri = issue.uri;
49
- }
50
- maxWidth = Math.max(maxWidth * 0.999, issue.text.length, 10);
51
- console.log(formatIssue(template, issue, Math.ceil(maxWidth)));
52
- };
53
- }
54
- function errorEmitter(message, error) {
55
- if ((0, cspell_lib_1.isSpellingDictionaryLoadError)(error)) {
56
- error = error.cause;
57
- }
58
- console.error(chalk_1.default.red(message), error.toString());
59
- }
60
- function nullEmitter() {
61
- /* empty */
62
- }
63
- function relativeFilename(filename, cwd = process.cwd()) {
64
- const rel = path.relative(cwd, filename);
65
- if (rel.startsWith('..'))
66
- return filename;
67
- return '.' + path.sep + rel;
68
- }
69
- function relativeUriFilename(uri, fsPathRoot) {
70
- const fsPath = uri_cjs_1.URI.parse(uri).fsPath;
71
- const rel = path.relative(fsPathRoot, fsPath);
72
- if (rel.startsWith('..'))
73
- return fsPath;
74
- return '.' + path.sep + rel;
75
- }
76
- function reportProgress(p) {
77
- if (p.type === 'ProgressFileComplete') {
78
- return reportProgressFileComplete(p);
79
- }
80
- if (p.type === 'ProgressFileBegin') {
81
- return reportProgressFileBegin(p);
82
- }
83
- }
84
- function reportProgressFileBegin(p) {
85
- const fc = '' + p.fileCount;
86
- const fn = (' '.repeat(fc.length) + p.fileNum).slice(-fc.length);
87
- const idx = fn + '/' + fc;
88
- const filename = chalk_1.default.gray(relativeFilename(p.filename));
89
- process.stderr.write(`\r${idx} ${filename}`);
90
- }
91
- function reportProgressFileComplete(p) {
92
- const time = reportTime(p.elapsedTimeMs, !!p.cached);
93
- const skipped = p.processed === false ? ' skipped' : '';
94
- const hasErrors = p.numErrors ? chalk_1.default.red ` X` : '';
95
- console.error(` ${time}${skipped}${hasErrors}`);
96
- }
97
- function reportTime(elapsedTimeMs, cached) {
98
- if (cached)
99
- return chalk_1.default.green('cached');
100
- if (elapsedTimeMs === undefined)
101
- return '-';
102
- const color = elapsedTimeMs < 1000 ? chalk_1.default.white : elapsedTimeMs < 2000 ? chalk_1.default.yellow : chalk_1.default.redBright;
103
- return color(elapsedTimeMs.toFixed(2) + 'ms');
104
- }
105
- function getReporter(options) {
106
- const issueTemplate = options.wordsOnly
107
- ? templateIssueWordsOnly
108
- : options.legacy
109
- ? templateIssueLegacy
110
- : options.showContext
111
- ? options.showSuggestions
112
- ? templateIssueWithContextWithSuggestions
113
- : templateIssueWithContext
114
- : options.showSuggestions
115
- ? templateIssueWithSuggestions
116
- : options.showSuggestions === false
117
- ? templateIssueNoFix
118
- : templateIssue;
119
- const { fileGlobs, silent, summary, issues, progress, verbose, debug } = options;
120
- const emitters = {
121
- Debug: !silent && debug ? (s) => console.info(chalk_1.default.cyan(s)) : nullEmitter,
122
- Info: !silent && verbose ? (s) => console.info(chalk_1.default.yellow(s)) : nullEmitter,
123
- Warning: (s) => console.info(chalk_1.default.yellow(s)),
124
- };
125
- function infoEmitter(message, msgType) {
126
- emitters[msgType]?.(message);
127
- }
128
- const root = uri_cjs_1.URI.file(options.root || process.cwd());
129
- const fsPathRoot = root.fsPath;
130
- function relativeIssue(fn) {
131
- const fnFilename = options.relative
132
- ? (uri) => relativeUriFilename(uri, fsPathRoot)
133
- : (uri) => uri_cjs_1.URI.parse(uri).fsPath;
134
- return (i) => {
135
- const filename = i.uri ? fnFilename(i.uri) : '';
136
- const r = { ...i, filename };
137
- fn(r);
138
- };
139
- }
140
- const resultEmitter = (result) => {
141
- if (!fileGlobs.length && !result.files) {
142
- return;
143
- }
144
- if (result.cachedFiles) {
145
- console.error('CSpell\x3a Files checked: %d (%d from cache), Issues found: %d in %d files', result.files, result.cachedFiles, result.issues, result.filesWithIssues.size);
146
- return;
147
- }
148
- console.error('CSpell\x3a Files checked: %d, Issues found: %d in %d files', result.files, result.issues, result.filesWithIssues.size);
149
- };
150
- return {
151
- issue: relativeIssue(silent || !issues ? nullEmitter : genIssueEmitter(issueTemplate)),
152
- error: silent ? nullEmitter : errorEmitter,
153
- info: infoEmitter,
154
- debug: emitters.Debug,
155
- progress: !silent && progress ? reportProgress : nullEmitter,
156
- result: !silent && summary ? resultEmitter : nullEmitter,
157
- };
158
- }
159
- exports.getReporter = getReporter;
160
- function formatIssue(templateStr, issue, maxIssueTextWidth) {
161
- function clean(t) {
162
- return t.replace(/\s+/, ' ');
163
- }
164
- const { uri = '', filename, row, col, text, context, offset } = issue;
165
- const contextLeft = clean(context.text.slice(0, offset - context.offset));
166
- const contextRight = clean(context.text.slice(offset + text.length - context.offset));
167
- const contextFull = clean(context.text);
168
- const padContext = ' '.repeat(Math.max(maxIssueTextWidth - text.length, 0));
169
- const rowText = row.toString();
170
- const colText = col.toString();
171
- const padRowCol = ' '.repeat(Math.max(1, 8 - (rowText.length + colText.length)));
172
- const suggestions = formatSuggestions(issue);
173
- const msg = issue.message || (issue.isFlagged ? 'Forbidden word' : 'Unknown word');
174
- const message = issue.isFlagged ? `{yellow ${msg}}` : msg;
175
- const substitutions = {
176
- $col: colText,
177
- $contextFull: contextFull,
178
- $contextLeft: contextLeft,
179
- $contextRight: contextRight,
180
- $filename: filename,
181
- $padContext: padContext,
182
- $padRowCol: padRowCol,
183
- $row: rowText,
184
- $suggestions: suggestions,
185
- $text: text,
186
- $uri: uri,
187
- $quickFix: formatQuickFix(issue),
188
- };
189
- const t = template(templateStr.replace(/\$message/g, message));
190
- return substitute((0, chalk_1.default)(t), substitutions).trimEnd();
191
- }
192
- function formatSuggestions(issue) {
193
- if (issue.suggestionsEx) {
194
- return issue.suggestionsEx
195
- .map((sug) => sug.isPreferred
196
- ? chalk_1.default.italic(chalk_1.default.bold(sug.wordAdjustedToMatchCase || sug.word)) + '*'
197
- : sug.wordAdjustedToMatchCase || sug.word)
198
- .join(', ');
199
- }
200
- if (issue.suggestions) {
201
- return issue.suggestions.join(', ');
202
- }
203
- return '';
204
- }
205
- function formatQuickFix(issue) {
206
- if (!issue.suggestionsEx?.length)
207
- return '';
208
- const preferred = issue.suggestionsEx
209
- .filter((sug) => sug.isPreferred)
210
- .map((sug) => sug.wordAdjustedToMatchCase || sug.word);
211
- if (!preferred.length)
212
- return '';
213
- const fixes = preferred.map((w) => chalk_1.default.italic(chalk_1.default.yellow(w)));
214
- return `fix: (${fixes.join(', ')})`;
215
- }
216
- class TS extends Array {
217
- constructor(s) {
218
- super(s);
219
- this.raw = [s];
220
- }
221
- }
222
- function template(s) {
223
- return new TS(s);
224
- }
225
- function substitute(text, substitutions) {
226
- const subs = [];
227
- for (const [match, replaceWith] of Object.entries(substitutions)) {
228
- const len = match.length;
229
- for (let i = text.indexOf(match); i >= 0; i = text.indexOf(match, i + 1)) {
230
- subs.push([i, i + len, replaceWith]);
231
- }
232
- }
233
- subs.sort((a, b) => a[0] - b[0]);
234
- let i = 0;
235
- function sub(r) {
236
- const [a, b, t] = r;
237
- const prefix = text.slice(i, a);
238
- i = b;
239
- return prefix + t;
240
- }
241
- const parts = subs.map(sub);
242
- return parts.join('') + text.slice(i);
243
- }
244
- exports.__testing__ = {
245
- formatIssue,
246
- };
247
- //# sourceMappingURL=cli-reporter.js.map
@@ -1,3 +0,0 @@
1
- import type { Command } from 'commander';
2
- export declare function commandCheck(prog: Command): Command;
3
- //# sourceMappingURL=commandCheck.d.ts.map
@@ -1,78 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.commandCheck = void 0;
30
- const chalk_1 = __importDefault(require("chalk"));
31
- const commander_1 = require("commander");
32
- const App = __importStar(require("./application.js"));
33
- const application_js_1 = require("./application.js");
34
- const errors_js_1 = require("./util/errors.js");
35
- function commandCheck(prog) {
36
- return prog
37
- .command('check <files...>')
38
- .description('Spell check file(s) and display the result. The full file is displayed in color.')
39
- .option('-c, --config <cspell.json>', 'Configuration file to use. By default cspell looks for cspell.json in the current directory.')
40
- .option('--validate-directives', 'Validate in-document CSpell directives.')
41
- .option('--no-validate-directives', 'Do not validate in-document CSpell directives.')
42
- .option('--no-color', 'Turn off color.')
43
- .option('--color', 'Force color')
44
- .addOption(new commander_1.Option('--default-configuration', 'Load the default configuration and dictionaries.').hideHelp())
45
- .addOption(new commander_1.Option('--no-default-configuration', 'Do not load the default configuration and dictionaries.'))
46
- .action(async (files, options) => {
47
- App.parseApplicationFeatureFlags(options.flag);
48
- let issueCount = 0;
49
- for (const filename of files) {
50
- console.log(chalk_1.default.yellowBright(`Check file: ${filename}`));
51
- console.log();
52
- try {
53
- const result = await (0, application_js_1.checkText)(filename, options);
54
- for (const item of result.items) {
55
- const fn = item.flagIE === App.IncludeExcludeFlag.EXCLUDE
56
- ? chalk_1.default.gray
57
- : item.isError
58
- ? chalk_1.default.red
59
- : chalk_1.default.whiteBright;
60
- const t = fn(item.text);
61
- process.stdout.write(t);
62
- issueCount += item.isError ? 1 : 0;
63
- }
64
- console.log();
65
- }
66
- catch (e) {
67
- console.error(`File not found "${filename}"`);
68
- throw new errors_js_1.CheckFailed('File not found', 1);
69
- }
70
- console.log();
71
- }
72
- if (issueCount) {
73
- throw new errors_js_1.CheckFailed('Issues found', 1);
74
- }
75
- });
76
- }
77
- exports.commandCheck = commandCheck;
78
- //# sourceMappingURL=commandCheck.js.map
@@ -1,3 +0,0 @@
1
- import type { Command } from 'commander';
2
- export declare function commandLink(prog: Command): Command;
3
- //# sourceMappingURL=commandLink.d.ts.map
@@ -1,51 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.commandLink = void 0;
4
- const link_js_1 = require("./link.js");
5
- const errors_js_1 = require("./util/errors.js");
6
- const table_js_1 = require("./util/table.js");
7
- function commandLink(prog) {
8
- const linkCommand = prog
9
- .command('link')
10
- .description('Link dictionaries and other settings to the cspell global config.');
11
- linkCommand
12
- .command('list', { isDefault: true })
13
- .alias('ls')
14
- .description('List currently linked configurations.')
15
- .action(() => {
16
- const imports = (0, link_js_1.listGlobalImports)();
17
- const table = (0, link_js_1.listGlobalImportsResultToTable)(imports.list);
18
- (0, table_js_1.tableToLines)(table).forEach((line) => console.log(line));
19
- return;
20
- });
21
- linkCommand
22
- .command('add <dictionaries...>')
23
- .alias('a')
24
- .description('Add dictionaries any other settings to the cspell global config.')
25
- .action((dictionaries) => {
26
- const r = (0, link_js_1.addPathsToGlobalImports)(dictionaries);
27
- const table = (0, link_js_1.addPathsToGlobalImportsResultToTable)(r);
28
- console.log('Adding:');
29
- (0, table_js_1.tableToLines)(table).forEach((line) => console.log(line));
30
- if (r.error) {
31
- throw new errors_js_1.CheckFailed(r.error, 1);
32
- }
33
- return;
34
- });
35
- linkCommand
36
- .command('remove <paths...>')
37
- .alias('r')
38
- .description('Remove matching paths / packages from the global config.')
39
- .action((dictionaries) => {
40
- const r = (0, link_js_1.removePathsFromGlobalImports)(dictionaries);
41
- console.log('Removing:');
42
- if (r.error) {
43
- throw new errors_js_1.CheckFailed(r.error, 1);
44
- }
45
- r.removed.map((f) => console.log(f));
46
- return;
47
- });
48
- return linkCommand;
49
- }
50
- exports.commandLink = commandLink;
51
- //# sourceMappingURL=commandLink.js.map
@@ -1,3 +0,0 @@
1
- import type { Command } from 'commander';
2
- export declare function commandLint(prog: Command): Command;
3
- //# sourceMappingURL=commandLint.d.ts.map
@@ -1,150 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.commandLint = void 0;
27
- const commander_1 = require("commander");
28
- const App = __importStar(require("./application.js"));
29
- const index_js_1 = require("./util/cache/index.js");
30
- const errors_js_1 = require("./util/errors.js");
31
- // interface InitOptions extends Options {}
32
- const usage = `\
33
- [options] [globs...] [file://<path> ...] [stdin[://<path>]]
34
-
35
- Patterns:
36
- - [globs...] Glob Patterns
37
- - [stdin] Read from "stdin" assume text file.
38
- - [stdin://<path>] Read from "stdin", use <path> for file type and config.
39
- - [file://<path>] Check the file at <path>
40
-
41
- Examples:
42
- cspell . Recursively check all files.
43
- cspell lint . The same as "cspell ."
44
- cspell "*.js" Check all .js files in the current directory
45
- cspell "**/*.js" Check all .js files recursively
46
- cspell "src/**/*.js" Only check .js under src
47
- cspell "**/*.txt" "**/*.js" Check both .js and .txt files.
48
- cspell "**/*.{txt,js,md}" Check .txt, .js, and .md files.
49
- cat LICENSE | cspell stdin Check stdin
50
- cspell stdin://docs/doc.md Check stdin as if it was "./docs/doc.md"\
51
- `;
52
- const advanced = `
53
- More Examples:
54
-
55
- cspell "**/*.js" --reporter @cspell/cspell-json-reporter
56
- This will spell check all ".js" files recursively and use
57
- "@cspell/cspell-json-reporter".
58
-
59
- cspell . --reporter default
60
- This will force the default reporter to be used overriding
61
- any reporters defined in the configuration.
62
-
63
- cspell . --reporter ./<path>/reporter.cjs
64
- Use a custom reporter. See API for details.
65
-
66
- References:
67
- https://cspell.org
68
- https://github.com/streetsidesoftware/cspell
69
- `;
70
- function collect(value, previous) {
71
- if (!previous) {
72
- return [value];
73
- }
74
- return previous.concat([value]);
75
- }
76
- function commandLint(prog) {
77
- const spellCheckCommand = prog.command('lint', { isDefault: true });
78
- spellCheckCommand
79
- .description('Check spelling')
80
- .option('-c, --config <cspell.json>', 'Configuration file to use. By default cspell looks for cspell.json in the current directory.')
81
- .option('-v, --verbose', 'Display more information about the files being checked and the configuration.')
82
- .option('--locale <locale>', 'Set language locales. i.e. "en,fr" for English and French, or "en-GB" for British English.')
83
- .option('--language-id <language>', 'Force programming language for unknown extensions. i.e. "php" or "scala"')
84
- .addOption(new commander_1.Option('--languageId <language>', 'Force programming language for unknown extensions. i.e. "php" or "scala"').hideHelp())
85
- .option('--words-only', 'Only output the words not found in the dictionaries.')
86
- .addOption(new commander_1.Option('--wordsOnly', 'Only output the words not found in the dictionaries.').hideHelp())
87
- .option('-u, --unique', 'Only output the first instance of a word not found in the dictionaries.')
88
- .option('-e, --exclude <glob>', 'Exclude files matching the glob pattern. This option can be used multiple times to add multiple globs. ', collect)
89
- .option('--file-list <path or stdin>', 'Specify a list of files to be spell checked.' +
90
- ' The list is filtered against the glob file patterns.' +
91
- ' Note: the format is 1 file path per line.', collect)
92
- .option('--no-issues', 'Do not show the spelling errors.')
93
- .option('--no-progress', 'Turn off progress messages')
94
- .option('--no-summary', 'Turn off summary message in console.')
95
- .option('-s, --silent', 'Silent mode, suppress error messages.')
96
- .option('--fail-fast', 'Exit after first file with an issue or error.')
97
- .addOption(new commander_1.Option('--no-fail-fast', 'Process all files even if there is an error.').hideHelp())
98
- .option('-r, --root <root folder>', 'Root directory, defaults to current directory.')
99
- .option('--relative', 'Issues are displayed relative to root.')
100
- .option('--show-context', 'Show the surrounding text around an issue.')
101
- .option('--show-suggestions', 'Show spelling suggestions.')
102
- .addOption(new commander_1.Option('--no-show-suggestions', 'Do not show spelling suggestions or fixes.').default(undefined))
103
- .addOption(new commander_1.Option('--must-find-files', 'Error if no files are found.').default(true).hideHelp())
104
- .option('--no-must-find-files', 'Do not error if no files are found.')
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(new commander_1.Option('--legacy', 'Legacy output').hideHelp())
109
- .addOption(new commander_1.Option('--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(new commander_1.Option('--cache-strategy <strategy>', 'Strategy to use for detecting changed files.').choices([
114
- 'metadata',
115
- 'content',
116
- ]))
117
- .option('--cache-location <path>', `Path to the cache file or directory. (default: "${index_js_1.DEFAULT_CACHE_LOCATION}")`)
118
- .option('--dot', 'Include files and directories starting with `.` (period) when matching globs.')
119
- .option('--gitignore', 'Ignore files matching glob patterns found in .gitignore files.')
120
- .option('--no-gitignore', 'Do NOT use .gitignore files.')
121
- .option('--gitignore-root <path>', 'Prevent searching for .gitignore files past root.', collect)
122
- .option('--validate-directives', 'Validate in-document CSpell directives.')
123
- .option('--no-validate-directives', 'Do not validate in-document CSpell directives.')
124
- .option('--no-color', 'Turn off color.')
125
- .option('--color', 'Force color.')
126
- .addOption(new commander_1.Option('--default-configuration', 'Load the default configuration and dictionaries.').hideHelp())
127
- .addOption(new commander_1.Option('--no-default-configuration', 'Do not load the default configuration and dictionaries.'))
128
- .option('--debug', 'Output information useful for debugging cspell.json files.')
129
- .option('--reporter <module|path>', 'Specify one or more reporters to use.', collect)
130
- .usage(usage)
131
- .addHelpText('after', advanced)
132
- .arguments('[globs...]')
133
- .action((fileGlobs, options) => {
134
- App.parseApplicationFeatureFlags(options.flag);
135
- const { mustFindFiles, fileList } = options;
136
- return App.lint(fileGlobs, options).then((result) => {
137
- if (!fileGlobs.length && !result.files && !result.errors && !fileList) {
138
- spellCheckCommand.outputHelp();
139
- throw new errors_js_1.CheckFailed('outputHelp', 1);
140
- }
141
- if (result.issues || result.errors || (mustFindFiles && !result.files)) {
142
- throw new errors_js_1.CheckFailed('check failed', 1);
143
- }
144
- return;
145
- });
146
- });
147
- return spellCheckCommand;
148
- }
149
- exports.commandLint = commandLint;
150
- //# sourceMappingURL=commandLint.js.map
@@ -1,3 +0,0 @@
1
- import type { Command } from 'commander';
2
- export declare function commandSuggestion(prog: Command): Command;
3
- //# sourceMappingURL=commandSuggestion.d.ts.map
@@ -1,88 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.commandSuggestion = void 0;
27
- const commander_1 = require("commander");
28
- const App = __importStar(require("./application.js"));
29
- const suggestionsEmitter_js_1 = require("./emitters/suggestionsEmitter.js");
30
- const errors_js_1 = require("./util/errors.js");
31
- function collect(value, previous) {
32
- value = value.replace(/^=/, '');
33
- if (!previous) {
34
- return [value];
35
- }
36
- return previous.concat([value]);
37
- }
38
- function count(_, previous) {
39
- return (previous || 0) + 1;
40
- }
41
- function asNumber(value, prev) {
42
- return parseInt(value, 10) ?? prev;
43
- }
44
- function commandSuggestion(prog) {
45
- const suggestionCommand = prog.command('suggestions');
46
- suggestionCommand
47
- .aliases(['sug', 'suggest'])
48
- .description('Spelling Suggestions for words.')
49
- .option('-c, --config <cspell.json>', 'Configuration file to use. By default cspell looks for cspell.json in the current directory.')
50
- .option('--locale <locale>', 'Set language locales. i.e. "en,fr" for English and French, or "en-GB" for British English.')
51
- .option('--language-id <language>', 'Use programming language. i.e. "php" or "scala".')
52
- .addOption(new commander_1.Option('--languageId <language>', 'Use programming language. i.e. "php" or "scala".').hideHelp())
53
- .option('-s, --no-strict', 'Ignore case and accents when searching for words.')
54
- .option('--ignore-case', 'Alias of --no-strict.')
55
- .option('--num-changes <number>', 'Number of changes allowed to a word', asNumber, 4)
56
- .option('--num-suggestions <number>', 'Number of suggestions', asNumber, 8)
57
- .option('--no-include-ties', 'Force the number of suggested to be limited, by not including suggestions that have the same edit cost.')
58
- .option('--stdin', 'Use stdin for input.')
59
- .addOption(new commander_1.Option('--repl', 'REPL interface for looking up suggestions.'))
60
- .option('-v, --verbose', 'Show detailed output.', count, 0)
61
- .option('-d, --dictionary <dictionary name>', 'Use the dictionary specified. Only dictionaries specified will be used.', collect)
62
- .option('--dictionaries <dictionary names...>', 'Use the dictionaries specified. Only dictionaries specified will be used.')
63
- .option('--no-color', 'Turn off color.')
64
- .option('--color', 'Force color')
65
- .arguments('[words...]')
66
- .action(async (words, options) => {
67
- App.parseApplicationFeatureFlags(options.flag);
68
- options.useStdin = options.stdin;
69
- options.dictionaries = mergeArrays(options.dictionaries, options.dictionary);
70
- if (!words.length && !options.useStdin && !options.repl) {
71
- suggestionCommand.outputHelp();
72
- throw new errors_js_1.CheckFailed('outputHelp', 1);
73
- }
74
- for await (const r of App.suggestions(words, options)) {
75
- (0, suggestionsEmitter_js_1.emitSuggestionResult)(r, options);
76
- }
77
- });
78
- return suggestionCommand;
79
- }
80
- exports.commandSuggestion = commandSuggestion;
81
- function mergeArrays(a, b) {
82
- if (a === undefined)
83
- return b;
84
- if (b === undefined)
85
- return a;
86
- return a.concat(b);
87
- }
88
- //# sourceMappingURL=commandSuggestion.js.map
@@ -1,3 +0,0 @@
1
- import type { Command } from 'commander';
2
- export declare function commandTrace(prog: Command): Command;
3
- //# sourceMappingURL=commandTrace.d.ts.map