cspell 5.12.0 → 5.12.4
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 +53 -38
- package/bin.js +0 -1
- package/dist/cli-reporter.js +4 -2
- package/dist/commandLint.js +2 -1
- package/dist/fileHelper.d.ts +2 -1
- package/dist/lint.js +17 -7
- package/dist/util/cache/DiskCache.js +4 -2
- package/package.json +10 -10
package/README.md
CHANGED
|
@@ -74,44 +74,59 @@ Usage: cspell lint [options] [files...]
|
|
|
74
74
|
Check spelling
|
|
75
75
|
|
|
76
76
|
Options:
|
|
77
|
-
-c, --config <cspell.json>
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
-v, --verbose
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
--locale <locale>
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
--language-id <language>
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
--wordsOnly
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
-u, --unique
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
--debug
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
-e, --exclude <glob>
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
--no-issues
|
|
103
|
-
--no-progress
|
|
104
|
-
--no-summary
|
|
105
|
-
-s, --silent
|
|
106
|
-
-r, --root <root folder>
|
|
107
|
-
--relative
|
|
108
|
-
--show-context
|
|
109
|
-
--show-suggestions
|
|
110
|
-
--must-find-files
|
|
111
|
-
|
|
112
|
-
--
|
|
113
|
-
--
|
|
114
|
-
|
|
77
|
+
-c, --config <cspell.json> Configuration file to use. By default cspell
|
|
78
|
+
looks for cspell.json in the current directory.
|
|
79
|
+
|
|
80
|
+
-v, --verbose display more information about the files being
|
|
81
|
+
checked and the configuration
|
|
82
|
+
|
|
83
|
+
--locale <locale> Set language locales. i.e. "en,fr" for English
|
|
84
|
+
and French, or "en-GB" for British English.
|
|
85
|
+
|
|
86
|
+
--language-id <language> Force programming language for unknown
|
|
87
|
+
extensions. i.e. "php" or "scala"
|
|
88
|
+
|
|
89
|
+
--wordsOnly Only output the words not found in the
|
|
90
|
+
dictionaries.
|
|
91
|
+
|
|
92
|
+
-u, --unique Only output the first instance of a word not
|
|
93
|
+
found in the dictionaries.
|
|
94
|
+
|
|
95
|
+
--debug Output information useful for debugging
|
|
96
|
+
cspell.json files.
|
|
97
|
+
|
|
98
|
+
-e, --exclude <glob> Exclude files matching the glob pattern. This
|
|
99
|
+
option can be used multiple times to add
|
|
100
|
+
multiple globs.
|
|
101
|
+
|
|
102
|
+
--no-issues Do not show the spelling errors.
|
|
103
|
+
--no-progress Turn off progress messages
|
|
104
|
+
--no-summary Turn off summary message in console
|
|
105
|
+
-s, --silent Silent mode, suppress error messages
|
|
106
|
+
-r, --root <root folder> Root directory, defaults to current directory.
|
|
107
|
+
--relative Issues are displayed relative to root.
|
|
108
|
+
--show-context Show the surrounding text around an issue.
|
|
109
|
+
--show-suggestions Show spelling suggestions.
|
|
110
|
+
--no-must-find-files Do not error if no files are found
|
|
111
|
+
|
|
112
|
+
--cache Only check changed files (default: false)
|
|
113
|
+
--cache-strategy <strategy> Strategy to use for detecting changed files
|
|
114
|
+
(choices: "metadata", "content")
|
|
115
|
+
|
|
116
|
+
--cache-location <path> Path to the cache file or directory (default:
|
|
117
|
+
".cspellcache")
|
|
118
|
+
|
|
119
|
+
--gitignore Ignore files matching glob patterns found in
|
|
120
|
+
.gitignore files.
|
|
121
|
+
|
|
122
|
+
--no-gitignore Do NOT use .gitignore files.
|
|
123
|
+
|
|
124
|
+
--gitignore-root <path> Prevent searching for .gitignore files past
|
|
125
|
+
root.
|
|
126
|
+
|
|
127
|
+
--no-color Turn off color.
|
|
128
|
+
--color Force color
|
|
129
|
+
-h, --help display help for command
|
|
115
130
|
|
|
116
131
|
|
|
117
132
|
Examples:
|
package/bin.js
CHANGED
package/dist/cli-reporter.js
CHANGED
|
@@ -73,12 +73,14 @@ function reportProgress(p) {
|
|
|
73
73
|
const fn = (' '.repeat(fc.length) + p.fileNum).slice(-fc.length);
|
|
74
74
|
const idx = fn + '/' + fc;
|
|
75
75
|
const filename = chalk.gray(relativeFilename(p.filename));
|
|
76
|
-
const time = reportTime(p.elapsedTimeMs);
|
|
76
|
+
const time = reportTime(p.elapsedTimeMs, !!p.cached);
|
|
77
77
|
const skipped = p.processed === false ? ' skipped' : '';
|
|
78
78
|
const hasErrors = p.numErrors ? chalk.red ` X` : '';
|
|
79
79
|
console.error(`${idx} ${filename} ${time}${skipped}${hasErrors}`);
|
|
80
80
|
}
|
|
81
|
-
function reportTime(elapsedTimeMs) {
|
|
81
|
+
function reportTime(elapsedTimeMs, cached) {
|
|
82
|
+
if (cached)
|
|
83
|
+
return chalk.green('cached');
|
|
82
84
|
if (elapsedTimeMs === undefined)
|
|
83
85
|
return '-';
|
|
84
86
|
const color = elapsedTimeMs < 1000 ? chalk.white : elapsedTimeMs < 2000 ? chalk.yellow : chalk.redBright;
|
package/dist/commandLint.js
CHANGED
|
@@ -51,7 +51,8 @@ function commandLint(prog) {
|
|
|
51
51
|
.option('--locale <locale>', 'Set language locales. i.e. "en,fr" for English and French, or "en-GB" for British English.')
|
|
52
52
|
.option('--language-id <language>', 'Force programming language for unknown extensions. i.e. "php" or "scala"')
|
|
53
53
|
.addOption(new commander_1.Option('--languageId <language>', 'Force programming language for unknown extensions. i.e. "php" or "scala"').hideHelp())
|
|
54
|
-
.option('--
|
|
54
|
+
.option('--words-only', 'Only output the words not found in the dictionaries.')
|
|
55
|
+
.addOption(new commander_1.Option('--wordsOnly', 'Only output the words not found in the dictionaries.').hideHelp())
|
|
55
56
|
.option('-u, --unique', 'Only output the first instance of a word not found in the dictionaries.')
|
|
56
57
|
.option('--debug', 'Output information useful for debugging cspell.json files.')
|
|
57
58
|
.option('-e, --exclude <glob>', 'Exclude files matching the glob pattern. This option can be used multiple times to add multiple globs. ', collect)
|
package/dist/fileHelper.d.ts
CHANGED
|
@@ -21,7 +21,8 @@ export interface FileResult {
|
|
|
21
21
|
issues: Issue[];
|
|
22
22
|
errors: number;
|
|
23
23
|
configErrors: number;
|
|
24
|
-
elapsedTimeMs: number;
|
|
24
|
+
elapsedTimeMs: number | undefined;
|
|
25
|
+
cached?: boolean;
|
|
25
26
|
}
|
|
26
27
|
export declare function fileInfoToDocument(fileInfo: FileInfo, languageId: string | undefined, locale: string | undefined): Document;
|
|
27
28
|
export declare function readFileInfo(filename: string, encoding?: string): Promise<Required<FileInfo>>;
|
package/dist/lint.js
CHANGED
|
@@ -104,6 +104,7 @@ async function runLint(cfg) {
|
|
|
104
104
|
elapsedTimeMs: result === null || result === void 0 ? void 0 : result.elapsedTimeMs,
|
|
105
105
|
processed: result === null || result === void 0 ? void 0 : result.processed,
|
|
106
106
|
numErrors: result === null || result === void 0 ? void 0 : result.issues.length,
|
|
107
|
+
cached: result === null || result === void 0 ? void 0 : result.cached,
|
|
107
108
|
});
|
|
108
109
|
async function* loadAndProcessFiles() {
|
|
109
110
|
for (let i = 0; i < files.length; i++) {
|
|
@@ -114,14 +115,15 @@ async function runLint(cfg) {
|
|
|
114
115
|
}
|
|
115
116
|
for await (const fileP of loadAndProcessFiles()) {
|
|
116
117
|
const { filename, fileNum, result } = await fileP;
|
|
117
|
-
if (!result.fileInfo.text) {
|
|
118
|
-
|
|
118
|
+
if (!result.fileInfo.text === undefined) {
|
|
119
|
+
status.files += result.cached ? 1 : 0;
|
|
120
|
+
emitProgress(filename, fileNum, result);
|
|
119
121
|
continue;
|
|
120
122
|
}
|
|
123
|
+
status.files += 1;
|
|
121
124
|
emitProgress(filename, fileNum, result);
|
|
122
125
|
// Show the spelling errors after emitting the progress.
|
|
123
126
|
result.issues.filter(cfg.uniqueFilter).forEach((issue) => reporter.issue(issue));
|
|
124
|
-
status.files += 1;
|
|
125
127
|
if (result.issues.length || result.errors) {
|
|
126
128
|
status.filesWithIssues.add(filename);
|
|
127
129
|
status.issues += result.issues.length;
|
|
@@ -172,7 +174,7 @@ async function runLint(cfg) {
|
|
|
172
174
|
cspell.setLogger(getLoggerFromReporter(reporter));
|
|
173
175
|
const useGitignore = (_b = (_a = cfg.options.gitignore) !== null && _a !== void 0 ? _a : configInfo.config.useGitignore) !== null && _b !== void 0 ? _b : false;
|
|
174
176
|
const gitignoreRoots = (_c = cfg.options.gitignoreRoot) !== null && _c !== void 0 ? _c : configInfo.config.gitignoreRoot;
|
|
175
|
-
const gitIgnore = useGitignore ? generateGitIgnore(gitignoreRoots) : undefined;
|
|
177
|
+
const gitIgnore = useGitignore ? await generateGitIgnore(gitignoreRoots) : undefined;
|
|
176
178
|
const cliGlobs = cfg.files;
|
|
177
179
|
const allGlobs = cliGlobs.length ? cliGlobs : configInfo.config.files || [];
|
|
178
180
|
const combinedGlobs = (0, glob_1.normalizeGlobsToRoot)(allGlobs, cfg.root, false);
|
|
@@ -238,7 +240,10 @@ Options:
|
|
|
238
240
|
}
|
|
239
241
|
function filterFiles(files, globMatcher) {
|
|
240
242
|
const patterns = globMatcher.patterns;
|
|
241
|
-
const excludeInfo = patterns
|
|
243
|
+
const excludeInfo = patterns
|
|
244
|
+
.map(extractGlobSource)
|
|
245
|
+
.map(({ glob, source }) => `Glob: ${glob} from ${source}`)
|
|
246
|
+
.filter(util.uniqueFn());
|
|
242
247
|
reporter.info(`Exclusion Globs: \n ${excludeInfo.join('\n ')}\n`, cspell_types_1.MessageTypes.Info);
|
|
243
248
|
const result = files.filter(util.uniqueFn()).filter((filename) => !isExcluded(filename, globMatcher));
|
|
244
249
|
return result;
|
|
@@ -300,8 +305,13 @@ function getLoggerFromReporter(reporter) {
|
|
|
300
305
|
error,
|
|
301
306
|
};
|
|
302
307
|
}
|
|
303
|
-
function generateGitIgnore(roots) {
|
|
304
|
-
const root = typeof roots === 'string' ? [roots] : roots;
|
|
308
|
+
async function generateGitIgnore(roots) {
|
|
309
|
+
const root = (typeof roots === 'string' ? [roots].filter((r) => !!r) : roots) || [];
|
|
310
|
+
if (!(root === null || root === void 0 ? void 0 : root.length)) {
|
|
311
|
+
const cwd = process.cwd();
|
|
312
|
+
const repo = (await (0, cspell_gitignore_1.findRepoRoot)(cwd)) || cwd;
|
|
313
|
+
root.push(repo);
|
|
314
|
+
}
|
|
305
315
|
return new cspell_gitignore_1.GitIgnore(root === null || root === void 0 ? void 0 : root.map((p) => path.resolve(p)));
|
|
306
316
|
}
|
|
307
317
|
//# sourceMappingURL=lint.js.map
|
|
@@ -27,11 +27,13 @@ class DiskCache {
|
|
|
27
27
|
}
|
|
28
28
|
// Skip reading empty files and files without lint error
|
|
29
29
|
const hasErrors = meta.result.errors > 0 || meta.result.configErrors > 0 || meta.result.issues.length > 0;
|
|
30
|
-
const
|
|
30
|
+
const cached = !!meta.size;
|
|
31
|
+
const shouldReadFile = cached && hasErrors;
|
|
31
32
|
return {
|
|
32
33
|
...meta.result,
|
|
33
|
-
elapsedTimeMs:
|
|
34
|
+
elapsedTimeMs: undefined,
|
|
34
35
|
fileInfo: shouldReadFile ? await (0, fileHelper_1.readFileInfo)(filename) : { filename },
|
|
36
|
+
cached,
|
|
35
37
|
};
|
|
36
38
|
}
|
|
37
39
|
setCachedLintResults({ fileInfo, elapsedTimeMs: _, ...result }, configInfo) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cspell",
|
|
3
|
-
"version": "5.12.
|
|
3
|
+
"version": "5.12.4",
|
|
4
4
|
"description": "A Spelling Checker for Code!",
|
|
5
5
|
"funding": "https://github.com/streetsidesoftware/cspell?sponsor=1",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -70,11 +70,11 @@
|
|
|
70
70
|
"homepage": "https://streetsidesoftware.github.io/cspell/",
|
|
71
71
|
"dependencies": {
|
|
72
72
|
"chalk": "^4.1.2",
|
|
73
|
-
"commander": "^8.
|
|
73
|
+
"commander": "^8.3.0",
|
|
74
74
|
"comment-json": "^4.1.1",
|
|
75
|
-
"cspell-gitignore": "^5.12.
|
|
76
|
-
"cspell-glob": "^5.12.
|
|
77
|
-
"cspell-lib": "^5.12.
|
|
75
|
+
"cspell-gitignore": "^5.12.4",
|
|
76
|
+
"cspell-glob": "^5.12.4",
|
|
77
|
+
"cspell-lib": "^5.12.4",
|
|
78
78
|
"fast-json-stable-stringify": "^2.1.0",
|
|
79
79
|
"file-entry-cache": "^6.0.1",
|
|
80
80
|
"fs-extra": "^10.0.0",
|
|
@@ -88,18 +88,18 @@
|
|
|
88
88
|
"node": ">=12.13.0"
|
|
89
89
|
},
|
|
90
90
|
"devDependencies": {
|
|
91
|
-
"@cspell/cspell-json-reporter": "^5.12.
|
|
92
|
-
"@cspell/cspell-types": "^5.12.
|
|
91
|
+
"@cspell/cspell-json-reporter": "^5.12.4",
|
|
92
|
+
"@cspell/cspell-types": "^5.12.4",
|
|
93
93
|
"@types/file-entry-cache": "^5.0.2",
|
|
94
94
|
"@types/fs-extra": "^9.0.13",
|
|
95
|
-
"@types/glob": "^7.
|
|
95
|
+
"@types/glob": "^7.2.0",
|
|
96
96
|
"@types/imurmurhash": "^0.1.1",
|
|
97
97
|
"@types/micromatch": "^4.0.2",
|
|
98
98
|
"@types/minimatch": "^3.0.5",
|
|
99
|
-
"jest": "^27.
|
|
99
|
+
"jest": "^27.3.1",
|
|
100
100
|
"micromatch": "^4.0.4",
|
|
101
101
|
"minimatch": "^3.0.4",
|
|
102
102
|
"rimraf": "^3.0.2"
|
|
103
103
|
},
|
|
104
|
-
"gitHead": "
|
|
104
|
+
"gitHead": "3e9973c39725f65141683b373ed839562f28bd94"
|
|
105
105
|
}
|