cspell 7.0.0-alpha.1 → 7.0.1-alpha.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.d.mts +1 -1
- package/dist/esm/cli-reporter.mjs +2 -1
- package/dist/esm/util/constants.d.mts +1 -1
- package/dist/esm/util/fileHelper.d.mts +1 -1
- package/dist/lib/file-entry-cache.cjs +3 -2
- package/dist/lib/file-entry-cache.d.cts +2 -2
- package/dist/lib/pkgInfo.cjs +3 -25
- package/package.json +31 -36
- package/bin.js +0 -16
- package/dist/cjs/app.d.ts +0 -5
- package/dist/cjs/app.js +0 -50
- package/dist/cjs/application.d.ts +0 -16
- package/dist/cjs/application.js +0 -121
- package/dist/cjs/cli-reporter.d.ts +0 -16
- package/dist/cjs/cli-reporter.js +0 -247
- package/dist/cjs/commandCheck.d.ts +0 -3
- package/dist/cjs/commandCheck.js +0 -78
- package/dist/cjs/commandLink.d.ts +0 -3
- package/dist/cjs/commandLink.js +0 -51
- package/dist/cjs/commandLint.d.ts +0 -3
- package/dist/cjs/commandLint.js +0 -150
- package/dist/cjs/commandSuggestion.d.ts +0 -3
- package/dist/cjs/commandSuggestion.js +0 -88
- package/dist/cjs/commandTrace.d.ts +0 -3
- package/dist/cjs/commandTrace.js +0 -87
- package/dist/cjs/emitters/DictionaryPathFormat.d.ts +0 -3
- package/dist/cjs/emitters/DictionaryPathFormat.js +0 -16
- package/dist/cjs/emitters/suggestionsEmitter.d.ts +0 -13
- package/dist/cjs/emitters/suggestionsEmitter.js +0 -84
- package/dist/cjs/emitters/traceEmitter.d.ts +0 -21
- package/dist/cjs/emitters/traceEmitter.js +0 -171
- package/dist/cjs/featureFlags/featureFlags.d.ts +0 -4
- package/dist/cjs/featureFlags/featureFlags.js +0 -25
- package/dist/cjs/featureFlags/index.d.ts +0 -2
- package/dist/cjs/featureFlags/index.js +0 -7
- package/dist/cjs/index.d.ts +0 -5
- package/dist/cjs/index.js +0 -22
- package/dist/cjs/link.d.ts +0 -8
- package/dist/cjs/link.js +0 -47
- package/dist/cjs/lint/LintRequest.d.ts +0 -23
- package/dist/cjs/lint/LintRequest.js +0 -48
- package/dist/cjs/lint/index.d.ts +0 -3
- package/dist/cjs/lint/index.js +0 -8
- package/dist/cjs/lint/lint.d.ts +0 -4
- package/dist/cjs/lint/lint.js +0 -499
- package/dist/cjs/options.d.ts +0 -178
- package/dist/cjs/options.js +0 -12
- package/dist/cjs/repl/index.d.ts +0 -18
- package/dist/cjs/repl/index.js +0 -75
- package/dist/cjs/util/InMemoryReporter.d.ts +0 -28
- package/dist/cjs/util/InMemoryReporter.js +0 -47
- package/dist/cjs/util/async.d.ts +0 -3
- package/dist/cjs/util/async.js +0 -12
- package/dist/cjs/util/cache/CSpellLintResultCache.d.ts +0 -20
- package/dist/cjs/util/cache/CSpellLintResultCache.js +0 -3
- package/dist/cjs/util/cache/CacheOptions.d.ts +0 -34
- package/dist/cjs/util/cache/CacheOptions.js +0 -3
- package/dist/cjs/util/cache/DiskCache.d.ts +0 -63
- package/dist/cjs/util/cache/DiskCache.js +0 -237
- package/dist/cjs/util/cache/DummyCache.d.ts +0 -11
- package/dist/cjs/util/cache/DummyCache.js +0 -22
- package/dist/cjs/util/cache/ObjectCollection.d.ts +0 -17
- package/dist/cjs/util/cache/ObjectCollection.js +0 -136
- package/dist/cjs/util/cache/createCache.d.ts +0 -31
- package/dist/cjs/util/cache/createCache.js +0 -77
- package/dist/cjs/util/cache/fileEntryCache.d.ts +0 -9
- package/dist/cjs/util/cache/fileEntryCache.js +0 -107
- package/dist/cjs/util/cache/index.d.ts +0 -4
- package/dist/cjs/util/cache/index.js +0 -8
- package/dist/cjs/util/constants.d.ts +0 -6
- package/dist/cjs/util/constants.js +0 -8
- package/dist/cjs/util/errors.d.ts +0 -23
- package/dist/cjs/util/errors.js +0 -60
- package/dist/cjs/util/fileHelper.d.ts +0 -63
- package/dist/cjs/util/fileHelper.js +0 -226
- package/dist/cjs/util/glob.d.ts +0 -45
- package/dist/cjs/util/glob.js +0 -175
- package/dist/cjs/util/prefetch.d.ts +0 -2
- package/dist/cjs/util/prefetch.js +0 -23
- package/dist/cjs/util/reporters.d.ts +0 -14
- package/dist/cjs/util/reporters.js +0 -68
- package/dist/cjs/util/stdin.d.ts +0 -2
- package/dist/cjs/util/stdin.js +0 -32
- package/dist/cjs/util/table.d.ts +0 -10
- package/dist/cjs/util/table.js +0 -40
- package/dist/cjs/util/timer.d.ts +0 -8
- package/dist/cjs/util/timer.js +0 -17
- package/dist/cjs/util/types.d.ts +0 -7
- package/dist/cjs/util/types.js +0 -6
- package/dist/cjs/util/util.d.ts +0 -13
- package/dist/cjs/util/util.js +0 -55
package/dist/cjs/commandTrace.js
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.commandTrace = void 0;
|
|
27
|
-
const commander_1 = require("commander");
|
|
28
|
-
const App = __importStar(require("./application.js"));
|
|
29
|
-
const DictionaryPathFormat_js_1 = require("./emitters/DictionaryPathFormat.js");
|
|
30
|
-
const traceEmitter_js_1 = require("./emitters/traceEmitter.js");
|
|
31
|
-
const errors_js_1 = require("./util/errors.js");
|
|
32
|
-
function commandTrace(prog) {
|
|
33
|
-
return prog
|
|
34
|
-
.command('trace')
|
|
35
|
-
.description(`Trace words -- Search for words in the configuration and dictionaries.`)
|
|
36
|
-
.option('-c, --config <cspell.json>', 'Configuration file to use. By default cspell looks for cspell.json in the current directory.')
|
|
37
|
-
.option('--locale <locale>', 'Set language locales. i.e. "en,fr" for English and French, or "en-GB" for British English.')
|
|
38
|
-
.option('--language-id <language>', 'Use programming language. i.e. "php" or "scala".')
|
|
39
|
-
.addOption(new commander_1.Option('--languageId <language>', 'Use programming language. i.e. "php" or "scala".').hideHelp())
|
|
40
|
-
.option('--allow-compound-words', 'Turn on allowCompoundWords')
|
|
41
|
-
.addOption(new commander_1.Option('--allowCompoundWords', 'Turn on allowCompoundWords.').hideHelp())
|
|
42
|
-
.option('--no-allow-compound-words', 'Turn off allowCompoundWords')
|
|
43
|
-
.option('--ignore-case', 'Ignore case and accents when searching for words.')
|
|
44
|
-
.option('--no-ignore-case', 'Do not ignore case and accents when searching for words.')
|
|
45
|
-
.addOption(new commander_1.Option('--dictionary-path <format>', 'Configure how to display the dictionary path.')
|
|
46
|
-
.choices(['hide', 'short', 'long', 'full'])
|
|
47
|
-
.default('long', 'Display most of the path.'))
|
|
48
|
-
.option('--stdin', 'Read words from stdin.')
|
|
49
|
-
.option('--all', 'Show all dictionaries.')
|
|
50
|
-
.addOption(new commander_1.Option('--only-found', 'Show only dictionaries that have the words.').conflicts('all'))
|
|
51
|
-
.option('--no-color', 'Turn off color.')
|
|
52
|
-
.option('--color', 'Force color')
|
|
53
|
-
.addOption(new commander_1.Option('--default-configuration', 'Load the default configuration and dictionaries.').hideHelp())
|
|
54
|
-
.addOption(new commander_1.Option('--no-default-configuration', 'Do not load the default configuration and dictionaries.'))
|
|
55
|
-
.arguments('[words...]')
|
|
56
|
-
.action(async (words, options) => {
|
|
57
|
-
App.parseApplicationFeatureFlags(options.flag);
|
|
58
|
-
let numFound = 0;
|
|
59
|
-
const dictionaryPathFormat = (0, DictionaryPathFormat_js_1.isDictionaryPathFormat)(options.dictionaryPath)
|
|
60
|
-
? options.dictionaryPath
|
|
61
|
-
: 'long';
|
|
62
|
-
for await (const results of App.trace(words, options)) {
|
|
63
|
-
const filtered = filterTraceResults(results, options);
|
|
64
|
-
(0, traceEmitter_js_1.emitTraceResults)(filtered, { cwd: process.cwd(), dictionaryPathFormat });
|
|
65
|
-
numFound += results.reduce((n, r) => n + (r.found ? 1 : 0), 0);
|
|
66
|
-
const numErrors = results.map((r) => r.errors?.length || 0).reduce((n, r) => n + r, 0);
|
|
67
|
-
if (numErrors) {
|
|
68
|
-
console.error('Dictionary Errors.');
|
|
69
|
-
throw new errors_js_1.CheckFailed('dictionary errors', 1);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
if (!numFound) {
|
|
73
|
-
console.error('No matches found');
|
|
74
|
-
throw new errors_js_1.CheckFailed('no matches', 1);
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
exports.commandTrace = commandTrace;
|
|
79
|
-
function filterTraceResults(results, options) {
|
|
80
|
-
if (options.all)
|
|
81
|
-
return results;
|
|
82
|
-
return results.filter((r) => filterTraceResult(r, options.onlyFound));
|
|
83
|
-
}
|
|
84
|
-
function filterTraceResult(result, onlyFound) {
|
|
85
|
-
return result.found || result.forbidden || result.noSuggest || (!onlyFound && result.dictActive);
|
|
86
|
-
}
|
|
87
|
-
//# sourceMappingURL=commandTrace.js.map
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isDictionaryPathFormat = void 0;
|
|
4
|
-
const formats = {
|
|
5
|
-
full: true,
|
|
6
|
-
hide: true,
|
|
7
|
-
long: true,
|
|
8
|
-
short: true,
|
|
9
|
-
};
|
|
10
|
-
function isDictionaryPathFormat(value) {
|
|
11
|
-
if (!value || typeof value !== 'string')
|
|
12
|
-
return false;
|
|
13
|
-
return value in formats;
|
|
14
|
-
}
|
|
15
|
-
exports.isDictionaryPathFormat = isDictionaryPathFormat;
|
|
16
|
-
//# sourceMappingURL=DictionaryPathFormat.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,84 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.emitSuggestionResult = void 0;
|
|
7
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
-
const util_js_1 = require("../util/util.js");
|
|
9
|
-
const regExpRTL = /([\u0591-\u07FF\uFB1D-\uFDFD\uFE70-\uFEFC י]+)/g;
|
|
10
|
-
function reverseRtlText(s) {
|
|
11
|
-
return s.replace(regExpRTL, (s) => s.split('').reverse().join(''));
|
|
12
|
-
}
|
|
13
|
-
function emitSuggestionResult(result, options) {
|
|
14
|
-
const { word, suggestions } = result;
|
|
15
|
-
const { verbose, output = console } = options;
|
|
16
|
-
const elapsed = verbose && verbose > 1 && result.elapsedTimeMs ? ` ${result.elapsedTimeMs.toFixed(2)} ms` : '';
|
|
17
|
-
const rWord = reverseRtlText(word);
|
|
18
|
-
const wordEx = rWord !== word ? ` (${chalk_1.default.yellow(rWord)})` : '';
|
|
19
|
-
output.log((word ? chalk_1.default.yellow(word) + wordEx : chalk_1.default.yellow('<empty>')) + ':' + elapsed);
|
|
20
|
-
if (!suggestions.length) {
|
|
21
|
-
console.log(chalk_1.default.yellow(' <no suggestions>'));
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
function handleRtl(word) {
|
|
25
|
-
const r = reverseRtlText(word);
|
|
26
|
-
return r === word ? word : `${word} (${r})`;
|
|
27
|
-
}
|
|
28
|
-
if (verbose) {
|
|
29
|
-
const mappedSugs = suggestions.map((s) => ({
|
|
30
|
-
...s,
|
|
31
|
-
w: handleRtl(s.compoundWord || s.wordAdjustedToMatchCase || s.word),
|
|
32
|
-
}));
|
|
33
|
-
const sugWidths = mappedSugs.map((s) => (0, util_js_1.width)(s.w));
|
|
34
|
-
const maxWidth = sugWidths.reduce((max, len) => Math.max(max, len), 0);
|
|
35
|
-
for (const sug of mappedSugs) {
|
|
36
|
-
const { cost, dictionaries, w } = sug;
|
|
37
|
-
const padding = ' '.repeat((0, util_js_1.padWidth)(w, maxWidth));
|
|
38
|
-
const forbid = sug.forbidden && sug.isPreferred
|
|
39
|
-
? chalk_1.default.red('*')
|
|
40
|
-
: sug.forbidden
|
|
41
|
-
? chalk_1.default.red('X')
|
|
42
|
-
: sug.isPreferred
|
|
43
|
-
? chalk_1.default.yellow('*')
|
|
44
|
-
: ' ';
|
|
45
|
-
const ignore = sug.noSuggest ? chalk_1.default.yellow('N') : ' ';
|
|
46
|
-
const strCost = (0, util_js_1.padLeft)(cost.toString(10), 4);
|
|
47
|
-
const dicts = dictionaries.map((n) => chalk_1.default.gray(n)).join(', ');
|
|
48
|
-
output.log(` - ${formatWord(w, sug)}${padding} ${forbid}${ignore} - ${chalk_1.default.yellow(strCost)} ${dicts}`);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
const mappedSugs = suggestions.map((s) => ({ ...s, word: handleRtl(s.wordAdjustedToMatchCase || s.word) }));
|
|
53
|
-
for (const r of mappedSugs) {
|
|
54
|
-
output.log(` - ${formatWordSingle(r)}`);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
exports.emitSuggestionResult = emitSuggestionResult;
|
|
59
|
-
function formatWord(word, r) {
|
|
60
|
-
return r.forbidden || r.noSuggest
|
|
61
|
-
? chalk_1.default.gray(chalk_1.default.strikethrough(word))
|
|
62
|
-
: word === r.wordAdjustedToMatchCase
|
|
63
|
-
? diff(word, r.word)
|
|
64
|
-
: word;
|
|
65
|
-
}
|
|
66
|
-
function diff(wordA, wordB) {
|
|
67
|
-
const a = [...wordA];
|
|
68
|
-
const b = [...wordB];
|
|
69
|
-
const parts = [];
|
|
70
|
-
for (let idx = 0; idx < a.length; ++idx) {
|
|
71
|
-
const aa = a[idx];
|
|
72
|
-
const bb = b[idx];
|
|
73
|
-
parts.push(aa === bb ? aa : chalk_1.default.yellow(aa));
|
|
74
|
-
}
|
|
75
|
-
return parts.join('');
|
|
76
|
-
}
|
|
77
|
-
function formatWordSingle(s) {
|
|
78
|
-
let word = formatWord(s.word, s);
|
|
79
|
-
word = s.forbidden ? word + chalk_1.default.red(' X') : word;
|
|
80
|
-
word = s.noSuggest ? word + chalk_1.default.yellow(' Not suggested.') : word;
|
|
81
|
-
word = s.isPreferred ? chalk_1.default.yellow(word + ' *') : word;
|
|
82
|
-
return word;
|
|
83
|
-
}
|
|
84
|
-
//# sourceMappingURL=suggestionsEmitter.js.map
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { TraceResult } from '../application.js';
|
|
2
|
-
import type { DictionaryPathFormat } from './DictionaryPathFormat.js';
|
|
3
|
-
interface PathInterface {
|
|
4
|
-
relative(from: string, to: string): string;
|
|
5
|
-
basename(path: string): string;
|
|
6
|
-
sep: string;
|
|
7
|
-
}
|
|
8
|
-
export interface EmitTraceOptions {
|
|
9
|
-
/** current working directory */
|
|
10
|
-
cwd: string;
|
|
11
|
-
lineWidth?: number;
|
|
12
|
-
dictionaryPathFormat: DictionaryPathFormat;
|
|
13
|
-
iPath?: PathInterface;
|
|
14
|
-
}
|
|
15
|
-
export declare function emitTraceResults(results: TraceResult[], options: EmitTraceOptions): void;
|
|
16
|
-
declare function trimMidPath(s: string, w: number, sep: string): string;
|
|
17
|
-
export declare const __testing__: {
|
|
18
|
-
trimMidPath: typeof trimMidPath;
|
|
19
|
-
};
|
|
20
|
-
export {};
|
|
21
|
-
//# sourceMappingURL=traceEmitter.d.ts.map
|
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.__testing__ = exports.emitTraceResults = void 0;
|
|
30
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
31
|
-
const iPath = __importStar(require("path"));
|
|
32
|
-
const strip_ansi_1 = __importDefault(require("strip-ansi"));
|
|
33
|
-
const util_js_1 = require("../util/util.js");
|
|
34
|
-
const colWidthDictionaryName = 20;
|
|
35
|
-
function emitTraceResults(results, options) {
|
|
36
|
-
const maxWordLength = results
|
|
37
|
-
.map((r) => r.foundWord || r.word)
|
|
38
|
-
.reduce((a, b) => Math.max(a, (0, util_js_1.width)(b)), 'Word'.length);
|
|
39
|
-
const maxDictNameLength = results
|
|
40
|
-
.map((r) => r.dictName.length)
|
|
41
|
-
.reduce((a, b) => Math.max(a, b), colWidthDictionaryName);
|
|
42
|
-
const cols = {
|
|
43
|
-
word: maxWordLength,
|
|
44
|
-
dictName: maxDictNameLength,
|
|
45
|
-
terminalWidth: options.lineWidth ?? (process.stdout.columns || 120),
|
|
46
|
-
location: options.dictionaryPathFormat === 'hide' ? 0 : 30,
|
|
47
|
-
};
|
|
48
|
-
const col = new Intl.Collator();
|
|
49
|
-
results.sort((a, b) => col.compare(a.dictName, b.dictName));
|
|
50
|
-
emitHeader(cols);
|
|
51
|
-
results.forEach((r) => emitTraceResult(r, cols, options));
|
|
52
|
-
}
|
|
53
|
-
exports.emitTraceResults = emitTraceResults;
|
|
54
|
-
function emitHeader(colWidths) {
|
|
55
|
-
const line = [
|
|
56
|
-
(0, util_js_1.pad)('Word', colWidths.word),
|
|
57
|
-
'F',
|
|
58
|
-
(0, util_js_1.pad)('Dictionary', colWidths.dictName),
|
|
59
|
-
colWidths.location ? (0, util_js_1.pad)('Dictionary Location', colWidths.location) : '',
|
|
60
|
-
];
|
|
61
|
-
console.log(chalk_1.default.underline(line.join(' ').trim().slice(0, colWidths.terminalWidth)));
|
|
62
|
-
}
|
|
63
|
-
function emitTraceResult(r, colWidths, options) {
|
|
64
|
-
const { word: wordColWidth, terminalWidth, dictName: widthName } = colWidths;
|
|
65
|
-
const errors = r.errors?.map((e) => e.message)?.join('\n\t') || '';
|
|
66
|
-
const word = (0, util_js_1.pad)(r.foundWord || r.word, wordColWidth);
|
|
67
|
-
const cWord = word.replace(/[+]/g, chalk_1.default.yellow('+'));
|
|
68
|
-
const w = r.forbidden ? chalk_1.default.red(cWord) : chalk_1.default.green(cWord);
|
|
69
|
-
const f = calcFoundChar(r);
|
|
70
|
-
const a = r.dictActive ? '*' : ' ';
|
|
71
|
-
const dictName = (0, util_js_1.pad)(r.dictName.slice(0, widthName - 1) + a, widthName);
|
|
72
|
-
const dictColor = r.dictActive ? chalk_1.default.yellowBright : chalk_1.default.rgb(200, 128, 50);
|
|
73
|
-
const n = dictColor(dictName);
|
|
74
|
-
const info = [w, f, n].join(' ') + ' ';
|
|
75
|
-
const used = (0, util_js_1.width)((0, strip_ansi_1.default)(info));
|
|
76
|
-
const widthSrc = terminalWidth - used;
|
|
77
|
-
const c = colorize(errors ? chalk_1.default.red : chalk_1.default.white);
|
|
78
|
-
const s = c(formatDictionaryLocation(r.dictSource, widthSrc, { iPath, ...options }));
|
|
79
|
-
const line = info + s;
|
|
80
|
-
console.log(line.trim());
|
|
81
|
-
if (errors) {
|
|
82
|
-
console.error('\t' + chalk_1.default.red(errors));
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
function trimMid(s, w) {
|
|
86
|
-
s = s.trim();
|
|
87
|
-
if (s.length <= w) {
|
|
88
|
-
return s;
|
|
89
|
-
}
|
|
90
|
-
const l = Math.floor((w - 3) / 2);
|
|
91
|
-
const r = Math.ceil((w - 3) / 2);
|
|
92
|
-
return s.slice(0, l) + '...' + s.slice(-r);
|
|
93
|
-
}
|
|
94
|
-
function calcFoundChar(r) {
|
|
95
|
-
const errors = r.errors?.map((e) => e.message)?.join('\n\t') || '';
|
|
96
|
-
let color = chalk_1.default.dim;
|
|
97
|
-
color = r.found ? chalk_1.default.whiteBright : color;
|
|
98
|
-
color = r.forbidden ? chalk_1.default.red : color;
|
|
99
|
-
color = r.noSuggest ? chalk_1.default.yellowBright : color;
|
|
100
|
-
color = errors ? chalk_1.default.red : color;
|
|
101
|
-
let char = '-';
|
|
102
|
-
char = r.found ? '*' : char;
|
|
103
|
-
char = r.forbidden ? '!' : char;
|
|
104
|
-
char = r.noSuggest ? 'I' : char;
|
|
105
|
-
char = errors ? 'X' : char;
|
|
106
|
-
return color(char);
|
|
107
|
-
}
|
|
108
|
-
function formatDictionaryLocation(dictSource, maxWidth, { cwd, dictionaryPathFormat: format, iPath, }) {
|
|
109
|
-
let relPath = cwd ? iPath.relative(cwd, dictSource) : dictSource;
|
|
110
|
-
const idxNodeModule = relPath.lastIndexOf('node_modules');
|
|
111
|
-
const isNodeModule = idxNodeModule >= 0;
|
|
112
|
-
if (format === 'hide')
|
|
113
|
-
return '';
|
|
114
|
-
if (format === 'short') {
|
|
115
|
-
const prefix = isNodeModule
|
|
116
|
-
? '[node_modules]/'
|
|
117
|
-
: relPath.startsWith('..' + iPath.sep + '..')
|
|
118
|
-
? '.../'
|
|
119
|
-
: relPath.startsWith('..' + iPath.sep)
|
|
120
|
-
? '../'
|
|
121
|
-
: '';
|
|
122
|
-
return prefix + iPath.basename(dictSource);
|
|
123
|
-
}
|
|
124
|
-
if (format === 'full')
|
|
125
|
-
return dictSource;
|
|
126
|
-
relPath = isNodeModule ? relPath.slice(idxNodeModule) : relPath;
|
|
127
|
-
const usePath = relPath.length < dictSource.length ? relPath : dictSource;
|
|
128
|
-
return trimMidPath(usePath, maxWidth, iPath.sep);
|
|
129
|
-
}
|
|
130
|
-
function colorize(fn) {
|
|
131
|
-
return (s) => (s ? fn(s) : '');
|
|
132
|
-
}
|
|
133
|
-
function trimMidPath(s, w, sep) {
|
|
134
|
-
if (s.length <= w)
|
|
135
|
-
return s;
|
|
136
|
-
const parts = s.split(sep);
|
|
137
|
-
if (parts[parts.length - 1].length > w)
|
|
138
|
-
return trimMid(s, w);
|
|
139
|
-
function join(left, right) {
|
|
140
|
-
// if (left === right) return parts.join(sep);
|
|
141
|
-
return [...parts.slice(0, left), '...', ...parts.slice(right)].join(sep);
|
|
142
|
-
}
|
|
143
|
-
let left = 0, right = parts.length, last = '';
|
|
144
|
-
for (let i = 0; i < parts.length; ++i) {
|
|
145
|
-
const incLeft = i & 1 ? 1 : 0;
|
|
146
|
-
const incRight = incLeft ? 0 : -1;
|
|
147
|
-
const next = join(left + incLeft, right + incRight);
|
|
148
|
-
if (next.length > w)
|
|
149
|
-
break;
|
|
150
|
-
left += incLeft;
|
|
151
|
-
right += incRight;
|
|
152
|
-
last = next;
|
|
153
|
-
}
|
|
154
|
-
for (let i = left + 1; i < right; ++i) {
|
|
155
|
-
const next = join(i, right);
|
|
156
|
-
if (next.length > w)
|
|
157
|
-
break;
|
|
158
|
-
last = next;
|
|
159
|
-
}
|
|
160
|
-
for (let i = right - 1; i > left; --i) {
|
|
161
|
-
const next = join(left, i);
|
|
162
|
-
if (next.length > w)
|
|
163
|
-
break;
|
|
164
|
-
last = next;
|
|
165
|
-
}
|
|
166
|
-
return last || trimMid(s, w);
|
|
167
|
-
}
|
|
168
|
-
exports.__testing__ = {
|
|
169
|
-
trimMidPath,
|
|
170
|
-
};
|
|
171
|
-
//# sourceMappingURL=traceEmitter.js.map
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseFeatureFlags = exports.getFeatureFlags = void 0;
|
|
4
|
-
const cspell_lib_1 = require("cspell-lib");
|
|
5
|
-
function getFeatureFlags() {
|
|
6
|
-
return (0, cspell_lib_1.getSystemFeatureFlags)();
|
|
7
|
-
}
|
|
8
|
-
exports.getFeatureFlags = getFeatureFlags;
|
|
9
|
-
function parseFeatureFlags(flags, featureFlags = getFeatureFlags()) {
|
|
10
|
-
if (!flags)
|
|
11
|
-
return featureFlags;
|
|
12
|
-
const flagsKvP = flags.map((f) => f.split(':', 2));
|
|
13
|
-
for (const flag of flagsKvP) {
|
|
14
|
-
const [name, value] = flag;
|
|
15
|
-
try {
|
|
16
|
-
featureFlags.setFlag(name, value);
|
|
17
|
-
}
|
|
18
|
-
catch (e) {
|
|
19
|
-
console.warn(`Unknown flag: "${name}"`);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
return featureFlags;
|
|
23
|
-
}
|
|
24
|
-
exports.parseFeatureFlags = parseFeatureFlags;
|
|
25
|
-
//# sourceMappingURL=featureFlags.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseFeatureFlags = exports.getFeatureFlags = void 0;
|
|
4
|
-
var featureFlags_js_1 = require("./featureFlags.js");
|
|
5
|
-
Object.defineProperty(exports, "getFeatureFlags", { enumerable: true, get: function () { return featureFlags_js_1.getFeatureFlags; } });
|
|
6
|
-
Object.defineProperty(exports, "parseFeatureFlags", { enumerable: true, get: function () { return featureFlags_js_1.parseFeatureFlags; } });
|
|
7
|
-
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export * from './application.js';
|
|
2
|
-
export { getReporter as getDefaultReporter } from './cli-reporter.js';
|
|
3
|
-
export type { BaseOptions, LinterCliOptions as CSpellApplicationOptions, TraceOptions } from './options.js';
|
|
4
|
-
export * from '@cspell/cspell-types';
|
|
5
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/cjs/index.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.getDefaultReporter = void 0;
|
|
18
|
-
__exportStar(require("./application.js"), exports);
|
|
19
|
-
var cli_reporter_js_1 = require("./cli-reporter.js");
|
|
20
|
-
Object.defineProperty(exports, "getDefaultReporter", { enumerable: true, get: function () { return cli_reporter_js_1.getReporter; } });
|
|
21
|
-
__exportStar(require("@cspell/cspell-types"), exports);
|
|
22
|
-
//# sourceMappingURL=index.js.map
|
package/dist/cjs/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/cjs/link.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.addPathsToGlobalImportsResultToTable = exports.listGlobalImportsResultToTable = exports.removePathsFromGlobalImports = exports.addPathsToGlobalImports = exports.listGlobalImports = void 0;
|
|
7
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
-
const cspell_lib_1 = require("cspell-lib");
|
|
9
|
-
exports.listGlobalImports = cspell_lib_1.Link.listGlobalImports;
|
|
10
|
-
exports.addPathsToGlobalImports = cspell_lib_1.Link.addPathsToGlobalImports;
|
|
11
|
-
exports.removePathsFromGlobalImports = cspell_lib_1.Link.removePathsFromGlobalImports;
|
|
12
|
-
function listGlobalImportsResultToTable(results) {
|
|
13
|
-
const header = ['id', 'package', 'name', 'filename', 'dictionaries', 'errors'];
|
|
14
|
-
const decorate = (isError) => (isError ? (s) => chalk_1.default.red(s) : (s) => s);
|
|
15
|
-
function toColumns(r) {
|
|
16
|
-
return [
|
|
17
|
-
r.id,
|
|
18
|
-
r.package?.name,
|
|
19
|
-
r.name,
|
|
20
|
-
r.filename,
|
|
21
|
-
r.dictionaryDefinitions?.map((def) => def.name).join(', '),
|
|
22
|
-
r.error ? 'Failed to read file.' : '',
|
|
23
|
-
]
|
|
24
|
-
.map((c) => c || '')
|
|
25
|
-
.map(decorate(!!r.error));
|
|
26
|
-
}
|
|
27
|
-
return {
|
|
28
|
-
header,
|
|
29
|
-
rows: results.map(toColumns),
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
exports.listGlobalImportsResultToTable = listGlobalImportsResultToTable;
|
|
33
|
-
function addPathsToGlobalImportsResultToTable(results) {
|
|
34
|
-
const header = ['filename', 'errors'];
|
|
35
|
-
const decorate = (isError) => (isError ? (s) => chalk_1.default.red(s) : (s) => s);
|
|
36
|
-
function toColumns(r) {
|
|
37
|
-
return [r.resolvedToFilename || r.filename, r.error ? 'Failed to read file.' : '']
|
|
38
|
-
.map((c) => c || '')
|
|
39
|
-
.map(decorate(!!r.error));
|
|
40
|
-
}
|
|
41
|
-
return {
|
|
42
|
-
header,
|
|
43
|
-
rows: results.resolvedSettings.map(toColumns),
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
exports.addPathsToGlobalImportsResultToTable = addPathsToGlobalImportsResultToTable;
|
|
47
|
-
//# sourceMappingURL=link.js.map
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { Issue } from '@cspell/cspell-types';
|
|
2
|
-
import type { 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
|
-
}
|
|
8
|
-
export declare class LintRequest {
|
|
9
|
-
readonly fileGlobs: string[];
|
|
10
|
-
readonly options: LinterOptions & Deprecated;
|
|
11
|
-
readonly reporter: FinalizedReporter;
|
|
12
|
-
readonly uniqueFilter: (issue: Issue) => boolean;
|
|
13
|
-
readonly locale: string;
|
|
14
|
-
readonly configFile: string | undefined;
|
|
15
|
-
readonly excludes: GlobSrcInfo[];
|
|
16
|
-
readonly root: string;
|
|
17
|
-
readonly showContext: number;
|
|
18
|
-
readonly enableGlobDot: boolean | undefined;
|
|
19
|
-
readonly fileLists: string[];
|
|
20
|
-
constructor(fileGlobs: string[], options: LinterOptions & Deprecated, reporter: FinalizedReporter);
|
|
21
|
-
}
|
|
22
|
-
export {};
|
|
23
|
-
//# sourceMappingURL=LintRequest.d.ts.map
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.LintRequest = void 0;
|
|
27
|
-
const path = __importStar(require("path"));
|
|
28
|
-
const glob_js_1 = require("../util/glob.js");
|
|
29
|
-
const util = __importStar(require("../util/util.js"));
|
|
30
|
-
const defaultContextRange = 20;
|
|
31
|
-
class LintRequest {
|
|
32
|
-
constructor(fileGlobs, options, reporter) {
|
|
33
|
-
this.fileGlobs = fileGlobs;
|
|
34
|
-
this.options = options;
|
|
35
|
-
this.reporter = reporter;
|
|
36
|
-
this.root = path.resolve(options.root || process.cwd());
|
|
37
|
-
this.configFile = options.config;
|
|
38
|
-
this.excludes = (0, glob_js_1.calcExcludeGlobInfo)(this.root, options.exclude);
|
|
39
|
-
this.locale = options.locale || '';
|
|
40
|
-
this.enableGlobDot = options.dot;
|
|
41
|
-
this.uniqueFilter = options.unique ? util.uniqueFilterFnGenerator((issue) => issue.text) : () => true;
|
|
42
|
-
this.showContext =
|
|
43
|
-
options.showContext === true ? defaultContextRange : options.showContext ? options.showContext : 0;
|
|
44
|
-
this.fileLists = (options.fileList ?? options.fileLists) || [];
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
exports.LintRequest = LintRequest;
|
|
48
|
-
//# sourceMappingURL=LintRequest.js.map
|
package/dist/cjs/lint/index.d.ts
DELETED
package/dist/cjs/lint/index.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LintRequest = exports.runLint = void 0;
|
|
4
|
-
var lint_js_1 = require("./lint.js");
|
|
5
|
-
Object.defineProperty(exports, "runLint", { enumerable: true, get: function () { return lint_js_1.runLint; } });
|
|
6
|
-
var LintRequest_js_1 = require("./LintRequest.js");
|
|
7
|
-
Object.defineProperty(exports, "LintRequest", { enumerable: true, get: function () { return LintRequest_js_1.LintRequest; } });
|
|
8
|
-
//# sourceMappingURL=index.js.map
|
package/dist/cjs/lint/lint.d.ts
DELETED