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
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { DictionaryPathFormat } from './DictionaryPathFormat.js';
|
|
2
|
-
export interface PathInterface {
|
|
3
|
-
relative(from: string, to: string): string;
|
|
4
|
-
basename(path: string): string;
|
|
5
|
-
sep: string;
|
|
6
|
-
}
|
|
7
|
-
export declare function trimMidPath(s: string, w: number, sep: string): string;
|
|
8
|
-
export declare function trimMid(s: string, w: number): string;
|
|
9
|
-
export declare function formatDictionaryLocation(dictSource: string, maxWidth: number, { cwd, dictionaryPathFormat: format, iPath, }: {
|
|
10
|
-
cwd: string;
|
|
11
|
-
dictionaryPathFormat: DictionaryPathFormat;
|
|
12
|
-
iPath: PathInterface;
|
|
13
|
-
}): string;
|
|
14
|
-
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
export function trimMidPath(s, w, sep) {
|
|
2
|
-
if (s.length <= w)
|
|
3
|
-
return s;
|
|
4
|
-
const parts = s.split(sep);
|
|
5
|
-
if (parts[parts.length - 1].length > w)
|
|
6
|
-
return trimMid(s, w);
|
|
7
|
-
function join(left, right) {
|
|
8
|
-
// if (left === right) return parts.join(sep);
|
|
9
|
-
return [...parts.slice(0, left), '…', ...parts.slice(right)].join(sep);
|
|
10
|
-
}
|
|
11
|
-
let left = 0, right = parts.length, last = '';
|
|
12
|
-
for (let i = 0; i < parts.length; ++i) {
|
|
13
|
-
const incLeft = i & 1 ? 1 : 0;
|
|
14
|
-
const incRight = incLeft ? 0 : -1;
|
|
15
|
-
const next = join(left + incLeft, right + incRight);
|
|
16
|
-
if (next.length > w)
|
|
17
|
-
break;
|
|
18
|
-
left += incLeft;
|
|
19
|
-
right += incRight;
|
|
20
|
-
last = next;
|
|
21
|
-
}
|
|
22
|
-
for (let i = left + 1; i < right; ++i) {
|
|
23
|
-
const next = join(i, right);
|
|
24
|
-
if (next.length > w)
|
|
25
|
-
break;
|
|
26
|
-
last = next;
|
|
27
|
-
}
|
|
28
|
-
for (let i = right - 1; i > left; --i) {
|
|
29
|
-
const next = join(left, i);
|
|
30
|
-
if (next.length > w)
|
|
31
|
-
break;
|
|
32
|
-
last = next;
|
|
33
|
-
}
|
|
34
|
-
return last || trimMid(s, w);
|
|
35
|
-
}
|
|
36
|
-
export function trimMid(s, w) {
|
|
37
|
-
s = s.trim();
|
|
38
|
-
if (s.length <= w) {
|
|
39
|
-
return s;
|
|
40
|
-
}
|
|
41
|
-
const l = Math.floor((w - 1) / 2);
|
|
42
|
-
const r = Math.ceil((w - 1) / 2);
|
|
43
|
-
return s.slice(0, l) + '…' + s.slice(-r);
|
|
44
|
-
}
|
|
45
|
-
export function formatDictionaryLocation(dictSource, maxWidth, { cwd, dictionaryPathFormat: format, iPath, }) {
|
|
46
|
-
let relPath = cwd ? iPath.relative(cwd, dictSource) : dictSource;
|
|
47
|
-
const idxNodeModule = relPath.lastIndexOf('node_modules');
|
|
48
|
-
const isNodeModule = idxNodeModule >= 0;
|
|
49
|
-
if (format === 'hide')
|
|
50
|
-
return '';
|
|
51
|
-
if (format === 'short') {
|
|
52
|
-
const prefix = isNodeModule
|
|
53
|
-
? '[node_modules]/'
|
|
54
|
-
: relPath.startsWith('..' + iPath.sep + '..')
|
|
55
|
-
? '…/'
|
|
56
|
-
: relPath.startsWith('..' + iPath.sep)
|
|
57
|
-
? '../'
|
|
58
|
-
: '';
|
|
59
|
-
return prefix + iPath.basename(dictSource);
|
|
60
|
-
}
|
|
61
|
-
if (format === 'full')
|
|
62
|
-
return dictSource;
|
|
63
|
-
relPath = isNodeModule ? relPath.slice(idxNodeModule) : relPath;
|
|
64
|
-
const usePath = relPath.length < dictSource.length ? relPath : dictSource;
|
|
65
|
-
return trimMidPath(usePath, maxWidth, iPath.sep);
|
|
66
|
-
}
|
|
67
|
-
//# sourceMappingURL=helpers.js.map
|
|
@@ -1,13 +0,0 @@
|
|
|
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 interface TimedSuggestionsForWordResult extends SuggestionsForWordResult {
|
|
10
|
-
elapsedTimeMs?: number;
|
|
11
|
-
}
|
|
12
|
-
export declare function emitSuggestionResult(result: TimedSuggestionsForWordResult, options: EmitSuggestionOptions): void;
|
|
13
|
-
//# sourceMappingURL=suggestionsEmitter.d.ts.map
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
import { console } from '../console.js';
|
|
3
|
-
import { padLeft, padWidth, width } from '../util/pad.js';
|
|
4
|
-
// eslint-disable-next-line no-misleading-character-class
|
|
5
|
-
const regExpRTL = /([ \u0591-\u07FF\uFB1D-\uFDFD\uFE70-\uFEFC]+)/g;
|
|
6
|
-
function reverseRtlText(s) {
|
|
7
|
-
return s.replaceAll(regExpRTL, (s) => [...s].reverse().join(''));
|
|
8
|
-
}
|
|
9
|
-
export function emitSuggestionResult(result, options) {
|
|
10
|
-
const { word, suggestions } = result;
|
|
11
|
-
const { verbose, output = console } = options;
|
|
12
|
-
const elapsed = verbose && verbose > 1 && result.elapsedTimeMs ? ` ${result.elapsedTimeMs.toFixed(2)} ms` : '';
|
|
13
|
-
const rWord = reverseRtlText(word);
|
|
14
|
-
const wordEx = rWord !== word ? ` (${chalk.yellow(rWord)})` : '';
|
|
15
|
-
output.log((word ? chalk.yellow(word) + wordEx : chalk.yellow('<empty>')) + ':' + elapsed);
|
|
16
|
-
if (!suggestions.length) {
|
|
17
|
-
console.log(chalk.yellow(' <no suggestions>'));
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
function handleRtl(word) {
|
|
21
|
-
const r = reverseRtlText(word);
|
|
22
|
-
return r === word ? word : `${word} (${r})`;
|
|
23
|
-
}
|
|
24
|
-
if (verbose) {
|
|
25
|
-
const mappedSugs = suggestions.map((s) => ({
|
|
26
|
-
...s,
|
|
27
|
-
w: handleRtl(s.compoundWord || s.wordAdjustedToMatchCase || s.word),
|
|
28
|
-
}));
|
|
29
|
-
const sugWidths = mappedSugs.map((s) => width(s.w));
|
|
30
|
-
const maxWidth = sugWidths.reduce((max, len) => Math.max(max, len), 0);
|
|
31
|
-
for (const sug of mappedSugs) {
|
|
32
|
-
const { cost, dictionaries, w } = sug;
|
|
33
|
-
const padding = ' '.repeat(padWidth(w, maxWidth));
|
|
34
|
-
const forbid = sug.forbidden && sug.isPreferred
|
|
35
|
-
? chalk.red('*')
|
|
36
|
-
: sug.forbidden
|
|
37
|
-
? chalk.red('X')
|
|
38
|
-
: sug.isPreferred
|
|
39
|
-
? chalk.yellow('*')
|
|
40
|
-
: ' ';
|
|
41
|
-
const ignore = sug.noSuggest ? chalk.yellow('N') : ' ';
|
|
42
|
-
const strCost = padLeft(cost.toString(10), 4);
|
|
43
|
-
const dicts = dictionaries.map((n) => chalk.gray(n)).join(', ');
|
|
44
|
-
output.log(` - ${formatWord(w, sug)}${padding} ${forbid}${ignore} - ${chalk.yellow(strCost)} ${dicts}`);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
const mappedSugs = suggestions.map((s) => ({ ...s, word: handleRtl(s.wordAdjustedToMatchCase || s.word) }));
|
|
49
|
-
for (const r of mappedSugs) {
|
|
50
|
-
output.log(` - ${formatWordSingle(r)}`);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
function formatWord(word, r) {
|
|
55
|
-
return r.forbidden || r.noSuggest
|
|
56
|
-
? chalk.gray(chalk.strikethrough(word))
|
|
57
|
-
: word === r.wordAdjustedToMatchCase
|
|
58
|
-
? diff(word, r.word)
|
|
59
|
-
: word;
|
|
60
|
-
}
|
|
61
|
-
function diff(wordA, wordB) {
|
|
62
|
-
const a = [...wordA];
|
|
63
|
-
const b = [...wordB];
|
|
64
|
-
const parts = [];
|
|
65
|
-
for (let idx = 0; idx < a.length; ++idx) {
|
|
66
|
-
const aa = a[idx];
|
|
67
|
-
const bb = b[idx];
|
|
68
|
-
parts.push(aa === bb ? aa : chalk.yellow(aa));
|
|
69
|
-
}
|
|
70
|
-
return parts.join('');
|
|
71
|
-
}
|
|
72
|
-
function formatWordSingle(s) {
|
|
73
|
-
let word = formatWord(s.word, s);
|
|
74
|
-
word = s.forbidden ? word + chalk.red(' X') : word;
|
|
75
|
-
word = s.noSuggest ? word + chalk.yellow(' Not suggested.') : word;
|
|
76
|
-
word = s.isPreferred ? chalk.yellow(word + ' *') : word;
|
|
77
|
-
return word;
|
|
78
|
-
}
|
|
79
|
-
//# sourceMappingURL=suggestionsEmitter.js.map
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { TraceResult } from '../application.mjs';
|
|
2
|
-
import type { DictionaryPathFormat } from './DictionaryPathFormat.js';
|
|
3
|
-
import { type PathInterface } from './helpers.js';
|
|
4
|
-
export interface EmitTraceOptions {
|
|
5
|
-
/** current working directory */
|
|
6
|
-
cwd: string;
|
|
7
|
-
lineWidth?: number;
|
|
8
|
-
dictionaryPathFormat: DictionaryPathFormat;
|
|
9
|
-
iPath?: PathInterface;
|
|
10
|
-
prefix?: string;
|
|
11
|
-
showWordFound?: boolean;
|
|
12
|
-
color?: boolean | undefined;
|
|
13
|
-
}
|
|
14
|
-
export declare function emitTraceResults(word: string, found: boolean, results: TraceResult[], options: EmitTraceOptions): void;
|
|
15
|
-
export declare function calcTraceResultsReport(word: string, found: boolean, results: TraceResult[], options: EmitTraceOptions): {
|
|
16
|
-
table: string;
|
|
17
|
-
errors: string;
|
|
18
|
-
};
|
|
19
|
-
//# sourceMappingURL=traceEmitter.d.ts.map
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import * as iPath from 'node:path';
|
|
2
|
-
import chalk from 'chalk';
|
|
3
|
-
import { console } from '../console.js';
|
|
4
|
-
import { tableToLines } from '../util/table.js';
|
|
5
|
-
import { formatDictionaryLocation } from './helpers.js';
|
|
6
|
-
const maxWidth = 120;
|
|
7
|
-
const colWidthDictionaryName = 20;
|
|
8
|
-
export function emitTraceResults(word, found, results, options) {
|
|
9
|
-
const report = calcTraceResultsReport(word, found, results, options);
|
|
10
|
-
console.log(report.table);
|
|
11
|
-
if (report.errors) {
|
|
12
|
-
console.error('Errors:');
|
|
13
|
-
console.error(report.errors);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
export function calcTraceResultsReport(word, found, results, options) {
|
|
17
|
-
if (options.color === true) {
|
|
18
|
-
chalk.level = 2;
|
|
19
|
-
}
|
|
20
|
-
else if (options.color === false) {
|
|
21
|
-
chalk.level = 0;
|
|
22
|
-
}
|
|
23
|
-
const col = new Intl.Collator();
|
|
24
|
-
results.sort((a, b) => col.compare(a.dictName, b.dictName));
|
|
25
|
-
options.showWordFound && console.log(`${options.prefix || ''}${word}: ${found ? 'Found' : 'Not Found'}`);
|
|
26
|
-
const header = emitHeader(options.dictionaryPathFormat !== 'hide');
|
|
27
|
-
const rows = results.map((r) => emitTraceResult(r, options));
|
|
28
|
-
const t = tableToLines({
|
|
29
|
-
header,
|
|
30
|
-
rows,
|
|
31
|
-
terminalWidth: options.lineWidth || process.stdout.columns || maxWidth,
|
|
32
|
-
deliminator: ' ',
|
|
33
|
-
});
|
|
34
|
-
return {
|
|
35
|
-
table: t.map((line) => line.trimEnd()).join('\n'),
|
|
36
|
-
errors: emitErrors(results).join('\n'),
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
function emitHeader(location) {
|
|
40
|
-
const headers = ['Word', 'F', 'Dictionary'];
|
|
41
|
-
location && headers.push('Dictionary Location');
|
|
42
|
-
return headers;
|
|
43
|
-
}
|
|
44
|
-
function emitTraceResult(r, options) {
|
|
45
|
-
const errors = !!r.errors?.length;
|
|
46
|
-
const word = r.foundWord || r.word;
|
|
47
|
-
const cWord = word.replaceAll('+', chalk.yellow('+'));
|
|
48
|
-
const sug = r.preferredSuggestions?.map((s) => chalk.yellowBright(s)).join(', ') || '';
|
|
49
|
-
const w = (r.forbidden ? chalk.red(cWord) : chalk.green(cWord)) + (sug ? `->(${sug})` : '');
|
|
50
|
-
const f = calcFoundChar(r);
|
|
51
|
-
const a = r.dictActive ? '*' : ' ';
|
|
52
|
-
const dictName = r.dictName.slice(0, colWidthDictionaryName - 1) + a;
|
|
53
|
-
const dictColor = r.dictActive ? chalk.yellowBright : chalk.rgb(200, 128, 50);
|
|
54
|
-
const n = dictColor(dictName);
|
|
55
|
-
const c = colorize(errors ? chalk.red : chalk.white);
|
|
56
|
-
return [
|
|
57
|
-
w,
|
|
58
|
-
f,
|
|
59
|
-
n,
|
|
60
|
-
(widthSrc) => c(formatDictionaryLocation(r.dictSource, widthSrc ?? maxWidth, { iPath, ...options })),
|
|
61
|
-
];
|
|
62
|
-
}
|
|
63
|
-
function emitErrors(results) {
|
|
64
|
-
const errorResults = results.filter((r) => r.errors?.length);
|
|
65
|
-
return errorResults.map((r) => {
|
|
66
|
-
const errors = r.errors?.map((e) => e.message)?.join('\n\t') || '';
|
|
67
|
-
return chalk.bold(r.dictName) + '\n\t' + chalk.red(errors);
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
function calcFoundChar(r) {
|
|
71
|
-
const errors = r.errors?.map((e) => e.message)?.join('\n\t') || '';
|
|
72
|
-
let color = chalk.dim;
|
|
73
|
-
color = r.found ? chalk.whiteBright : color;
|
|
74
|
-
color = r.forbidden ? chalk.red : color;
|
|
75
|
-
color = r.noSuggest ? chalk.yellowBright : color;
|
|
76
|
-
color = errors ? chalk.red : color;
|
|
77
|
-
let char = '-';
|
|
78
|
-
char = r.found ? '*' : char;
|
|
79
|
-
char = r.forbidden ? '!' : char;
|
|
80
|
-
char = r.noSuggest ? 'I' : char;
|
|
81
|
-
char = errors ? 'X' : char;
|
|
82
|
-
return color(char);
|
|
83
|
-
}
|
|
84
|
-
function colorize(fn) {
|
|
85
|
-
return (s) => (s ? fn(s) : '');
|
|
86
|
-
}
|
|
87
|
-
//# sourceMappingURL=traceEmitter.js.map
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
export interface CSpellEnvironmentVariables {
|
|
2
|
-
/**
|
|
3
|
-
* Enable logging ALL dictionary requests.
|
|
4
|
-
* Acceptable values are: 'true', 'false', 't', 'f', 'on', 'off', 'yes', 'no', '1', '0'
|
|
5
|
-
*/
|
|
6
|
-
CSPELL_ENABLE_DICTIONARY_LOGGING?: string;
|
|
7
|
-
/**
|
|
8
|
-
* The path to the dictionary log file.
|
|
9
|
-
*/
|
|
10
|
-
CSPELL_ENABLE_DICTIONARY_LOG_FILE?: string;
|
|
11
|
-
/**
|
|
12
|
-
* A Csv list of fields to log.
|
|
13
|
-
* Fields:
|
|
14
|
-
* - time: the time the check was made in milliseconds
|
|
15
|
-
* - word: the word being checked
|
|
16
|
-
* - value: the result of the check
|
|
17
|
-
*/
|
|
18
|
-
CSPELL_ENABLE_DICTIONARY_LOG_FIELDS?: string;
|
|
19
|
-
CSPELL_GLOB_ROOT?: string;
|
|
20
|
-
/**
|
|
21
|
-
* Path to a specific CSpell config file.
|
|
22
|
-
*/
|
|
23
|
-
CSPELL_CONFIG_PATH?: string;
|
|
24
|
-
/**
|
|
25
|
-
* Path to the default CSpell config file, used if no other config is found.
|
|
26
|
-
*/
|
|
27
|
-
CSPELL_DEFAULT_CONFIG_PATH?: string;
|
|
28
|
-
}
|
|
29
|
-
export type EnvironmentKeys = keyof CSpellEnvironmentVariables;
|
|
30
|
-
type EnvironmentKeyNames = {
|
|
31
|
-
[K in EnvironmentKeys]: K;
|
|
32
|
-
};
|
|
33
|
-
export declare const environmentKeys: EnvironmentKeyNames;
|
|
34
|
-
export declare function getEnvironmentVariables(): CSpellEnvironmentVariables;
|
|
35
|
-
export declare function setEnvironmentVariable<K extends EnvironmentKeys>(key: K, value: CSpellEnvironmentVariables[K]): void;
|
|
36
|
-
export declare function getEnvironmentVariable<K extends EnvironmentKeys>(key: K): CSpellEnvironmentVariables[K] | undefined;
|
|
37
|
-
export declare function truthy(value: string | undefined): boolean;
|
|
38
|
-
export {};
|
|
39
|
-
//# sourceMappingURL=environment.d.ts.map
|
package/dist/esm/environment.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
export const environmentKeys = {
|
|
2
|
-
CSPELL_ENABLE_DICTIONARY_LOGGING: 'CSPELL_ENABLE_DICTIONARY_LOGGING',
|
|
3
|
-
CSPELL_ENABLE_DICTIONARY_LOG_FILE: 'CSPELL_ENABLE_DICTIONARY_LOG_FILE',
|
|
4
|
-
CSPELL_ENABLE_DICTIONARY_LOG_FIELDS: 'CSPELL_ENABLE_DICTIONARY_LOG_FIELDS',
|
|
5
|
-
CSPELL_GLOB_ROOT: 'CSPELL_GLOB_ROOT',
|
|
6
|
-
CSPELL_CONFIG_PATH: 'CSPELL_CONFIG_PATH',
|
|
7
|
-
CSPELL_DEFAULT_CONFIG_PATH: 'CSPELL_DEFAULT_CONFIG_PATH',
|
|
8
|
-
};
|
|
9
|
-
export function getEnvironmentVariables() {
|
|
10
|
-
return process.env;
|
|
11
|
-
}
|
|
12
|
-
export function setEnvironmentVariable(key, value) {
|
|
13
|
-
process.env[key] = value;
|
|
14
|
-
}
|
|
15
|
-
export function getEnvironmentVariable(key) {
|
|
16
|
-
return process.env[key];
|
|
17
|
-
}
|
|
18
|
-
export function truthy(value) {
|
|
19
|
-
switch (value?.toLowerCase().trim()) {
|
|
20
|
-
case 't':
|
|
21
|
-
case 'true':
|
|
22
|
-
case 'on':
|
|
23
|
-
case 'yes':
|
|
24
|
-
case '1': {
|
|
25
|
-
return true;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
//# sourceMappingURL=environment.js.map
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { getSystemFeatureFlags } from 'cspell-lib';
|
|
2
|
-
import { console } from '../console.js';
|
|
3
|
-
export function getFeatureFlags() {
|
|
4
|
-
return getSystemFeatureFlags();
|
|
5
|
-
}
|
|
6
|
-
export function parseFeatureFlags(flags, featureFlags = getFeatureFlags()) {
|
|
7
|
-
if (!flags)
|
|
8
|
-
return featureFlags;
|
|
9
|
-
const flagsKvP = flags.map((f) => f.split(':', 2));
|
|
10
|
-
for (const flag of flagsKvP) {
|
|
11
|
-
const [name, value] = flag;
|
|
12
|
-
try {
|
|
13
|
-
featureFlags.setFlag(name, value);
|
|
14
|
-
}
|
|
15
|
-
catch {
|
|
16
|
-
console.warn(`Unknown flag: "${name}"`);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return featureFlags;
|
|
20
|
-
}
|
|
21
|
-
//# sourceMappingURL=featureFlags.js.map
|
package/dist/esm/index.d.mts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export * from './application.mjs';
|
|
2
|
-
export { getReporter as getDefaultReporter } from './cli-reporter.js';
|
|
3
|
-
export type { CSpellReporterConfiguration, CSpellReporterModule } from './models.js';
|
|
4
|
-
export type { BaseOptions, LinterCliOptions as CSpellApplicationOptions, TraceOptions } from './options.js';
|
|
5
|
-
export * from '@cspell/cspell-types';
|
|
6
|
-
//# sourceMappingURL=index.d.mts.map
|
package/dist/esm/index.mjs
DELETED
package/dist/esm/link.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Link } from 'cspell-lib';
|
|
2
|
-
import type { Table } from './util/table.js';
|
|
3
|
-
export declare const listGlobalImports: typeof Link.listGlobalImports;
|
|
4
|
-
export declare const addPathsToGlobalImports: typeof Link.addPathsToGlobalImports;
|
|
5
|
-
export declare const removePathsFromGlobalImports: typeof Link.removePathsFromGlobalImports;
|
|
6
|
-
export declare function listGlobalImportsResultToTable(results: Link.ListGlobalImportsResult[]): Table;
|
|
7
|
-
export declare function addPathsToGlobalImportsResultToTable(results: Link.AddPathsToGlobalImportsResults): Table;
|
|
8
|
-
//# sourceMappingURL=link.d.ts.map
|
package/dist/esm/link.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
import { Link } from 'cspell-lib';
|
|
3
|
-
export const listGlobalImports = Link.listGlobalImports;
|
|
4
|
-
export const addPathsToGlobalImports = Link.addPathsToGlobalImports;
|
|
5
|
-
export const removePathsFromGlobalImports = Link.removePathsFromGlobalImports;
|
|
6
|
-
export function listGlobalImportsResultToTable(results) {
|
|
7
|
-
const header = ['id', 'package', 'name', 'filename', 'dictionaries', 'errors'];
|
|
8
|
-
const decorate = (isError) => (isError ? (s) => chalk.red(s) : (s) => s);
|
|
9
|
-
function toColumns(r) {
|
|
10
|
-
return [
|
|
11
|
-
r.id,
|
|
12
|
-
r.package?.name,
|
|
13
|
-
r.name,
|
|
14
|
-
r.filename,
|
|
15
|
-
r.dictionaryDefinitions?.map((def) => def.name).join(', '),
|
|
16
|
-
r.error ? 'Failed to read file.' : '',
|
|
17
|
-
]
|
|
18
|
-
.map((c) => c || '')
|
|
19
|
-
.map(decorate(!!r.error));
|
|
20
|
-
}
|
|
21
|
-
return {
|
|
22
|
-
header,
|
|
23
|
-
rows: results.map(toColumns),
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
export function addPathsToGlobalImportsResultToTable(results) {
|
|
27
|
-
const header = ['filename', 'errors'];
|
|
28
|
-
const decorate = (isError) => (isError ? (s) => chalk.red(s) : (s) => s);
|
|
29
|
-
function toColumns(r) {
|
|
30
|
-
return [r.resolvedToFilename || r.filename, r.error ? 'Failed to read file.' : '']
|
|
31
|
-
.map((c) => c || '')
|
|
32
|
-
.map(decorate(!!r.error));
|
|
33
|
-
}
|
|
34
|
-
return {
|
|
35
|
-
header,
|
|
36
|
-
rows: results.resolvedSettings.map(toColumns),
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
//# sourceMappingURL=link.js.map
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { type CSpellUserSettings, type UnknownWordsConfiguration } from '@cspell/cspell-types';
|
|
2
|
-
import type { CSpellConfigFile, LinterCliOptions, LinterOptions } from '../options.js';
|
|
3
|
-
import type { GlobSrcInfo } from '../util/glob.js';
|
|
4
|
-
import type { FinalizedReporter } from '../util/reporters.js';
|
|
5
|
-
interface Deprecated {
|
|
6
|
-
fileLists?: LinterOptions['fileList'];
|
|
7
|
-
local?: LinterOptions['locale'];
|
|
8
|
-
}
|
|
9
|
-
export declare class LintRequest {
|
|
10
|
-
readonly fileGlobs: string[];
|
|
11
|
-
readonly options: LinterCliOptions & Deprecated;
|
|
12
|
-
readonly reporter: FinalizedReporter;
|
|
13
|
-
readonly locale: string;
|
|
14
|
-
readonly configFile: string | CSpellConfigFile | undefined;
|
|
15
|
-
readonly excludes: GlobSrcInfo[];
|
|
16
|
-
readonly root: string;
|
|
17
|
-
readonly showContext: number;
|
|
18
|
-
readonly enableGlobDot: boolean | undefined;
|
|
19
|
-
readonly fileLists: string[];
|
|
20
|
-
readonly files: string[] | undefined;
|
|
21
|
-
readonly cspellSettingsFromCliOptions: CSpellUserSettings;
|
|
22
|
-
constructor(fileGlobs: string[], options: LinterCliOptions & Deprecated, reporter: FinalizedReporter);
|
|
23
|
-
}
|
|
24
|
-
export declare function extractUnknownWordsConfig(options: LinterCliOptions): UnknownWordsConfiguration;
|
|
25
|
-
export {};
|
|
26
|
-
//# sourceMappingURL=LintRequest.d.ts.map
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import * as path from 'node:path';
|
|
2
|
-
import { unknownWordsChoices } from '@cspell/cspell-types';
|
|
3
|
-
import { calcExcludeGlobInfo } from '../util/glob.js';
|
|
4
|
-
const defaultContextRange = 20;
|
|
5
|
-
export class LintRequest {
|
|
6
|
-
fileGlobs;
|
|
7
|
-
options;
|
|
8
|
-
reporter;
|
|
9
|
-
locale;
|
|
10
|
-
configFile;
|
|
11
|
-
excludes;
|
|
12
|
-
root;
|
|
13
|
-
showContext;
|
|
14
|
-
enableGlobDot;
|
|
15
|
-
fileLists;
|
|
16
|
-
files;
|
|
17
|
-
cspellSettingsFromCliOptions;
|
|
18
|
-
constructor(fileGlobs, options, reporter) {
|
|
19
|
-
this.fileGlobs = fileGlobs;
|
|
20
|
-
this.options = options;
|
|
21
|
-
this.reporter = reporter;
|
|
22
|
-
this.root = path.resolve(options.root || process.cwd());
|
|
23
|
-
this.configFile = options.config;
|
|
24
|
-
this.excludes = calcExcludeGlobInfo(this.root, options.exclude);
|
|
25
|
-
this.locale = options.locale ?? options.local ?? '';
|
|
26
|
-
this.enableGlobDot = options.dot;
|
|
27
|
-
this.showContext = Math.max(options.showContext === true ? defaultContextRange : options.showContext ? options.showContext : 0, 0);
|
|
28
|
-
this.fileLists = (options.fileList ?? options.fileLists) || [];
|
|
29
|
-
this.files = mergeFiles(options.file, options.files);
|
|
30
|
-
const noConfigSearch = options.configSearch === false ? true : options.configSearch === true ? false : undefined;
|
|
31
|
-
const dictionaries = [
|
|
32
|
-
...(options.disableDictionary ?? []).map((d) => `!${d}`), // first disable dictionaries
|
|
33
|
-
...(options.dictionary ?? []).map((d) => `!!${d}`), // Use `!!` to ensure dictionaries are enabled
|
|
34
|
-
];
|
|
35
|
-
const languageSettings = [
|
|
36
|
-
// Use `*` to match all languages and locales
|
|
37
|
-
{ languageId: '*', locale: '*', dictionaries },
|
|
38
|
-
];
|
|
39
|
-
this.cspellSettingsFromCliOptions = {
|
|
40
|
-
...(noConfigSearch !== undefined ? { noConfigSearch } : {}),
|
|
41
|
-
...extractUnknownWordsConfig(options),
|
|
42
|
-
languageSettings,
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
function mergeFiles(a, b) {
|
|
47
|
-
const files = merge(a, b);
|
|
48
|
-
if (!files)
|
|
49
|
-
return undefined;
|
|
50
|
-
return [...new Set(files.flatMap((a) => a.split('\n').map((a) => a.trim())).filter((a) => !!a))];
|
|
51
|
-
}
|
|
52
|
-
function merge(a, b) {
|
|
53
|
-
if (!a)
|
|
54
|
-
return b;
|
|
55
|
-
if (!b)
|
|
56
|
-
return a;
|
|
57
|
-
return [...a, ...b];
|
|
58
|
-
}
|
|
59
|
-
export function extractUnknownWordsConfig(options) {
|
|
60
|
-
const config = {};
|
|
61
|
-
if (!options.report)
|
|
62
|
-
return config;
|
|
63
|
-
switch (options.report) {
|
|
64
|
-
case 'all': {
|
|
65
|
-
config.unknownWords = unknownWordsChoices.ReportAll;
|
|
66
|
-
break;
|
|
67
|
-
}
|
|
68
|
-
case 'simple': {
|
|
69
|
-
config.unknownWords = unknownWordsChoices.ReportSimple;
|
|
70
|
-
break;
|
|
71
|
-
}
|
|
72
|
-
case 'typos': {
|
|
73
|
-
config.unknownWords = unknownWordsChoices.ReportCommonTypos;
|
|
74
|
-
break;
|
|
75
|
-
}
|
|
76
|
-
case 'flagged': {
|
|
77
|
-
config.unknownWords = unknownWordsChoices.ReportFlagged;
|
|
78
|
-
break;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
return config;
|
|
82
|
-
}
|
|
83
|
-
//# sourceMappingURL=LintRequest.js.map
|
package/dist/esm/lint/index.d.ts
DELETED
package/dist/esm/lint/index.js
DELETED
package/dist/esm/lint/lint.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { RunResult } from '@cspell/cspell-types';
|
|
2
|
-
import type { LintRequest } from './LintRequest.js';
|
|
3
|
-
export declare function runLint(cfg: LintRequest): Promise<RunResult>;
|
|
4
|
-
export declare class LinterError extends Error {
|
|
5
|
-
constructor(message: string);
|
|
6
|
-
toString(): string;
|
|
7
|
-
}
|
|
8
|
-
//# sourceMappingURL=lint.d.ts.map
|