cspell 5.18.0-alpha.0 → 5.18.3
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/dist/cli-reporter.js +19 -3
- package/dist/emitters/suggestionsEmitter.js +8 -5
- package/dist/emitters/traceEmitter.js +2 -2
- package/dist/lint/lint.js +10 -3
- package/dist/util/InMemoryReporter.d.ts +2 -2
- package/dist/util/util.d.ts +2 -0
- package/dist/util/util.js +17 -5
- package/package.json +11 -11
package/dist/cli-reporter.js
CHANGED
|
@@ -66,9 +66,21 @@ function relativeUriFilename(uri, fsPathRoot) {
|
|
|
66
66
|
return '.' + path.sep + rel;
|
|
67
67
|
}
|
|
68
68
|
function reportProgress(p) {
|
|
69
|
-
if (p.type
|
|
70
|
-
return;
|
|
69
|
+
if (p.type === 'ProgressFileComplete') {
|
|
70
|
+
return reportProgressFileComplete(p);
|
|
71
71
|
}
|
|
72
|
+
if (p.type === 'ProgressFileBegin') {
|
|
73
|
+
return reportProgressFileBegin(p);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function reportProgressFileBegin(p) {
|
|
77
|
+
const fc = '' + p.fileCount;
|
|
78
|
+
const fn = (' '.repeat(fc.length) + p.fileNum).slice(-fc.length);
|
|
79
|
+
const idx = fn + '/' + fc;
|
|
80
|
+
const filename = chalk.gray(relativeFilename(p.filename));
|
|
81
|
+
process.stderr.write(`\r${idx} ${filename} ...`);
|
|
82
|
+
}
|
|
83
|
+
function reportProgressFileComplete(p) {
|
|
72
84
|
const fc = '' + p.fileCount;
|
|
73
85
|
const fn = (' '.repeat(fc.length) + p.fileNum).slice(-fc.length);
|
|
74
86
|
const idx = fn + '/' + fc;
|
|
@@ -76,7 +88,7 @@ function reportProgress(p) {
|
|
|
76
88
|
const time = reportTime(p.elapsedTimeMs, !!p.cached);
|
|
77
89
|
const skipped = p.processed === false ? ' skipped' : '';
|
|
78
90
|
const hasErrors = p.numErrors ? chalk.red ` X` : '';
|
|
79
|
-
console.error(
|
|
91
|
+
console.error(`\r${idx} ${filename} ${time}${skipped}${hasErrors}`);
|
|
80
92
|
}
|
|
81
93
|
function reportTime(elapsedTimeMs, cached) {
|
|
82
94
|
if (cached)
|
|
@@ -124,6 +136,10 @@ function getReporter(options) {
|
|
|
124
136
|
if (!fileGlobs.length && !result.files) {
|
|
125
137
|
return;
|
|
126
138
|
}
|
|
139
|
+
if (result.cachedFiles) {
|
|
140
|
+
console.error('CSpell: Files checked: %d (%d from cache), Issues found: %d in %d files', result.files, result.cachedFiles, result.issues, result.filesWithIssues.size);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
127
143
|
console.error('CSpell: Files checked: %d, Issues found: %d in %d files', result.files, result.issues, result.filesWithIssues.size);
|
|
128
144
|
};
|
|
129
145
|
return {
|
|
@@ -6,21 +6,24 @@ const util_1 = require("../util/util");
|
|
|
6
6
|
function emitSuggestionResult(result, options) {
|
|
7
7
|
const { word, suggestions } = result;
|
|
8
8
|
const { verbose, output = console } = options;
|
|
9
|
-
output.log(word ? chalk.
|
|
9
|
+
output.log(word ? chalk.yellow(word) : chalk.yellow('<empty>') + ':');
|
|
10
10
|
if (!suggestions.length) {
|
|
11
11
|
console.log(chalk.yellow(' <no suggestions>'));
|
|
12
12
|
return;
|
|
13
13
|
}
|
|
14
14
|
if (verbose) {
|
|
15
|
-
const maxWidth = suggestions
|
|
15
|
+
const maxWidth = suggestions
|
|
16
|
+
.map((r) => (0, util_1.width)(r.compoundWord || r.word))
|
|
17
|
+
.reduce((max, len) => Math.max(max, len), 0);
|
|
16
18
|
for (const sug of suggestions) {
|
|
17
|
-
const { word, cost, dictionaries } = sug;
|
|
18
|
-
const
|
|
19
|
+
const { word, cost, dictionaries, compoundWord } = sug;
|
|
20
|
+
const w = compoundWord || word;
|
|
21
|
+
const padding = ' '.repeat((0, util_1.padWidth)(w, maxWidth));
|
|
19
22
|
const forbid = sug.forbidden ? chalk.red('X') : ' ';
|
|
20
23
|
const ignore = sug.noSuggest ? chalk.yellow('N') : ' ';
|
|
21
24
|
const strCost = (0, util_1.padLeft)(cost.toString(10), 4);
|
|
22
25
|
const dicts = dictionaries.map((n) => chalk.gray(n)).join(', ');
|
|
23
|
-
output.log(` - ${formatWord(
|
|
26
|
+
output.log(` - ${formatWord(w, sug)}${padding} ${forbid}${ignore} - ${chalk.yellow(strCost)} ${dicts}`);
|
|
24
27
|
}
|
|
25
28
|
}
|
|
26
29
|
else {
|
|
@@ -32,7 +32,7 @@ function emitTraceResults(results, options) {
|
|
|
32
32
|
var _a;
|
|
33
33
|
const maxWordLength = results
|
|
34
34
|
.map((r) => r.foundWord || r.word)
|
|
35
|
-
.reduce((a, b) => Math.max(a,
|
|
35
|
+
.reduce((a, b) => Math.max(a, (0, util_1.width)(b)), 'Word'.length);
|
|
36
36
|
const cols = {
|
|
37
37
|
word: maxWordLength,
|
|
38
38
|
dictName: colWidthDictionaryName,
|
|
@@ -66,7 +66,7 @@ function emitTraceResult(r, colWidths, options) {
|
|
|
66
66
|
const dictColor = r.dictActive ? chalk.yellowBright : chalk.rgb(200, 128, 50);
|
|
67
67
|
const n = dictColor(dictName);
|
|
68
68
|
const info = [w, f, n].join(' ') + ' ';
|
|
69
|
-
const used = (0, strip_ansi_1.default)(info)
|
|
69
|
+
const used = (0, util_1.width)((0, strip_ansi_1.default)(info));
|
|
70
70
|
const widthSrc = terminalWidth - used;
|
|
71
71
|
const c = errors ? chalk.red : chalk.white;
|
|
72
72
|
const s = c(formatDictionaryLocation(r.dictSource, widthSrc, options.cwd));
|
package/dist/lint/lint.js
CHANGED
|
@@ -114,10 +114,16 @@ async function runLint(cfg) {
|
|
|
114
114
|
const status = runResult();
|
|
115
115
|
const cache = (0, cache_1.createCache)(cacheSettings);
|
|
116
116
|
const failFast = (_b = (_a = cfg.options.failFast) !== null && _a !== void 0 ? _a : configInfo.config.failFast) !== null && _b !== void 0 ? _b : false;
|
|
117
|
-
const
|
|
117
|
+
const emitProgressBegin = (filename, fileNum, fileCount) => reporter.progress({
|
|
118
|
+
type: 'ProgressFileBegin',
|
|
119
|
+
fileNum,
|
|
120
|
+
fileCount,
|
|
121
|
+
filename,
|
|
122
|
+
});
|
|
123
|
+
const emitProgressComplete = (filename, fileNum, fileCount, result) => reporter.progress({
|
|
118
124
|
type: 'ProgressFileComplete',
|
|
119
125
|
fileNum,
|
|
120
|
-
fileCount
|
|
126
|
+
fileCount,
|
|
121
127
|
filename,
|
|
122
128
|
elapsedTimeMs: result === null || result === void 0 ? void 0 : result.elapsedTimeMs,
|
|
123
129
|
processed: result === null || result === void 0 ? void 0 : result.processed,
|
|
@@ -128,6 +134,7 @@ async function runLint(cfg) {
|
|
|
128
134
|
let i = 0;
|
|
129
135
|
for await (const filename of files) {
|
|
130
136
|
++i;
|
|
137
|
+
emitProgressBegin(filename, i, fileCount !== null && fileCount !== void 0 ? fileCount : i);
|
|
131
138
|
const result = await processFile(filename, configInfo, cache);
|
|
132
139
|
yield { filename, fileNum: i, result };
|
|
133
140
|
}
|
|
@@ -136,7 +143,7 @@ async function runLint(cfg) {
|
|
|
136
143
|
const { filename, fileNum, result } = await fileP;
|
|
137
144
|
status.files += 1;
|
|
138
145
|
status.cachedFiles = (status.cachedFiles || 0) + (result.cached ? 1 : 0);
|
|
139
|
-
|
|
146
|
+
emitProgressComplete(filename, fileNum, fileCount !== null && fileCount !== void 0 ? fileCount : fileNum, result);
|
|
140
147
|
// Show the spelling errors after emitting the progress.
|
|
141
148
|
result.issues.filter(cfg.uniqueFilter).forEach((issue) => reporter.issue(issue));
|
|
142
149
|
if (result.issues.length || result.errors) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CSpellReporter, Issue,
|
|
1
|
+
import type { CSpellReporter, Issue, ProgressItem, RunResult } from '@cspell/cspell-types';
|
|
2
2
|
export interface InMemoryResult {
|
|
3
3
|
log: string[];
|
|
4
4
|
issues: Issue[];
|
|
@@ -21,7 +21,7 @@ export declare class InMemoryReporter implements CSpellReporter, InMemoryResult
|
|
|
21
21
|
error: (message: string, error: Error) => void;
|
|
22
22
|
info: (message: string) => void;
|
|
23
23
|
debug: (message: string) => void;
|
|
24
|
-
progress: (p:
|
|
24
|
+
progress: (p: ProgressItem) => void;
|
|
25
25
|
result: (r: RunResult) => void;
|
|
26
26
|
dump: () => InMemoryResult;
|
|
27
27
|
}
|
package/dist/util/util.d.ts
CHANGED
|
@@ -4,7 +4,9 @@ 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 padWidth(s: string, target: number): number;
|
|
7
8
|
export declare function pad(s: string, w: number): string;
|
|
8
9
|
export declare function padLeft(s: string, w: number): string;
|
|
10
|
+
export declare function width(s: string): number;
|
|
9
11
|
export {};
|
|
10
12
|
//# 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.padLeft = exports.pad = exports.clean = exports.unique = exports.uniqueFilterFnGenerator = exports.uniqueFn = void 0;
|
|
3
|
+
exports.width = exports.padLeft = exports.pad = exports.padWidth = 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,16 +28,28 @@ function clean(src) {
|
|
|
28
28
|
return r;
|
|
29
29
|
}
|
|
30
30
|
exports.clean = clean;
|
|
31
|
+
function padWidth(s, target) {
|
|
32
|
+
const sWidth = width(s);
|
|
33
|
+
return Math.max(target - sWidth, 0);
|
|
34
|
+
}
|
|
35
|
+
exports.padWidth = padWidth;
|
|
31
36
|
function pad(s, w) {
|
|
32
|
-
|
|
37
|
+
const p = padWidth(s, w);
|
|
38
|
+
if (!p)
|
|
33
39
|
return s;
|
|
34
|
-
return
|
|
40
|
+
return s + ' '.repeat(p);
|
|
35
41
|
}
|
|
36
42
|
exports.pad = pad;
|
|
37
43
|
function padLeft(s, w) {
|
|
38
|
-
|
|
44
|
+
const p = padWidth(s, w);
|
|
45
|
+
if (!p)
|
|
39
46
|
return s;
|
|
40
|
-
return
|
|
47
|
+
return ' '.repeat(p) + s;
|
|
41
48
|
}
|
|
42
49
|
exports.padLeft = padLeft;
|
|
50
|
+
function width(s) {
|
|
51
|
+
// eslint-disable-next-line no-control-regex
|
|
52
|
+
return s.replace(/[\u0300-\u036f\x00-\x1f]/g, '').length;
|
|
53
|
+
}
|
|
54
|
+
exports.width = width;
|
|
43
55
|
//# sourceMappingURL=util.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cspell",
|
|
3
|
-
"version": "5.18.
|
|
3
|
+
"version": "5.18.3",
|
|
4
4
|
"description": "A Spelling Checker for Code!",
|
|
5
5
|
"funding": "https://github.com/streetsidesoftware/cspell?sponsor=1",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -70,13 +70,13 @@
|
|
|
70
70
|
},
|
|
71
71
|
"homepage": "https://streetsidesoftware.github.io/cspell/",
|
|
72
72
|
"dependencies": {
|
|
73
|
-
"@cspell/cspell-pipe": "^5.18.
|
|
73
|
+
"@cspell/cspell-pipe": "^5.18.3",
|
|
74
74
|
"chalk": "^4.1.2",
|
|
75
|
-
"commander": "^
|
|
76
|
-
"comment-json": "^4.
|
|
77
|
-
"cspell-gitignore": "^5.18.
|
|
78
|
-
"cspell-glob": "^5.18.
|
|
79
|
-
"cspell-lib": "^5.18.
|
|
75
|
+
"commander": "^9.0.0",
|
|
76
|
+
"comment-json": "^4.2.2",
|
|
77
|
+
"cspell-gitignore": "^5.18.3",
|
|
78
|
+
"cspell-glob": "^5.18.3",
|
|
79
|
+
"cspell-lib": "^5.18.3",
|
|
80
80
|
"fast-json-stable-stringify": "^2.1.0",
|
|
81
81
|
"file-entry-cache": "^6.0.1",
|
|
82
82
|
"fs-extra": "^10.0.0",
|
|
@@ -91,8 +91,8 @@
|
|
|
91
91
|
"node": ">=12.13.0"
|
|
92
92
|
},
|
|
93
93
|
"devDependencies": {
|
|
94
|
-
"@cspell/cspell-json-reporter": "^5.18.
|
|
95
|
-
"@cspell/cspell-types": "^5.18.
|
|
94
|
+
"@cspell/cspell-json-reporter": "^5.18.3",
|
|
95
|
+
"@cspell/cspell-types": "^5.18.3",
|
|
96
96
|
"@types/file-entry-cache": "^5.0.2",
|
|
97
97
|
"@types/fs-extra": "^9.0.13",
|
|
98
98
|
"@types/glob": "^7.2.0",
|
|
@@ -104,8 +104,8 @@
|
|
|
104
104
|
"micromatch": "^4.0.4",
|
|
105
105
|
"minimatch": "^3.0.4",
|
|
106
106
|
"rimraf": "^3.0.2",
|
|
107
|
-
"rollup": "^2.
|
|
107
|
+
"rollup": "^2.67.0",
|
|
108
108
|
"rollup-plugin-dts": "^4.1.0"
|
|
109
109
|
},
|
|
110
|
-
"gitHead": "
|
|
110
|
+
"gitHead": "c650c8d0d58fc0398a6f745a0ad48d46f982332f"
|
|
111
111
|
}
|