cspell 5.19.4 → 5.19.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.
@@ -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) {
@@ -92,6 +92,8 @@ function commandLint(prog) {
92
92
  .option('--gitignore-root <path>', 'Prevent searching for .gitignore files past root.', collect)
93
93
  .option('--no-color', 'Turn off color.')
94
94
  .option('--color', 'Force color.')
95
+ .addOption(new commander_1.Option('--default-configuration', 'Load the default configuration and dictionaries.').hideHelp())
96
+ .addOption(new commander_1.Option('--no-default-configuration', 'Do not load the default configuration and dictionaries.'))
95
97
  .option('--debug', 'Output information useful for debugging cspell.json files.')
96
98
  .addHelpText('after', usage)
97
99
  .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
@@ -51,7 +51,7 @@ async function runLint(cfg) {
51
51
  await reporter.result(lintResult);
52
52
  return lintResult;
53
53
  async function processFile(filename, configInfo, cache) {
54
- var _a, _b, _c, _d;
54
+ var _a, _b, _c, _d, _e;
55
55
  const getElapsedTimeMs = (0, timer_1.getTimeMeasurer)();
56
56
  const cachedResult = await cache.getCachedLintResults(filename);
57
57
  if (cachedResult) {
@@ -79,10 +79,9 @@ async function runLint(cfg) {
79
79
  }
80
80
  const doc = (0, fileHelper_1.fileInfoToDocument)(fileInfo, cfg.options.languageId, cfg.locale);
81
81
  const { text } = fileInfo;
82
- reporter.debug(`Filename: ${filename}, LanguageIds: ${(_a = doc.languageId) !== null && _a !== void 0 ? _a : 'default'}`);
83
82
  result.fileInfo = fileInfo;
84
83
  let spellResult = {};
85
- 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);
86
85
  try {
87
86
  const validateOptions = { generateSuggestions: cfg.options.showSuggestions, numSuggestions: 5 };
88
87
  const r = await cspell.spellCheckDocument(doc, validateOptions, configInfo.config);
@@ -95,18 +94,23 @@ async function runLint(cfg) {
95
94
  result.errors += 1;
96
95
  }
97
96
  result.elapsedTimeMs = getElapsedTimeMs();
98
- const config = (_d = spellResult.settingsUsed) !== null && _d !== void 0 ? _d : {};
97
+ const config = (_c = spellResult.settingsUsed) !== null && _c !== void 0 ? _c : {};
99
98
  result.configErrors += await reportConfigurationErrors(config);
100
- if (cfg.options.debug) {
101
- const { id: _id, name: _name, ...cfg } = config;
102
- const debugCfg = { config: { ...cfg, source: null }, source: spellResult.localConfigFilepath };
103
- reporter.debug(JSON.stringify(debugCfg, undefined, 2));
104
- }
105
99
  const elapsed = result.elapsedTimeMs / 1000.0;
106
100
  const dictionaries = config.dictionaries || [];
107
101
  reporter.info(`Checked: ${filename}, File type: ${config.languageId}, Language: ${config.language} ... Issues: ${result.issues.length} ${elapsed}S`, cspell_types_1.MessageTypes.Info);
108
102
  reporter.info(`Config file Used: ${spellResult.localConfigFilepath || configInfo.source}`, cspell_types_1.MessageTypes.Info);
109
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
+ }
110
114
  const dep = calcDependencies(config);
111
115
  cache.setCachedLintResults(result, dep.files);
112
116
  return result;
@@ -207,6 +211,9 @@ async function runLint(cfg) {
207
211
  process.env[cspell.ENV_CSPELL_GLOB_ROOT] = cfg.root;
208
212
  }
209
213
  const configInfo = await (0, fileHelper_1.readConfig)(cfg.configFile, cfg.root);
214
+ if (cfg.options.defaultConfiguration !== undefined) {
215
+ configInfo.config.loadDefaultConfiguration = cfg.options.defaultConfiguration;
216
+ }
210
217
  reporter = (0, reporters_1.mergeReporters)(cfg.reporter, ...(0, reporters_1.loadReporters)(configInfo.config));
211
218
  cspell.setLogger(getLoggerFromReporter(reporter));
212
219
  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;
@@ -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 {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cspell",
3
- "version": "5.19.4",
3
+ "version": "5.19.5",
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,12 +70,12 @@
70
70
  },
71
71
  "homepage": "https://streetsidesoftware.github.io/cspell/",
72
72
  "dependencies": {
73
- "@cspell/cspell-pipe": "^5.19.4",
73
+ "@cspell/cspell-pipe": "^5.19.5",
74
74
  "chalk": "^4.1.2",
75
75
  "commander": "^9.1.0",
76
- "cspell-gitignore": "^5.19.4",
77
- "cspell-glob": "^5.19.4",
78
- "cspell-lib": "^5.19.4",
76
+ "cspell-gitignore": "^5.19.5",
77
+ "cspell-glob": "^5.19.5",
78
+ "cspell-lib": "^5.19.5",
79
79
  "fast-json-stable-stringify": "^2.1.0",
80
80
  "file-entry-cache": "^6.0.1",
81
81
  "fs-extra": "^10.0.1",
@@ -90,8 +90,8 @@
90
90
  "node": ">=12.13.0"
91
91
  },
92
92
  "devDependencies": {
93
- "@cspell/cspell-json-reporter": "^5.19.4",
94
- "@cspell/cspell-types": "^5.19.4",
93
+ "@cspell/cspell-json-reporter": "^5.19.5",
94
+ "@cspell/cspell-types": "^5.19.5",
95
95
  "@types/file-entry-cache": "^5.0.2",
96
96
  "@types/fs-extra": "^9.0.13",
97
97
  "@types/glob": "^7.2.0",
@@ -106,5 +106,5 @@
106
106
  "rollup": "^2.70.1",
107
107
  "rollup-plugin-dts": "^4.2.0"
108
108
  },
109
- "gitHead": "9f7e77c95eb1e8fabf53c5b74b7418b2d114ef02"
109
+ "gitHead": "0d113f01b51c3bc149a01269878d4217a58ecb97"
110
110
  }