cspell 9.1.3 → 9.2.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 +29 -21
- package/bin.mjs +1 -1
- package/dist/esm/app.d.ts +19 -0
- package/dist/esm/app.js +1033 -0
- package/dist/esm/application-D8WjsMdV.d.ts +116 -0
- package/dist/esm/application-_MFvh02K.js +2761 -0
- package/dist/esm/application.d.ts +3 -0
- package/dist/esm/application.js +3 -0
- package/dist/esm/index.d.ts +55 -0
- package/dist/esm/index.js +5 -0
- package/dist/esm/options-ChaXtdFn.d.ts +387 -0
- package/package.json +28 -27
- package/dist/esm/app.d.mts +0 -5
- package/dist/esm/app.mjs +0 -34
- package/dist/esm/application.d.mts +0 -17
- package/dist/esm/application.mjs +0 -99
- package/dist/esm/cli-reporter.d.ts +0 -38
- package/dist/esm/cli-reporter.js +0 -386
- package/dist/esm/commandCheck.d.ts +0 -3
- package/dist/esm/commandCheck.js +0 -52
- package/dist/esm/commandConfig.d.ts +0 -3
- package/dist/esm/commandConfig.js +0 -18
- package/dist/esm/commandDictionaries.d.ts +0 -3
- package/dist/esm/commandDictionaries.js +0 -40
- package/dist/esm/commandHelpers.d.ts +0 -18
- package/dist/esm/commandHelpers.js +0 -30
- package/dist/esm/commandInit.d.ts +0 -3
- package/dist/esm/commandInit.js +0 -25
- package/dist/esm/commandLink.d.ts +0 -3
- package/dist/esm/commandLink.js +0 -48
- package/dist/esm/commandLint.d.ts +0 -3
- package/dist/esm/commandLint.js +0 -226
- package/dist/esm/commandSuggestion.d.ts +0 -3
- package/dist/esm/commandSuggestion.js +0 -61
- package/dist/esm/commandTrace.d.ts +0 -3
- package/dist/esm/commandTrace.js +0 -91
- package/dist/esm/config/adjustConfig.d.ts +0 -7
- package/dist/esm/config/adjustConfig.js +0 -137
- package/dist/esm/config/config.d.ts +0 -5
- package/dist/esm/config/config.js +0 -18
- package/dist/esm/config/configInit.d.ts +0 -3
- package/dist/esm/config/configInit.js +0 -104
- package/dist/esm/config/constants.d.ts +0 -17
- package/dist/esm/config/constants.js +0 -23
- package/dist/esm/config/index.d.ts +0 -3
- package/dist/esm/config/index.js +0 -2
- package/dist/esm/config/options.d.ts +0 -62
- package/dist/esm/config/options.js +0 -2
- package/dist/esm/config/updateConfig.d.ts +0 -3
- package/dist/esm/config/updateConfig.js +0 -2
- package/dist/esm/console.d.ts +0 -25
- package/dist/esm/console.js +0 -53
- package/dist/esm/dictionaries/index.d.ts +0 -3
- package/dist/esm/dictionaries/index.js +0 -2
- package/dist/esm/dictionaries/listDictionaries.d.ts +0 -33
- package/dist/esm/dictionaries/listDictionaries.js +0 -131
- package/dist/esm/dirname.d.ts +0 -2
- package/dist/esm/dirname.js +0 -13
- package/dist/esm/emitters/DictionaryPathFormat.d.ts +0 -3
- package/dist/esm/emitters/DictionaryPathFormat.js +0 -12
- package/dist/esm/emitters/dictionaryListEmitter.d.ts +0 -19
- package/dist/esm/emitters/dictionaryListEmitter.js +0 -82
- package/dist/esm/emitters/helpers.d.ts +0 -14
- package/dist/esm/emitters/helpers.js +0 -67
- package/dist/esm/emitters/suggestionsEmitter.d.ts +0 -13
- package/dist/esm/emitters/suggestionsEmitter.js +0 -79
- package/dist/esm/emitters/traceEmitter.d.ts +0 -19
- package/dist/esm/emitters/traceEmitter.js +0 -87
- package/dist/esm/environment.d.ts +0 -39
- package/dist/esm/environment.js +0 -30
- package/dist/esm/featureFlags/featureFlags.d.ts +0 -4
- package/dist/esm/featureFlags/featureFlags.js +0 -21
- package/dist/esm/featureFlags/index.d.ts +0 -2
- package/dist/esm/featureFlags/index.js +0 -2
- package/dist/esm/index.d.mts +0 -6
- package/dist/esm/index.mjs +0 -4
- package/dist/esm/link.d.ts +0 -8
- package/dist/esm/link.js +0 -39
- package/dist/esm/lint/LintRequest.d.ts +0 -26
- package/dist/esm/lint/LintRequest.js +0 -83
- package/dist/esm/lint/index.d.ts +0 -3
- package/dist/esm/lint/index.js +0 -3
- package/dist/esm/lint/lint.d.ts +0 -8
- package/dist/esm/lint/lint.js +0 -515
- package/dist/esm/models.d.ts +0 -15
- package/dist/esm/models.js +0 -2
- package/dist/esm/options.d.ts +0 -353
- package/dist/esm/options.js +0 -9
- package/dist/esm/pkgInfo.d.ts +0 -14
- package/dist/esm/pkgInfo.js +0 -7
- package/dist/esm/repl/index.d.ts +0 -18
- package/dist/esm/repl/index.js +0 -52
- package/dist/esm/util/InMemoryReporter.d.ts +0 -31
- package/dist/esm/util/InMemoryReporter.js +0 -49
- package/dist/esm/util/LintFileResult.d.ts +0 -14
- package/dist/esm/util/LintFileResult.js +0 -2
- package/dist/esm/util/async.d.ts +0 -3
- package/dist/esm/util/async.js +0 -4
- package/dist/esm/util/cache/CSpellLintResultCache.d.ts +0 -20
- package/dist/esm/util/cache/CSpellLintResultCache.js +0 -2
- package/dist/esm/util/cache/CacheOptions.d.ts +0 -34
- package/dist/esm/util/cache/CacheOptions.js +0 -2
- package/dist/esm/util/cache/DiskCache.d.ts +0 -63
- package/dist/esm/util/cache/DiskCache.js +0 -214
- package/dist/esm/util/cache/DummyCache.d.ts +0 -11
- package/dist/esm/util/cache/DummyCache.js +0 -18
- package/dist/esm/util/cache/ObjectCollection.d.ts +0 -17
- package/dist/esm/util/cache/ObjectCollection.js +0 -127
- package/dist/esm/util/cache/createCache.d.ts +0 -31
- package/dist/esm/util/cache/createCache.js +0 -69
- package/dist/esm/util/cache/file-entry-cache.d.mts +0 -4
- package/dist/esm/util/cache/file-entry-cache.mjs +0 -5
- package/dist/esm/util/cache/fileEntryCache.d.ts +0 -9
- package/dist/esm/util/cache/fileEntryCache.js +0 -79
- package/dist/esm/util/cache/index.d.ts +0 -4
- package/dist/esm/util/cache/index.js +0 -2
- package/dist/esm/util/canUseColor.d.ts +0 -2
- package/dist/esm/util/canUseColor.js +0 -10
- package/dist/esm/util/configFileHelper.d.ts +0 -15
- package/dist/esm/util/configFileHelper.js +0 -43
- package/dist/esm/util/constants.d.ts +0 -6
- package/dist/esm/util/constants.js +0 -6
- package/dist/esm/util/errors.d.ts +0 -24
- package/dist/esm/util/errors.js +0 -60
- package/dist/esm/util/extractContext.d.ts +0 -5
- package/dist/esm/util/extractContext.js +0 -75
- package/dist/esm/util/fileHelper.d.ts +0 -44
- package/dist/esm/util/fileHelper.js +0 -165
- package/dist/esm/util/glob.d.ts +0 -45
- package/dist/esm/util/glob.js +0 -147
- package/dist/esm/util/pad.d.ts +0 -45
- package/dist/esm/util/pad.js +0 -191
- package/dist/esm/util/prefetch.d.ts +0 -2
- package/dist/esm/util/prefetch.js +0 -15
- package/dist/esm/util/reporters.d.ts +0 -30
- package/dist/esm/util/reporters.js +0 -209
- package/dist/esm/util/stdin.d.ts +0 -2
- package/dist/esm/util/stdin.js +0 -5
- package/dist/esm/util/stdinUrl.d.ts +0 -9
- package/dist/esm/util/stdinUrl.js +0 -26
- package/dist/esm/util/table.d.ts +0 -41
- package/dist/esm/util/table.js +0 -115
- package/dist/esm/util/timer.d.ts +0 -4
- package/dist/esm/util/timer.js +0 -9
- package/dist/esm/util/types.d.ts +0 -7
- package/dist/esm/util/types.js +0 -5
- package/dist/esm/util/unindent.d.ts +0 -14
- package/dist/esm/util/unindent.js +0 -55
- package/dist/esm/util/util.d.ts +0 -14
- package/dist/esm/util/util.js +0 -30
- package/dist/esm/util/writeFile.d.ts +0 -3
- package/dist/esm/util/writeFile.js +0 -30
package/dist/esm/util/pad.d.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
export declare function pad(s: string, w: number): string;
|
|
2
|
-
export declare function padWidth(s: string, target: number): number;
|
|
3
|
-
export declare function padLeft(s: string, w: number): string;
|
|
4
|
-
export declare function isAnsiString(s: string): boolean;
|
|
5
|
-
export declare function width(s: string): number;
|
|
6
|
-
export declare function ansiWidth(s: string): number;
|
|
7
|
-
/**
|
|
8
|
-
* Prune the end of a string to fit within a specified width, adding an ellipsis if necessary.
|
|
9
|
-
* @param str - the text to prune - ANSI is not supported
|
|
10
|
-
* @param maxWidth - the maximum width of the text
|
|
11
|
-
* @param pad - the string to use for padding, default is '…'
|
|
12
|
-
* @returns the pruned text
|
|
13
|
-
*/
|
|
14
|
-
export declare function pruneTextEnd(str: string, maxWidth: number | undefined, pad?: string): string;
|
|
15
|
-
/**
|
|
16
|
-
* Prune the start of a string to fit within a specified width, adding an ellipsis if necessary.
|
|
17
|
-
* @param str - the text to prune - ANSI is not supported
|
|
18
|
-
* @param maxWidth - the maximum width of the text
|
|
19
|
-
* @param pad - the string to use for padding, default is '…'
|
|
20
|
-
* @returns the pruned text
|
|
21
|
-
*/
|
|
22
|
-
export declare function pruneTextStart(str: string, maxWidth: number | undefined, pad?: string): string;
|
|
23
|
-
interface AnsiStrFragment {
|
|
24
|
-
type: 'text' | 'ansi';
|
|
25
|
-
text: string;
|
|
26
|
-
}
|
|
27
|
-
export declare function parseAnsiStr(str: string): AnsiStrFragment[];
|
|
28
|
-
/**
|
|
29
|
-
* Prune the end of a string to fit within a specified width, adding an ellipsis if necessary.
|
|
30
|
-
* @param str - the text to prune - ANSI is supported
|
|
31
|
-
* @param maxWidth - the maximum width of the text
|
|
32
|
-
* @param pad - the string to use for padding, default is '…'
|
|
33
|
-
* @returns the pruned text
|
|
34
|
-
*/
|
|
35
|
-
export declare function pruneAnsiTextEnd(str: string, maxWidth: number | undefined, pad?: string): string;
|
|
36
|
-
/**
|
|
37
|
-
* Prune the start of a string to fit within a specified width, adding an ellipsis if necessary.
|
|
38
|
-
* @param str - the text to prune - ANSI is supported
|
|
39
|
-
* @param maxWidth - the maximum width of the text
|
|
40
|
-
* @param pad - the string to use for padding, default is '…'
|
|
41
|
-
* @returns the pruned text
|
|
42
|
-
*/
|
|
43
|
-
export declare function pruneAnsiTextStart(str: string, maxWidth: number | undefined, pad?: string): string;
|
|
44
|
-
export {};
|
|
45
|
-
//# sourceMappingURL=pad.d.ts.map
|
package/dist/esm/util/pad.js
DELETED
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert';
|
|
2
|
-
import { stripVTControlCharacters } from 'node:util';
|
|
3
|
-
export function pad(s, w) {
|
|
4
|
-
const p = padWidth(s, w);
|
|
5
|
-
if (!p)
|
|
6
|
-
return s;
|
|
7
|
-
return s.padEnd(p + s.length);
|
|
8
|
-
}
|
|
9
|
-
export function padWidth(s, target) {
|
|
10
|
-
const sWidth = ansiWidth(s);
|
|
11
|
-
return Math.max(target - sWidth, 0);
|
|
12
|
-
}
|
|
13
|
-
export function padLeft(s, w) {
|
|
14
|
-
const p = padWidth(s, w);
|
|
15
|
-
if (!p)
|
|
16
|
-
return s;
|
|
17
|
-
return s.padStart(p + s.length);
|
|
18
|
-
}
|
|
19
|
-
export function isAnsiString(s) {
|
|
20
|
-
// Check if the string contains ANSI control characters.
|
|
21
|
-
return s.includes('\u001B') || s.includes('\u009B');
|
|
22
|
-
}
|
|
23
|
-
export function width(s) {
|
|
24
|
-
// Remove control codes and high surrogates to get the approximate width.
|
|
25
|
-
assert(!s.includes('\u001B'), 'String contains ANSI control characters');
|
|
26
|
-
return (s
|
|
27
|
-
// eslint-disable-next-line no-control-regex, no-misleading-character-class
|
|
28
|
-
.replaceAll(/[\u0000-\u001F\u0300-\u036F]/g, '')
|
|
29
|
-
.replaceAll(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, '.')
|
|
30
|
-
.replaceAll('…', '.')
|
|
31
|
-
.replaceAll(/\p{M}/gu, '').length);
|
|
32
|
-
}
|
|
33
|
-
export function ansiWidth(s) {
|
|
34
|
-
return width(stripVTControlCharacters(s));
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Prune the end of a string to fit within a specified width, adding an ellipsis if necessary.
|
|
38
|
-
* @param str - the text to prune - ANSI is not supported
|
|
39
|
-
* @param maxWidth - the maximum width of the text
|
|
40
|
-
* @param pad - the string to use for padding, default is '…'
|
|
41
|
-
* @returns the pruned text
|
|
42
|
-
*/
|
|
43
|
-
export function pruneTextEnd(str, maxWidth, pad = '…') {
|
|
44
|
-
if (!maxWidth || maxWidth <= 0)
|
|
45
|
-
return str;
|
|
46
|
-
if (str.length <= maxWidth)
|
|
47
|
-
return str;
|
|
48
|
-
if (isAnsiString(str))
|
|
49
|
-
return pruneAnsiTextEnd(str, maxWidth, pad);
|
|
50
|
-
const padWidth = width(pad);
|
|
51
|
-
const maxWidthWithPad = maxWidth - padWidth;
|
|
52
|
-
const letters = [...str];
|
|
53
|
-
let len = 0;
|
|
54
|
-
for (let i = 0; i < letters.length; i++) {
|
|
55
|
-
const c = letters[i];
|
|
56
|
-
len += width(c);
|
|
57
|
-
if (len > maxWidthWithPad) {
|
|
58
|
-
let j = i + 1;
|
|
59
|
-
while (j < letters.length && width(letters[j]) === 0) {
|
|
60
|
-
++j;
|
|
61
|
-
}
|
|
62
|
-
return j === letters.length ? str : letters.slice(0, i).join('') + pad;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return str;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Prune the start of a string to fit within a specified width, adding an ellipsis if necessary.
|
|
69
|
-
* @param str - the text to prune - ANSI is not supported
|
|
70
|
-
* @param maxWidth - the maximum width of the text
|
|
71
|
-
* @param pad - the string to use for padding, default is '…'
|
|
72
|
-
* @returns the pruned text
|
|
73
|
-
*/
|
|
74
|
-
export function pruneTextStart(str, maxWidth, pad = '…') {
|
|
75
|
-
if (!maxWidth || maxWidth <= 0)
|
|
76
|
-
return str;
|
|
77
|
-
if (str.length <= maxWidth)
|
|
78
|
-
return str;
|
|
79
|
-
const padWidth = width(pad);
|
|
80
|
-
const maxWidthWithPad = maxWidth - padWidth;
|
|
81
|
-
const letters = [...str];
|
|
82
|
-
let len = 0;
|
|
83
|
-
for (let i = letters.length - 1; i >= 1; i--) {
|
|
84
|
-
const c = letters[i];
|
|
85
|
-
len += width(c);
|
|
86
|
-
if (len > maxWidthWithPad) {
|
|
87
|
-
i += 1;
|
|
88
|
-
while (i < letters.length && width(letters[i]) === 0) {
|
|
89
|
-
++i;
|
|
90
|
-
}
|
|
91
|
-
return pad + letters.slice(i).join('');
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
return str;
|
|
95
|
-
}
|
|
96
|
-
// https://github.com/nodejs/node/blob/0ab50c2768453e932b5402eaea3df813e725e330/lib/internal/util/inspect.js#L283
|
|
97
|
-
const ansi = new RegExp('[\\u001B\\u009B][[\\]()#;?]*' +
|
|
98
|
-
'(?:(?:(?:(?:;[-a-zA-Z\\d\\/\\#&.:=?%@~_]+)*' +
|
|
99
|
-
'|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/\\#&.:=?%@~_]*)*)?' +
|
|
100
|
-
'(?:\\u0007|\\u001B\\u005C|\\u009C))' +
|
|
101
|
-
'|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?' +
|
|
102
|
-
'[\\dA-PR-TZcf-nq-uy=><~]))', 'g');
|
|
103
|
-
export function parseAnsiStr(str) {
|
|
104
|
-
const fragments = [];
|
|
105
|
-
let lastIndex = 0;
|
|
106
|
-
for (const match of str.matchAll(ansi)) {
|
|
107
|
-
if (match.index > lastIndex) {
|
|
108
|
-
fragments.push({ type: 'text', text: str.slice(lastIndex, match.index) });
|
|
109
|
-
}
|
|
110
|
-
fragments.push({ type: 'ansi', text: match[0] });
|
|
111
|
-
lastIndex = match.index + match[0].length;
|
|
112
|
-
}
|
|
113
|
-
if (lastIndex < str.length) {
|
|
114
|
-
fragments.push({ type: 'text', text: str.slice(lastIndex) });
|
|
115
|
-
}
|
|
116
|
-
return fragments;
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Prune the end of a string to fit within a specified width, adding an ellipsis if necessary.
|
|
120
|
-
* @param str - the text to prune - ANSI is supported
|
|
121
|
-
* @param maxWidth - the maximum width of the text
|
|
122
|
-
* @param pad - the string to use for padding, default is '…'
|
|
123
|
-
* @returns the pruned text
|
|
124
|
-
*/
|
|
125
|
-
export function pruneAnsiTextEnd(str, maxWidth, pad = '…') {
|
|
126
|
-
if (!maxWidth || maxWidth <= 0)
|
|
127
|
-
return str;
|
|
128
|
-
if (str.length <= maxWidth)
|
|
129
|
-
return str;
|
|
130
|
-
if (ansiWidth(str) <= maxWidth)
|
|
131
|
-
return str;
|
|
132
|
-
const padWidth = ansiWidth(pad);
|
|
133
|
-
const fragments = parseAnsiStr(str);
|
|
134
|
-
const maxWidthWithPad = maxWidth - padWidth;
|
|
135
|
-
let remaining = maxWidthWithPad;
|
|
136
|
-
for (const frag of fragments) {
|
|
137
|
-
if (frag.type !== 'text')
|
|
138
|
-
continue;
|
|
139
|
-
if (remaining <= 0) {
|
|
140
|
-
frag.text = '';
|
|
141
|
-
continue;
|
|
142
|
-
}
|
|
143
|
-
const pruned = pruneTextEnd(frag.text, remaining, pad);
|
|
144
|
-
if (pruned !== frag.text) {
|
|
145
|
-
frag.text = pruned;
|
|
146
|
-
remaining = 0; // Stop processing further fragments
|
|
147
|
-
continue;
|
|
148
|
-
}
|
|
149
|
-
remaining -= width(frag.text);
|
|
150
|
-
}
|
|
151
|
-
return fragments.map((frag) => frag.text).join('');
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* Prune the start of a string to fit within a specified width, adding an ellipsis if necessary.
|
|
155
|
-
* @param str - the text to prune - ANSI is supported
|
|
156
|
-
* @param maxWidth - the maximum width of the text
|
|
157
|
-
* @param pad - the string to use for padding, default is '…'
|
|
158
|
-
* @returns the pruned text
|
|
159
|
-
*/
|
|
160
|
-
export function pruneAnsiTextStart(str, maxWidth, pad = '…') {
|
|
161
|
-
if (!maxWidth || maxWidth <= 0)
|
|
162
|
-
return str;
|
|
163
|
-
if (str.length <= maxWidth)
|
|
164
|
-
return str;
|
|
165
|
-
if (ansiWidth(str) <= maxWidth)
|
|
166
|
-
return str;
|
|
167
|
-
const padWidth = ansiWidth(pad);
|
|
168
|
-
const fragments = parseAnsiStr(str);
|
|
169
|
-
const maxWidthWithPad = maxWidth - padWidth;
|
|
170
|
-
let remaining = maxWidthWithPad;
|
|
171
|
-
for (const frag of fragments.reverse()) {
|
|
172
|
-
if (frag.type !== 'text')
|
|
173
|
-
continue;
|
|
174
|
-
if (remaining <= 0) {
|
|
175
|
-
frag.text = '';
|
|
176
|
-
continue;
|
|
177
|
-
}
|
|
178
|
-
const pruned = pruneTextStart(frag.text, remaining, pad);
|
|
179
|
-
if (pruned !== frag.text) {
|
|
180
|
-
frag.text = pruned;
|
|
181
|
-
remaining = 0; // Stop processing further fragments
|
|
182
|
-
continue;
|
|
183
|
-
}
|
|
184
|
-
remaining -= width(frag.text);
|
|
185
|
-
}
|
|
186
|
-
return fragments
|
|
187
|
-
.reverse()
|
|
188
|
-
.map((frag) => frag.text)
|
|
189
|
-
.join('');
|
|
190
|
-
}
|
|
191
|
-
//# sourceMappingURL=pad.js.map
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert';
|
|
2
|
-
export function* prefetchIterable(iterable, size) {
|
|
3
|
-
assert(size >= 0);
|
|
4
|
-
const buffer = [];
|
|
5
|
-
for (const value of iterable) {
|
|
6
|
-
buffer.push(value);
|
|
7
|
-
if (buffer.length >= size - 1) {
|
|
8
|
-
const value = buffer[0];
|
|
9
|
-
buffer.shift();
|
|
10
|
-
yield value;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
yield* buffer;
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=prefetch.js.map
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { type CSpellReporter, type CSpellSettings, type FeaturesSupportedByReporter, type FileSettings, type Issue, type ReporterConfiguration, type ReportIssueOptions, type RunResult } from '@cspell/cspell-types';
|
|
2
|
-
import { LintFileResult } from './LintFileResult.js';
|
|
3
|
-
export type FinalizedReporter = Required<CSpellReporter>;
|
|
4
|
-
/**
|
|
5
|
-
* Loads reporter modules configured in cspell config file
|
|
6
|
-
*/
|
|
7
|
-
export declare function loadReporters(reporters: FileSettings['reporters'], defaultReporter: CSpellReporter, config: ReporterConfiguration): Promise<ReadonlyArray<CSpellReporter>>;
|
|
8
|
-
export declare function finalizeReporter(reporter: undefined): undefined;
|
|
9
|
-
export declare function finalizeReporter(reporter: CSpellReporter): FinalizedReporter;
|
|
10
|
-
export declare function finalizeReporter(reporter: CSpellReporter | undefined): FinalizedReporter | undefined;
|
|
11
|
-
export declare function extractReporterIssueOptions(settings: CSpellSettings | ReportIssueOptions): ReportIssueOptions;
|
|
12
|
-
export declare function mergeReportIssueOptions(a: ReportIssueOptions | CSpellSettings, b: ReportIssueOptions | undefined): ReportIssueOptions;
|
|
13
|
-
export declare class LintReporter {
|
|
14
|
-
#private;
|
|
15
|
-
readonly defaultReporter: CSpellReporter;
|
|
16
|
-
constructor(defaultReporter: CSpellReporter, config: ReporterConfiguration);
|
|
17
|
-
get config(): ReporterConfiguration;
|
|
18
|
-
set config(config: ReporterConfiguration);
|
|
19
|
-
issue(issue: Issue, reportOptions?: ReportIssueOptions): void;
|
|
20
|
-
info(...params: Parameters<FinalizedReporter['info']>): void;
|
|
21
|
-
debug(...params: Parameters<FinalizedReporter['debug']>): void;
|
|
22
|
-
error(...params: Parameters<FinalizedReporter['error']>): void;
|
|
23
|
-
progress(...params: Parameters<FinalizedReporter['progress']>): void;
|
|
24
|
-
result(result: RunResult): Promise<void>;
|
|
25
|
-
get features(): FeaturesSupportedByReporter;
|
|
26
|
-
loadReportersAndFinalize(reporters: FileSettings['reporters']): Promise<void>;
|
|
27
|
-
emitProgressBegin(filename: string, fileNum: number, fileCount: number): void;
|
|
28
|
-
emitProgressComplete(filename: string, fileNum: number, fileCount: number, result: LintFileResult): number;
|
|
29
|
-
}
|
|
30
|
-
//# sourceMappingURL=reporters.d.ts.map
|
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert';
|
|
2
|
-
import { IssueType, unknownWordsChoices, } from '@cspell/cspell-types';
|
|
3
|
-
import { dynamicImport } from '@cspell/dynamic-import';
|
|
4
|
-
import { pkgDir } from '../pkgInfo.js';
|
|
5
|
-
import { ApplicationError, toError } from './errors.js';
|
|
6
|
-
import { clean } from './util.js';
|
|
7
|
-
function filterFeatureIssues(features, issue, reportOptions) {
|
|
8
|
-
if (issue.issueType === IssueType.directive) {
|
|
9
|
-
return (features?.issueType && reportOptions?.validateDirectives) || false;
|
|
10
|
-
}
|
|
11
|
-
if (features?.unknownWords) {
|
|
12
|
-
return true;
|
|
13
|
-
}
|
|
14
|
-
if (!reportOptions) {
|
|
15
|
-
// If no options are provided, report the issue.
|
|
16
|
-
return true;
|
|
17
|
-
}
|
|
18
|
-
// The reporter doesn't support the `unknownWords` feature. Handle the logic here.
|
|
19
|
-
let reportIssue = issue.isFlagged;
|
|
20
|
-
reportIssue ||= !reportOptions.unknownWords || reportOptions.unknownWords === unknownWordsChoices.ReportAll;
|
|
21
|
-
reportIssue ||= reportOptions.unknownWords === unknownWordsChoices.ReportSimple && issue.hasSimpleSuggestions;
|
|
22
|
-
reportIssue ||=
|
|
23
|
-
reportOptions.unknownWords === unknownWordsChoices.ReportCommonTypos && issue.hasPreferredSuggestions;
|
|
24
|
-
return reportIssue || false;
|
|
25
|
-
}
|
|
26
|
-
function handleIssue(reporter, issue, reportOptions) {
|
|
27
|
-
if (!reporter.issue)
|
|
28
|
-
return;
|
|
29
|
-
if (!filterFeatureIssues(reporter.features, issue, reportOptions)) {
|
|
30
|
-
// The reporter does not want to handle this issue.
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
if (!reporter.features?.contextGeneration && !issue.context) {
|
|
34
|
-
issue = { ...issue };
|
|
35
|
-
issue.context = issue.line; // Ensure context is always set if the reporter does not support context generation.
|
|
36
|
-
}
|
|
37
|
-
return reporter.issue(issue, reportOptions);
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Loads reporter modules configured in cspell config file
|
|
41
|
-
*/
|
|
42
|
-
export async function loadReporters(reporters, defaultReporter, config) {
|
|
43
|
-
async function loadReporter(reporterSettings) {
|
|
44
|
-
if (reporterSettings === 'default')
|
|
45
|
-
return defaultReporter;
|
|
46
|
-
if (!Array.isArray(reporterSettings)) {
|
|
47
|
-
reporterSettings = [reporterSettings];
|
|
48
|
-
}
|
|
49
|
-
const [moduleName, settings] = reporterSettings;
|
|
50
|
-
try {
|
|
51
|
-
const { getReporter } = await dynamicImport(moduleName, [process.cwd(), pkgDir]);
|
|
52
|
-
return getReporter(settings, config);
|
|
53
|
-
}
|
|
54
|
-
catch (e) {
|
|
55
|
-
throw new ApplicationError(`Failed to load reporter ${moduleName}: ${toError(e).message}`);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
reporters = !reporters || !reporters.length ? ['default'] : [...reporters];
|
|
59
|
-
const loadedReporters = await Promise.all(reporters.map(loadReporter));
|
|
60
|
-
return loadedReporters.filter((v) => v !== undefined);
|
|
61
|
-
}
|
|
62
|
-
export function finalizeReporter(reporter) {
|
|
63
|
-
if (!reporter)
|
|
64
|
-
return undefined;
|
|
65
|
-
if (reporterIsFinalized(reporter)) {
|
|
66
|
-
return reporter;
|
|
67
|
-
}
|
|
68
|
-
const final = {
|
|
69
|
-
issue: (...params) => reporter.issue?.(...params),
|
|
70
|
-
info: (...params) => reporter.info?.(...params),
|
|
71
|
-
debug: (...params) => reporter.debug?.(...params),
|
|
72
|
-
progress: (...params) => reporter.progress?.(...params),
|
|
73
|
-
error: (...params) => reporter.error?.(...params),
|
|
74
|
-
result: (...params) => reporter.result?.(...params),
|
|
75
|
-
features: reporter.features,
|
|
76
|
-
};
|
|
77
|
-
return final;
|
|
78
|
-
}
|
|
79
|
-
function reporterIsFinalized(reporter) {
|
|
80
|
-
return ((!!reporter &&
|
|
81
|
-
reporter.features &&
|
|
82
|
-
typeof reporter.issue === 'function' &&
|
|
83
|
-
typeof reporter.info === 'function' &&
|
|
84
|
-
typeof reporter.debug === 'function' &&
|
|
85
|
-
typeof reporter.error === 'function' &&
|
|
86
|
-
typeof reporter.progress === 'function' &&
|
|
87
|
-
typeof reporter.result === 'function') ||
|
|
88
|
-
false);
|
|
89
|
-
}
|
|
90
|
-
const reportIssueOptionsKeyMap = {
|
|
91
|
-
unknownWords: 'unknownWords',
|
|
92
|
-
validateDirectives: 'validateDirectives',
|
|
93
|
-
showContext: 'showContext',
|
|
94
|
-
};
|
|
95
|
-
function setValue(options, key, value) {
|
|
96
|
-
if (value !== undefined) {
|
|
97
|
-
options[key] = value;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
export function extractReporterIssueOptions(settings) {
|
|
101
|
-
const src = settings;
|
|
102
|
-
const options = {};
|
|
103
|
-
for (const key in reportIssueOptionsKeyMap) {
|
|
104
|
-
const k = key;
|
|
105
|
-
setValue(options, k, src[k]);
|
|
106
|
-
}
|
|
107
|
-
return options;
|
|
108
|
-
}
|
|
109
|
-
export function mergeReportIssueOptions(a, b) {
|
|
110
|
-
const options = extractReporterIssueOptions(a);
|
|
111
|
-
if (!b)
|
|
112
|
-
return options;
|
|
113
|
-
for (const key in reportIssueOptionsKeyMap) {
|
|
114
|
-
const k = key;
|
|
115
|
-
setValue(options, k, b[k]);
|
|
116
|
-
}
|
|
117
|
-
return options;
|
|
118
|
-
}
|
|
119
|
-
export class LintReporter {
|
|
120
|
-
defaultReporter;
|
|
121
|
-
#reporters = [];
|
|
122
|
-
#config;
|
|
123
|
-
#finalized = false;
|
|
124
|
-
constructor(defaultReporter, config) {
|
|
125
|
-
this.defaultReporter = defaultReporter;
|
|
126
|
-
this.#config = config;
|
|
127
|
-
if (defaultReporter) {
|
|
128
|
-
this.#reporters.push(finalizeReporter(defaultReporter));
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
get config() {
|
|
132
|
-
return this.#config;
|
|
133
|
-
}
|
|
134
|
-
set config(config) {
|
|
135
|
-
assert(!this.#finalized, 'Cannot change the configuration of a finalized reporter');
|
|
136
|
-
this.#config = config;
|
|
137
|
-
}
|
|
138
|
-
issue(issue, reportOptions) {
|
|
139
|
-
for (const reporter of this.#reporters) {
|
|
140
|
-
handleIssue(reporter, issue, reportOptions);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
info(...params) {
|
|
144
|
-
for (const reporter of this.#reporters) {
|
|
145
|
-
reporter.info(...params);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
debug(...params) {
|
|
149
|
-
for (const reporter of this.#reporters) {
|
|
150
|
-
reporter.debug(...params);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
error(...params) {
|
|
154
|
-
for (const reporter of this.#reporters) {
|
|
155
|
-
reporter.error(...params);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
progress(...params) {
|
|
159
|
-
for (const reporter of this.#reporters) {
|
|
160
|
-
reporter.progress(...params);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
async result(result) {
|
|
164
|
-
await Promise.all(this.#reporters.map((reporter) => reporter.result?.(result)));
|
|
165
|
-
}
|
|
166
|
-
get features() {
|
|
167
|
-
return {
|
|
168
|
-
unknownWords: true,
|
|
169
|
-
issueType: true,
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
async loadReportersAndFinalize(reporters) {
|
|
173
|
-
assert(!this.#finalized, 'Cannot change the configuration of a finalized reporter');
|
|
174
|
-
const loaded = await loadReporters(reporters, this.defaultReporter, this.config);
|
|
175
|
-
this.#reporters = [...new Set(loaded)].map((reporter) => finalizeReporter(reporter));
|
|
176
|
-
}
|
|
177
|
-
emitProgressBegin(filename, fileNum, fileCount) {
|
|
178
|
-
this.progress({
|
|
179
|
-
type: 'ProgressFileBegin',
|
|
180
|
-
fileNum,
|
|
181
|
-
fileCount,
|
|
182
|
-
filename,
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
emitProgressComplete(filename, fileNum, fileCount, result) {
|
|
186
|
-
const filteredIssues = result.issues.filter((issue) => filterFeatureIssues({}, issue, result.reportIssueOptions));
|
|
187
|
-
const numIssues = filteredIssues.length;
|
|
188
|
-
for (const reporter of this.#reporters) {
|
|
189
|
-
const progress = clean({
|
|
190
|
-
type: 'ProgressFileComplete',
|
|
191
|
-
fileNum,
|
|
192
|
-
fileCount,
|
|
193
|
-
filename,
|
|
194
|
-
elapsedTimeMs: result.elapsedTimeMs,
|
|
195
|
-
processed: result.processed,
|
|
196
|
-
numErrors: numIssues || result.errors,
|
|
197
|
-
cached: result.cached,
|
|
198
|
-
perf: result.perf,
|
|
199
|
-
issues: reporter.features && result.issues,
|
|
200
|
-
reportIssueOptions: reporter.features && result.reportIssueOptions,
|
|
201
|
-
});
|
|
202
|
-
reporter.progress(progress);
|
|
203
|
-
}
|
|
204
|
-
// Show the spelling errors after emitting the progress.
|
|
205
|
-
result.issues.forEach((issue) => this.issue(issue, result.reportIssueOptions));
|
|
206
|
-
return numIssues;
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
//# sourceMappingURL=reporters.js.map
|
package/dist/esm/util/stdin.d.ts
DELETED
package/dist/esm/util/stdin.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export declare function isStdinUrl(url: string | URL): boolean;
|
|
2
|
-
/**
|
|
3
|
-
* Normalize and resolve a stdin url.
|
|
4
|
-
* @param url - stdin url to resolve.
|
|
5
|
-
* @param cwd - file path to resolve relative paths against.
|
|
6
|
-
* @returns
|
|
7
|
-
*/
|
|
8
|
-
export declare function resolveStdinUrl(url: string, cwd: string): string;
|
|
9
|
-
//# sourceMappingURL=stdinUrl.d.ts.map
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert';
|
|
2
|
-
import { toFileURL } from '@cspell/url';
|
|
3
|
-
import { STDINProtocol } from './constants.js';
|
|
4
|
-
export function isStdinUrl(url) {
|
|
5
|
-
if (url instanceof URL) {
|
|
6
|
-
return url.protocol === STDINProtocol;
|
|
7
|
-
}
|
|
8
|
-
return url.startsWith(STDINProtocol);
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Normalize and resolve a stdin url.
|
|
12
|
-
* @param url - stdin url to resolve.
|
|
13
|
-
* @param cwd - file path to resolve relative paths against.
|
|
14
|
-
* @returns
|
|
15
|
-
*/
|
|
16
|
-
export function resolveStdinUrl(url, cwd) {
|
|
17
|
-
assert(url.startsWith(STDINProtocol), `Expected url to start with ${STDINProtocol}`);
|
|
18
|
-
const path = decodeURIComponent(url)
|
|
19
|
-
.slice(STDINProtocol.length)
|
|
20
|
-
.replace(/^\/\//, '')
|
|
21
|
-
.replace(/^\/([a-z]:)/i, '$1');
|
|
22
|
-
const fileUrl = toFileURL(path, cwd);
|
|
23
|
-
// If the path is empty,
|
|
24
|
-
return fileUrl.toString().replace(/^file:/, STDINProtocol) + (path ? '' : '/');
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=stdinUrl.js.map
|
package/dist/esm/util/table.d.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
export type RowTextFn = (maxWidth: number | undefined) => string;
|
|
2
|
-
export type TableCell = string | RowTextFn;
|
|
3
|
-
export type TableRow = TableCell[] | Record<string, TableCell>;
|
|
4
|
-
export type TableHeaderColumnFieldTitle = [field: string, title: string];
|
|
5
|
-
export type TableHeader = string[] | TableHeaderColumnFieldTitle[];
|
|
6
|
-
export type TextDecorator = (t: string, columnIndex: number) => string;
|
|
7
|
-
export interface MaxColumnWidths {
|
|
8
|
-
/**
|
|
9
|
-
* [field name or column index]: number of characters
|
|
10
|
-
*/
|
|
11
|
-
[column: string | number]: number | undefined;
|
|
12
|
-
}
|
|
13
|
-
export interface Table {
|
|
14
|
-
/**
|
|
15
|
-
* The header of the table.
|
|
16
|
-
* Can be an array of strings or an array of tuples with field name and title.
|
|
17
|
-
*/
|
|
18
|
-
header: TableHeader;
|
|
19
|
-
/**
|
|
20
|
-
* The rows of the table.
|
|
21
|
-
* Can be an array of arrays or an array of objects with field names as keys.
|
|
22
|
-
*/
|
|
23
|
-
rows: TableRow[];
|
|
24
|
-
/**
|
|
25
|
-
* The width of the terminal, used to adjust column widths.
|
|
26
|
-
*/
|
|
27
|
-
terminalWidth?: number;
|
|
28
|
-
/**
|
|
29
|
-
* The deliminator used to separate columns in the table.
|
|
30
|
-
* Defaults to ' | ' if not provided.
|
|
31
|
-
*/
|
|
32
|
-
deliminator?: string;
|
|
33
|
-
/**
|
|
34
|
-
* The maximum widths for each column.
|
|
35
|
-
* If provided, it will override the calculated widths.
|
|
36
|
-
*/
|
|
37
|
-
maxColumnWidths?: MaxColumnWidths;
|
|
38
|
-
}
|
|
39
|
-
export declare function tableToLines(table: Table, deliminator?: string): string[];
|
|
40
|
-
export declare function decorateRowWith(row: string[], ...decorators: TextDecorator[]): string[];
|
|
41
|
-
//# sourceMappingURL=table.d.ts.map
|