cspell 7.3.9 → 8.1.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/dist/esm/application.js +3 -3
- package/dist/esm/application.mjs +3 -3
- package/dist/esm/cli-reporter.d.mts +2 -2
- package/dist/esm/cli-reporter.d.ts +2 -2
- package/dist/esm/cli-reporter.js +9 -3
- package/dist/esm/cli-reporter.mjs +9 -3
- package/dist/esm/commandLink.js +6 -6
- package/dist/esm/commandLink.mjs +6 -6
- package/dist/esm/commandLint.js +21 -15
- package/dist/esm/commandLint.mjs +21 -15
- package/dist/esm/lint/LintRequest.js +13 -2
- package/dist/esm/lint/LintRequest.mjs +13 -2
- package/dist/esm/lint/lint.js +33 -16
- package/dist/esm/lint/lint.mjs +33 -16
- package/dist/esm/options.d.mts +8 -0
- package/dist/esm/options.d.ts +8 -0
- package/dist/esm/repl/index.js +5 -0
- package/dist/esm/repl/index.mjs +5 -0
- package/dist/esm/util/InMemoryReporter.js +36 -37
- package/dist/esm/util/InMemoryReporter.mjs +36 -37
- package/dist/esm/util/cache/DiskCache.js +11 -4
- package/dist/esm/util/cache/DiskCache.mjs +11 -4
- package/dist/esm/util/cache/ObjectCollection.js +2 -6
- package/dist/esm/util/cache/ObjectCollection.mjs +2 -6
- package/dist/esm/util/constants.d.mts +4 -5
- package/dist/esm/util/constants.d.ts +4 -5
- package/dist/esm/util/errors.js +4 -0
- package/dist/esm/util/errors.mjs +4 -0
- package/dist/esm/util/fileHelper.d.mts +4 -2
- package/dist/esm/util/fileHelper.d.ts +4 -2
- package/dist/esm/util/fileHelper.js +0 -21
- package/dist/esm/util/fileHelper.mjs +0 -21
- package/dist/esm/util/timer.d.mts +2 -6
- package/dist/esm/util/timer.d.ts +2 -6
- package/dist/esm/util/timer.js +5 -7
- package/dist/esm/util/timer.mjs +5 -7
- package/package.json +14 -14
package/dist/esm/lint/lint.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { MessageTypes } from '@cspell/cspell-types';
|
|
|
4
4
|
import chalk from 'chalk';
|
|
5
5
|
import { findRepoRoot, GitIgnore } from 'cspell-gitignore';
|
|
6
6
|
import { GlobMatcher } from 'cspell-glob';
|
|
7
|
-
import
|
|
7
|
+
import { ENV_CSPELL_GLOB_ROOT, extractDependencies, extractImportErrors, getDictionary, isBinaryFile as cspellIsBinaryFile, setLogger, shouldCheckDocument, spellCheckDocument, Text as cspellText, } from 'cspell-lib';
|
|
8
8
|
import * as path from 'path';
|
|
9
9
|
import { format } from 'util';
|
|
10
10
|
import { URI } from 'vscode-uri';
|
|
@@ -23,7 +23,7 @@ const BATCH_SIZE = 8;
|
|
|
23
23
|
const { opFilterAsync } = operators;
|
|
24
24
|
export async function runLint(cfg) {
|
|
25
25
|
let { reporter } = cfg;
|
|
26
|
-
|
|
26
|
+
setLogger(getLoggerFromReporter(reporter));
|
|
27
27
|
const configErrors = new Set();
|
|
28
28
|
const timer = getTimeMeasurer();
|
|
29
29
|
const lintResult = await run();
|
|
@@ -45,7 +45,7 @@ export async function runLint(cfg) {
|
|
|
45
45
|
return { fileResult };
|
|
46
46
|
}
|
|
47
47
|
const uri = filenameToUri(filename, cfg.root);
|
|
48
|
-
const checkResult = await
|
|
48
|
+
const checkResult = await shouldCheckDocument({ uri }, {}, configInfo.config);
|
|
49
49
|
if (!checkResult.shouldCheck)
|
|
50
50
|
return { skip: true };
|
|
51
51
|
const fileInfo = await readFileInfo(filename, undefined, true);
|
|
@@ -88,13 +88,20 @@ export async function runLint(cfg) {
|
|
|
88
88
|
let spellResult = {};
|
|
89
89
|
reporter.info(`Checking: ${filename}, File type: ${doc.languageId ?? 'auto'}, Language: ${doc.locale ?? 'default'}`, MessageTypes.Info);
|
|
90
90
|
try {
|
|
91
|
-
const { showSuggestions: generateSuggestions, validateDirectives } = cfg.options;
|
|
91
|
+
const { showSuggestions: generateSuggestions, validateDirectives, skipValidation } = cfg.options;
|
|
92
92
|
const numSuggestions = configInfo.config.numSuggestions ?? 5;
|
|
93
|
-
const validateOptions = util.clean({
|
|
94
|
-
|
|
93
|
+
const validateOptions = util.clean({
|
|
94
|
+
generateSuggestions,
|
|
95
|
+
numSuggestions,
|
|
96
|
+
validateDirectives,
|
|
97
|
+
skipValidation,
|
|
98
|
+
});
|
|
99
|
+
const r = await spellCheckDocument(doc, validateOptions, configInfo.config);
|
|
100
|
+
// console.warn('filename: %o %o', path.relative(process.cwd(), filename), r.perf);
|
|
95
101
|
spellResult = r;
|
|
96
102
|
result.processed = r.checked;
|
|
97
|
-
result.
|
|
103
|
+
result.perf = r.perf ? { ...r.perf } : undefined;
|
|
104
|
+
result.issues = cspellText.calculateTextDocumentOffsets(doc.uri, text, r.issues).map(mapIssue);
|
|
98
105
|
}
|
|
99
106
|
catch (e) {
|
|
100
107
|
reporter.error(`Failed to process "${filename}"`, toError(e));
|
|
@@ -103,9 +110,9 @@ export async function runLint(cfg) {
|
|
|
103
110
|
result.elapsedTimeMs = getElapsedTimeMs();
|
|
104
111
|
const config = spellResult.settingsUsed ?? {};
|
|
105
112
|
result.configErrors += await reportConfigurationErrors(config);
|
|
106
|
-
const elapsed = result.elapsedTimeMs
|
|
113
|
+
const elapsed = result.elapsedTimeMs;
|
|
107
114
|
const dictionaries = config.dictionaries || [];
|
|
108
|
-
reporter.info(`Checked: ${filename}, File type: ${config.languageId}, Language: ${config.language} ... Issues: ${result.issues.length} ${elapsed}
|
|
115
|
+
reporter.info(`Checked: ${filename}, File type: ${config.languageId}, Language: ${config.language} ... Issues: ${result.issues.length} ${elapsed.toFixed(2)}ms`, MessageTypes.Info);
|
|
109
116
|
reporter.info(`Config file Used: ${spellResult.localConfigFilepath || configInfo.source}`, MessageTypes.Info);
|
|
110
117
|
reporter.info(`Dictionaries Used: ${dictionaries.join(', ')}`, MessageTypes.Info);
|
|
111
118
|
if (cfg.options.debug) {
|
|
@@ -193,8 +200,18 @@ export async function runLint(cfg) {
|
|
|
193
200
|
else {
|
|
194
201
|
for (const pf of prefetchFiles(files)) {
|
|
195
202
|
await pf.result;
|
|
196
|
-
yield
|
|
203
|
+
yield processPrefetchFileResult(pf, ++i);
|
|
197
204
|
}
|
|
205
|
+
// const iter = prefetchIterable(
|
|
206
|
+
// pipe(
|
|
207
|
+
// prefetchFiles(files),
|
|
208
|
+
// opMap(async (pf) => {
|
|
209
|
+
// return processPrefetchFileResult(pf, ++i);
|
|
210
|
+
// }),
|
|
211
|
+
// ),
|
|
212
|
+
// BATCH_SIZE,
|
|
213
|
+
// );
|
|
214
|
+
// yield* iter;
|
|
198
215
|
}
|
|
199
216
|
}
|
|
200
217
|
for await (const fileP of loadAndProcessFiles()) {
|
|
@@ -218,11 +235,11 @@ export async function runLint(cfg) {
|
|
|
218
235
|
return status;
|
|
219
236
|
}
|
|
220
237
|
function calcDependencies(config) {
|
|
221
|
-
const { configFiles, dictionaryFiles } =
|
|
238
|
+
const { configFiles, dictionaryFiles } = extractDependencies(config);
|
|
222
239
|
return { files: configFiles.concat(dictionaryFiles) };
|
|
223
240
|
}
|
|
224
241
|
async function reportConfigurationErrors(config) {
|
|
225
|
-
const errors =
|
|
242
|
+
const errors = extractImportErrors(config);
|
|
226
243
|
let count = 0;
|
|
227
244
|
errors.forEach((ref) => {
|
|
228
245
|
const key = ref.error.toString();
|
|
@@ -232,7 +249,7 @@ export async function runLint(cfg) {
|
|
|
232
249
|
count += 1;
|
|
233
250
|
reporter.error('Configuration', ref.error);
|
|
234
251
|
});
|
|
235
|
-
const dictCollection = await
|
|
252
|
+
const dictCollection = await getDictionary(config);
|
|
236
253
|
dictCollection.dictionaries.forEach((dict) => {
|
|
237
254
|
const dictErrors = dict.getErrors?.() || [];
|
|
238
255
|
const msg = `Dictionary Error with (${dict.name})`;
|
|
@@ -252,7 +269,7 @@ export async function runLint(cfg) {
|
|
|
252
269
|
}
|
|
253
270
|
async function run() {
|
|
254
271
|
if (cfg.options.root) {
|
|
255
|
-
process.env[
|
|
272
|
+
process.env[ENV_CSPELL_GLOB_ROOT] = cfg.root;
|
|
256
273
|
}
|
|
257
274
|
const configInfo = await readConfig(cfg.configFile, cfg.root);
|
|
258
275
|
if (cfg.options.defaultConfiguration !== undefined) {
|
|
@@ -266,7 +283,7 @@ export async function runLint(cfg) {
|
|
|
266
283
|
});
|
|
267
284
|
const reporters = cfg.options.reporter ?? configInfo.config.reporters;
|
|
268
285
|
reporter = mergeReporters(...(await loadReporters(reporters, cfg.reporter, reporterConfig)));
|
|
269
|
-
|
|
286
|
+
setLogger(getLoggerFromReporter(reporter));
|
|
270
287
|
const globInfo = await determineGlobs(configInfo, cfg);
|
|
271
288
|
const { fileGlobs, excludeGlobs } = globInfo;
|
|
272
289
|
const hasFileLists = !!cfg.fileLists.length;
|
|
@@ -361,7 +378,7 @@ async function determineFilesToCheck(configInfo, cfg, reporter, globInfo) {
|
|
|
361
378
|
return files;
|
|
362
379
|
}
|
|
363
380
|
function isExcluded(filename, globMatcherExclude) {
|
|
364
|
-
if (
|
|
381
|
+
if (cspellIsBinaryFile(URI.file(filename))) {
|
|
365
382
|
return true;
|
|
366
383
|
}
|
|
367
384
|
const { root } = cfg;
|
package/dist/esm/options.d.mts
CHANGED
|
@@ -67,6 +67,10 @@ export interface LinterOptions extends BaseOptions, Omit<CacheOptions, 'version'
|
|
|
67
67
|
* configuration.
|
|
68
68
|
*/
|
|
69
69
|
reporter?: string[];
|
|
70
|
+
/**
|
|
71
|
+
* Load and parse documents, but do not spell check.
|
|
72
|
+
*/
|
|
73
|
+
skipValidation?: boolean;
|
|
70
74
|
}
|
|
71
75
|
export interface TraceOptions extends BaseOptions {
|
|
72
76
|
stdin?: boolean;
|
|
@@ -178,6 +182,10 @@ export interface LinterCliOptions extends LinterOptions {
|
|
|
178
182
|
* Files must be found or cli will exit with an error.
|
|
179
183
|
*/
|
|
180
184
|
mustFindFiles?: boolean;
|
|
185
|
+
/**
|
|
186
|
+
* Generate a summary report of issues.
|
|
187
|
+
*/
|
|
188
|
+
issuesSummaryReport?: boolean;
|
|
181
189
|
}
|
|
182
190
|
export declare function fixLegacy<T extends BaseOptions>(opts: T & LegacyOptions): Omit<T & LegacyOptions, 'local'>;
|
|
183
191
|
//# sourceMappingURL=options.d.mts.map
|
package/dist/esm/options.d.ts
CHANGED
|
@@ -67,6 +67,10 @@ export interface LinterOptions extends BaseOptions, Omit<CacheOptions, 'version'
|
|
|
67
67
|
* configuration.
|
|
68
68
|
*/
|
|
69
69
|
reporter?: string[];
|
|
70
|
+
/**
|
|
71
|
+
* Load and parse documents, but do not spell check.
|
|
72
|
+
*/
|
|
73
|
+
skipValidation?: boolean;
|
|
70
74
|
}
|
|
71
75
|
export interface TraceOptions extends BaseOptions {
|
|
72
76
|
stdin?: boolean;
|
|
@@ -178,6 +182,10 @@ export interface LinterCliOptions extends LinterOptions {
|
|
|
178
182
|
* Files must be found or cli will exit with an error.
|
|
179
183
|
*/
|
|
180
184
|
mustFindFiles?: boolean;
|
|
185
|
+
/**
|
|
186
|
+
* Generate a summary report of issues.
|
|
187
|
+
*/
|
|
188
|
+
issuesSummaryReport?: boolean;
|
|
181
189
|
}
|
|
182
190
|
export declare function fixLegacy<T extends BaseOptions>(opts: T & LegacyOptions): Omit<T & LegacyOptions, 'local'>;
|
|
183
191
|
//# sourceMappingURL=options.d.ts.map
|
package/dist/esm/repl/index.js
CHANGED
package/dist/esm/repl/index.mjs
CHANGED
|
@@ -2,42 +2,41 @@
|
|
|
2
2
|
* Simple reporter for test purposes
|
|
3
3
|
*/
|
|
4
4
|
export class InMemoryReporter {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
5
|
+
log = [];
|
|
6
|
+
errors = [];
|
|
7
|
+
issueCount = 0;
|
|
8
|
+
errorCount = 0;
|
|
9
|
+
debugCount = 0;
|
|
10
|
+
infoCount = 0;
|
|
11
|
+
progressCount = 0;
|
|
12
|
+
issues = [];
|
|
13
|
+
runResult;
|
|
14
|
+
issue = (issue) => {
|
|
15
|
+
this.issues.push(issue);
|
|
16
|
+
this.issueCount += 1;
|
|
17
|
+
const { uri, row, col, text } = issue;
|
|
18
|
+
this.log.push(`Issue: ${uri}[${row}, ${col}]: Unknown word: ${text}`);
|
|
19
|
+
};
|
|
20
|
+
error = (message, error) => {
|
|
21
|
+
this.errorCount += 1;
|
|
22
|
+
this.errors.push(error);
|
|
23
|
+
this.log.push(`Error: ${message} ${error.toString()}`);
|
|
24
|
+
};
|
|
25
|
+
info = (message) => {
|
|
26
|
+
this.infoCount += 1;
|
|
27
|
+
this.log.push(`Info: ${message}`);
|
|
28
|
+
};
|
|
29
|
+
debug = (message) => {
|
|
30
|
+
this.debugCount += 1;
|
|
31
|
+
this.log.push(`Debug: ${message}`);
|
|
32
|
+
};
|
|
33
|
+
progress = (p) => {
|
|
34
|
+
this.progressCount += 1;
|
|
35
|
+
this.log.push(`Progress: ${p.type} ${p.fileNum} ${p.fileCount} ${p.filename}`);
|
|
36
|
+
};
|
|
37
|
+
result = (r) => {
|
|
38
|
+
this.runResult = r;
|
|
39
|
+
};
|
|
40
|
+
dump = () => ({ log: this.log, issues: this.issues, runResult: this.runResult });
|
|
42
41
|
}
|
|
43
42
|
//# sourceMappingURL=InMemoryReporter.js.map
|
|
@@ -2,42 +2,41 @@
|
|
|
2
2
|
* Simple reporter for test purposes
|
|
3
3
|
*/
|
|
4
4
|
export class InMemoryReporter {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
5
|
+
log = [];
|
|
6
|
+
errors = [];
|
|
7
|
+
issueCount = 0;
|
|
8
|
+
errorCount = 0;
|
|
9
|
+
debugCount = 0;
|
|
10
|
+
infoCount = 0;
|
|
11
|
+
progressCount = 0;
|
|
12
|
+
issues = [];
|
|
13
|
+
runResult;
|
|
14
|
+
issue = (issue) => {
|
|
15
|
+
this.issues.push(issue);
|
|
16
|
+
this.issueCount += 1;
|
|
17
|
+
const { uri, row, col, text } = issue;
|
|
18
|
+
this.log.push(`Issue: ${uri}[${row}, ${col}]: Unknown word: ${text}`);
|
|
19
|
+
};
|
|
20
|
+
error = (message, error) => {
|
|
21
|
+
this.errorCount += 1;
|
|
22
|
+
this.errors.push(error);
|
|
23
|
+
this.log.push(`Error: ${message} ${error.toString()}`);
|
|
24
|
+
};
|
|
25
|
+
info = (message) => {
|
|
26
|
+
this.infoCount += 1;
|
|
27
|
+
this.log.push(`Info: ${message}`);
|
|
28
|
+
};
|
|
29
|
+
debug = (message) => {
|
|
30
|
+
this.debugCount += 1;
|
|
31
|
+
this.log.push(`Debug: ${message}`);
|
|
32
|
+
};
|
|
33
|
+
progress = (p) => {
|
|
34
|
+
this.progressCount += 1;
|
|
35
|
+
this.log.push(`Progress: ${p.type} ${p.fileNum} ${p.fileCount} ${p.filename}`);
|
|
36
|
+
};
|
|
37
|
+
result = (r) => {
|
|
38
|
+
this.runResult = r;
|
|
39
|
+
};
|
|
40
|
+
dump = () => ({ log: this.log, issues: this.issues, runResult: this.runResult });
|
|
42
41
|
}
|
|
43
42
|
//# sourceMappingURL=InMemoryReporter.mjs.map
|
|
@@ -20,14 +20,21 @@ const META_DATA_VERSION_SUFFIX = '-' + META_DATA_BASE_VERSION + '-' + Object.key
|
|
|
20
20
|
* Caches cspell results on disk
|
|
21
21
|
*/
|
|
22
22
|
export class DiskCache {
|
|
23
|
+
useCheckSum;
|
|
24
|
+
cspellVersion;
|
|
25
|
+
useUniversalCache;
|
|
26
|
+
cacheFileLocation;
|
|
27
|
+
cacheDir;
|
|
28
|
+
fileEntryCache;
|
|
29
|
+
dependencyCache = new Map();
|
|
30
|
+
dependencyCacheTree = {};
|
|
31
|
+
objectCollection = new ShallowObjectCollection();
|
|
32
|
+
ocCacheFileResult = new ShallowObjectCollection();
|
|
33
|
+
version;
|
|
23
34
|
constructor(cacheFileLocation, useCheckSum, cspellVersion, useUniversalCache) {
|
|
24
35
|
this.useCheckSum = useCheckSum;
|
|
25
36
|
this.cspellVersion = cspellVersion;
|
|
26
37
|
this.useUniversalCache = useUniversalCache;
|
|
27
|
-
this.dependencyCache = new Map();
|
|
28
|
-
this.dependencyCacheTree = {};
|
|
29
|
-
this.objectCollection = new ShallowObjectCollection();
|
|
30
|
-
this.ocCacheFileResult = new ShallowObjectCollection();
|
|
31
38
|
this.cacheFileLocation = resolvePath(cacheFileLocation);
|
|
32
39
|
this.cacheDir = dirname(this.cacheFileLocation);
|
|
33
40
|
this.fileEntryCache = createFromFile(this.cacheFileLocation, useCheckSum, useUniversalCache);
|
|
@@ -20,14 +20,21 @@ const META_DATA_VERSION_SUFFIX = '-' + META_DATA_BASE_VERSION + '-' + Object.key
|
|
|
20
20
|
* Caches cspell results on disk
|
|
21
21
|
*/
|
|
22
22
|
export class DiskCache {
|
|
23
|
+
useCheckSum;
|
|
24
|
+
cspellVersion;
|
|
25
|
+
useUniversalCache;
|
|
26
|
+
cacheFileLocation;
|
|
27
|
+
cacheDir;
|
|
28
|
+
fileEntryCache;
|
|
29
|
+
dependencyCache = new Map();
|
|
30
|
+
dependencyCacheTree = {};
|
|
31
|
+
objectCollection = new ShallowObjectCollection();
|
|
32
|
+
ocCacheFileResult = new ShallowObjectCollection();
|
|
33
|
+
version;
|
|
23
34
|
constructor(cacheFileLocation, useCheckSum, cspellVersion, useUniversalCache) {
|
|
24
35
|
this.useCheckSum = useCheckSum;
|
|
25
36
|
this.cspellVersion = cspellVersion;
|
|
26
37
|
this.useUniversalCache = useUniversalCache;
|
|
27
|
-
this.dependencyCache = new Map();
|
|
28
|
-
this.dependencyCacheTree = {};
|
|
29
|
-
this.objectCollection = new ShallowObjectCollection();
|
|
30
|
-
this.ocCacheFileResult = new ShallowObjectCollection();
|
|
31
38
|
this.cacheFileLocation = resolvePath(cacheFileLocation);
|
|
32
39
|
this.cacheDir = dirname(this.cacheFileLocation);
|
|
33
40
|
this.fileEntryCache = createFromFile(this.cacheFileLocation, useCheckSum, useUniversalCache);
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
2
|
const compare = Intl.Collator().compare;
|
|
3
3
|
export class ShallowObjectCollection {
|
|
4
|
-
|
|
5
|
-
this.tree = {};
|
|
6
|
-
}
|
|
4
|
+
tree = {};
|
|
7
5
|
get(v) {
|
|
8
6
|
if (typeof v !== 'object' || v === null) {
|
|
9
7
|
return v;
|
|
@@ -35,9 +33,7 @@ export class ShallowObjectCollection {
|
|
|
35
33
|
}
|
|
36
34
|
}
|
|
37
35
|
export class Collection {
|
|
38
|
-
|
|
39
|
-
this.col = { contains: new Map() };
|
|
40
|
-
}
|
|
36
|
+
col = { contains: new Map() };
|
|
41
37
|
/**
|
|
42
38
|
* Add a plain object to the collection.
|
|
43
39
|
* The actual object used is returned.
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
2
|
const compare = Intl.Collator().compare;
|
|
3
3
|
export class ShallowObjectCollection {
|
|
4
|
-
|
|
5
|
-
this.tree = {};
|
|
6
|
-
}
|
|
4
|
+
tree = {};
|
|
7
5
|
get(v) {
|
|
8
6
|
if (typeof v !== 'object' || v === null) {
|
|
9
7
|
return v;
|
|
@@ -35,9 +33,7 @@ export class ShallowObjectCollection {
|
|
|
35
33
|
}
|
|
36
34
|
}
|
|
37
35
|
export class Collection {
|
|
38
|
-
|
|
39
|
-
this.col = { contains: new Map() };
|
|
40
|
-
}
|
|
36
|
+
col = { contains: new Map() };
|
|
41
37
|
/**
|
|
42
38
|
* Add a plain object to the collection.
|
|
43
39
|
* The actual object used is returned.
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const FileProtocol = "file://";
|
|
1
|
+
export declare const UTF8: "utf8";
|
|
2
|
+
export declare const STDIN: "stdin";
|
|
3
|
+
export declare const STDINProtocol: "stdin://";
|
|
4
|
+
export declare const FileProtocol: "file://";
|
|
6
5
|
//# sourceMappingURL=constants.d.mts.map
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const FileProtocol = "file://";
|
|
1
|
+
export declare const UTF8: "utf8";
|
|
2
|
+
export declare const STDIN: "stdin";
|
|
3
|
+
export declare const STDINProtocol: "stdin://";
|
|
4
|
+
export declare const FileProtocol: "file://";
|
|
6
5
|
//# sourceMappingURL=constants.d.ts.map
|
package/dist/esm/util/errors.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { format } from 'util';
|
|
2
2
|
export class CheckFailed extends Error {
|
|
3
|
+
exitCode;
|
|
3
4
|
constructor(message, exitCode = 1) {
|
|
4
5
|
super(message);
|
|
5
6
|
this.exitCode = exitCode;
|
|
6
7
|
}
|
|
7
8
|
}
|
|
8
9
|
export class ApplicationError extends Error {
|
|
10
|
+
exitCode;
|
|
11
|
+
cause;
|
|
9
12
|
constructor(message, exitCode = 1, cause) {
|
|
10
13
|
super(message);
|
|
11
14
|
this.exitCode = exitCode;
|
|
@@ -13,6 +16,7 @@ export class ApplicationError extends Error {
|
|
|
13
16
|
}
|
|
14
17
|
}
|
|
15
18
|
export class IOError extends ApplicationError {
|
|
19
|
+
cause;
|
|
16
20
|
constructor(message, cause) {
|
|
17
21
|
super(message, undefined, cause);
|
|
18
22
|
this.cause = cause;
|
package/dist/esm/util/errors.mjs
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { format } from 'util';
|
|
2
2
|
export class CheckFailed extends Error {
|
|
3
|
+
exitCode;
|
|
3
4
|
constructor(message, exitCode = 1) {
|
|
4
5
|
super(message);
|
|
5
6
|
this.exitCode = exitCode;
|
|
6
7
|
}
|
|
7
8
|
}
|
|
8
9
|
export class ApplicationError extends Error {
|
|
10
|
+
exitCode;
|
|
11
|
+
cause;
|
|
9
12
|
constructor(message, exitCode = 1, cause) {
|
|
10
13
|
super(message);
|
|
11
14
|
this.exitCode = exitCode;
|
|
@@ -13,6 +16,7 @@ export class ApplicationError extends Error {
|
|
|
13
16
|
}
|
|
14
17
|
}
|
|
15
18
|
export class IOError extends ApplicationError {
|
|
19
|
+
cause;
|
|
16
20
|
constructor(message, cause) {
|
|
17
21
|
super(message, undefined, cause);
|
|
18
22
|
this.cause = cause;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import type { BufferEncoding } from 'cspell-io';
|
|
2
2
|
import type { CSpellUserSettings, Document, Issue } from 'cspell-lib';
|
|
3
3
|
import { URI } from 'vscode-uri';
|
|
4
4
|
import type { GlobOptions } from './glob.mjs';
|
|
@@ -18,6 +18,7 @@ export interface FileInfo {
|
|
|
18
18
|
text?: string;
|
|
19
19
|
errorCode?: string;
|
|
20
20
|
}
|
|
21
|
+
type Perf = Record<string, number | undefined>;
|
|
21
22
|
export interface FileResult {
|
|
22
23
|
fileInfo: FileInfo;
|
|
23
24
|
processed: boolean;
|
|
@@ -25,6 +26,7 @@ export interface FileResult {
|
|
|
25
26
|
errors: number;
|
|
26
27
|
configErrors: number;
|
|
27
28
|
elapsedTimeMs: number | undefined;
|
|
29
|
+
perf?: Perf | undefined;
|
|
28
30
|
cached?: boolean;
|
|
29
31
|
}
|
|
30
32
|
export declare function fileInfoToDocument(fileInfo: FileInfo, languageId: string | undefined, locale: string | undefined): Document;
|
|
@@ -42,7 +44,6 @@ export declare function readFile(filename: string, encoding?: BufferEncoding): P
|
|
|
42
44
|
* @param globPatterns patterns or stdin
|
|
43
45
|
*/
|
|
44
46
|
export declare function findFiles(globPatterns: string[], options: GlobOptions): Promise<string[]>;
|
|
45
|
-
export declare function calcFinalConfigInfo(configInfo: ConfigInfo, settingsFromCommandLine: CSpellUserSettings, filename: string, text: string): FileConfigInfo;
|
|
46
47
|
/**
|
|
47
48
|
* Read
|
|
48
49
|
* @param listFiles - array of file paths to read that will contain a list of files. Paths contained in each
|
|
@@ -60,4 +61,5 @@ export declare function readFileListFile(listFile: string): Promise<string[]>;
|
|
|
60
61
|
export declare function isFile(filename: string): Promise<boolean>;
|
|
61
62
|
export declare function isDir(filename: string): Promise<boolean>;
|
|
62
63
|
export declare function isNotDir(filename: string): Promise<boolean>;
|
|
64
|
+
export {};
|
|
63
65
|
//# sourceMappingURL=fileHelper.d.mts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import type { BufferEncoding } from 'cspell-io';
|
|
2
2
|
import type { CSpellUserSettings, Document, Issue } from 'cspell-lib';
|
|
3
3
|
import { URI } from 'vscode-uri';
|
|
4
4
|
import type { GlobOptions } from './glob.js';
|
|
@@ -18,6 +18,7 @@ export interface FileInfo {
|
|
|
18
18
|
text?: string;
|
|
19
19
|
errorCode?: string;
|
|
20
20
|
}
|
|
21
|
+
type Perf = Record<string, number | undefined>;
|
|
21
22
|
export interface FileResult {
|
|
22
23
|
fileInfo: FileInfo;
|
|
23
24
|
processed: boolean;
|
|
@@ -25,6 +26,7 @@ export interface FileResult {
|
|
|
25
26
|
errors: number;
|
|
26
27
|
configErrors: number;
|
|
27
28
|
elapsedTimeMs: number | undefined;
|
|
29
|
+
perf?: Perf | undefined;
|
|
28
30
|
cached?: boolean;
|
|
29
31
|
}
|
|
30
32
|
export declare function fileInfoToDocument(fileInfo: FileInfo, languageId: string | undefined, locale: string | undefined): Document;
|
|
@@ -42,7 +44,6 @@ export declare function readFile(filename: string, encoding?: BufferEncoding): P
|
|
|
42
44
|
* @param globPatterns patterns or stdin
|
|
43
45
|
*/
|
|
44
46
|
export declare function findFiles(globPatterns: string[], options: GlobOptions): Promise<string[]>;
|
|
45
|
-
export declare function calcFinalConfigInfo(configInfo: ConfigInfo, settingsFromCommandLine: CSpellUserSettings, filename: string, text: string): FileConfigInfo;
|
|
46
47
|
/**
|
|
47
48
|
* Read
|
|
48
49
|
* @param listFiles - array of file paths to read that will contain a list of files. Paths contained in each
|
|
@@ -60,4 +61,5 @@ export declare function readFileListFile(listFile: string): Promise<string[]>;
|
|
|
60
61
|
export declare function isFile(filename: string): Promise<boolean>;
|
|
61
62
|
export declare function isDir(filename: string): Promise<boolean>;
|
|
62
63
|
export declare function isNotDir(filename: string): Promise<boolean>;
|
|
64
|
+
export {};
|
|
63
65
|
//# sourceMappingURL=fileHelper.d.ts.map
|
|
@@ -97,27 +97,6 @@ export async function findFiles(globPatterns, options) {
|
|
|
97
97
|
const cwd = options.cwd || process.cwd();
|
|
98
98
|
return [...stdin, ...globResults].map((filename) => resolveFilename(filename, cwd));
|
|
99
99
|
}
|
|
100
|
-
export function calcFinalConfigInfo(configInfo, settingsFromCommandLine, filename, text) {
|
|
101
|
-
const basename = path.basename(filename);
|
|
102
|
-
const fileSettings = cspell.calcOverrideSettings(configInfo.config, path.resolve(filename));
|
|
103
|
-
const loadDefault = settingsFromCommandLine.loadDefaultConfiguration ??
|
|
104
|
-
configInfo.config.loadDefaultConfiguration ??
|
|
105
|
-
fileSettings.loadDefaultConfiguration ??
|
|
106
|
-
true;
|
|
107
|
-
const settings = cspell.mergeSettings(cspell.getDefaultSettings(loadDefault), cspell.getGlobalSettings(), fileSettings, settingsFromCommandLine);
|
|
108
|
-
const languageIds = settings.languageId
|
|
109
|
-
? Array.isArray(settings.languageId)
|
|
110
|
-
? settings.languageId
|
|
111
|
-
: [settings.languageId]
|
|
112
|
-
: cspell.getLanguageIdsForBaseFilename(basename);
|
|
113
|
-
const config = cspell.constructSettingsForText(settings, text, languageIds);
|
|
114
|
-
return {
|
|
115
|
-
configInfo: { ...configInfo, config },
|
|
116
|
-
filename,
|
|
117
|
-
text,
|
|
118
|
-
languageIds,
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
100
|
const resolveFilenames = asyncMap(resolveFilename);
|
|
122
101
|
/**
|
|
123
102
|
* Read
|
|
@@ -97,27 +97,6 @@ export async function findFiles(globPatterns, options) {
|
|
|
97
97
|
const cwd = options.cwd || process.cwd();
|
|
98
98
|
return [...stdin, ...globResults].map((filename) => resolveFilename(filename, cwd));
|
|
99
99
|
}
|
|
100
|
-
export function calcFinalConfigInfo(configInfo, settingsFromCommandLine, filename, text) {
|
|
101
|
-
const basename = path.basename(filename);
|
|
102
|
-
const fileSettings = cspell.calcOverrideSettings(configInfo.config, path.resolve(filename));
|
|
103
|
-
const loadDefault = settingsFromCommandLine.loadDefaultConfiguration ??
|
|
104
|
-
configInfo.config.loadDefaultConfiguration ??
|
|
105
|
-
fileSettings.loadDefaultConfiguration ??
|
|
106
|
-
true;
|
|
107
|
-
const settings = cspell.mergeSettings(cspell.getDefaultSettings(loadDefault), cspell.getGlobalSettings(), fileSettings, settingsFromCommandLine);
|
|
108
|
-
const languageIds = settings.languageId
|
|
109
|
-
? Array.isArray(settings.languageId)
|
|
110
|
-
? settings.languageId
|
|
111
|
-
: [settings.languageId]
|
|
112
|
-
: cspell.getLanguageIdsForBaseFilename(basename);
|
|
113
|
-
const config = cspell.constructSettingsForText(settings, text, languageIds);
|
|
114
|
-
return {
|
|
115
|
-
configInfo: { ...configInfo, config },
|
|
116
|
-
filename,
|
|
117
|
-
text,
|
|
118
|
-
languageIds,
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
100
|
const resolveFilenames = asyncMap(resolveFilename);
|
|
122
101
|
/**
|
|
123
102
|
* Read
|