cspell 9.1.2 → 9.1.5

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.
Files changed (152) hide show
  1. package/README.md +29 -21
  2. package/bin.mjs +1 -1
  3. package/dist/esm/app.d.ts +19 -0
  4. package/dist/esm/app.js +1033 -0
  5. package/dist/esm/application-D-NwS6qb.js +2573 -0
  6. package/dist/esm/application-DbOQYm56.d.ts +116 -0
  7. package/dist/esm/application.d.ts +3 -0
  8. package/dist/esm/application.js +3 -0
  9. package/dist/esm/index.d.ts +55 -0
  10. package/dist/esm/index.js +5 -0
  11. package/dist/esm/options-ChaXtdFn.d.ts +387 -0
  12. package/package.json +27 -25
  13. package/dist/esm/app.d.mts +0 -5
  14. package/dist/esm/app.mjs +0 -34
  15. package/dist/esm/application.d.mts +0 -17
  16. package/dist/esm/application.mjs +0 -99
  17. package/dist/esm/cli-reporter.d.ts +0 -38
  18. package/dist/esm/cli-reporter.js +0 -386
  19. package/dist/esm/commandCheck.d.ts +0 -3
  20. package/dist/esm/commandCheck.js +0 -52
  21. package/dist/esm/commandConfig.d.ts +0 -3
  22. package/dist/esm/commandConfig.js +0 -18
  23. package/dist/esm/commandDictionaries.d.ts +0 -3
  24. package/dist/esm/commandDictionaries.js +0 -40
  25. package/dist/esm/commandHelpers.d.ts +0 -18
  26. package/dist/esm/commandHelpers.js +0 -30
  27. package/dist/esm/commandInit.d.ts +0 -3
  28. package/dist/esm/commandInit.js +0 -25
  29. package/dist/esm/commandLink.d.ts +0 -3
  30. package/dist/esm/commandLink.js +0 -48
  31. package/dist/esm/commandLint.d.ts +0 -3
  32. package/dist/esm/commandLint.js +0 -226
  33. package/dist/esm/commandSuggestion.d.ts +0 -3
  34. package/dist/esm/commandSuggestion.js +0 -61
  35. package/dist/esm/commandTrace.d.ts +0 -3
  36. package/dist/esm/commandTrace.js +0 -91
  37. package/dist/esm/config/adjustConfig.d.ts +0 -7
  38. package/dist/esm/config/adjustConfig.js +0 -137
  39. package/dist/esm/config/config.d.ts +0 -5
  40. package/dist/esm/config/config.js +0 -18
  41. package/dist/esm/config/configInit.d.ts +0 -3
  42. package/dist/esm/config/configInit.js +0 -104
  43. package/dist/esm/config/constants.d.ts +0 -17
  44. package/dist/esm/config/constants.js +0 -23
  45. package/dist/esm/config/index.d.ts +0 -3
  46. package/dist/esm/config/index.js +0 -2
  47. package/dist/esm/config/options.d.ts +0 -62
  48. package/dist/esm/config/options.js +0 -2
  49. package/dist/esm/config/updateConfig.d.ts +0 -3
  50. package/dist/esm/config/updateConfig.js +0 -2
  51. package/dist/esm/console.d.ts +0 -25
  52. package/dist/esm/console.js +0 -53
  53. package/dist/esm/dictionaries/index.d.ts +0 -3
  54. package/dist/esm/dictionaries/index.js +0 -2
  55. package/dist/esm/dictionaries/listDictionaries.d.ts +0 -33
  56. package/dist/esm/dictionaries/listDictionaries.js +0 -131
  57. package/dist/esm/dirname.d.ts +0 -2
  58. package/dist/esm/dirname.js +0 -13
  59. package/dist/esm/emitters/DictionaryPathFormat.d.ts +0 -3
  60. package/dist/esm/emitters/DictionaryPathFormat.js +0 -12
  61. package/dist/esm/emitters/dictionaryListEmitter.d.ts +0 -19
  62. package/dist/esm/emitters/dictionaryListEmitter.js +0 -82
  63. package/dist/esm/emitters/helpers.d.ts +0 -14
  64. package/dist/esm/emitters/helpers.js +0 -67
  65. package/dist/esm/emitters/suggestionsEmitter.d.ts +0 -13
  66. package/dist/esm/emitters/suggestionsEmitter.js +0 -79
  67. package/dist/esm/emitters/traceEmitter.d.ts +0 -19
  68. package/dist/esm/emitters/traceEmitter.js +0 -87
  69. package/dist/esm/environment.d.ts +0 -39
  70. package/dist/esm/environment.js +0 -30
  71. package/dist/esm/featureFlags/featureFlags.d.ts +0 -4
  72. package/dist/esm/featureFlags/featureFlags.js +0 -21
  73. package/dist/esm/featureFlags/index.d.ts +0 -2
  74. package/dist/esm/featureFlags/index.js +0 -2
  75. package/dist/esm/index.d.mts +0 -6
  76. package/dist/esm/index.mjs +0 -4
  77. package/dist/esm/link.d.ts +0 -8
  78. package/dist/esm/link.js +0 -39
  79. package/dist/esm/lint/LintRequest.d.ts +0 -26
  80. package/dist/esm/lint/LintRequest.js +0 -83
  81. package/dist/esm/lint/index.d.ts +0 -3
  82. package/dist/esm/lint/index.js +0 -3
  83. package/dist/esm/lint/lint.d.ts +0 -8
  84. package/dist/esm/lint/lint.js +0 -515
  85. package/dist/esm/models.d.ts +0 -15
  86. package/dist/esm/models.js +0 -2
  87. package/dist/esm/options.d.ts +0 -353
  88. package/dist/esm/options.js +0 -9
  89. package/dist/esm/pkgInfo.d.ts +0 -14
  90. package/dist/esm/pkgInfo.js +0 -7
  91. package/dist/esm/repl/index.d.ts +0 -18
  92. package/dist/esm/repl/index.js +0 -52
  93. package/dist/esm/util/InMemoryReporter.d.ts +0 -31
  94. package/dist/esm/util/InMemoryReporter.js +0 -49
  95. package/dist/esm/util/LintFileResult.d.ts +0 -14
  96. package/dist/esm/util/LintFileResult.js +0 -2
  97. package/dist/esm/util/async.d.ts +0 -3
  98. package/dist/esm/util/async.js +0 -4
  99. package/dist/esm/util/cache/CSpellLintResultCache.d.ts +0 -20
  100. package/dist/esm/util/cache/CSpellLintResultCache.js +0 -2
  101. package/dist/esm/util/cache/CacheOptions.d.ts +0 -34
  102. package/dist/esm/util/cache/CacheOptions.js +0 -2
  103. package/dist/esm/util/cache/DiskCache.d.ts +0 -63
  104. package/dist/esm/util/cache/DiskCache.js +0 -214
  105. package/dist/esm/util/cache/DummyCache.d.ts +0 -11
  106. package/dist/esm/util/cache/DummyCache.js +0 -18
  107. package/dist/esm/util/cache/ObjectCollection.d.ts +0 -17
  108. package/dist/esm/util/cache/ObjectCollection.js +0 -127
  109. package/dist/esm/util/cache/createCache.d.ts +0 -31
  110. package/dist/esm/util/cache/createCache.js +0 -69
  111. package/dist/esm/util/cache/file-entry-cache.d.mts +0 -4
  112. package/dist/esm/util/cache/file-entry-cache.mjs +0 -5
  113. package/dist/esm/util/cache/fileEntryCache.d.ts +0 -9
  114. package/dist/esm/util/cache/fileEntryCache.js +0 -79
  115. package/dist/esm/util/cache/index.d.ts +0 -4
  116. package/dist/esm/util/cache/index.js +0 -2
  117. package/dist/esm/util/canUseColor.d.ts +0 -2
  118. package/dist/esm/util/canUseColor.js +0 -10
  119. package/dist/esm/util/configFileHelper.d.ts +0 -15
  120. package/dist/esm/util/configFileHelper.js +0 -43
  121. package/dist/esm/util/constants.d.ts +0 -6
  122. package/dist/esm/util/constants.js +0 -6
  123. package/dist/esm/util/errors.d.ts +0 -24
  124. package/dist/esm/util/errors.js +0 -60
  125. package/dist/esm/util/extractContext.d.ts +0 -5
  126. package/dist/esm/util/extractContext.js +0 -75
  127. package/dist/esm/util/fileHelper.d.ts +0 -44
  128. package/dist/esm/util/fileHelper.js +0 -165
  129. package/dist/esm/util/glob.d.ts +0 -45
  130. package/dist/esm/util/glob.js +0 -147
  131. package/dist/esm/util/pad.d.ts +0 -45
  132. package/dist/esm/util/pad.js +0 -191
  133. package/dist/esm/util/prefetch.d.ts +0 -2
  134. package/dist/esm/util/prefetch.js +0 -15
  135. package/dist/esm/util/reporters.d.ts +0 -30
  136. package/dist/esm/util/reporters.js +0 -209
  137. package/dist/esm/util/stdin.d.ts +0 -2
  138. package/dist/esm/util/stdin.js +0 -5
  139. package/dist/esm/util/stdinUrl.d.ts +0 -9
  140. package/dist/esm/util/stdinUrl.js +0 -26
  141. package/dist/esm/util/table.d.ts +0 -41
  142. package/dist/esm/util/table.js +0 -115
  143. package/dist/esm/util/timer.d.ts +0 -4
  144. package/dist/esm/util/timer.js +0 -9
  145. package/dist/esm/util/types.d.ts +0 -7
  146. package/dist/esm/util/types.js +0 -5
  147. package/dist/esm/util/unindent.d.ts +0 -14
  148. package/dist/esm/util/unindent.js +0 -55
  149. package/dist/esm/util/util.d.ts +0 -14
  150. package/dist/esm/util/util.js +0 -30
  151. package/dist/esm/util/writeFile.d.ts +0 -3
  152. package/dist/esm/util/writeFile.js +0 -30
@@ -1,3 +0,0 @@
1
- export type DictionaryPathFormat = 'hide' | 'long' | 'short' | 'full';
2
- export declare function isDictionaryPathFormat(value: string | undefined): value is DictionaryPathFormat;
3
- //# sourceMappingURL=DictionaryPathFormat.d.ts.map
@@ -1,12 +0,0 @@
1
- const formats = {
2
- full: true,
3
- hide: true,
4
- long: true,
5
- short: true,
6
- };
7
- export function isDictionaryPathFormat(value) {
8
- if (!value || typeof value !== 'string')
9
- return false;
10
- return value in formats;
11
- }
12
- //# sourceMappingURL=DictionaryPathFormat.js.map
@@ -1,19 +0,0 @@
1
- import type { ListDictionariesResult } from '../dictionaries/index.js';
2
- import type { DictionariesOptions } from '../options.js';
3
- import type { DictionaryPathFormat } from './DictionaryPathFormat.js';
4
- import { type PathInterface } from './helpers.js';
5
- export interface EmitDictOptions {
6
- /** current working directory */
7
- cwd: string;
8
- lineWidth?: number;
9
- dictionaryPathFormat: DictionaryPathFormat;
10
- iPath?: PathInterface;
11
- color?: boolean | undefined;
12
- options: DictionariesOptions;
13
- }
14
- export declare function emitListDictionariesResults(results: ListDictionariesResult[], options: EmitDictOptions): void;
15
- export declare function calcListDictsResultsReport(results: ListDictionariesResult[], options: EmitDictOptions): {
16
- table: string;
17
- errors: string;
18
- };
19
- //# sourceMappingURL=dictionaryListEmitter.d.ts.map
@@ -1,82 +0,0 @@
1
- import * as iPath from 'node:path';
2
- import chalk from 'chalk';
3
- import { console } from '../console.js';
4
- import { pruneAnsiTextEnd, pruneAnsiTextStart } from '../util/pad.js';
5
- import { tableToLines } from '../util/table.js';
6
- import { formatDictionaryLocation } from './helpers.js';
7
- const maxWidth = 120;
8
- export function emitListDictionariesResults(results, options) {
9
- const report = calcListDictsResultsReport(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 calcListDictsResultsReport(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.name, b.name));
25
- const header = calcHeaders(options);
26
- const rows = results.map((r) => dictTableRowToTableRow(emitDictResult(r, options)));
27
- const t = tableToLines({
28
- header,
29
- rows,
30
- terminalWidth: options.lineWidth || process.stdout.columns || maxWidth,
31
- deliminator: ' ',
32
- maxColumnWidths: {
33
- locales: 12,
34
- fileTypes: 40,
35
- },
36
- });
37
- return {
38
- table: t.map((line) => line.trimEnd()).join('\n'),
39
- errors: '',
40
- };
41
- }
42
- function calcHeaders(options) {
43
- const showLocation = options.dictionaryPathFormat !== 'hide' && (options.options.showLocation ?? true);
44
- const showLocales = options.options.showLocales ?? true;
45
- const showFileTypes = options.options.showFileTypes ?? true;
46
- const headers = [['name', 'Dictionary']];
47
- showLocales && headers.push(['locales', 'Locales']);
48
- showFileTypes && headers.push(['fileTypes', 'File Types']);
49
- showLocation && headers.push(['location', 'Dictionary Location']);
50
- return headers;
51
- }
52
- function emitDictResult(r, options) {
53
- const a = r.enabled ? '*' : ' ';
54
- const dictColor = r.enabled ? chalk.yellowBright : chalk.rgb(200, 128, 50);
55
- const n = (width) => dictColor(pruneAnsiTextEnd(r.name, width && width - a.length) + a);
56
- const c = colorize(chalk.white);
57
- const locales = (width) => c(pruneAnsiTextEnd(r.locales?.join(',') || '', width));
58
- const fileTypes = (width) => c(pruneAnsiTextEnd(r.fileTypes?.join(',') || '', width));
59
- if (!r.path) {
60
- return {
61
- name: n,
62
- location: c(r.inline?.join(', ') || ''),
63
- locales,
64
- fileTypes,
65
- };
66
- }
67
- return {
68
- name: n,
69
- location: (widthSrc) => c((r.path &&
70
- pruneAnsiTextStart(formatDictionaryLocation(r.path, widthSrc ?? maxWidth, { iPath, ...options }), widthSrc ?? maxWidth)) ||
71
- ''),
72
- locales,
73
- fileTypes,
74
- };
75
- }
76
- function dictTableRowToTableRow(row) {
77
- return Object.fromEntries(Object.entries(row));
78
- }
79
- function colorize(fn) {
80
- return (s) => (s ? fn(s) : '');
81
- }
82
- //# sourceMappingURL=dictionaryListEmitter.js.map
@@ -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
@@ -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,4 +0,0 @@
1
- import type { FeatureFlags } from 'cspell-lib';
2
- export declare function getFeatureFlags(): FeatureFlags;
3
- export declare function parseFeatureFlags(flags: string[] | undefined, featureFlags?: FeatureFlags): FeatureFlags;
4
- //# sourceMappingURL=featureFlags.d.ts.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
@@ -1,2 +0,0 @@
1
- export { getFeatureFlags, parseFeatureFlags } from './featureFlags.js';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1,2 +0,0 @@
1
- export { getFeatureFlags, parseFeatureFlags } from './featureFlags.js';
2
- //# sourceMappingURL=index.js.map
@@ -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
@@ -1,4 +0,0 @@
1
- export * from './application.mjs';
2
- export { getReporter as getDefaultReporter } from './cli-reporter.js';
3
- export * from '@cspell/cspell-types';
4
- //# sourceMappingURL=index.mjs.map
@@ -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