@cspell/eslint-plugin 6.26.0 → 6.26.2
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.
|
@@ -64,13 +64,13 @@ function create(context) {
|
|
|
64
64
|
};
|
|
65
65
|
}
|
|
66
66
|
log('Suggestions: %o', issue.suggestions);
|
|
67
|
-
const fixable = issue.
|
|
67
|
+
const fixable = issue.suggestions?.filter((sug) => !!sug.isPreferred);
|
|
68
68
|
const canFix = fixable?.length === 1;
|
|
69
69
|
const preferredSuggestion = autoFix && canFix && fixable[0];
|
|
70
70
|
const fix = preferredSuggestion
|
|
71
71
|
? fixFactory(preferredSuggestion.wordAdjustedToMatchCase || preferredSuggestion.word)
|
|
72
72
|
: nullFix;
|
|
73
|
-
const suggestions = issue.
|
|
73
|
+
const suggestions = issue.suggestions?.map((sug) => createSug(sug));
|
|
74
74
|
const suggest = suggestions;
|
|
75
75
|
const des = {
|
|
76
76
|
messageId,
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import type { ValidationIssue } from 'cspell-lib';
|
|
2
2
|
import type { Node } from 'estree';
|
|
3
3
|
import type { WorkerOptions } from '../common/options.js';
|
|
4
|
+
import type { NodeType } from './ASTNode.mjs';
|
|
5
|
+
type Suggestions = ValidationIssue['suggestionsEx'];
|
|
4
6
|
export interface Issue {
|
|
5
7
|
start: number;
|
|
6
8
|
end: number;
|
|
7
9
|
word: string;
|
|
8
10
|
severity: 'Forbidden' | 'Unknown' | 'Hint';
|
|
9
|
-
suggestions:
|
|
10
|
-
|
|
11
|
+
suggestions: Suggestions;
|
|
12
|
+
nodeType: NodeType;
|
|
11
13
|
}
|
|
12
14
|
type SpellCheckFn = typeof spellCheck;
|
|
13
15
|
export type SpellCheckSyncFn = (...p: Parameters<SpellCheckFn>) => Awaited<ReturnType<SpellCheckFn>>;
|
|
@@ -101,7 +101,7 @@ export async function spellCheck(filename, text, root, options) {
|
|
|
101
101
|
const range = [node.range[0] + adj, node.range[1] - adj];
|
|
102
102
|
const scope = calcScope(node);
|
|
103
103
|
const result = validator.checkText(range, text, scope);
|
|
104
|
-
result.forEach((issue) => reportIssue(issue));
|
|
104
|
+
result.forEach((issue) => reportIssue(issue, node.type));
|
|
105
105
|
}
|
|
106
106
|
function calcScope(_node) {
|
|
107
107
|
// inheritance(node);
|
|
@@ -149,14 +149,13 @@ export async function spellCheck(filename, text, root, options) {
|
|
|
149
149
|
function isObjectProperty(node) {
|
|
150
150
|
return node.parent?.type === 'MemberExpression';
|
|
151
151
|
}
|
|
152
|
-
function reportIssue(issue) {
|
|
152
|
+
function reportIssue(issue, nodeType) {
|
|
153
153
|
const word = issue.text;
|
|
154
154
|
const start = issue.offset;
|
|
155
155
|
const end = issue.offset + (issue.length || issue.text.length);
|
|
156
|
-
const suggestions = issue.
|
|
157
|
-
const suggestionsEx = issue.suggestionsEx;
|
|
156
|
+
const suggestions = normalizeSuggestions(issue.suggestionsEx, nodeType);
|
|
158
157
|
const severity = issue.isFlagged ? 'Forbidden' : 'Unknown';
|
|
159
|
-
issues.push({ word, start, end,
|
|
158
|
+
issues.push({ word, start, end, nodeType, suggestions, severity });
|
|
160
159
|
}
|
|
161
160
|
const processors = {
|
|
162
161
|
Line: checkComment,
|
|
@@ -318,3 +317,24 @@ function getTextDocument(filename, content) {
|
|
|
318
317
|
function isCustomWordListFile(value) {
|
|
319
318
|
return !!value && typeof value === 'object';
|
|
320
319
|
}
|
|
320
|
+
const needToAdjustSpace = {
|
|
321
|
+
Identifier: true,
|
|
322
|
+
};
|
|
323
|
+
const isSpecial = /[^\p{L}_0-9]/u;
|
|
324
|
+
const allSpecial = /[^\p{L}_0-9]/gu;
|
|
325
|
+
function normalizeSuggestions(suggestions, nodeType) {
|
|
326
|
+
if (!suggestions)
|
|
327
|
+
return undefined;
|
|
328
|
+
if (!(nodeType in needToAdjustSpace))
|
|
329
|
+
return suggestions;
|
|
330
|
+
return suggestions.map((sug) => {
|
|
331
|
+
if (!isSpecial.test(sug.word))
|
|
332
|
+
return sug;
|
|
333
|
+
const s = { ...sug };
|
|
334
|
+
s.word = s.word.replace(allSpecial, '_');
|
|
335
|
+
if (s.wordAdjustedToMatchCase) {
|
|
336
|
+
s.wordAdjustedToMatchCase = s.wordAdjustedToMatchCase.replace(allSpecial, '_');
|
|
337
|
+
}
|
|
338
|
+
return s;
|
|
339
|
+
});
|
|
340
|
+
}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "6.26.
|
|
6
|
+
"version": "6.26.2",
|
|
7
7
|
"description": "CSpell ESLint plugin",
|
|
8
8
|
"keywords": [
|
|
9
9
|
"cspell",
|
|
@@ -66,9 +66,9 @@
|
|
|
66
66
|
"ts-json-schema-generator": "^1.2.0"
|
|
67
67
|
},
|
|
68
68
|
"dependencies": {
|
|
69
|
-
"cspell-lib": "6.26.
|
|
69
|
+
"cspell-lib": "6.26.2",
|
|
70
70
|
"estree-walker": "^3.0.3",
|
|
71
71
|
"synckit": "^0.8.5"
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "9c983b5f96c3d7b089e49178ab0b437b5eada256"
|
|
74
74
|
}
|