cspell 8.3.0 → 8.3.2
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/esm/application.d.mts +2 -2
- package/dist/esm/application.d.ts +2 -2
- package/dist/esm/commandTrace.js +28 -7
- package/dist/esm/commandTrace.mjs +28 -7
- package/dist/esm/emitters/traceEmitter.d.mts +3 -1
- package/dist/esm/emitters/traceEmitter.d.ts +3 -1
- package/dist/esm/emitters/traceEmitter.js +2 -1
- package/dist/esm/emitters/traceEmitter.mjs +2 -1
- package/package.json +10 -10
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
|
2
2
|
import type { CSpellReporter, RunResult } from '@cspell/cspell-types';
|
|
3
|
-
import type { CheckTextInfo, FeatureFlags,
|
|
3
|
+
import type { CheckTextInfo, FeatureFlags, TraceWordResult } from 'cspell-lib';
|
|
4
4
|
import type { TimedSuggestionsForWordResult } from './emitters/suggestionsEmitter.mjs';
|
|
5
5
|
import type { BaseOptions, LegacyOptions, LinterCliOptions, SuggestionOptions, TraceOptions } from './options.mjs';
|
|
6
6
|
export type { TraceResult } from 'cspell-lib';
|
|
7
7
|
export { IncludeExcludeFlag } from 'cspell-lib';
|
|
8
8
|
export type AppError = NodeJS.ErrnoException;
|
|
9
9
|
export declare function lint(fileGlobs: string[], options: LinterCliOptions, reporter?: CSpellReporter): Promise<RunResult>;
|
|
10
|
-
export declare function trace(words: string[], options: TraceOptions): AsyncIterableIterator<
|
|
10
|
+
export declare function trace(words: string[], options: TraceOptions): AsyncIterableIterator<TraceWordResult>;
|
|
11
11
|
export type CheckTextResult = CheckTextInfo;
|
|
12
12
|
export declare function checkText(filename: string, options: BaseOptions & LegacyOptions): Promise<CheckTextResult>;
|
|
13
13
|
export declare function suggestions(words: string[], options: SuggestionOptions): AsyncIterable<TimedSuggestionsForWordResult>;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
|
2
2
|
import type { CSpellReporter, RunResult } from '@cspell/cspell-types';
|
|
3
|
-
import type { CheckTextInfo, FeatureFlags,
|
|
3
|
+
import type { CheckTextInfo, FeatureFlags, TraceWordResult } from 'cspell-lib';
|
|
4
4
|
import type { TimedSuggestionsForWordResult } from './emitters/suggestionsEmitter.js';
|
|
5
5
|
import type { BaseOptions, LegacyOptions, LinterCliOptions, SuggestionOptions, TraceOptions } from './options.js';
|
|
6
6
|
export type { TraceResult } from 'cspell-lib';
|
|
7
7
|
export { IncludeExcludeFlag } from 'cspell-lib';
|
|
8
8
|
export type AppError = NodeJS.ErrnoException;
|
|
9
9
|
export declare function lint(fileGlobs: string[], options: LinterCliOptions, reporter?: CSpellReporter): Promise<RunResult>;
|
|
10
|
-
export declare function trace(words: string[], options: TraceOptions): AsyncIterableIterator<
|
|
10
|
+
export declare function trace(words: string[], options: TraceOptions): AsyncIterableIterator<TraceWordResult>;
|
|
11
11
|
export type CheckTextResult = CheckTextInfo;
|
|
12
12
|
export declare function checkText(filename: string, options: BaseOptions & LegacyOptions): Promise<CheckTextResult>;
|
|
13
13
|
export declare function suggestions(words: string[], options: SuggestionOptions): AsyncIterable<TimedSuggestionsForWordResult>;
|
package/dist/esm/commandTrace.js
CHANGED
|
@@ -33,14 +33,25 @@ export function commandTrace(prog) {
|
|
|
33
33
|
const dictionaryPathFormat = isDictionaryPathFormat(options.dictionaryPath)
|
|
34
34
|
? options.dictionaryPath
|
|
35
35
|
: 'long';
|
|
36
|
+
let prefix = '';
|
|
36
37
|
for await (const results of App.trace(words, options)) {
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
const byWord = groupBy(results, (r) => r.word);
|
|
39
|
+
for (const split of results.splits) {
|
|
40
|
+
const splitResults = byWord.get(split.word) || [];
|
|
41
|
+
const filtered = filterTraceResults(splitResults, options);
|
|
42
|
+
emitTraceResults(split.word, split.found, filtered, {
|
|
43
|
+
cwd: process.cwd(),
|
|
44
|
+
dictionaryPathFormat,
|
|
45
|
+
prefix,
|
|
46
|
+
showWordFound: results.splits.length > 1,
|
|
47
|
+
});
|
|
48
|
+
prefix = '\n';
|
|
49
|
+
numFound += results.reduce((n, r) => n + (r.found ? 1 : 0), 0);
|
|
50
|
+
const numErrors = results.map((r) => r.errors?.length || 0).reduce((n, r) => n + r, 0);
|
|
51
|
+
if (numErrors) {
|
|
52
|
+
console.error('Dictionary Errors.');
|
|
53
|
+
throw new CheckFailed('dictionary errors', 1);
|
|
54
|
+
}
|
|
44
55
|
}
|
|
45
56
|
}
|
|
46
57
|
if (!numFound) {
|
|
@@ -57,4 +68,14 @@ function filterTraceResults(results, options) {
|
|
|
57
68
|
function filterTraceResult(result, onlyFound) {
|
|
58
69
|
return result.found || result.forbidden || result.noSuggest || (!onlyFound && result.dictActive);
|
|
59
70
|
}
|
|
71
|
+
function groupBy(items, key) {
|
|
72
|
+
const map = new Map();
|
|
73
|
+
for (const item of items) {
|
|
74
|
+
const k = key(item);
|
|
75
|
+
const a = map.get(k) || [];
|
|
76
|
+
a.push(item);
|
|
77
|
+
map.set(k, a);
|
|
78
|
+
}
|
|
79
|
+
return map;
|
|
80
|
+
}
|
|
60
81
|
//# sourceMappingURL=commandTrace.js.map
|
|
@@ -33,14 +33,25 @@ export function commandTrace(prog) {
|
|
|
33
33
|
const dictionaryPathFormat = isDictionaryPathFormat(options.dictionaryPath)
|
|
34
34
|
? options.dictionaryPath
|
|
35
35
|
: 'long';
|
|
36
|
+
let prefix = '';
|
|
36
37
|
for await (const results of App.trace(words, options)) {
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
const byWord = groupBy(results, (r) => r.word);
|
|
39
|
+
for (const split of results.splits) {
|
|
40
|
+
const splitResults = byWord.get(split.word) || [];
|
|
41
|
+
const filtered = filterTraceResults(splitResults, options);
|
|
42
|
+
emitTraceResults(split.word, split.found, filtered, {
|
|
43
|
+
cwd: process.cwd(),
|
|
44
|
+
dictionaryPathFormat,
|
|
45
|
+
prefix,
|
|
46
|
+
showWordFound: results.splits.length > 1,
|
|
47
|
+
});
|
|
48
|
+
prefix = '\n';
|
|
49
|
+
numFound += results.reduce((n, r) => n + (r.found ? 1 : 0), 0);
|
|
50
|
+
const numErrors = results.map((r) => r.errors?.length || 0).reduce((n, r) => n + r, 0);
|
|
51
|
+
if (numErrors) {
|
|
52
|
+
console.error('Dictionary Errors.');
|
|
53
|
+
throw new CheckFailed('dictionary errors', 1);
|
|
54
|
+
}
|
|
44
55
|
}
|
|
45
56
|
}
|
|
46
57
|
if (!numFound) {
|
|
@@ -57,4 +68,14 @@ function filterTraceResults(results, options) {
|
|
|
57
68
|
function filterTraceResult(result, onlyFound) {
|
|
58
69
|
return result.found || result.forbidden || result.noSuggest || (!onlyFound && result.dictActive);
|
|
59
70
|
}
|
|
71
|
+
function groupBy(items, key) {
|
|
72
|
+
const map = new Map();
|
|
73
|
+
for (const item of items) {
|
|
74
|
+
const k = key(item);
|
|
75
|
+
const a = map.get(k) || [];
|
|
76
|
+
a.push(item);
|
|
77
|
+
map.set(k, a);
|
|
78
|
+
}
|
|
79
|
+
return map;
|
|
80
|
+
}
|
|
60
81
|
//# sourceMappingURL=commandTrace.mjs.map
|
|
@@ -11,8 +11,10 @@ export interface EmitTraceOptions {
|
|
|
11
11
|
lineWidth?: number;
|
|
12
12
|
dictionaryPathFormat: DictionaryPathFormat;
|
|
13
13
|
iPath?: PathInterface;
|
|
14
|
+
prefix?: string;
|
|
15
|
+
showWordFound?: boolean;
|
|
14
16
|
}
|
|
15
|
-
export declare function emitTraceResults(results: TraceResult[], options: EmitTraceOptions): void;
|
|
17
|
+
export declare function emitTraceResults(word: string, found: boolean, results: TraceResult[], options: EmitTraceOptions): void;
|
|
16
18
|
declare function trimMidPath(s: string, w: number, sep: string): string;
|
|
17
19
|
export declare const __testing__: {
|
|
18
20
|
trimMidPath: typeof trimMidPath;
|
|
@@ -11,8 +11,10 @@ export interface EmitTraceOptions {
|
|
|
11
11
|
lineWidth?: number;
|
|
12
12
|
dictionaryPathFormat: DictionaryPathFormat;
|
|
13
13
|
iPath?: PathInterface;
|
|
14
|
+
prefix?: string;
|
|
15
|
+
showWordFound?: boolean;
|
|
14
16
|
}
|
|
15
|
-
export declare function emitTraceResults(results: TraceResult[], options: EmitTraceOptions): void;
|
|
17
|
+
export declare function emitTraceResults(word: string, found: boolean, results: TraceResult[], options: EmitTraceOptions): void;
|
|
16
18
|
declare function trimMidPath(s: string, w: number, sep: string): string;
|
|
17
19
|
export declare const __testing__: {
|
|
18
20
|
trimMidPath: typeof trimMidPath;
|
|
@@ -3,7 +3,7 @@ import * as iPath from 'path';
|
|
|
3
3
|
import strip from 'strip-ansi';
|
|
4
4
|
import { pad, width } from '../util/util.js';
|
|
5
5
|
const colWidthDictionaryName = 20;
|
|
6
|
-
export function emitTraceResults(results, options) {
|
|
6
|
+
export function emitTraceResults(word, found, results, options) {
|
|
7
7
|
const maxWordLength = results
|
|
8
8
|
.map((r) => r.foundWord || r.word)
|
|
9
9
|
.reduce((a, b) => Math.max(a, width(b)), 'Word'.length);
|
|
@@ -18,6 +18,7 @@ export function emitTraceResults(results, options) {
|
|
|
18
18
|
};
|
|
19
19
|
const col = new Intl.Collator();
|
|
20
20
|
results.sort((a, b) => col.compare(a.dictName, b.dictName));
|
|
21
|
+
options.showWordFound && console.log(`${options.prefix || ''}${word}: ${found ? 'Found' : 'Not Found'}`);
|
|
21
22
|
emitHeader(cols);
|
|
22
23
|
results.forEach((r) => emitTraceResult(r, cols, options));
|
|
23
24
|
}
|
|
@@ -3,7 +3,7 @@ import * as iPath from 'path';
|
|
|
3
3
|
import strip from 'strip-ansi';
|
|
4
4
|
import { pad, width } from '../util/util.mjs';
|
|
5
5
|
const colWidthDictionaryName = 20;
|
|
6
|
-
export function emitTraceResults(results, options) {
|
|
6
|
+
export function emitTraceResults(word, found, results, options) {
|
|
7
7
|
const maxWordLength = results
|
|
8
8
|
.map((r) => r.foundWord || r.word)
|
|
9
9
|
.reduce((a, b) => Math.max(a, width(b)), 'Word'.length);
|
|
@@ -18,6 +18,7 @@ export function emitTraceResults(results, options) {
|
|
|
18
18
|
};
|
|
19
19
|
const col = new Intl.Collator();
|
|
20
20
|
results.sort((a, b) => col.compare(a.dictName, b.dictName));
|
|
21
|
+
options.showWordFound && console.log(`${options.prefix || ''}${word}: ${found ? 'Found' : 'Not Found'}`);
|
|
21
22
|
emitHeader(cols);
|
|
22
23
|
results.forEach((r) => emitTraceResult(r, cols, options));
|
|
23
24
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cspell",
|
|
3
|
-
"version": "8.3.
|
|
3
|
+
"version": "8.3.2",
|
|
4
4
|
"description": "A Spelling Checker for Code!",
|
|
5
5
|
"funding": "https://github.com/streetsidesoftware/cspell?sponsor=1",
|
|
6
6
|
"bin": {
|
|
@@ -81,17 +81,17 @@
|
|
|
81
81
|
},
|
|
82
82
|
"homepage": "https://streetsidesoftware.github.io/cspell/",
|
|
83
83
|
"dependencies": {
|
|
84
|
-
"@cspell/cspell-json-reporter": "8.3.
|
|
85
|
-
"@cspell/cspell-pipe": "8.3.
|
|
86
|
-
"@cspell/cspell-types": "8.3.
|
|
87
|
-
"@cspell/dynamic-import": "8.3.
|
|
84
|
+
"@cspell/cspell-json-reporter": "8.3.2",
|
|
85
|
+
"@cspell/cspell-pipe": "8.3.2",
|
|
86
|
+
"@cspell/cspell-types": "8.3.2",
|
|
87
|
+
"@cspell/dynamic-import": "8.3.2",
|
|
88
88
|
"chalk": "^5.3.0",
|
|
89
89
|
"chalk-template": "^1.1.0",
|
|
90
90
|
"commander": "^11.1.0",
|
|
91
|
-
"cspell-gitignore": "8.3.
|
|
92
|
-
"cspell-glob": "8.3.
|
|
93
|
-
"cspell-io": "8.3.
|
|
94
|
-
"cspell-lib": "8.3.
|
|
91
|
+
"cspell-gitignore": "8.3.2",
|
|
92
|
+
"cspell-glob": "8.3.2",
|
|
93
|
+
"cspell-io": "8.3.2",
|
|
94
|
+
"cspell-lib": "8.3.2",
|
|
95
95
|
"fast-glob": "^3.3.2",
|
|
96
96
|
"fast-json-stable-stringify": "^2.1.0",
|
|
97
97
|
"file-entry-cache": "^8.0.0",
|
|
@@ -111,5 +111,5 @@
|
|
|
111
111
|
"micromatch": "^4.0.5",
|
|
112
112
|
"minimatch": "^9.0.3"
|
|
113
113
|
},
|
|
114
|
-
"gitHead": "
|
|
114
|
+
"gitHead": "98f622b2b12529f2d1ccf0f3a57991e4c08b3e3a"
|
|
115
115
|
}
|