cspell 6.29.2 → 6.30.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/README.md CHANGED
@@ -155,6 +155,7 @@ Options:
155
155
  --relative Issues are displayed relative to root.
156
156
  --show-context Show the surrounding text around an issue.
157
157
  --show-suggestions Show spelling suggestions.
158
+ --no-show-suggestions Do not show spelling suggestions or fixes.
158
159
  --no-must-find-files Do not error if no files are found.
159
160
  --cache Use cache to only check changed files.
160
161
  --no-cache Do not use cache.
@@ -31,7 +31,8 @@ const chalk_1 = __importDefault(require("chalk"));
31
31
  const cspell_lib_1 = require("cspell-lib");
32
32
  const path = __importStar(require("path"));
33
33
  const uri_cjs_1 = require("../lib/uri.cjs");
34
- const templateIssue = `{green $filename}:{yellow $row:$col} - $message ({red $text})`;
34
+ const templateIssue = `{green $filename}:{yellow $row:$col} - $message ({red $text}) $quickFix`;
35
+ const templateIssueNoFix = `{green $filename}:{yellow $row:$col} - $message ({red $text})`;
35
36
  const templateIssueWithSuggestions = `{green $filename}:{yellow $row:$col} - $message ({red $text}) Suggestions: {yellow [$suggestions]}`;
36
37
  const templateIssueWithContext = `{green $filename}:{yellow $row:$col} $padRowCol- $message ({red $text})$padContext -- {gray $contextLeft}{red {underline $text}}{gray $contextRight}`;
37
38
  const templateIssueWithContextWithSuggestions = `{green $filename}:{yellow $row:$col} $padRowCol- $message ({red $text})$padContext -- {gray $contextLeft}{red {underline $text}}{gray $contextRight}\n\t Suggestions: {yellow [$suggestions]}`;
@@ -112,7 +113,9 @@ function getReporter(options) {
112
113
  : templateIssueWithContext
113
114
  : options.showSuggestions
114
115
  ? templateIssueWithSuggestions
115
- : templateIssue;
116
+ : options.showSuggestions === false
117
+ ? templateIssueNoFix
118
+ : templateIssue;
116
119
  const { fileGlobs, silent, summary, issues, progress, verbose, debug } = options;
117
120
  const emitters = {
118
121
  Debug: !silent && debug ? (s) => console.info(chalk_1.default.cyan(s)) : nullEmitter,
@@ -181,9 +184,10 @@ function formatIssue(templateStr, issue, maxIssueTextWidth) {
181
184
  $suggestions: suggestions,
182
185
  $text: text,
183
186
  $uri: uri,
187
+ $quickFix: formatQuickFix(issue),
184
188
  };
185
189
  const t = template(templateStr.replace(/\$message/g, message));
186
- return substitute((0, chalk_1.default)(t), substitutions);
190
+ return substitute((0, chalk_1.default)(t), substitutions).trimEnd();
187
191
  }
188
192
  function formatSuggestions(issue) {
189
193
  if (issue.suggestionsEx) {
@@ -198,6 +202,17 @@ function formatSuggestions(issue) {
198
202
  }
199
203
  return '';
200
204
  }
205
+ function formatQuickFix(issue) {
206
+ if (!issue.suggestionsEx?.length)
207
+ return '';
208
+ const preferred = issue.suggestionsEx
209
+ .filter((sug) => sug.isPreferred)
210
+ .map((sug) => sug.wordAdjustedToMatchCase || sug.word);
211
+ if (!preferred.length)
212
+ return '';
213
+ const fixes = preferred.map((w) => chalk_1.default.italic(chalk_1.default.yellow(w)));
214
+ return `fix: (${fixes.join(', ')})`;
215
+ }
201
216
  class TS extends Array {
202
217
  constructor(s) {
203
218
  super(s);
@@ -99,6 +99,7 @@ function commandLint(prog) {
99
99
  .option('--relative', 'Issues are displayed relative to root.')
100
100
  .option('--show-context', 'Show the surrounding text around an issue.')
101
101
  .option('--show-suggestions', 'Show spelling suggestions.')
102
+ .addOption(new commander_1.Option('--no-show-suggestions', 'Do not show spelling suggestions or fixes.').default(undefined))
102
103
  .addOption(new commander_1.Option('--must-find-files', 'Error if no files are found.').default(true).hideHelp())
103
104
  .option('--no-must-find-files', 'Do not error if no files are found.')
104
105
  // The following options are planned features
@@ -2,7 +2,8 @@ import chalk from 'chalk';
2
2
  import { isSpellingDictionaryLoadError } from 'cspell-lib';
3
3
  import * as path from 'path';
4
4
  import { URI } from '../lib/uri.cjs';
5
- const templateIssue = `{green $filename}:{yellow $row:$col} - $message ({red $text})`;
5
+ const templateIssue = `{green $filename}:{yellow $row:$col} - $message ({red $text}) $quickFix`;
6
+ const templateIssueNoFix = `{green $filename}:{yellow $row:$col} - $message ({red $text})`;
6
7
  const templateIssueWithSuggestions = `{green $filename}:{yellow $row:$col} - $message ({red $text}) Suggestions: {yellow [$suggestions]}`;
7
8
  const templateIssueWithContext = `{green $filename}:{yellow $row:$col} $padRowCol- $message ({red $text})$padContext -- {gray $contextLeft}{red {underline $text}}{gray $contextRight}`;
8
9
  const templateIssueWithContextWithSuggestions = `{green $filename}:{yellow $row:$col} $padRowCol- $message ({red $text})$padContext -- {gray $contextLeft}{red {underline $text}}{gray $contextRight}\n\t Suggestions: {yellow [$suggestions]}`;
@@ -83,7 +84,9 @@ export function getReporter(options) {
83
84
  : templateIssueWithContext
84
85
  : options.showSuggestions
85
86
  ? templateIssueWithSuggestions
86
- : templateIssue;
87
+ : options.showSuggestions === false
88
+ ? templateIssueNoFix
89
+ : templateIssue;
87
90
  const { fileGlobs, silent, summary, issues, progress, verbose, debug } = options;
88
91
  const emitters = {
89
92
  Debug: !silent && debug ? (s) => console.info(chalk.cyan(s)) : nullEmitter,
@@ -151,9 +154,10 @@ function formatIssue(templateStr, issue, maxIssueTextWidth) {
151
154
  $suggestions: suggestions,
152
155
  $text: text,
153
156
  $uri: uri,
157
+ $quickFix: formatQuickFix(issue),
154
158
  };
155
159
  const t = template(templateStr.replace(/\$message/g, message));
156
- return substitute(chalk(t), substitutions);
160
+ return substitute(chalk(t), substitutions).trimEnd();
157
161
  }
158
162
  function formatSuggestions(issue) {
159
163
  if (issue.suggestionsEx) {
@@ -168,6 +172,17 @@ function formatSuggestions(issue) {
168
172
  }
169
173
  return '';
170
174
  }
175
+ function formatQuickFix(issue) {
176
+ if (!issue.suggestionsEx?.length)
177
+ return '';
178
+ const preferred = issue.suggestionsEx
179
+ .filter((sug) => sug.isPreferred)
180
+ .map((sug) => sug.wordAdjustedToMatchCase || sug.word);
181
+ if (!preferred.length)
182
+ return '';
183
+ const fixes = preferred.map((w) => chalk.italic(chalk.yellow(w)));
184
+ return `fix: (${fixes.join(', ')})`;
185
+ }
171
186
  class TS extends Array {
172
187
  constructor(s) {
173
188
  super(s);
@@ -73,6 +73,7 @@ export function commandLint(prog) {
73
73
  .option('--relative', 'Issues are displayed relative to root.')
74
74
  .option('--show-context', 'Show the surrounding text around an issue.')
75
75
  .option('--show-suggestions', 'Show spelling suggestions.')
76
+ .addOption(new CommanderOption('--no-show-suggestions', 'Do not show spelling suggestions or fixes.').default(undefined))
76
77
  .addOption(new CommanderOption('--must-find-files', 'Error if no files are found.').default(true).hideHelp())
77
78
  .option('--no-must-find-files', 'Do not error if no files are found.')
78
79
  // The following options are planned features
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cspell",
3
- "version": "6.29.2",
3
+ "version": "6.30.0",
4
4
  "description": "A Spelling Checker for Code!",
5
5
  "funding": "https://github.com/streetsidesoftware/cspell?sponsor=1",
6
6
  "bin": {
@@ -88,14 +88,14 @@
88
88
  },
89
89
  "homepage": "https://streetsidesoftware.github.io/cspell/",
90
90
  "dependencies": {
91
- "@cspell/cspell-pipe": "6.29.2",
92
- "@cspell/dynamic-import": "6.29.2",
91
+ "@cspell/cspell-pipe": "6.30.0",
92
+ "@cspell/dynamic-import": "6.30.0",
93
93
  "chalk": "^4.1.2",
94
94
  "commander": "^10.0.0",
95
- "cspell-gitignore": "6.29.2",
96
- "cspell-glob": "6.29.2",
97
- "cspell-io": "6.29.2",
98
- "cspell-lib": "6.29.2",
95
+ "cspell-gitignore": "6.30.0",
96
+ "cspell-glob": "6.30.0",
97
+ "cspell-io": "6.30.0",
98
+ "cspell-lib": "6.30.0",
99
99
  "fast-glob": "^3.2.12",
100
100
  "fast-json-stable-stringify": "^2.1.0",
101
101
  "file-entry-cache": "^6.0.1",
@@ -109,8 +109,8 @@
109
109
  "node": ">=14"
110
110
  },
111
111
  "devDependencies": {
112
- "@cspell/cspell-json-reporter": "6.29.2",
113
- "@cspell/cspell-types": "6.29.2",
112
+ "@cspell/cspell-json-reporter": "6.30.0",
113
+ "@cspell/cspell-types": "6.30.0",
114
114
  "@types/file-entry-cache": "^5.0.2",
115
115
  "@types/glob": "^8.1.0",
116
116
  "@types/imurmurhash": "^0.1.1",
@@ -119,5 +119,5 @@
119
119
  "micromatch": "^4.0.5",
120
120
  "minimatch": "^7.4.2"
121
121
  },
122
- "gitHead": "fae497508ec03795dfe0e0b70ea80cdf3d7be5a5"
122
+ "gitHead": "9af8c211fdeeb58e2d7a2be0e72405a23fe954cc"
123
123
  }