cspell 5.16.0 → 5.18.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 +5 -1
- package/dist/app.d.ts +2 -2
- package/dist/app.js +7 -5
- package/dist/application.d.ts +5 -4
- package/dist/application.js +30 -10
- package/dist/commandLink.js +1 -1
- package/dist/commandLint.js +2 -0
- package/dist/commandSuggestion.d.ts +3 -0
- package/dist/commandSuggestion.js +83 -0
- package/dist/commandTrace.js +14 -12
- package/dist/emitters/suggestionsEmitter.d.ts +10 -0
- package/dist/emitters/suggestionsEmitter.js +42 -0
- package/dist/{traceEmitter.d.ts → emitters/traceEmitter.d.ts} +1 -1
- package/dist/{traceEmitter.js → emitters/traceEmitter.js} +9 -11
- package/dist/lint/LintRequest.js +1 -1
- package/dist/lint/lint.js +86 -51
- package/dist/options.d.ts +40 -4
- package/dist/options.js +9 -0
- package/dist/util/async.d.ts +2 -0
- package/dist/util/async.js +7 -0
- package/dist/util/cache/CSpellLintResultCache.d.ts +1 -1
- package/dist/util/cache/DiskCache.d.ts +1 -1
- package/dist/util/cache/DiskCache.js +1 -1
- package/dist/util/cache/getConfigHash.d.ts +1 -1
- package/dist/{fileHelper.d.ts → util/fileHelper.d.ts} +2 -2
- package/dist/{fileHelper.js → util/fileHelper.js} +13 -3
- package/dist/util/glob.d.ts +10 -2
- package/dist/util/stdin.d.ts +2 -0
- package/dist/util/stdin.js +28 -0
- package/dist/util/util.d.ts +2 -0
- package/dist/util/util.js +13 -1
- package/package.json +13 -9
package/README.md
CHANGED
|
@@ -11,6 +11,9 @@ A Spell Checker for Code!
|
|
|
11
11
|
## Support Future Development
|
|
12
12
|
|
|
13
13
|
- Become a [<img src="https://github.githubassets.com/images/modules/site/icons/funding_platforms/patreon.svg" width="16" height="16" alt="Patreon">Patreon!](https://patreon.com/streetsidesoftware)
|
|
14
|
+
- [Support through ](https://www.paypal.com/donate/?hosted_button_id=26LNBP2Q6MKCY)
|
|
15
|
+
- [Open Collective](https://opencollective.com/cspell)
|
|
16
|
+
- [Street Side Software](https://streetsidesoftware.com/support)
|
|
14
17
|
|
|
15
18
|
## Features
|
|
16
19
|
|
|
@@ -110,6 +113,7 @@ Options:
|
|
|
110
113
|
--no-progress Turn off progress messages
|
|
111
114
|
--no-summary Turn off summary message in console.
|
|
112
115
|
-s, --silent Silent mode, suppress error messages.
|
|
116
|
+
--fail-fast Exit after first file with an issue or error.
|
|
113
117
|
-r, --root <root folder> Root directory, defaults to current directory.
|
|
114
118
|
--relative Issues are displayed relative to root.
|
|
115
119
|
--show-context Show the surrounding text around an issue.
|
|
@@ -206,7 +210,7 @@ npm install -SD cspell
|
|
|
206
210
|
```
|
|
207
211
|
#!/bin/sh
|
|
208
212
|
|
|
209
|
-
exec git diff --cached --name-only | npx cspell --
|
|
213
|
+
exec git diff --cached --name-only | npx cspell --no-summary --no-progress --no-must-find-files --file-list stdin
|
|
210
214
|
```
|
|
211
215
|
|
|
212
216
|
## Requirements
|
package/dist/app.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { Command } from 'commander';
|
|
2
2
|
export { LinterCliOptions as Options } from './options';
|
|
3
3
|
export { CheckFailed } from './util/errors';
|
|
4
|
-
export declare function run(
|
|
4
|
+
export declare function run(command?: Command, argv?: string[]): Promise<void>;
|
|
5
5
|
//# sourceMappingURL=app.d.ts.map
|
package/dist/app.js
CHANGED
|
@@ -20,30 +20,32 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
20
20
|
};
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
22
|
exports.run = exports.CheckFailed = void 0;
|
|
23
|
-
const
|
|
23
|
+
const commander_1 = require("commander");
|
|
24
24
|
const path = __importStar(require("path"));
|
|
25
|
-
const
|
|
25
|
+
const semver_1 = require("semver");
|
|
26
26
|
const commandCheck_1 = require("./commandCheck");
|
|
27
27
|
const commandLink_1 = require("./commandLink");
|
|
28
28
|
const commandLint_1 = require("./commandLint");
|
|
29
|
+
const commandSuggestion_1 = require("./commandSuggestion");
|
|
29
30
|
const commandTrace_1 = require("./commandTrace");
|
|
30
31
|
const errors_1 = require("./util/errors");
|
|
31
32
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
32
33
|
const npmPackage = require(path.join(__dirname, '..', 'package.json'));
|
|
33
34
|
var errors_2 = require("./util/errors");
|
|
34
35
|
Object.defineProperty(exports, "CheckFailed", { enumerable: true, get: function () { return errors_2.CheckFailed; } });
|
|
35
|
-
async function run(
|
|
36
|
-
const prog =
|
|
36
|
+
async function run(command, argv) {
|
|
37
|
+
const prog = command || commander_1.program;
|
|
37
38
|
const args = argv || process.argv;
|
|
38
39
|
prog.exitOverride();
|
|
39
40
|
prog.version(npmPackage.version).description('Spelling Checker for Code').name('cspell');
|
|
40
|
-
if (!
|
|
41
|
+
if (!(0, semver_1.satisfies)(process.versions.node, npmPackage.engines.node)) {
|
|
41
42
|
throw new errors_1.ApplicationError(`Unsupported NodeJS version (${process.versions.node}); ${npmPackage.engines.node} is required`);
|
|
42
43
|
}
|
|
43
44
|
(0, commandLint_1.commandLint)(prog);
|
|
44
45
|
(0, commandTrace_1.commandTrace)(prog);
|
|
45
46
|
(0, commandCheck_1.commandCheck)(prog);
|
|
46
47
|
(0, commandLink_1.commandLink)(prog);
|
|
48
|
+
(0, commandSuggestion_1.commandSuggestion)(prog);
|
|
47
49
|
/*
|
|
48
50
|
program
|
|
49
51
|
.command('init')
|
package/dist/application.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import type { CSpellReporter, RunResult } from '@cspell/cspell-types';
|
|
3
|
-
import { CheckTextInfo, TraceResult } from 'cspell-lib';
|
|
4
|
-
import { BaseOptions, LinterOptions, TraceOptions } from './options';
|
|
3
|
+
import type { CheckTextInfo, SuggestionsForWordResult, TraceResult } from 'cspell-lib';
|
|
4
|
+
import { BaseOptions, LegacyOptions, LinterOptions, SuggestionOptions, TraceOptions } from './options';
|
|
5
5
|
export { IncludeExcludeFlag } from 'cspell-lib';
|
|
6
6
|
export type { TraceResult } from 'cspell-lib';
|
|
7
7
|
export declare type AppError = NodeJS.ErrnoException;
|
|
8
8
|
export declare function lint(fileGlobs: string[], options: LinterOptions, emitters: CSpellReporter): Promise<RunResult>;
|
|
9
|
-
export declare function trace(words: string[], options: TraceOptions):
|
|
9
|
+
export declare function trace(words: string[], options: TraceOptions): AsyncIterableIterator<TraceResult[]>;
|
|
10
10
|
export declare type CheckTextResult = CheckTextInfo;
|
|
11
|
-
export declare function checkText(filename: string, options: BaseOptions): Promise<CheckTextResult>;
|
|
11
|
+
export declare function checkText(filename: string, options: BaseOptions & LegacyOptions): Promise<CheckTextResult>;
|
|
12
|
+
export declare function suggestions(words: string[], options: SuggestionOptions): AsyncIterable<SuggestionsForWordResult>;
|
|
12
13
|
export declare function createInit(): Promise<void>;
|
|
13
14
|
//# sourceMappingURL=application.d.ts.map
|
package/dist/application.js
CHANGED
|
@@ -19,30 +19,34 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.createInit = exports.checkText = exports.trace = exports.lint = exports.IncludeExcludeFlag = void 0;
|
|
23
|
-
const cspell = __importStar(require("cspell-lib"));
|
|
22
|
+
exports.createInit = exports.suggestions = exports.checkText = exports.trace = exports.lint = exports.IncludeExcludeFlag = void 0;
|
|
24
23
|
const cspell_lib_1 = require("cspell-lib");
|
|
25
24
|
const path = __importStar(require("path"));
|
|
26
|
-
const fileHelper_1 = require("./fileHelper");
|
|
27
25
|
const lint_1 = require("./lint");
|
|
26
|
+
const options_1 = require("./options");
|
|
27
|
+
const async = __importStar(require("@cspell/cspell-pipe"));
|
|
28
|
+
const fileHelper_1 = require("./util/fileHelper");
|
|
29
|
+
const stdin_1 = require("./util/stdin");
|
|
28
30
|
const util = __importStar(require("./util/util"));
|
|
29
31
|
var cspell_lib_2 = require("cspell-lib");
|
|
30
32
|
Object.defineProperty(exports, "IncludeExcludeFlag", { enumerable: true, get: function () { return cspell_lib_2.IncludeExcludeFlag; } });
|
|
31
33
|
function lint(fileGlobs, options, emitters) {
|
|
34
|
+
options = (0, options_1.fixLegacy)(options);
|
|
32
35
|
const cfg = new lint_1.LintRequest(fileGlobs, options, emitters);
|
|
33
36
|
return (0, lint_1.runLint)(cfg);
|
|
34
37
|
}
|
|
35
38
|
exports.lint = lint;
|
|
36
|
-
async function trace(words, options) {
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
+
async function* trace(words, options) {
|
|
40
|
+
options = (0, options_1.fixLegacy)(options);
|
|
41
|
+
const iWords = options.stdin ? async.toAsyncIterable(words, (0, stdin_1.readStdin)()) : words;
|
|
42
|
+
const { languageId, locale, allowCompoundWords, ignoreCase } = options;
|
|
39
43
|
const configFile = await (0, fileHelper_1.readConfig)(options.config, undefined);
|
|
40
|
-
const config =
|
|
41
|
-
|
|
42
|
-
return results;
|
|
44
|
+
const config = (0, cspell_lib_1.mergeSettings)((0, cspell_lib_1.getDefaultSettings)(), (0, cspell_lib_1.getGlobalSettings)(), configFile.config);
|
|
45
|
+
yield* (0, cspell_lib_1.traceWordsAsync)(iWords, config, { languageId, locale, ignoreCase, allowCompoundWords });
|
|
43
46
|
}
|
|
44
47
|
exports.trace = trace;
|
|
45
48
|
async function checkText(filename, options) {
|
|
49
|
+
options = (0, options_1.fixLegacy)(options);
|
|
46
50
|
const pSettings = (0, fileHelper_1.readConfig)(options.config, path.dirname(filename));
|
|
47
51
|
const [foundSettings, text] = await Promise.all([pSettings, (0, fileHelper_1.readFile)(filename)]);
|
|
48
52
|
const settingsFromCommandLine = util.clean({
|
|
@@ -50,9 +54,25 @@ async function checkText(filename, options) {
|
|
|
50
54
|
language: options.locale || options.local || undefined,
|
|
51
55
|
});
|
|
52
56
|
const info = (0, fileHelper_1.calcFinalConfigInfo)(foundSettings, settingsFromCommandLine, filename, text);
|
|
53
|
-
return
|
|
57
|
+
return (0, cspell_lib_1.checkText)(text, info.configInfo.config);
|
|
54
58
|
}
|
|
55
59
|
exports.checkText = checkText;
|
|
60
|
+
async function* suggestions(words, options) {
|
|
61
|
+
options = (0, options_1.fixLegacy)(options);
|
|
62
|
+
const configFile = await (0, fileHelper_1.readConfig)(options.config, undefined);
|
|
63
|
+
const iWords = options.useStdin ? async.toAsyncIterable(words, (0, stdin_1.readStdin)()) : words;
|
|
64
|
+
try {
|
|
65
|
+
const results = (0, cspell_lib_1.suggestionsForWords)(iWords, options, configFile.config);
|
|
66
|
+
yield* results;
|
|
67
|
+
}
|
|
68
|
+
catch (e) {
|
|
69
|
+
if (!(e instanceof cspell_lib_1.SuggestionError))
|
|
70
|
+
throw e;
|
|
71
|
+
console.error(e.message);
|
|
72
|
+
process.exitCode = 1;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.suggestions = suggestions;
|
|
56
76
|
function createInit() {
|
|
57
77
|
return Promise.reject();
|
|
58
78
|
}
|
package/dist/commandLink.js
CHANGED
|
@@ -7,7 +7,7 @@ const table_1 = require("./util/table");
|
|
|
7
7
|
function commandLink(prog) {
|
|
8
8
|
const linkCommand = prog
|
|
9
9
|
.command('link')
|
|
10
|
-
.description('Link dictionaries
|
|
10
|
+
.description('Link dictionaries and other settings to the cspell global config.');
|
|
11
11
|
linkCommand
|
|
12
12
|
.command('list', { isDefault: true })
|
|
13
13
|
.alias('ls')
|
package/dist/commandLint.js
CHANGED
|
@@ -62,6 +62,8 @@ function commandLint(prog) {
|
|
|
62
62
|
.option('--no-progress', 'Turn off progress messages')
|
|
63
63
|
.option('--no-summary', 'Turn off summary message in console.')
|
|
64
64
|
.option('-s, --silent', 'Silent mode, suppress error messages.')
|
|
65
|
+
.option('--fail-fast', 'Exit after first file with an issue or error.')
|
|
66
|
+
.addOption(new commander_1.Option('--no-fail-fast', 'Process all files even if there is an error.').hideHelp())
|
|
65
67
|
.option('-r, --root <root folder>', 'Root directory, defaults to current directory.')
|
|
66
68
|
.option('--relative', 'Issues are displayed relative to root.')
|
|
67
69
|
.option('--show-context', 'Show the surrounding text around an issue.')
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.commandSuggestion = void 0;
|
|
23
|
+
const commander_1 = require("commander");
|
|
24
|
+
const App = __importStar(require("./application"));
|
|
25
|
+
const suggestionsEmitter_1 = require("./emitters/suggestionsEmitter");
|
|
26
|
+
const errors_1 = require("./util/errors");
|
|
27
|
+
function collect(value, previous) {
|
|
28
|
+
value = value.replace(/^=/, '');
|
|
29
|
+
if (!previous) {
|
|
30
|
+
return [value];
|
|
31
|
+
}
|
|
32
|
+
return previous.concat([value]);
|
|
33
|
+
}
|
|
34
|
+
function count(_, previous) {
|
|
35
|
+
return (previous || 0) + 1;
|
|
36
|
+
}
|
|
37
|
+
function asNumber(value, prev) {
|
|
38
|
+
var _a;
|
|
39
|
+
return (_a = parseInt(value, 10)) !== null && _a !== void 0 ? _a : prev;
|
|
40
|
+
}
|
|
41
|
+
function commandSuggestion(prog) {
|
|
42
|
+
const suggestionCommand = prog.command('suggestions');
|
|
43
|
+
suggestionCommand
|
|
44
|
+
.aliases(['sug', 'suggest'])
|
|
45
|
+
.description('Spelling Suggestions for words.')
|
|
46
|
+
.option('-c, --config <cspell.json>', 'Configuration file to use. By default cspell looks for cspell.json in the current directory.')
|
|
47
|
+
.option('--locale <locale>', 'Set language locales. i.e. "en,fr" for English and French, or "en-GB" for British English.')
|
|
48
|
+
.option('--language-id <language>', 'Use programming language. i.e. "php" or "scala".')
|
|
49
|
+
.addOption(new commander_1.Option('--languageId <language>', 'Use programming language. i.e. "php" or "scala".').hideHelp())
|
|
50
|
+
.option('-s, --no-strict', 'Ignore case and accents when searching for words.')
|
|
51
|
+
.option('--ignore-case', 'Alias of --no-strict.')
|
|
52
|
+
.option('--num-changes <number>', 'Number of changes allowed to a word', asNumber, 4)
|
|
53
|
+
.option('--num-suggestions <number>', 'Number of suggestions', asNumber, 8)
|
|
54
|
+
.option('--no-include-ties', 'Force the number of suggested to be limited, by not including suggestions that have the same edit cost.')
|
|
55
|
+
.option('--stdin', 'Use stdin for input.')
|
|
56
|
+
.option('-v, --verbose', 'Show detailed output.', count, 0)
|
|
57
|
+
.option('-d, --dictionary <dictionary name>', 'Use the dictionary specified. Only dictionaries specified will be used.', collect)
|
|
58
|
+
.option('--dictionaries <dictionary names...>', 'Use the dictionaries specified. Only dictionaries specified will be used.')
|
|
59
|
+
.option('--no-color', 'Turn off color.')
|
|
60
|
+
.option('--color', 'Force color')
|
|
61
|
+
.arguments('[words...]')
|
|
62
|
+
.action(async (words, options) => {
|
|
63
|
+
options.useStdin = options.stdin;
|
|
64
|
+
options.dictionaries = mergeArrays(options.dictionaries, options.dictionary);
|
|
65
|
+
if (!words.length && !options.useStdin) {
|
|
66
|
+
suggestionCommand.outputHelp();
|
|
67
|
+
throw new errors_1.CheckFailed('outputHelp', 1);
|
|
68
|
+
}
|
|
69
|
+
for await (const r of App.suggestions(words, options)) {
|
|
70
|
+
(0, suggestionsEmitter_1.emitSuggestionResult)(r, options);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
return suggestionCommand;
|
|
74
|
+
}
|
|
75
|
+
exports.commandSuggestion = commandSuggestion;
|
|
76
|
+
function mergeArrays(a, b) {
|
|
77
|
+
if (a === undefined)
|
|
78
|
+
return b;
|
|
79
|
+
if (b === undefined)
|
|
80
|
+
return a;
|
|
81
|
+
return a.concat(b);
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=commandSuggestion.js.map
|
package/dist/commandTrace.js
CHANGED
|
@@ -22,13 +22,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
22
22
|
exports.commandTrace = void 0;
|
|
23
23
|
const commander_1 = require("commander");
|
|
24
24
|
const App = __importStar(require("./application"));
|
|
25
|
-
const traceEmitter_1 = require("./traceEmitter");
|
|
25
|
+
const traceEmitter_1 = require("./emitters/traceEmitter");
|
|
26
26
|
const errors_1 = require("./util/errors");
|
|
27
27
|
function commandTrace(prog) {
|
|
28
28
|
return prog
|
|
29
29
|
.command('trace')
|
|
30
|
-
.description(`Trace words
|
|
31
|
-
Search for words in the configuration and dictionaries.`)
|
|
30
|
+
.description(`Trace words -- Search for words in the configuration and dictionaries.`)
|
|
32
31
|
.option('-c, --config <cspell.json>', 'Configuration file to use. By default cspell looks for cspell.json in the current directory.')
|
|
33
32
|
.option('--locale <locale>', 'Set language locales. i.e. "en,fr" for English and French, or "en-GB" for British English.')
|
|
34
33
|
.option('--language-id <language>', 'Use programming language. i.e. "php" or "scala"')
|
|
@@ -37,22 +36,25 @@ function commandTrace(prog) {
|
|
|
37
36
|
.addOption(new commander_1.Option('--allowCompoundWords', 'Turn on allowCompoundWords').hideHelp())
|
|
38
37
|
.option('--no-allow-compound-words', 'Turn off allowCompoundWords')
|
|
39
38
|
.option('--no-ignore-case', 'Do not ignore case and accents when searching for words')
|
|
39
|
+
.option('--stdin', 'Read words from stdin.')
|
|
40
40
|
.option('--no-color', 'Turn off color.')
|
|
41
41
|
.option('--color', 'Force color')
|
|
42
|
-
.arguments('
|
|
42
|
+
.arguments('[words...]')
|
|
43
43
|
.action(async (words, options) => {
|
|
44
|
-
|
|
45
|
-
(
|
|
46
|
-
|
|
44
|
+
let numFound = 0;
|
|
45
|
+
for await (const results of App.trace(words, options)) {
|
|
46
|
+
(0, traceEmitter_1.emitTraceResults)(results, { cwd: process.cwd() });
|
|
47
|
+
numFound += results.reduce((n, r) => n + (r.found ? 1 : 0), 0);
|
|
48
|
+
const numErrors = results.map((r) => { var _a; return ((_a = r.errors) === null || _a === void 0 ? void 0 : _a.length) || 0; }).reduce((n, r) => n + r, 0);
|
|
49
|
+
if (numErrors) {
|
|
50
|
+
console.error('Dictionary Errors.');
|
|
51
|
+
throw new errors_1.CheckFailed('dictionary errors', 1);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
47
54
|
if (!numFound) {
|
|
48
55
|
console.error('No matches found');
|
|
49
56
|
throw new errors_1.CheckFailed('no matches', 1);
|
|
50
57
|
}
|
|
51
|
-
const numErrors = results.map((r) => { var _a; return ((_a = r.errors) === null || _a === void 0 ? void 0 : _a.length) || 0; }).reduce((n, r) => n + r, 0);
|
|
52
|
-
if (numErrors) {
|
|
53
|
-
console.error('Dictionary Errors.');
|
|
54
|
-
throw new errors_1.CheckFailed('dictionary errors', 1);
|
|
55
|
-
}
|
|
56
58
|
});
|
|
57
59
|
}
|
|
58
60
|
exports.commandTrace = commandTrace;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { SuggestionsForWordResult } from 'cspell-lib';
|
|
2
|
+
export interface EmitSuggestionOptions {
|
|
3
|
+
verbose?: number;
|
|
4
|
+
lineWidth?: number;
|
|
5
|
+
output?: {
|
|
6
|
+
log: (text: string) => void;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export declare function emitSuggestionResult(result: SuggestionsForWordResult, options: EmitSuggestionOptions): void;
|
|
10
|
+
//# sourceMappingURL=suggestionsEmitter.d.ts.map
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.emitSuggestionResult = void 0;
|
|
4
|
+
const chalk = require("chalk");
|
|
5
|
+
const util_1 = require("../util/util");
|
|
6
|
+
function emitSuggestionResult(result, options) {
|
|
7
|
+
const { word, suggestions } = result;
|
|
8
|
+
const { verbose, output = console } = options;
|
|
9
|
+
output.log(word ? chalk.green(word) : chalk.yellow('<empty>') + ':');
|
|
10
|
+
if (!suggestions.length) {
|
|
11
|
+
console.log(chalk.yellow(' <no suggestions>'));
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
if (verbose) {
|
|
15
|
+
const maxWidth = suggestions.map((r) => r.word.length).reduce((max, len) => Math.max(max, len), 0);
|
|
16
|
+
for (const sug of suggestions) {
|
|
17
|
+
const { word, cost, dictionaries } = sug;
|
|
18
|
+
const padding = ' '.repeat(maxWidth - word.length);
|
|
19
|
+
const forbid = sug.forbidden ? chalk.red('X') : ' ';
|
|
20
|
+
const ignore = sug.noSuggest ? chalk.yellow('N') : ' ';
|
|
21
|
+
const strCost = (0, util_1.padLeft)(cost.toString(10), 4);
|
|
22
|
+
const dicts = dictionaries.map((n) => chalk.gray(n)).join(', ');
|
|
23
|
+
output.log(` - ${formatWord(word, sug)}${padding} ${forbid}${ignore} - ${chalk.yellow(strCost)} ${dicts}`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
for (const r of suggestions) {
|
|
28
|
+
output.log(` - ${formatWordSingle(r)}`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.emitSuggestionResult = emitSuggestionResult;
|
|
33
|
+
function formatWord(word, r) {
|
|
34
|
+
return r.forbidden || r.noSuggest ? chalk.gray(chalk.strikethrough(word)) : word;
|
|
35
|
+
}
|
|
36
|
+
function formatWordSingle(s) {
|
|
37
|
+
let word = formatWord(s.word, s);
|
|
38
|
+
word = s.forbidden ? word + chalk.red(' X') : word;
|
|
39
|
+
word = s.noSuggest ? word + chalk.yellow(' Not suggested.') : word;
|
|
40
|
+
return word;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=suggestionsEmitter.js.map
|
|
@@ -23,9 +23,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
23
23
|
};
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
25
|
exports.emitTraceResults = void 0;
|
|
26
|
-
const chalk = require("chalk");
|
|
27
|
-
const strip_ansi_1 = __importDefault(require("strip-ansi"));
|
|
28
26
|
const Path = __importStar(require("path"));
|
|
27
|
+
const strip_ansi_1 = __importDefault(require("strip-ansi"));
|
|
28
|
+
const util_1 = require("../util/util");
|
|
29
|
+
const chalk = require("chalk");
|
|
29
30
|
const colWidthDictionaryName = 20;
|
|
30
31
|
function emitTraceResults(results, options) {
|
|
31
32
|
var _a;
|
|
@@ -45,10 +46,10 @@ function emitTraceResults(results, options) {
|
|
|
45
46
|
exports.emitTraceResults = emitTraceResults;
|
|
46
47
|
function emitHeader(colWidths) {
|
|
47
48
|
const line = [
|
|
48
|
-
pad('Word', colWidths.word),
|
|
49
|
+
(0, util_1.pad)('Word', colWidths.word),
|
|
49
50
|
'F',
|
|
50
|
-
pad('Dictionary', colWidths.dictName),
|
|
51
|
-
pad('Dictionary Location', 30),
|
|
51
|
+
(0, util_1.pad)('Dictionary', colWidths.dictName),
|
|
52
|
+
(0, util_1.pad)('Dictionary Location', 30),
|
|
52
53
|
];
|
|
53
54
|
console.log(chalk.underline(line.join(' ').slice(0, colWidths.terminalWidth)));
|
|
54
55
|
}
|
|
@@ -56,12 +57,12 @@ function emitTraceResult(r, colWidths, options) {
|
|
|
56
57
|
var _a, _b;
|
|
57
58
|
const { word: wordColWidth, terminalWidth, dictName: widthName } = colWidths;
|
|
58
59
|
const errors = ((_b = (_a = r.errors) === null || _a === void 0 ? void 0 : _a.map((e) => e.message)) === null || _b === void 0 ? void 0 : _b.join('\n\t')) || '';
|
|
59
|
-
const word = pad(r.foundWord || r.word, wordColWidth);
|
|
60
|
+
const word = (0, util_1.pad)(r.foundWord || r.word, wordColWidth);
|
|
60
61
|
const cWord = word.replace(/[+]/g, chalk.yellow('+'));
|
|
61
62
|
const w = r.forbidden ? chalk.red(cWord) : chalk.green(cWord);
|
|
62
63
|
const f = calcFoundChar(r);
|
|
63
64
|
const a = r.dictActive ? '*' : ' ';
|
|
64
|
-
const dictName = pad(r.dictName.slice(0, widthName - 1) + a, widthName);
|
|
65
|
+
const dictName = (0, util_1.pad)(r.dictName.slice(0, widthName - 1) + a, widthName);
|
|
65
66
|
const dictColor = r.dictActive ? chalk.yellowBright : chalk.rgb(200, 128, 50);
|
|
66
67
|
const n = dictColor(dictName);
|
|
67
68
|
const info = [w, f, n].join(' ') + ' ';
|
|
@@ -75,9 +76,6 @@ function emitTraceResult(r, colWidths, options) {
|
|
|
75
76
|
console.error('\t' + chalk.red(errors));
|
|
76
77
|
}
|
|
77
78
|
}
|
|
78
|
-
function pad(s, w) {
|
|
79
|
-
return (s + ' '.repeat(w)).substr(0, w);
|
|
80
|
-
}
|
|
81
79
|
function trimMid(s, w) {
|
|
82
80
|
s = s.trim();
|
|
83
81
|
if (s.length <= w) {
|
|
@@ -85,7 +83,7 @@ function trimMid(s, w) {
|
|
|
85
83
|
}
|
|
86
84
|
const l = Math.floor((w - 3) / 2);
|
|
87
85
|
const r = Math.ceil((w - 3) / 2);
|
|
88
|
-
return s.
|
|
86
|
+
return s.slice(0, l) + '...' + s.slice(-r);
|
|
89
87
|
}
|
|
90
88
|
function calcFoundChar(r) {
|
|
91
89
|
var _a, _b;
|
package/dist/lint/LintRequest.js
CHANGED
|
@@ -32,7 +32,7 @@ class LintRequest {
|
|
|
32
32
|
this.root = path.resolve(options.root || process.cwd());
|
|
33
33
|
this.configFile = options.config;
|
|
34
34
|
this.excludes = (0, glob_1.calcExcludeGlobInfo)(this.root, options.exclude);
|
|
35
|
-
this.locale = options.locale ||
|
|
35
|
+
this.locale = options.locale || '';
|
|
36
36
|
this.enableGlobDot = options.dot;
|
|
37
37
|
this.uniqueFilter = options.unique ? util.uniqueFilterFnGenerator((issue) => issue.text) : () => true;
|
|
38
38
|
this.showContext =
|
package/dist/lint/lint.js
CHANGED
|
@@ -28,16 +28,17 @@ const cspell = __importStar(require("cspell-lib"));
|
|
|
28
28
|
const path = __importStar(require("path"));
|
|
29
29
|
const util_1 = require("util");
|
|
30
30
|
const vscode_uri_1 = require("vscode-uri");
|
|
31
|
-
const
|
|
31
|
+
const cspell_pipe_1 = require("@cspell/cspell-pipe");
|
|
32
32
|
const cache_1 = require("../util/cache");
|
|
33
33
|
const errors_1 = require("../util/errors");
|
|
34
|
+
const fileHelper_1 = require("../util/fileHelper");
|
|
34
35
|
const glob_1 = require("../util/glob");
|
|
35
36
|
const reporters_1 = require("../util/reporters");
|
|
36
37
|
const timer_1 = require("../util/timer");
|
|
37
38
|
const util = __importStar(require("../util/util"));
|
|
39
|
+
const chalk = require("chalk");
|
|
38
40
|
async function runLint(cfg) {
|
|
39
41
|
let { reporter } = cfg;
|
|
40
|
-
const { fileLists } = cfg;
|
|
41
42
|
cspell.setLogger(getLoggerFromReporter(reporter));
|
|
42
43
|
const configErrors = new Set();
|
|
43
44
|
const lintResult = await run();
|
|
@@ -108,13 +109,15 @@ async function runLint(cfg) {
|
|
|
108
109
|
return { ...tdo, context };
|
|
109
110
|
}
|
|
110
111
|
async function processFiles(files, configInfo, cacheSettings) {
|
|
111
|
-
|
|
112
|
+
var _a, _b;
|
|
113
|
+
const fileCount = files instanceof Array ? files.length : undefined;
|
|
112
114
|
const status = runResult();
|
|
113
115
|
const cache = (0, cache_1.createCache)(cacheSettings);
|
|
116
|
+
const failFast = (_b = (_a = cfg.options.failFast) !== null && _a !== void 0 ? _a : configInfo.config.failFast) !== null && _b !== void 0 ? _b : false;
|
|
114
117
|
const emitProgress = (filename, fileNum, result) => reporter.progress({
|
|
115
118
|
type: 'ProgressFileComplete',
|
|
116
119
|
fileNum,
|
|
117
|
-
fileCount,
|
|
120
|
+
fileCount: fileCount !== null && fileCount !== void 0 ? fileCount : fileNum,
|
|
118
121
|
filename,
|
|
119
122
|
elapsedTimeMs: result === null || result === void 0 ? void 0 : result.elapsedTimeMs,
|
|
120
123
|
processed: result === null || result === void 0 ? void 0 : result.processed,
|
|
@@ -122,10 +125,11 @@ async function runLint(cfg) {
|
|
|
122
125
|
cached: result === null || result === void 0 ? void 0 : result.cached,
|
|
123
126
|
});
|
|
124
127
|
async function* loadAndProcessFiles() {
|
|
125
|
-
|
|
126
|
-
|
|
128
|
+
let i = 0;
|
|
129
|
+
for await (const filename of files) {
|
|
130
|
+
++i;
|
|
127
131
|
const result = await processFile(filename, configInfo, cache);
|
|
128
|
-
yield { filename, fileNum: i
|
|
132
|
+
yield { filename, fileNum: i, result };
|
|
129
133
|
}
|
|
130
134
|
}
|
|
131
135
|
for await (const fileP of loadAndProcessFiles()) {
|
|
@@ -139,6 +143,9 @@ async function runLint(cfg) {
|
|
|
139
143
|
status.filesWithIssues.add(filename);
|
|
140
144
|
status.issues += result.issues.length;
|
|
141
145
|
status.errors += result.errors;
|
|
146
|
+
if (failFast) {
|
|
147
|
+
return status;
|
|
148
|
+
}
|
|
142
149
|
}
|
|
143
150
|
status.errors += result.configErrors;
|
|
144
151
|
}
|
|
@@ -180,57 +187,30 @@ async function runLint(cfg) {
|
|
|
180
187
|
return reportConfigurationErrors(configInfo.config);
|
|
181
188
|
}
|
|
182
189
|
async function run() {
|
|
183
|
-
var _a, _b, _c, _d;
|
|
184
190
|
if (cfg.options.root) {
|
|
185
191
|
process.env[cspell.ENV_CSPELL_GLOB_ROOT] = cfg.root;
|
|
186
192
|
}
|
|
187
193
|
const configInfo = await (0, fileHelper_1.readConfig)(cfg.configFile, cfg.root);
|
|
188
194
|
reporter = (0, reporters_1.mergeReporters)(cfg.reporter, ...(0, reporters_1.loadReporters)(configInfo.config));
|
|
189
195
|
cspell.setLogger(getLoggerFromReporter(reporter));
|
|
190
|
-
const
|
|
191
|
-
const
|
|
192
|
-
const
|
|
193
|
-
const cliGlobs = cfg.fileGlobs;
|
|
194
|
-
const allGlobs = cliGlobs.length ? cliGlobs : configInfo.config.files || [];
|
|
195
|
-
const combinedGlobs = (0, glob_1.normalizeGlobsToRoot)(allGlobs, cfg.root, false);
|
|
196
|
-
const cliExcludeGlobs = (0, glob_1.extractPatterns)(cfg.excludes).map((p) => p.glob);
|
|
197
|
-
const normalizedExcludes = (0, glob_1.normalizeGlobsToRoot)(cliExcludeGlobs, cfg.root, true);
|
|
198
|
-
const includeGlobs = combinedGlobs.filter((g) => !g.startsWith('!'));
|
|
199
|
-
const excludeGlobs = combinedGlobs.filter((g) => g.startsWith('!')).concat(normalizedExcludes);
|
|
200
|
-
const fileGlobs = includeGlobs;
|
|
201
|
-
const hasFileLists = !!fileLists.length;
|
|
196
|
+
const globInfo = await determineGlobs(configInfo, cfg);
|
|
197
|
+
const { fileGlobs, excludeGlobs } = globInfo;
|
|
198
|
+
const hasFileLists = !!cfg.fileLists.length;
|
|
202
199
|
if (!fileGlobs.length && !hasFileLists) {
|
|
203
200
|
// Nothing to do.
|
|
204
201
|
return runResult();
|
|
205
202
|
}
|
|
206
203
|
header(fileGlobs, excludeGlobs);
|
|
204
|
+
checkGlobs(cfg.fileGlobs, reporter);
|
|
207
205
|
reporter.info(`Config Files Found:\n ${configInfo.source}\n`, cspell_types_1.MessageTypes.Info);
|
|
208
206
|
const configErrors = await countConfigErrors(configInfo);
|
|
209
207
|
if (configErrors)
|
|
210
208
|
return runResult({ errors: configErrors });
|
|
211
209
|
// Get Exclusions from the config files.
|
|
212
210
|
const { root } = cfg;
|
|
213
|
-
const globsToExclude = (configInfo.config.ignorePaths || []).concat(excludeGlobs);
|
|
214
|
-
const globMatcher = (0, glob_1.buildGlobMatcher)(globsToExclude, root, true);
|
|
215
|
-
const ignoreGlobs = (0, glob_1.extractGlobsFromMatcher)(globMatcher);
|
|
216
|
-
// cspell:word nodir
|
|
217
|
-
const globOptions = {
|
|
218
|
-
root,
|
|
219
|
-
cwd: root,
|
|
220
|
-
ignore: ignoreGlobs.concat(normalizedExcludes),
|
|
221
|
-
nodir: true,
|
|
222
|
-
};
|
|
223
|
-
const enableGlobDot = (_d = cfg.enableGlobDot) !== null && _d !== void 0 ? _d : configInfo.config.enableGlobDot;
|
|
224
|
-
if (enableGlobDot !== undefined) {
|
|
225
|
-
globOptions.dot = enableGlobDot;
|
|
226
|
-
}
|
|
227
211
|
try {
|
|
228
212
|
const cacheSettings = await (0, cache_1.calcCacheSettings)(configInfo.config, cfg.options, root);
|
|
229
|
-
const
|
|
230
|
-
? useFileLists(fileLists, allGlobs, root, enableGlobDot)
|
|
231
|
-
: (0, fileHelper_1.findFiles)(fileGlobs, globOptions));
|
|
232
|
-
const filtered = gitIgnore ? await gitIgnore.filterOutIgnored(foundFiles) : foundFiles;
|
|
233
|
-
const files = filterFiles(filtered, globMatcher);
|
|
213
|
+
const files = await determineFilesToCheck(configInfo, cfg, reporter, globInfo);
|
|
234
214
|
return await processFiles(files, configInfo, cacheSettings);
|
|
235
215
|
}
|
|
236
216
|
catch (e) {
|
|
@@ -253,6 +233,61 @@ Options:
|
|
|
253
233
|
unique: ${yesNo(!!cfg.options.unique)}
|
|
254
234
|
`, cspell_types_1.MessageTypes.Info);
|
|
255
235
|
}
|
|
236
|
+
}
|
|
237
|
+
exports.runLint = runLint;
|
|
238
|
+
function checkGlobs(globs, reporter) {
|
|
239
|
+
globs
|
|
240
|
+
.filter((g) => g.startsWith("'") || g.endsWith("'"))
|
|
241
|
+
.map((glob) => chalk.yellow(glob))
|
|
242
|
+
.forEach((glob) => reporter.error('Linter', new errors_1.CheckFailed(`Glob starting or ending with ' (single quote) is not likely to match any files: ${glob}.`)));
|
|
243
|
+
}
|
|
244
|
+
async function determineGlobs(configInfo, cfg) {
|
|
245
|
+
var _a, _b, _c;
|
|
246
|
+
const useGitignore = (_b = (_a = cfg.options.gitignore) !== null && _a !== void 0 ? _a : configInfo.config.useGitignore) !== null && _b !== void 0 ? _b : false;
|
|
247
|
+
const gitignoreRoots = (_c = cfg.options.gitignoreRoot) !== null && _c !== void 0 ? _c : configInfo.config.gitignoreRoot;
|
|
248
|
+
const gitIgnore = useGitignore ? await generateGitIgnore(gitignoreRoots) : undefined;
|
|
249
|
+
const cliGlobs = cfg.fileGlobs;
|
|
250
|
+
const allGlobs = cliGlobs.length ? cliGlobs : configInfo.config.files || [];
|
|
251
|
+
const combinedGlobs = (0, glob_1.normalizeGlobsToRoot)(allGlobs, cfg.root, false);
|
|
252
|
+
const cliExcludeGlobs = (0, glob_1.extractPatterns)(cfg.excludes).map((p) => p.glob);
|
|
253
|
+
const normalizedExcludes = (0, glob_1.normalizeGlobsToRoot)(cliExcludeGlobs, cfg.root, true);
|
|
254
|
+
const includeGlobs = combinedGlobs.filter((g) => !g.startsWith('!'));
|
|
255
|
+
const excludeGlobs = combinedGlobs.filter((g) => g.startsWith('!')).concat(normalizedExcludes);
|
|
256
|
+
const fileGlobs = includeGlobs;
|
|
257
|
+
return { allGlobs, gitIgnore, fileGlobs, excludeGlobs, normalizedExcludes };
|
|
258
|
+
}
|
|
259
|
+
async function determineFilesToCheck(configInfo, cfg, reporter, globInfo) {
|
|
260
|
+
async function _determineFilesToCheck() {
|
|
261
|
+
var _a;
|
|
262
|
+
const { fileLists } = cfg;
|
|
263
|
+
const hasFileLists = !!fileLists.length;
|
|
264
|
+
const { allGlobs, gitIgnore, fileGlobs, excludeGlobs, normalizedExcludes } = globInfo;
|
|
265
|
+
// Get Exclusions from the config files.
|
|
266
|
+
const { root } = cfg;
|
|
267
|
+
const globsToExclude = (configInfo.config.ignorePaths || []).concat(excludeGlobs);
|
|
268
|
+
const globMatcher = (0, glob_1.buildGlobMatcher)(globsToExclude, root, true);
|
|
269
|
+
const ignoreGlobs = (0, glob_1.extractGlobsFromMatcher)(globMatcher);
|
|
270
|
+
// cspell:word nodir
|
|
271
|
+
const globOptions = {
|
|
272
|
+
root,
|
|
273
|
+
cwd: root,
|
|
274
|
+
ignore: ignoreGlobs.concat(normalizedExcludes),
|
|
275
|
+
nodir: true,
|
|
276
|
+
};
|
|
277
|
+
const enableGlobDot = (_a = cfg.enableGlobDot) !== null && _a !== void 0 ? _a : configInfo.config.enableGlobDot;
|
|
278
|
+
if (enableGlobDot !== undefined) {
|
|
279
|
+
globOptions.dot = enableGlobDot;
|
|
280
|
+
}
|
|
281
|
+
const filterFiles = (0, cspell_pipe_1.opFilter)(filterFilesFn(globMatcher));
|
|
282
|
+
const foundFiles = await (hasFileLists
|
|
283
|
+
? useFileLists(fileLists, allGlobs, root, enableGlobDot)
|
|
284
|
+
: (0, fileHelper_1.findFiles)(fileGlobs, globOptions));
|
|
285
|
+
const filtered = gitIgnore ? await gitIgnore.filterOutIgnored(foundFiles) : foundFiles;
|
|
286
|
+
const files = (0, cspell_pipe_1.isAsyncIterable)(filtered)
|
|
287
|
+
? (0, cspell_pipe_1.pipeAsync)(filtered, filterFiles)
|
|
288
|
+
: [...(0, cspell_pipe_1.pipeSync)(filtered, filterFiles)];
|
|
289
|
+
return files;
|
|
290
|
+
}
|
|
256
291
|
function isExcluded(filename, globMatcherExclude) {
|
|
257
292
|
if (cspell.isBinaryFile(vscode_uri_1.URI.file(filename))) {
|
|
258
293
|
return true;
|
|
@@ -266,25 +301,17 @@ Options:
|
|
|
266
301
|
}
|
|
267
302
|
return r.matched;
|
|
268
303
|
}
|
|
269
|
-
function
|
|
270
|
-
const { glob, rawGlob, source } = g;
|
|
271
|
-
return {
|
|
272
|
-
glob: rawGlob || glob,
|
|
273
|
-
source,
|
|
274
|
-
};
|
|
275
|
-
}
|
|
276
|
-
function filterFiles(files, globMatcherExclude) {
|
|
304
|
+
function filterFilesFn(globMatcherExclude) {
|
|
277
305
|
const patterns = globMatcherExclude.patterns;
|
|
278
306
|
const excludeInfo = patterns
|
|
279
307
|
.map(extractGlobSource)
|
|
280
308
|
.map(({ glob, source }) => `Glob: ${glob} from ${source}`)
|
|
281
309
|
.filter(util.uniqueFn());
|
|
282
310
|
reporter.info(`Exclusion Globs: \n ${excludeInfo.join('\n ')}\n`, cspell_types_1.MessageTypes.Info);
|
|
283
|
-
|
|
284
|
-
return result;
|
|
311
|
+
return (filename) => !isExcluded(filename, globMatcherExclude);
|
|
285
312
|
}
|
|
313
|
+
return _determineFilesToCheck();
|
|
286
314
|
}
|
|
287
|
-
exports.runLint = runLint;
|
|
288
315
|
function extractContext(tdo, contextRange) {
|
|
289
316
|
const { line, offset } = tdo;
|
|
290
317
|
const textOffsetInLine = offset - line.offset;
|
|
@@ -313,6 +340,13 @@ function extractContext(tdo, contextRange) {
|
|
|
313
340
|
};
|
|
314
341
|
return context;
|
|
315
342
|
}
|
|
343
|
+
function extractGlobSource(g) {
|
|
344
|
+
const { glob, rawGlob, source } = g;
|
|
345
|
+
return {
|
|
346
|
+
glob: rawGlob || glob,
|
|
347
|
+
source,
|
|
348
|
+
};
|
|
349
|
+
}
|
|
316
350
|
function runResult(init = {}) {
|
|
317
351
|
const { files = 0, filesWithIssues = new Set(), issues = 0, errors = 0, cachedFiles = 0 } = init;
|
|
318
352
|
return { files, filesWithIssues, issues, errors, cachedFiles };
|
|
@@ -357,6 +391,7 @@ async function useFileLists(fileListFiles, includeGlobPatterns, root, dot) {
|
|
|
357
391
|
}
|
|
358
392
|
const globMatcher = new cspell_glob_1.GlobMatcher(includeGlobPatterns, options);
|
|
359
393
|
const files = await (0, fileHelper_1.readFileListFiles)(fileListFiles);
|
|
360
|
-
|
|
394
|
+
const filterFiles = (file) => globMatcher.match(file);
|
|
395
|
+
return files instanceof Array ? files.filter(filterFiles) : (0, cspell_pipe_1.pipeAsync)(files, (0, cspell_pipe_1.opFilter)(filterFiles));
|
|
361
396
|
}
|
|
362
397
|
//# sourceMappingURL=lint.js.map
|
package/dist/options.d.ts
CHANGED
|
@@ -58,11 +58,50 @@ export interface LinterOptions extends BaseOptions, CacheOptions {
|
|
|
58
58
|
* Files must be found and processed otherwise it is considered an error.
|
|
59
59
|
*/
|
|
60
60
|
mustFindFiles?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Stop processing and exit if an issue or error is found.
|
|
63
|
+
*/
|
|
64
|
+
failFast?: boolean;
|
|
61
65
|
}
|
|
62
66
|
export interface TraceOptions extends BaseOptions {
|
|
67
|
+
stdin?: boolean;
|
|
63
68
|
allowCompoundWords?: boolean;
|
|
64
69
|
ignoreCase?: boolean;
|
|
65
70
|
}
|
|
71
|
+
export interface SuggestionOptions extends BaseOptions {
|
|
72
|
+
/**
|
|
73
|
+
* Strict case and accent checking
|
|
74
|
+
* @default true
|
|
75
|
+
*/
|
|
76
|
+
strict?: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* List of dictionaries to use. If specified, only that list of dictionaries will be used.
|
|
79
|
+
*/
|
|
80
|
+
dictionaries?: string[];
|
|
81
|
+
/**
|
|
82
|
+
* The number of suggestions to make.
|
|
83
|
+
* @default 8
|
|
84
|
+
*/
|
|
85
|
+
numSuggestions?: number;
|
|
86
|
+
/**
|
|
87
|
+
* Max number of changes / edits to the word to get to a suggestion matching suggestion.
|
|
88
|
+
* @default 4
|
|
89
|
+
*/
|
|
90
|
+
numChanges?: number;
|
|
91
|
+
/**
|
|
92
|
+
* If multiple suggestions have the same edit / change "cost", then included them even if
|
|
93
|
+
* it causes more than `numSuggestions` to be returned.
|
|
94
|
+
* @default true
|
|
95
|
+
*/
|
|
96
|
+
includeTies?: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Use stdin for the input
|
|
99
|
+
*/
|
|
100
|
+
useStdin?: boolean;
|
|
101
|
+
}
|
|
102
|
+
export interface LegacyOptions {
|
|
103
|
+
local?: string;
|
|
104
|
+
}
|
|
66
105
|
export interface BaseOptions {
|
|
67
106
|
/**
|
|
68
107
|
* Path to configuration file.
|
|
@@ -76,10 +115,6 @@ export interface BaseOptions {
|
|
|
76
115
|
* Locale to use.
|
|
77
116
|
*/
|
|
78
117
|
locale?: string;
|
|
79
|
-
/**
|
|
80
|
-
* @deprecated
|
|
81
|
-
*/
|
|
82
|
-
local?: string;
|
|
83
118
|
}
|
|
84
119
|
export interface LinterCliOptions extends Omit<LinterOptions, 'fileLists'> {
|
|
85
120
|
legacy?: boolean;
|
|
@@ -97,4 +132,5 @@ export interface LinterCliOptions extends Omit<LinterOptions, 'fileLists'> {
|
|
|
97
132
|
*/
|
|
98
133
|
fileList?: string[];
|
|
99
134
|
}
|
|
135
|
+
export declare function fixLegacy<T extends BaseOptions>(opts: T & LegacyOptions): Omit<T & LegacyOptions, 'local'>;
|
|
100
136
|
//# sourceMappingURL=options.d.ts.map
|
package/dist/options.js
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fixLegacy = void 0;
|
|
4
|
+
function fixLegacy(opts) {
|
|
5
|
+
const { local, ...rest } = opts;
|
|
6
|
+
if (local && !rest.locale) {
|
|
7
|
+
rest.locale = local;
|
|
8
|
+
}
|
|
9
|
+
return rest;
|
|
10
|
+
}
|
|
11
|
+
exports.fixLegacy = fixLegacy;
|
|
3
12
|
//# sourceMappingURL=options.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.asyncIterableToArray = exports.mergeAsyncIterables = void 0;
|
|
4
|
+
var cspell_pipe_1 = require("@cspell/cspell-pipe");
|
|
5
|
+
Object.defineProperty(exports, "mergeAsyncIterables", { enumerable: true, get: function () { return cspell_pipe_1.toAsyncIterable; } });
|
|
6
|
+
Object.defineProperty(exports, "asyncIterableToArray", { enumerable: true, get: function () { return cspell_pipe_1.toArray; } });
|
|
7
|
+
//# sourceMappingURL=async.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FileDescriptor } from 'file-entry-cache';
|
|
2
|
-
import type { FileResult } from '../../fileHelper';
|
|
2
|
+
import type { FileResult } from '../../util/fileHelper';
|
|
3
3
|
import type { CSpellLintResultCache } from './CSpellLintResultCache';
|
|
4
4
|
export declare type CachedFileResult = Omit<FileResult, 'fileInfo' | 'elapsedTimeMs'>;
|
|
5
5
|
/**
|
|
@@ -22,7 +22,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
22
22
|
exports.DiskCache = void 0;
|
|
23
23
|
const fileEntryCache = __importStar(require("file-entry-cache"));
|
|
24
24
|
const path_1 = require("path");
|
|
25
|
-
const fileHelper_1 = require("../../fileHelper");
|
|
25
|
+
const fileHelper_1 = require("../../util/fileHelper");
|
|
26
26
|
/**
|
|
27
27
|
* Caches cspell results on disk
|
|
28
28
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GlobOptions } from './
|
|
1
|
+
import { GlobOptions } from './glob';
|
|
2
2
|
import { CSpellUserSettings, Document, Issue } from 'cspell-lib';
|
|
3
3
|
export interface ConfigInfo {
|
|
4
4
|
source: string;
|
|
@@ -43,7 +43,7 @@ export declare function calcFinalConfigInfo(configInfo: ConfigInfo, settingsFrom
|
|
|
43
43
|
* file will be resolved relative to the containing file.
|
|
44
44
|
* @returns - a list of files to be processed.
|
|
45
45
|
*/
|
|
46
|
-
export declare function readFileListFiles(listFiles: string[]): Promise<string[]
|
|
46
|
+
export declare function readFileListFiles(listFiles: string[]): Promise<string[] | AsyncIterable<string>>;
|
|
47
47
|
/**
|
|
48
48
|
* Read a `listFile` and return the containing file paths resolved relative to the `listFile`.
|
|
49
49
|
* @param listFiles - array of file paths to read that will contain a list of files. Paths contained in each
|
|
@@ -26,10 +26,12 @@ exports.readFileListFile = exports.readFileListFiles = exports.calcFinalConfigIn
|
|
|
26
26
|
const cspell = __importStar(require("cspell-lib"));
|
|
27
27
|
const fsp = __importStar(require("fs-extra"));
|
|
28
28
|
const get_stdin_1 = __importDefault(require("get-stdin"));
|
|
29
|
-
const glob_1 = require("./
|
|
29
|
+
const glob_1 = require("./glob");
|
|
30
30
|
const path = __importStar(require("path"));
|
|
31
31
|
const cspell_lib_1 = require("cspell-lib");
|
|
32
|
-
const errors_1 = require("./
|
|
32
|
+
const errors_1 = require("./errors");
|
|
33
|
+
const async_1 = require("./async");
|
|
34
|
+
const stdin_1 = require("./stdin");
|
|
33
35
|
const UTF8 = 'utf8';
|
|
34
36
|
const STDIN = 'stdin';
|
|
35
37
|
async function readConfig(configFile, root) {
|
|
@@ -106,7 +108,15 @@ exports.calcFinalConfigInfo = calcFinalConfigInfo;
|
|
|
106
108
|
* @returns - a list of files to be processed.
|
|
107
109
|
*/
|
|
108
110
|
async function readFileListFiles(listFiles) {
|
|
109
|
-
|
|
111
|
+
let useStdin = false;
|
|
112
|
+
const files = listFiles.filter((file) => {
|
|
113
|
+
const isStdin = file === 'stdin';
|
|
114
|
+
useStdin = useStdin || isStdin;
|
|
115
|
+
return !isStdin;
|
|
116
|
+
});
|
|
117
|
+
const found = flatten(await Promise.all(files.map(readFileListFile)));
|
|
118
|
+
// Move `stdin` to the end.
|
|
119
|
+
return useStdin ? (0, async_1.mergeAsyncIterables)(found, (0, stdin_1.readStdin)()) : found;
|
|
110
120
|
}
|
|
111
121
|
exports.readFileListFiles = readFileListFiles;
|
|
112
122
|
/**
|
package/dist/util/glob.d.ts
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import type { CSpellUserSettings, Glob } from '@cspell/cspell-types';
|
|
2
2
|
import { GlobMatcher, GlobPatternWithRoot } from 'cspell-glob';
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
/**
|
|
4
|
+
* This is a subset of IOptions from 'glob'.
|
|
5
|
+
*/
|
|
6
|
+
export interface GlobOptions {
|
|
7
|
+
cwd?: string | undefined;
|
|
8
|
+
root?: string | undefined;
|
|
9
|
+
dot?: boolean | undefined;
|
|
10
|
+
nodir?: boolean | undefined;
|
|
11
|
+
ignore?: string | ReadonlyArray<string> | undefined;
|
|
12
|
+
}
|
|
5
13
|
/**
|
|
6
14
|
*
|
|
7
15
|
* @param pattern - glob patterns and NOT file paths. It can be a file path turned into a glob.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.readStdin = void 0;
|
|
23
|
+
const readline = __importStar(require("readline"));
|
|
24
|
+
function readStdin() {
|
|
25
|
+
return readline.createInterface(process.stdin);
|
|
26
|
+
}
|
|
27
|
+
exports.readStdin = readStdin;
|
|
28
|
+
//# sourceMappingURL=stdin.js.map
|
package/dist/util/util.d.ts
CHANGED
|
@@ -4,5 +4,7 @@ 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
6
|
export declare function clean<T>(src: T): T;
|
|
7
|
+
export declare function pad(s: string, w: number): string;
|
|
8
|
+
export declare function padLeft(s: string, w: number): string;
|
|
7
9
|
export {};
|
|
8
10
|
//# sourceMappingURL=util.d.ts.map
|
package/dist/util/util.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.clean = exports.unique = exports.uniqueFilterFnGenerator = exports.uniqueFn = void 0;
|
|
3
|
+
exports.padLeft = exports.pad = exports.clean = exports.unique = exports.uniqueFilterFnGenerator = exports.uniqueFn = void 0;
|
|
4
4
|
// alias for uniqueFilterFnGenerator
|
|
5
5
|
exports.uniqueFn = uniqueFilterFnGenerator;
|
|
6
6
|
function uniqueFilterFnGenerator(extractFn) {
|
|
@@ -28,4 +28,16 @@ function clean(src) {
|
|
|
28
28
|
return r;
|
|
29
29
|
}
|
|
30
30
|
exports.clean = clean;
|
|
31
|
+
function pad(s, w) {
|
|
32
|
+
if (s.length >= w)
|
|
33
|
+
return s;
|
|
34
|
+
return (s + ' '.repeat(w)).slice(0, w);
|
|
35
|
+
}
|
|
36
|
+
exports.pad = pad;
|
|
37
|
+
function padLeft(s, w) {
|
|
38
|
+
if (s.length >= w)
|
|
39
|
+
return s;
|
|
40
|
+
return (' '.repeat(w) + s).slice(-w);
|
|
41
|
+
}
|
|
42
|
+
exports.padLeft = padLeft;
|
|
31
43
|
//# sourceMappingURL=util.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cspell",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.18.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",
|
|
@@ -36,7 +36,8 @@
|
|
|
36
36
|
],
|
|
37
37
|
"scripts": {
|
|
38
38
|
"clean": "rimraf dist coverage .tsbuildinfo",
|
|
39
|
-
"build": "npm run compile",
|
|
39
|
+
"build": "npm run compile && npm run build-api",
|
|
40
|
+
"build-api": "rollup -c rollup.config.mjs",
|
|
40
41
|
"build-dev": "tsc -p tsconfig.dev.json",
|
|
41
42
|
"clean-build": "npm run clean && npm run build",
|
|
42
43
|
"compile": "tsc -p .",
|
|
@@ -69,12 +70,13 @@
|
|
|
69
70
|
},
|
|
70
71
|
"homepage": "https://streetsidesoftware.github.io/cspell/",
|
|
71
72
|
"dependencies": {
|
|
73
|
+
"@cspell/cspell-pipe": "^5.18.0",
|
|
72
74
|
"chalk": "^4.1.2",
|
|
73
75
|
"commander": "^8.3.0",
|
|
74
76
|
"comment-json": "^4.1.1",
|
|
75
|
-
"cspell-gitignore": "^5.
|
|
76
|
-
"cspell-glob": "^5.
|
|
77
|
-
"cspell-lib": "^5.
|
|
77
|
+
"cspell-gitignore": "^5.18.0",
|
|
78
|
+
"cspell-glob": "^5.18.0",
|
|
79
|
+
"cspell-lib": "^5.18.0",
|
|
78
80
|
"fast-json-stable-stringify": "^2.1.0",
|
|
79
81
|
"file-entry-cache": "^6.0.1",
|
|
80
82
|
"fs-extra": "^10.0.0",
|
|
@@ -89,8 +91,8 @@
|
|
|
89
91
|
"node": ">=12.13.0"
|
|
90
92
|
},
|
|
91
93
|
"devDependencies": {
|
|
92
|
-
"@cspell/cspell-json-reporter": "^5.
|
|
93
|
-
"@cspell/cspell-types": "^5.
|
|
94
|
+
"@cspell/cspell-json-reporter": "^5.18.0",
|
|
95
|
+
"@cspell/cspell-types": "^5.18.0",
|
|
94
96
|
"@types/file-entry-cache": "^5.0.2",
|
|
95
97
|
"@types/fs-extra": "^9.0.13",
|
|
96
98
|
"@types/glob": "^7.2.0",
|
|
@@ -101,7 +103,9 @@
|
|
|
101
103
|
"jest": "^27.4.7",
|
|
102
104
|
"micromatch": "^4.0.4",
|
|
103
105
|
"minimatch": "^3.0.4",
|
|
104
|
-
"rimraf": "^3.0.2"
|
|
106
|
+
"rimraf": "^3.0.2",
|
|
107
|
+
"rollup": "^2.66.1",
|
|
108
|
+
"rollup-plugin-dts": "^4.1.0"
|
|
105
109
|
},
|
|
106
|
-
"gitHead": "
|
|
110
|
+
"gitHead": "ef4c46dfb6f2938724afb5332ea2fdf9b67d99e4"
|
|
107
111
|
}
|