cspell 5.19.3 → 5.19.6

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.
@@ -43,11 +43,13 @@ function lint(fileGlobs, options, emitters) {
43
43
  }
44
44
  exports.lint = lint;
45
45
  async function* trace(words, options) {
46
+ var _a, _b;
46
47
  options = (0, options_1.fixLegacy)(options);
47
48
  const iWords = options.stdin ? (0, cspell_pipe_1.toAsyncIterable)(words, (0, stdin_1.readStdin)()) : words;
48
49
  const { languageId, locale, allowCompoundWords, ignoreCase } = options;
49
50
  const configFile = await (0, fileHelper_1.readConfig)(options.config, undefined);
50
- const config = (0, cspell_lib_1.mergeSettings)((0, cspell_lib_1.getDefaultSettings)(), (0, cspell_lib_1.getGlobalSettings)(), configFile.config);
51
+ const loadDefault = (_b = (_a = options.defaultConfiguration) !== null && _a !== void 0 ? _a : configFile.config.loadDefaultConfiguration) !== null && _b !== void 0 ? _b : true;
52
+ const config = (0, cspell_lib_1.mergeSettings)((0, cspell_lib_1.getDefaultSettings)(loadDefault), (0, cspell_lib_1.getGlobalSettings)(), configFile.config);
51
53
  yield* (0, cspell_lib_1.traceWordsAsync)(iWords, config, { languageId, locale, ignoreCase, allowCompoundWords });
52
54
  }
53
55
  exports.trace = trace;
@@ -58,6 +60,7 @@ async function checkText(filename, options) {
58
60
  const settingsFromCommandLine = util.clean({
59
61
  languageId: options.languageId || undefined,
60
62
  language: options.locale || options.local || undefined,
63
+ loadDefaultConfiguration: options.defaultConfiguration,
61
64
  });
62
65
  const info = (0, fileHelper_1.calcFinalConfigInfo)(foundSettings, settingsFromCommandLine, filename, text);
63
66
  return (0, cspell_lib_1.checkText)(text, info.configInfo.config);
@@ -24,6 +24,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.commandCheck = void 0;
27
+ const commander_1 = require("commander");
27
28
  const App = __importStar(require("./application"));
28
29
  const application_1 = require("./application");
29
30
  const errors_1 = require("./util/errors");
@@ -35,6 +36,8 @@ function commandCheck(prog) {
35
36
  .option('-c, --config <cspell.json>', 'Configuration file to use. By default cspell looks for cspell.json in the current directory.')
36
37
  .option('--no-color', 'Turn off color.')
37
38
  .option('--color', 'Force color')
39
+ .addOption(new commander_1.Option('--default-configuration', 'Load the default configuration and dictionaries.').hideHelp())
40
+ .addOption(new commander_1.Option('--no-default-configuration', 'Do not load the default configuration and dictionaries.'))
38
41
  .action(async (files, options) => {
39
42
  let issueCount = 0;
40
43
  for (const filename of files) {
@@ -81,6 +81,7 @@ function commandLint(prog) {
81
81
  .addOption(new commander_1.Option('--local <local>', 'Deprecated -- Use: --locale').hideHelp())
82
82
  .option('--cache', 'Use cache to only check changed files.')
83
83
  .option('--no-cache', 'Do not use cache.')
84
+ .option('--cache-reset', 'Reset the cache file.')
84
85
  .addOption(new commander_1.Option('--cache-strategy <strategy>', 'Strategy to use for detecting changed files.').choices([
85
86
  'metadata',
86
87
  'content',
@@ -92,6 +93,8 @@ function commandLint(prog) {
92
93
  .option('--gitignore-root <path>', 'Prevent searching for .gitignore files past root.', collect)
93
94
  .option('--no-color', 'Turn off color.')
94
95
  .option('--color', 'Force color.')
96
+ .addOption(new commander_1.Option('--default-configuration', 'Load the default configuration and dictionaries.').hideHelp())
97
+ .addOption(new commander_1.Option('--no-default-configuration', 'Do not load the default configuration and dictionaries.'))
95
98
  .option('--debug', 'Output information useful for debugging cspell.json files.')
96
99
  .addHelpText('after', usage)
97
100
  .arguments('[globs...]')
@@ -43,6 +43,8 @@ function commandTrace(prog) {
43
43
  .option('--stdin', 'Read words from stdin.')
44
44
  .option('--no-color', 'Turn off color.')
45
45
  .option('--color', 'Force color')
46
+ .addOption(new commander_1.Option('--default-configuration', 'Load the default configuration and dictionaries.').hideHelp())
47
+ .addOption(new commander_1.Option('--no-default-configuration', 'Do not load the default configuration and dictionaries.'))
46
48
  .arguments('[words...]')
47
49
  .action(async (words, options) => {
48
50
  let numFound = 0;
package/dist/lint/lint.js CHANGED
@@ -24,15 +24,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.runLint = void 0;
27
+ const cspell_pipe_1 = require("@cspell/cspell-pipe");
27
28
  const cspell_types_1 = require("@cspell/cspell-types");
28
- const commentJson = __importStar(require("comment-json"));
29
29
  const cspell_gitignore_1 = require("cspell-gitignore");
30
30
  const cspell_glob_1 = require("cspell-glob");
31
31
  const cspell = __importStar(require("cspell-lib"));
32
32
  const path = __importStar(require("path"));
33
33
  const util_1 = require("util");
34
34
  const vscode_uri_1 = require("vscode-uri");
35
- const cspell_pipe_1 = require("@cspell/cspell-pipe");
36
35
  const cache_1 = require("../util/cache");
37
36
  const errors_1 = require("../util/errors");
38
37
  const fileHelper_1 = require("../util/fileHelper");
@@ -52,7 +51,7 @@ async function runLint(cfg) {
52
51
  await reporter.result(lintResult);
53
52
  return lintResult;
54
53
  async function processFile(filename, configInfo, cache) {
55
- var _a, _b, _c, _d;
54
+ var _a, _b, _c, _d, _e;
56
55
  const getElapsedTimeMs = (0, timer_1.getTimeMeasurer)();
57
56
  const cachedResult = await cache.getCachedLintResults(filename);
58
57
  if (cachedResult) {
@@ -80,10 +79,9 @@ async function runLint(cfg) {
80
79
  }
81
80
  const doc = (0, fileHelper_1.fileInfoToDocument)(fileInfo, cfg.options.languageId, cfg.locale);
82
81
  const { text } = fileInfo;
83
- reporter.debug(`Filename: ${filename}, LanguageIds: ${(_a = doc.languageId) !== null && _a !== void 0 ? _a : 'default'}`);
84
82
  result.fileInfo = fileInfo;
85
83
  let spellResult = {};
86
- reporter.info(`Checking: ${filename}, File type: ${(_b = doc.languageId) !== null && _b !== void 0 ? _b : 'auto'}, Language: ${(_c = doc.locale) !== null && _c !== void 0 ? _c : 'default'}`, cspell_types_1.MessageTypes.Info);
84
+ reporter.info(`Checking: ${filename}, File type: ${(_a = doc.languageId) !== null && _a !== void 0 ? _a : 'auto'}, Language: ${(_b = doc.locale) !== null && _b !== void 0 ? _b : 'default'}`, cspell_types_1.MessageTypes.Info);
87
85
  try {
88
86
  const validateOptions = { generateSuggestions: cfg.options.showSuggestions, numSuggestions: 5 };
89
87
  const r = await cspell.spellCheckDocument(doc, validateOptions, configInfo.config);
@@ -96,15 +94,23 @@ async function runLint(cfg) {
96
94
  result.errors += 1;
97
95
  }
98
96
  result.elapsedTimeMs = getElapsedTimeMs();
99
- const config = (_d = spellResult.settingsUsed) !== null && _d !== void 0 ? _d : {};
97
+ const config = (_c = spellResult.settingsUsed) !== null && _c !== void 0 ? _c : {};
100
98
  result.configErrors += await reportConfigurationErrors(config);
101
- const debugCfg = { config: { ...config, source: null }, source: spellResult.localConfigFilepath };
102
- reporter.debug(commentJson.stringify(debugCfg, undefined, 2));
103
99
  const elapsed = result.elapsedTimeMs / 1000.0;
104
100
  const dictionaries = config.dictionaries || [];
105
101
  reporter.info(`Checked: ${filename}, File type: ${config.languageId}, Language: ${config.language} ... Issues: ${result.issues.length} ${elapsed}S`, cspell_types_1.MessageTypes.Info);
106
102
  reporter.info(`Config file Used: ${spellResult.localConfigFilepath || configInfo.source}`, cspell_types_1.MessageTypes.Info);
107
103
  reporter.info(`Dictionaries Used: ${dictionaries.join(', ')}`, cspell_types_1.MessageTypes.Info);
104
+ if (cfg.options.debug) {
105
+ const { id: _id, name: _name, __imports, __importRef, ...cfg } = config;
106
+ const debugCfg = {
107
+ filename,
108
+ languageId: (_e = (_d = doc.languageId) !== null && _d !== void 0 ? _d : cfg.languageId) !== null && _e !== void 0 ? _e : 'default',
109
+ config: { ...cfg, source: null },
110
+ source: spellResult.localConfigFilepath,
111
+ };
112
+ reporter.debug(JSON.stringify(debugCfg, undefined, 2));
113
+ }
108
114
  const dep = calcDependencies(config);
109
115
  cache.setCachedLintResults(result, dep.files);
110
116
  return result;
@@ -120,6 +126,9 @@ async function runLint(cfg) {
120
126
  const fileCount = files instanceof Array ? files.length : undefined;
121
127
  const status = runResult();
122
128
  const cache = (0, cache_1.createCache)(cacheSettings);
129
+ if (cfg.options.cacheReset) {
130
+ cache.reset();
131
+ }
123
132
  const failFast = (_b = (_a = cfg.options.failFast) !== null && _a !== void 0 ? _a : configInfo.config.failFast) !== null && _b !== void 0 ? _b : false;
124
133
  const emitProgressBegin = (filename, fileNum, fileCount) => reporter.progress({
125
134
  type: 'ProgressFileBegin',
@@ -205,6 +214,9 @@ async function runLint(cfg) {
205
214
  process.env[cspell.ENV_CSPELL_GLOB_ROOT] = cfg.root;
206
215
  }
207
216
  const configInfo = await (0, fileHelper_1.readConfig)(cfg.configFile, cfg.root);
217
+ if (cfg.options.defaultConfiguration !== undefined) {
218
+ configInfo.config.loadDefaultConfiguration = cfg.options.defaultConfiguration;
219
+ }
208
220
  reporter = (0, reporters_1.mergeReporters)(cfg.reporter, ...(0, reporters_1.loadReporters)(configInfo.config));
209
221
  cspell.setLogger(getLoggerFromReporter(reporter));
210
222
  const globInfo = await determineGlobs(configInfo, cfg);
package/dist/options.d.ts CHANGED
@@ -119,6 +119,11 @@ export interface BaseOptions {
119
119
  * Locale to use.
120
120
  */
121
121
  locale?: string;
122
+ /**
123
+ * Load the default configuration
124
+ * @default true
125
+ */
126
+ defaultConfiguration?: boolean;
122
127
  }
123
128
  export interface LinterCliOptions extends Omit<LinterOptions, 'fileLists'> {
124
129
  legacy?: boolean;
@@ -1,2 +1,2 @@
1
- export { toAsyncIterable as mergeAsyncIterables, toArray as asyncIterableToArray } from '@cspell/cspell-pipe';
1
+ export { toAsyncIterable as mergeAsyncIterables, toArray as asyncIterableToArray, opMap as asyncMap, } from '@cspell/cspell-pipe';
2
2
  //# sourceMappingURL=async.d.ts.map
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.asyncIterableToArray = exports.mergeAsyncIterables = void 0;
3
+ exports.asyncMap = exports.asyncIterableToArray = exports.mergeAsyncIterables = void 0;
4
4
  var cspell_pipe_1 = require("@cspell/cspell-pipe");
5
5
  Object.defineProperty(exports, "mergeAsyncIterables", { enumerable: true, get: function () { return cspell_pipe_1.toAsyncIterable; } });
6
6
  Object.defineProperty(exports, "asyncIterableToArray", { enumerable: true, get: function () { return cspell_pipe_1.toArray; } });
7
+ Object.defineProperty(exports, "asyncMap", { enumerable: true, get: function () { return cspell_pipe_1.opMap; } });
7
8
  //# sourceMappingURL=async.js.map
@@ -12,5 +12,9 @@ export interface CSpellLintResultCache {
12
12
  * Persists the in-memory cache to disk.
13
13
  */
14
14
  reconcile(): void;
15
+ /**
16
+ * Resets the cache.
17
+ */
18
+ reset(): void;
15
19
  }
16
20
  //# sourceMappingURL=CSpellLintResultCache.d.ts.map
@@ -19,5 +19,9 @@ export interface CacheOptions {
19
19
  * Strategy to use for detecting changed files, default: metadata
20
20
  */
21
21
  cacheStrategy?: CacheStrategy;
22
+ /**
23
+ * Resets the cache
24
+ */
25
+ cacheReset?: boolean;
22
26
  }
23
27
  //# sourceMappingURL=CacheOptions.d.ts.map
@@ -1,37 +1,58 @@
1
1
  import type { FileDescriptor } from 'file-entry-cache';
2
2
  import type { FileResult } from '../../util/fileHelper';
3
3
  import type { CSpellLintResultCache } from './CSpellLintResultCache';
4
- export declare type CachedFileResult = Omit<FileResult, 'fileInfo' | 'elapsedTimeMs'>;
4
+ export declare type CachedFileResult = Omit<FileResult, 'fileInfo' | 'elapsedTimeMs' | 'cached'>;
5
5
  /**
6
6
  * This is the data cached.
7
7
  * Property names are short to help keep the cache file size small.
8
8
  */
9
9
  interface CachedData {
10
+ /** meta version + suffix */
11
+ v?: string;
10
12
  /** results */
11
- r: CachedFileResult;
13
+ r?: CachedFileResult;
12
14
  /** dependencies */
13
- d: string[];
14
- /** meta version */
15
- v: string;
15
+ d?: Dependency[];
16
+ }
17
+ interface Dependency {
18
+ /** filename */
19
+ f: string;
20
+ /** hash of file contents */
21
+ h?: string | undefined;
16
22
  }
17
23
  interface CSpellCachedMetaData {
18
24
  data?: CachedData;
19
25
  }
20
- export declare type CSpellCacheMeta = (FileDescriptor['meta'] & CSpellCachedMetaData) | undefined;
26
+ declare type Meta = FileDescriptor['meta'];
27
+ export declare type CSpellCacheMeta = (Meta & CSpellCachedMetaData) | undefined;
21
28
  /**
22
29
  * Caches cspell results on disk
23
30
  */
24
31
  export declare class DiskCache implements CSpellLintResultCache {
25
- readonly version: string;
32
+ readonly useCheckSum: boolean;
33
+ readonly cspellVersion: string;
26
34
  private fileEntryCache;
27
- private changedDependencies;
28
- private knownDependencies;
29
- constructor(cacheFileLocation: string, useCheckSum: boolean, version: string);
35
+ private dependencyCache;
36
+ private dependencyCacheTree;
37
+ private objectCollection;
38
+ private ocCacheFileResult;
39
+ readonly version: string;
40
+ constructor(cacheFileLocation: string, useCheckSum: boolean, cspellVersion: string);
30
41
  getCachedLintResults(filename: string): Promise<FileResult | undefined>;
31
- setCachedLintResults({ fileInfo, elapsedTimeMs: _, ...result }: FileResult, dependsUponFiles: string[]): void;
42
+ setCachedLintResults({ fileInfo, elapsedTimeMs: _, cached: __, ...result }: FileResult, dependsUponFiles: string[]): void;
32
43
  reconcile(): void;
33
- private cacheDependencies;
44
+ reset(): void;
45
+ private normalizeResult;
46
+ private calcDependencyHashes;
47
+ private checkDependency;
48
+ private getDependency;
49
+ private getFileDep;
34
50
  private checkDependencies;
51
+ private getHash;
35
52
  }
53
+ declare function calcVersion(version: string): string;
54
+ export declare const __testing__: {
55
+ calcVersion: typeof calcVersion;
56
+ };
36
57
  export {};
37
58
  //# sourceMappingURL=DiskCache.d.ts.map
@@ -23,19 +23,37 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.DiskCache = void 0;
26
+ exports.__testing__ = exports.DiskCache = void 0;
27
+ const crypto = __importStar(require("crypto"));
27
28
  const fileEntryCache = __importStar(require("file-entry-cache"));
29
+ const fs = __importStar(require("fs"));
28
30
  const path_1 = require("path");
29
31
  const fileHelper_1 = require("../../util/fileHelper");
32
+ const ObjectCollection_1 = require("./ObjectCollection");
33
+ const cacheDataKeys = {
34
+ v: 'v',
35
+ r: 'r',
36
+ d: 'd',
37
+ };
38
+ /**
39
+ * Meta Data Version is used to detect if the structure of the meta data has changed.
40
+ * This is used in combination with the Suffix and the version of CSpell.
41
+ */
42
+ const META_DATA_BASE_VERSION = '1';
43
+ const META_DATA_VERSION_SUFFIX = '-' + META_DATA_BASE_VERSION + '-' + Object.keys(cacheDataKeys).join('|');
30
44
  /**
31
45
  * Caches cspell results on disk
32
46
  */
33
47
  class DiskCache {
34
- constructor(cacheFileLocation, useCheckSum, version) {
35
- this.version = version;
36
- this.changedDependencies = new Set();
37
- this.knownDependencies = new Set();
48
+ constructor(cacheFileLocation, useCheckSum, cspellVersion) {
49
+ this.useCheckSum = useCheckSum;
50
+ this.cspellVersion = cspellVersion;
51
+ this.dependencyCache = new Map();
52
+ this.dependencyCacheTree = {};
53
+ this.objectCollection = new ObjectCollection_1.ShallowObjectCollection();
54
+ this.ocCacheFileResult = new ObjectCollection_1.ShallowObjectCollection();
38
55
  this.fileEntryCache = fileEntryCache.createFromFile((0, path_1.resolve)(cacheFileLocation), useCheckSum);
56
+ this.version = calcVersion(cspellVersion);
39
57
  }
40
58
  async getCachedLintResults(filename) {
41
59
  const fileDescriptor = this.fileEntryCache.getFileDescriptor(filename);
@@ -56,6 +74,12 @@ class DiskCache {
56
74
  !this.checkDependencies(data.d)) {
57
75
  return undefined;
58
76
  }
77
+ const dd = { ...data };
78
+ if (dd.d) {
79
+ dd.d = setTreeEntry(this.dependencyCacheTree, dd.d);
80
+ }
81
+ dd.r = dd.r && this.normalizeResult(dd.r);
82
+ meta.data = this.objectCollection.get(dd);
59
83
  // Skip reading empty files and files without lint error
60
84
  const hasErrors = !!result && (result.errors > 0 || result.configErrors > 0 || result.issues.length > 0);
61
85
  const cached = true;
@@ -67,41 +91,131 @@ class DiskCache {
67
91
  cached,
68
92
  };
69
93
  }
70
- setCachedLintResults({ fileInfo, elapsedTimeMs: _, ...result }, dependsUponFiles) {
94
+ setCachedLintResults({ fileInfo, elapsedTimeMs: _, cached: __, ...result }, dependsUponFiles) {
71
95
  const fileDescriptor = this.fileEntryCache.getFileDescriptor(fileInfo.filename);
72
96
  const meta = fileDescriptor.meta;
73
97
  if (fileDescriptor.notFound || !meta) {
74
98
  return;
75
99
  }
76
- const data = {
77
- r: result,
78
- d: dependsUponFiles,
100
+ const data = this.objectCollection.get({
79
101
  v: this.version,
80
- };
102
+ r: this.normalizeResult(result),
103
+ d: this.calcDependencyHashes(dependsUponFiles),
104
+ });
81
105
  meta.data = data;
82
- this.cacheDependencies(dependsUponFiles);
83
106
  }
84
107
  reconcile() {
85
108
  this.fileEntryCache.reconcile();
86
109
  }
87
- cacheDependencies(files) {
88
- this.fileEntryCache.analyzeFiles(files);
110
+ reset() {
111
+ this.fileEntryCache.destroy();
112
+ this.dependencyCache.clear();
113
+ this.dependencyCacheTree = {};
114
+ this.objectCollection = new ObjectCollection_1.ShallowObjectCollection();
115
+ this.ocCacheFileResult = new ObjectCollection_1.ShallowObjectCollection();
89
116
  }
90
- checkDependencies(files) {
91
- for (const file of files) {
92
- if (this.changedDependencies.has(file)) {
93
- return false;
94
- }
117
+ normalizeResult(result) {
118
+ const { issues, processed, errors, configErrors, ...rest } = result;
119
+ if (!Object.keys(rest).length) {
120
+ return this.ocCacheFileResult.get(result);
95
121
  }
96
- const unknown = files.filter((f) => !this.knownDependencies.has(f));
97
- if (!unknown.length) {
122
+ return this.ocCacheFileResult.get({ issues, processed, errors, configErrors });
123
+ }
124
+ calcDependencyHashes(dependsUponFiles) {
125
+ dependsUponFiles.sort();
126
+ const c = getTreeEntry(this.dependencyCacheTree, dependsUponFiles);
127
+ if (c === null || c === void 0 ? void 0 : c.d) {
128
+ return c.d;
129
+ }
130
+ const dependencies = dependsUponFiles.map((f) => this.getDependency(f));
131
+ return setTreeEntry(this.dependencyCacheTree, dependencies);
132
+ }
133
+ checkDependency(dep) {
134
+ const cDep = this.dependencyCache.get(dep.f);
135
+ if (cDep && compDep(dep, cDep))
98
136
  return true;
137
+ if (cDep)
138
+ return false;
139
+ const d = this.getFileDep(dep.f);
140
+ if (compDep(dep, d)) {
141
+ this.dependencyCache.set(dep.f, dep);
142
+ return true;
143
+ }
144
+ this.dependencyCache.set(d.f, d);
145
+ return false;
146
+ }
147
+ getDependency(file) {
148
+ const dep = this.dependencyCache.get(file);
149
+ if (dep)
150
+ return dep;
151
+ const d = this.getFileDep(file);
152
+ this.dependencyCache.set(file, d);
153
+ return d;
154
+ }
155
+ getFileDep(file) {
156
+ let h;
157
+ try {
158
+ const buffer = fs.readFileSync(file);
159
+ h = this.getHash(buffer);
160
+ }
161
+ catch (e) {
162
+ return { f: file };
99
163
  }
100
- const { changedFiles, notFoundFiles } = this.fileEntryCache.analyzeFiles(files);
101
- changedFiles.map((f) => this.changedDependencies.add(f));
102
- unknown.forEach((f) => this.knownDependencies.add(f));
103
- return changedFiles.length === 0 && notFoundFiles.length === 0;
164
+ return { f: file, h };
165
+ }
166
+ checkDependencies(dependencies) {
167
+ if (!dependencies)
168
+ return false;
169
+ for (const dep of dependencies) {
170
+ if (!this.checkDependency(dep)) {
171
+ return false;
172
+ }
173
+ }
174
+ return true;
175
+ }
176
+ getHash(buffer) {
177
+ return crypto.createHash('md5').update(buffer).digest('hex');
104
178
  }
105
179
  }
106
180
  exports.DiskCache = DiskCache;
181
+ function getTreeEntry(tree, keys) {
182
+ var _a;
183
+ let r = tree;
184
+ for (const k of keys) {
185
+ r = (_a = r.c) === null || _a === void 0 ? void 0 : _a.get(k);
186
+ if (!r)
187
+ return r;
188
+ }
189
+ return r;
190
+ }
191
+ function setTreeEntry(tree, deps, update = false) {
192
+ let r = tree;
193
+ for (const d of deps) {
194
+ const k = d.f;
195
+ if (!r.c) {
196
+ r.c = new Map();
197
+ }
198
+ const cn = r.c.get(k);
199
+ const n = cn !== null && cn !== void 0 ? cn : {};
200
+ if (!cn) {
201
+ r.c.set(k, n);
202
+ }
203
+ r = n;
204
+ }
205
+ let d = r.d;
206
+ if (!d || (r.d && update)) {
207
+ r.d = deps;
208
+ d = deps;
209
+ }
210
+ return d;
211
+ }
212
+ function compDep(a, b) {
213
+ return a.f === b.f && a.h === b.h;
214
+ }
215
+ function calcVersion(version) {
216
+ return version + META_DATA_VERSION_SUFFIX;
217
+ }
218
+ exports.__testing__ = {
219
+ calcVersion,
220
+ };
107
221
  //# sourceMappingURL=DiskCache.js.map
@@ -6,5 +6,6 @@ export declare class DummyCache implements CSpellLintResultCache {
6
6
  getCachedLintResults(): Promise<undefined>;
7
7
  setCachedLintResults(): void;
8
8
  reconcile(): void;
9
+ reset(): void;
9
10
  }
10
11
  //# sourceMappingURL=DummyCache.d.ts.map
@@ -14,6 +14,9 @@ class DummyCache {
14
14
  reconcile() {
15
15
  return;
16
16
  }
17
+ reset() {
18
+ return;
19
+ }
17
20
  }
18
21
  exports.DummyCache = DummyCache;
19
22
  //# sourceMappingURL=DummyCache.js.map
@@ -0,0 +1,17 @@
1
+ export declare class ShallowObjectCollection<T extends object> {
2
+ private tree;
3
+ get(v: T): T;
4
+ }
5
+ export declare class Collection {
6
+ private col;
7
+ /**
8
+ * Add a plain object to the collection.
9
+ * The actual object used is returned.
10
+ * By adding the object to the collection, it is now owned by the collection.
11
+ * Do not add class objects.
12
+ * @param v any object or primitive
13
+ * @returns v or the matching object.
14
+ */
15
+ add<T>(v: T): T;
16
+ }
17
+ //# sourceMappingURL=ObjectCollection.d.ts.map
@@ -0,0 +1,137 @@
1
+ "use strict";
2
+ /* eslint-disable @typescript-eslint/no-explicit-any */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.Collection = exports.ShallowObjectCollection = void 0;
5
+ const compare = Intl.Collator().compare;
6
+ class ShallowObjectCollection {
7
+ constructor() {
8
+ this.tree = {};
9
+ }
10
+ get(v) {
11
+ if (typeof v !== 'object' || v === null) {
12
+ return v;
13
+ }
14
+ const keys = Object.entries(v)
15
+ .filter((entry) => entry[1] !== undefined)
16
+ .sort((a, b) => compare(a[0], b[0]));
17
+ let t = this.tree;
18
+ for (const [key, obj] of keys) {
19
+ if (!t.c) {
20
+ t.c = new Map();
21
+ }
22
+ const c0 = t.c.get(key);
23
+ const cc = c0 || new Map();
24
+ if (!c0) {
25
+ t.c.set(key, cc);
26
+ }
27
+ const c1 = cc.get(obj);
28
+ const ccc = c1 || {};
29
+ if (!c1) {
30
+ cc.set(obj, ccc);
31
+ }
32
+ t = ccc;
33
+ }
34
+ if (t.v)
35
+ return t.v;
36
+ t.v = v;
37
+ return v;
38
+ }
39
+ }
40
+ exports.ShallowObjectCollection = ShallowObjectCollection;
41
+ class Collection {
42
+ constructor() {
43
+ this.col = { contains: new Map() };
44
+ }
45
+ /**
46
+ * Add a plain object to the collection.
47
+ * The actual object used is returned.
48
+ * By adding the object to the collection, it is now owned by the collection.
49
+ * Do not add class objects.
50
+ * @param v any object or primitive
51
+ * @returns v or the matching object.
52
+ */
53
+ add(v) {
54
+ return addToCollection(this.col, v);
55
+ }
56
+ }
57
+ exports.Collection = Collection;
58
+ // const objectLike: TypeMask = {
59
+ // array: true,
60
+ // object: true,
61
+ // };
62
+ function addToCollection(root, v) {
63
+ const known = root.contains;
64
+ function addValToCol(c, v) {
65
+ var _a;
66
+ const t = toValueType(v);
67
+ const val = c.v || Object.create(null);
68
+ const r = (_a = val[t]) !== null && _a !== void 0 ? _a : v;
69
+ val[t] = r;
70
+ c.v = val;
71
+ return val[t];
72
+ }
73
+ function walk(col, path) {
74
+ path = path.filter((entry) => entry[1] !== undefined).sort((a, b) => compare(a[0], b[0]));
75
+ for (const [k, v] of path) {
76
+ const c = col.c || Object.create(null);
77
+ col.c = c;
78
+ const m = c[k] || new Map();
79
+ c[k] = m;
80
+ const has = m.get(v);
81
+ col = has || Object.create(null);
82
+ if (!has) {
83
+ m.set(v, col);
84
+ }
85
+ }
86
+ return col;
87
+ }
88
+ function normalizeObjectEntries(entries) {
89
+ for (const entry of entries) {
90
+ entry[1] = add(entry[1]);
91
+ }
92
+ return entries;
93
+ }
94
+ function normalizeToPath(v) {
95
+ if (typeof v !== 'object' || !v) {
96
+ return [['', v]];
97
+ }
98
+ const entries = normalizeObjectEntries(Object.entries(v));
99
+ const obj = v;
100
+ if (!Object.isFrozen(v)) {
101
+ for (const [k, v] of entries) {
102
+ obj[k] = v;
103
+ }
104
+ Object.freeze(obj);
105
+ }
106
+ return entries;
107
+ }
108
+ function add(v) {
109
+ const isObjectLike = typeof v === 'object' && !!v;
110
+ if (isObjectLike) {
111
+ const cached = known.get(v);
112
+ if (cached !== undefined) {
113
+ return cached;
114
+ }
115
+ known.set(v, v);
116
+ }
117
+ const path = normalizeToPath(v);
118
+ const c = walk(root, path);
119
+ const r = addValToCol(c, v);
120
+ if (isObjectLike) {
121
+ known.set(v, r);
122
+ }
123
+ return r;
124
+ }
125
+ return add(v);
126
+ }
127
+ function toValueType(v) {
128
+ const t = typeof v;
129
+ if (t !== 'object')
130
+ return t;
131
+ if (v instanceof Array)
132
+ return 'array';
133
+ if (v === null)
134
+ return 'null';
135
+ return t;
136
+ }
137
+ //# sourceMappingURL=ObjectCollection.js.map
@@ -92,9 +92,11 @@ async function findFiles(globPatterns, options) {
92
92
  }
93
93
  exports.findFiles = findFiles;
94
94
  function calcFinalConfigInfo(configInfo, settingsFromCommandLine, filename, text) {
95
+ var _a, _b, _c;
95
96
  const ext = path.extname(filename);
96
97
  const fileSettings = cspell.calcOverrideSettings(configInfo.config, path.resolve(filename));
97
- const settings = cspell.mergeSettings(cspell.getDefaultSettings(), cspell.getGlobalSettings(), fileSettings, settingsFromCommandLine);
98
+ const loadDefault = (_c = (_b = (_a = settingsFromCommandLine.loadDefaultConfiguration) !== null && _a !== void 0 ? _a : configInfo.config.loadDefaultConfiguration) !== null && _b !== void 0 ? _b : fileSettings.loadDefaultConfiguration) !== null && _c !== void 0 ? _c : true;
99
+ const settings = cspell.mergeSettings(cspell.getDefaultSettings(loadDefault), cspell.getGlobalSettings(), fileSettings, settingsFromCommandLine);
98
100
  const languageIds = settings.languageId ? [settings.languageId] : cspell.getLanguagesForExt(ext);
99
101
  const config = cspell.constructSettingsForText(settings, text, languageIds);
100
102
  return {
@@ -105,6 +107,10 @@ function calcFinalConfigInfo(configInfo, settingsFromCommandLine, filename, text
105
107
  };
106
108
  }
107
109
  exports.calcFinalConfigInfo = calcFinalConfigInfo;
110
+ function resolveFilename(filename) {
111
+ return path.resolve(filename);
112
+ }
113
+ const resolveFilenames = (0, async_1.asyncMap)(resolveFilename);
108
114
  /**
109
115
  * Read
110
116
  * @param listFiles - array of file paths to read that will contain a list of files. Paths contained in each
@@ -120,7 +126,7 @@ async function readFileListFiles(listFiles) {
120
126
  });
121
127
  const found = flatten(await Promise.all(files.map(readFileListFile)));
122
128
  // Move `stdin` to the end.
123
- return useStdin ? (0, async_1.mergeAsyncIterables)(found, (0, stdin_1.readStdin)()) : found;
129
+ return useStdin ? resolveFilenames((0, async_1.mergeAsyncIterables)(found, (0, stdin_1.readStdin)())) : found;
124
130
  }
125
131
  exports.readFileListFiles = readFileListFiles;
126
132
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cspell",
3
- "version": "5.19.3",
3
+ "version": "5.19.6",
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,20 +70,19 @@
70
70
  },
71
71
  "homepage": "https://streetsidesoftware.github.io/cspell/",
72
72
  "dependencies": {
73
- "@cspell/cspell-pipe": "^5.19.3",
73
+ "@cspell/cspell-pipe": "^5.19.6",
74
74
  "chalk": "^4.1.2",
75
75
  "commander": "^9.1.0",
76
- "comment-json": "^4.2.2",
77
- "cspell-gitignore": "^5.19.3",
78
- "cspell-glob": "^5.19.3",
79
- "cspell-lib": "^5.19.3",
76
+ "cspell-gitignore": "^5.19.6",
77
+ "cspell-glob": "^5.19.6",
78
+ "cspell-lib": "^5.19.6",
80
79
  "fast-json-stable-stringify": "^2.1.0",
81
80
  "file-entry-cache": "^6.0.1",
82
81
  "fs-extra": "^10.0.1",
83
82
  "get-stdin": "^8.0.0",
84
83
  "glob": "^7.2.0",
85
84
  "imurmurhash": "^0.1.4",
86
- "semver": "^7.3.5",
85
+ "semver": "^7.3.6",
87
86
  "strip-ansi": "^6.0.1",
88
87
  "vscode-uri": "^3.0.3"
89
88
  },
@@ -91,8 +90,8 @@
91
90
  "node": ">=12.13.0"
92
91
  },
93
92
  "devDependencies": {
94
- "@cspell/cspell-json-reporter": "^5.19.3",
95
- "@cspell/cspell-types": "^5.19.3",
93
+ "@cspell/cspell-json-reporter": "^5.19.6",
94
+ "@cspell/cspell-types": "^5.19.6",
96
95
  "@types/file-entry-cache": "^5.0.2",
97
96
  "@types/fs-extra": "^9.0.13",
98
97
  "@types/glob": "^7.2.0",
@@ -101,11 +100,11 @@
101
100
  "@types/minimatch": "^3.0.5",
102
101
  "@types/semver": "^7.3.9",
103
102
  "jest": "^27.5.1",
104
- "micromatch": "^4.0.4",
103
+ "micromatch": "^4.0.5",
105
104
  "minimatch": "^5.0.1",
106
105
  "rimraf": "^3.0.2",
107
106
  "rollup": "^2.70.1",
108
107
  "rollup-plugin-dts": "^4.2.0"
109
108
  },
110
- "gitHead": "df43735d8f85fddbbd0befca7d98956f50474ce7"
109
+ "gitHead": "288584aa11eb262dab45201824c90206d7db65c3"
111
110
  }
@@ -1,6 +0,0 @@
1
- import { ConfigInfo } from '../../util/fileHelper';
2
- /**
3
- * Hashes ConfigInfo and cspell version for using in DiskCache
4
- */
5
- export declare function getConfigHash(configInfo: ConfigInfo): string;
6
- //# sourceMappingURL=getConfigHash.d.ts.map
@@ -1,26 +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.getConfigHash = void 0;
7
- const fast_json_stable_stringify_1 = __importDefault(require("fast-json-stable-stringify"));
8
- const path_1 = __importDefault(require("path"));
9
- const hash_1 = require("./hash");
10
- // eslint-disable-next-line @typescript-eslint/no-var-requires
11
- const { version } = require(path_1.default.join(__dirname, '..', '..', '..', 'package.json'));
12
- const configHashes = new WeakMap();
13
- /**
14
- * Hashes ConfigInfo and cspell version for using in DiskCache
15
- */
16
- function getConfigHash(configInfo) {
17
- const cachedHash = configHashes.get(configInfo);
18
- if (cachedHash !== undefined) {
19
- return cachedHash;
20
- }
21
- const hashValue = (0, hash_1.hash)(`${version}_${(0, fast_json_stable_stringify_1.default)(configInfo)}`);
22
- configHashes.set(configInfo, hashValue);
23
- return hashValue;
24
- }
25
- exports.getConfigHash = getConfigHash;
26
- //# sourceMappingURL=getConfigHash.js.map
@@ -1,5 +0,0 @@
1
- /**
2
- * Hash the given string using MurmurHash3
3
- */
4
- export declare function hash(str: string): string;
5
- //# sourceMappingURL=hash.d.ts.map
@@ -1,16 +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.hash = void 0;
7
- // cspell:word imurmurhash
8
- const imurmurhash_1 = __importDefault(require("imurmurhash"));
9
- /**
10
- * Hash the given string using MurmurHash3
11
- */
12
- function hash(str) {
13
- return (0, imurmurhash_1.default)(str).result().toString(36);
14
- }
15
- exports.hash = hash;
16
- //# sourceMappingURL=hash.js.map