cspell 5.15.2 → 5.17.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 +95 -57
- package/dist/options.d.ts +44 -4
- package/dist/options.js +9 -0
- package/dist/util/async.d.ts +46 -0
- package/dist/util/async.js +101 -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/util/errors.d.ts +9 -3
- package/dist/util/errors.js +17 -2
- package/dist/{fileHelper.d.ts → util/fileHelper.d.ts} +8 -3
- package/dist/{fileHelper.js → util/fileHelper.js} +21 -8
- 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 +12 -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("./util/async"));
|
|
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.mergeAsyncIterables(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.mergeAsyncIterables(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 =
|