@cspell/eslint-plugin 7.3.6 → 7.3.7
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 +39 -9
- package/assets/options.schema.json +51 -50
- package/dist/common/logger.cjs +53 -0
- package/dist/common/logger.d.cts +22 -0
- package/dist/common/options.d.cts +4 -4
- package/dist/plugin/cspell-eslint-plugin.cjs +24 -23
- package/dist/plugin/defaultCheckOptions.cjs +0 -1
- package/dist/worker/spellCheck.d.mts +2 -2
- package/dist/worker/spellCheck.mjs +65 -18
- package/dist/worker/types.d.cts +5 -1
- package/dist/worker/worker.d.mts +1 -0
- package/dist/worker/worker.mjs +2 -1
- package/package.json +18 -15
package/README.md
CHANGED
|
@@ -84,16 +84,46 @@ interface Options {
|
|
|
84
84
|
*/
|
|
85
85
|
checkComments?: boolean;
|
|
86
86
|
/**
|
|
87
|
-
* CSpell
|
|
88
|
-
*
|
|
89
|
-
* @words - list of words to be always considered correct
|
|
90
|
-
*
|
|
91
|
-
* @ignoreWords - a list of words to be ignored (even if they are in the flagWords)
|
|
92
|
-
*
|
|
93
|
-
* @flagWords - a list of words to be always considered incorrect, unless ignored.
|
|
94
|
-
*
|
|
87
|
+
* Some CSpell Settings
|
|
95
88
|
*/
|
|
96
|
-
|
|
89
|
+
cspell?: {
|
|
90
|
+
/** List of words to be considered correct. */
|
|
91
|
+
words?: string[];
|
|
92
|
+
/**
|
|
93
|
+
* List of words to be ignored.
|
|
94
|
+
* An ignored word will not show up as an error, even if it is also
|
|
95
|
+
* in the `flagWords`.
|
|
96
|
+
*/
|
|
97
|
+
ignoreWords?: string[];
|
|
98
|
+
/**
|
|
99
|
+
* List of words to always be considered incorrect.
|
|
100
|
+
* Words found in `flagWords` override `words`.
|
|
101
|
+
* Format of `flagWords`
|
|
102
|
+
* - single word entry - `word`
|
|
103
|
+
* - with suggestions - `word:suggestion` or `word->suggestion, suggestions`
|
|
104
|
+
*/
|
|
105
|
+
flagWords?: string[];
|
|
106
|
+
/**
|
|
107
|
+
* List of regular expression patterns or pattern names to exclude
|
|
108
|
+
* from spell checking.
|
|
109
|
+
*/
|
|
110
|
+
ignoreRegExpList?: string[];
|
|
111
|
+
/**
|
|
112
|
+
* List of regular expression patterns or defined pattern names to
|
|
113
|
+
* match for spell checking.
|
|
114
|
+
* If this property is defined, only text matching the included
|
|
115
|
+
* patterns will be checked.
|
|
116
|
+
*/
|
|
117
|
+
includeRegExpList?: string[];
|
|
118
|
+
/** Allows words to be glued together. */
|
|
119
|
+
allowCompoundWords?: boolean;
|
|
120
|
+
/** Import cspell config file. */
|
|
121
|
+
import?: string[];
|
|
122
|
+
/** List of dictionaries to enable */
|
|
123
|
+
dictionaries?: string[];
|
|
124
|
+
/** Define dictionaries. */
|
|
125
|
+
dictionaryDefinitions?: DictionaryDefinition[];
|
|
126
|
+
};
|
|
97
127
|
/**
|
|
98
128
|
* Specify a path to a custom word list file.
|
|
99
129
|
*
|
|
@@ -50,60 +50,62 @@
|
|
|
50
50
|
},
|
|
51
51
|
"type": "array"
|
|
52
52
|
},
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
|
|
56
|
-
"
|
|
57
|
-
"description":
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
"
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
"
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
"
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
"items": {
|
|
53
|
+
"dictionaryDefinitions": {
|
|
54
|
+
"items": {
|
|
55
|
+
"additionalProperties": false,
|
|
56
|
+
"properties": {
|
|
57
|
+
"description": {
|
|
58
|
+
"description": "Optional description.",
|
|
59
|
+
"type": "string"
|
|
60
|
+
},
|
|
61
|
+
"name": {
|
|
62
|
+
"description": "This is the name of a dictionary.\n\nName Format:\n- Must contain at least 1 number or letter.\n- Spaces are allowed.\n- Leading and trailing space will be removed.\n- Names ARE case-sensitive.\n- Must not contain `*`, `!`, `;`, `,`, `{`, `}`, `[`, `]`, `~`.",
|
|
63
|
+
"pattern": "^(?=[^!*,;{}[\\]~\\n]+$)(?=(.*\\w)).+$",
|
|
64
|
+
"type": "string"
|
|
65
|
+
},
|
|
66
|
+
"noSuggest": {
|
|
67
|
+
"description": "Indicate that suggestions should not come from this dictionary. Words in this dictionary are considered correct, but will not be used when making spell correction suggestions.\n\nNote: if a word is suggested by another dictionary, but found in this dictionary, it will be removed from the set of possible suggestions.",
|
|
68
|
+
"type": "boolean"
|
|
69
|
+
},
|
|
70
|
+
"path": {
|
|
71
|
+
"description": "Path to the file.",
|
|
72
|
+
"type": "string"
|
|
73
|
+
},
|
|
74
|
+
"repMap": {
|
|
75
|
+
"description": "Replacement pairs.",
|
|
77
76
|
"items": {
|
|
78
|
-
"
|
|
77
|
+
"items": {
|
|
78
|
+
"type": "string"
|
|
79
|
+
},
|
|
80
|
+
"maxItems": 2,
|
|
81
|
+
"minItems": 2,
|
|
82
|
+
"type": "array"
|
|
79
83
|
},
|
|
80
|
-
"maxItems": 2,
|
|
81
|
-
"minItems": 2,
|
|
82
84
|
"type": "array"
|
|
83
85
|
},
|
|
84
|
-
"type":
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
"
|
|
94
|
-
|
|
95
|
-
"
|
|
86
|
+
"type": {
|
|
87
|
+
"default": "S",
|
|
88
|
+
"description": "Type of file:\n- S - single word per line,\n- W - each line can contain one or more words separated by space,\n- C - each line is treated like code (Camel Case is allowed).\n\nDefault is S.\n\nC is the slowest to load due to the need to split each line based upon code splitting rules.",
|
|
89
|
+
"enum": [
|
|
90
|
+
"S",
|
|
91
|
+
"W",
|
|
92
|
+
"C",
|
|
93
|
+
"T"
|
|
94
|
+
],
|
|
95
|
+
"type": "string"
|
|
96
|
+
},
|
|
97
|
+
"useCompounds": {
|
|
98
|
+
"description": "Use Compounds.",
|
|
99
|
+
"type": "boolean"
|
|
100
|
+
}
|
|
96
101
|
},
|
|
97
|
-
"
|
|
98
|
-
"
|
|
99
|
-
"
|
|
100
|
-
|
|
102
|
+
"required": [
|
|
103
|
+
"name",
|
|
104
|
+
"path"
|
|
105
|
+
],
|
|
106
|
+
"type": "object"
|
|
101
107
|
},
|
|
102
|
-
"
|
|
103
|
-
"name",
|
|
104
|
-
"path"
|
|
105
|
-
],
|
|
106
|
-
"type": "object"
|
|
108
|
+
"type": "array"
|
|
107
109
|
},
|
|
108
110
|
"enabled": {
|
|
109
111
|
"default": true,
|
|
@@ -189,8 +191,7 @@
|
|
|
189
191
|
"description": "Specify a path to a custom word list file.\n\nexample: ```js customWordListFile: \"./myWords.txt\" ```"
|
|
190
192
|
},
|
|
191
193
|
"debugMode": {
|
|
192
|
-
"
|
|
193
|
-
"description": "Output debug logs",
|
|
194
|
+
"description": "Output debug logs to `.cspell-eslint-plugin.log` default false",
|
|
194
195
|
"type": "boolean"
|
|
195
196
|
},
|
|
196
197
|
"generateSuggestions": {
|
|
@@ -0,0 +1,53 @@
|
|
|
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.getDefaultLogger = exports.Logger = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const util_1 = require("util");
|
|
10
|
+
const debugMode = false;
|
|
11
|
+
class Logger {
|
|
12
|
+
constructor(options) {
|
|
13
|
+
this.options = options;
|
|
14
|
+
this.logToFile = true;
|
|
15
|
+
this.enabled = true;
|
|
16
|
+
this.useAsync = false;
|
|
17
|
+
this.log = this._log.bind(this);
|
|
18
|
+
this.cwd = path_1.default.resolve(options.cwd || '.');
|
|
19
|
+
const logFileBasename = options.logFile || '.cspell-eslint-plugin.log';
|
|
20
|
+
this.logFile = path_1.default.resolve(this.cwd, logFileBasename);
|
|
21
|
+
this.logToFile = options.logToFile ?? true;
|
|
22
|
+
this.enabled = options.enabled ?? debugMode;
|
|
23
|
+
this.useAsync = options.useAsync ?? false;
|
|
24
|
+
}
|
|
25
|
+
_log(...p) {
|
|
26
|
+
if (!this.enabled)
|
|
27
|
+
return;
|
|
28
|
+
if (!this.logToFile)
|
|
29
|
+
return console.log(...p);
|
|
30
|
+
const message = new Date().toISOString() + ' ' + prefixLines((0, util_1.format)(...p), ' ') + '\n';
|
|
31
|
+
this.useAsync
|
|
32
|
+
? fs_1.default.appendFile(this.logFile, message, (err) => err && console.error(err))
|
|
33
|
+
: fs_1.default.appendFileSync(this.logFile, message);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.Logger = Logger;
|
|
38
|
+
let logger;
|
|
39
|
+
function getDefaultLogger() {
|
|
40
|
+
if (logger)
|
|
41
|
+
return logger;
|
|
42
|
+
logger = new Logger({});
|
|
43
|
+
return logger;
|
|
44
|
+
}
|
|
45
|
+
exports.getDefaultLogger = getDefaultLogger;
|
|
46
|
+
function prefixLines(text, prefix, startIndex = 1) {
|
|
47
|
+
return text
|
|
48
|
+
.split('\n')
|
|
49
|
+
.map((line, index) => (index >= startIndex ? prefix + line : line))
|
|
50
|
+
.map((line) => (line.trim() == '' ? '' : line))
|
|
51
|
+
.join('\n');
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=logger.cjs.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface LoggerOptions {
|
|
2
|
+
logFile?: string;
|
|
3
|
+
cwd?: string;
|
|
4
|
+
/** true - write to file, false - output to console. */
|
|
5
|
+
logToFile?: boolean;
|
|
6
|
+
/** enable logging by default? */
|
|
7
|
+
enabled?: boolean;
|
|
8
|
+
useAsync?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare class Logger {
|
|
11
|
+
readonly options: LoggerOptions;
|
|
12
|
+
readonly logFile: string;
|
|
13
|
+
readonly cwd: string;
|
|
14
|
+
logToFile: boolean;
|
|
15
|
+
enabled: boolean;
|
|
16
|
+
useAsync: boolean;
|
|
17
|
+
constructor(options: LoggerOptions);
|
|
18
|
+
private _log;
|
|
19
|
+
log: (message?: any, ...optionalParams: any[]) => void;
|
|
20
|
+
}
|
|
21
|
+
export declare function getDefaultLogger(): Logger;
|
|
22
|
+
//# sourceMappingURL=logger.d.cts.map
|
|
@@ -17,16 +17,16 @@ export interface Options extends Check {
|
|
|
17
17
|
*/
|
|
18
18
|
autoFix: boolean;
|
|
19
19
|
/**
|
|
20
|
-
* Output debug logs
|
|
21
|
-
*
|
|
20
|
+
* Output debug logs to `.cspell-eslint-plugin.log`
|
|
21
|
+
* default false
|
|
22
22
|
*/
|
|
23
23
|
debugMode?: boolean;
|
|
24
24
|
}
|
|
25
25
|
type DictionaryDefinition = DictionaryDefinitionPreferred;
|
|
26
26
|
export type CSpellOptions = Pick<CSpellSettings, 'allowCompoundWords' | 'dictionaries' | 'enabled' | 'flagWords' | 'ignoreWords' | 'ignoreRegExpList' | 'includeRegExpList' | 'import' | 'words'> & {
|
|
27
|
-
|
|
27
|
+
dictionaryDefinitions?: DictionaryDefinition[];
|
|
28
28
|
};
|
|
29
|
-
export type RequiredOptions = Required<Options>;
|
|
29
|
+
export type RequiredOptions = Required<Pick<Options, Exclude<keyof Options, 'debugMode'>>> & Pick<Options, 'debugMode'>;
|
|
30
30
|
export interface Check {
|
|
31
31
|
/**
|
|
32
32
|
* Ignore import and require names
|
|
@@ -4,6 +4,7 @@ exports.configs = exports.rules = void 0;
|
|
|
4
4
|
const fs_1 = require("fs");
|
|
5
5
|
const path_1 = require("path");
|
|
6
6
|
const synckit_1 = require("synckit");
|
|
7
|
+
const logger_cjs_1 = require("../common/logger.cjs");
|
|
7
8
|
const defaultCheckOptions_cjs_1 = require("./defaultCheckOptions.cjs");
|
|
8
9
|
const optionsSchema = JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(__dirname, '../../assets/options.schema.json'), 'utf8'));
|
|
9
10
|
const schema = optionsSchema;
|
|
@@ -25,26 +26,24 @@ const meta = {
|
|
|
25
26
|
schema: [schema],
|
|
26
27
|
};
|
|
27
28
|
let isDebugMode = false;
|
|
28
|
-
function log(...args) {
|
|
29
|
-
if (!isDebugMode)
|
|
30
|
-
return;
|
|
31
|
-
console.log(...args);
|
|
32
|
-
}
|
|
33
29
|
function nullFix() {
|
|
34
30
|
return null;
|
|
35
31
|
}
|
|
36
32
|
function create(context) {
|
|
37
|
-
const
|
|
33
|
+
const logger = (0, logger_cjs_1.getDefaultLogger)();
|
|
34
|
+
const log = logger.log;
|
|
35
|
+
const options = (0, defaultCheckOptions_cjs_1.normalizeOptions)(context.options[0], context.cwd);
|
|
38
36
|
const autoFix = options.autoFix;
|
|
39
|
-
isDebugMode = options.debugMode
|
|
40
|
-
|
|
37
|
+
isDebugMode = options.debugMode ?? isDebugMode;
|
|
38
|
+
logger.enabled = options.debugMode ?? (logger.enabled || isDebugMode);
|
|
39
|
+
logContext(log, context);
|
|
41
40
|
function reportIssue(issue) {
|
|
42
41
|
const messageId = issue.severity === 'Forbidden' ? 'wordForbidden' : 'wordUnknown';
|
|
43
42
|
const { word, start, end } = issue;
|
|
44
43
|
const data = {
|
|
45
44
|
word,
|
|
46
45
|
};
|
|
47
|
-
const code = context.
|
|
46
|
+
const code = context.sourceCode;
|
|
48
47
|
const startPos = code.getLocFromIndex(start);
|
|
49
48
|
const endPos = code.getLocFromIndex(end);
|
|
50
49
|
const loc = { start: startPos, end: endPos };
|
|
@@ -62,7 +61,7 @@ function create(context) {
|
|
|
62
61
|
fix: fixFactory(word),
|
|
63
62
|
};
|
|
64
63
|
}
|
|
65
|
-
log('Suggestions: %o', issue.suggestions);
|
|
64
|
+
// log('Suggestions: %o', issue.suggestions);
|
|
66
65
|
const issueSuggestions = issue.suggestions;
|
|
67
66
|
const fixable = issueSuggestions?.filter((sug) => !!sug.isPreferred);
|
|
68
67
|
const canFix = fixable?.length === 1;
|
|
@@ -82,8 +81,12 @@ function create(context) {
|
|
|
82
81
|
context.report(des);
|
|
83
82
|
}
|
|
84
83
|
function checkProgram() {
|
|
85
|
-
const sc = context.
|
|
86
|
-
const issues = spellCheck(context.
|
|
84
|
+
const sc = context.sourceCode;
|
|
85
|
+
const { issues, errors } = spellCheck(context.filename, sc.text, sc.ast, options);
|
|
86
|
+
if (errors && errors.length) {
|
|
87
|
+
log('errors: %o', errors.map((e) => e.message));
|
|
88
|
+
errors.forEach((error) => console.error('%s', error.message));
|
|
89
|
+
}
|
|
87
90
|
issues.forEach((issue) => reportIssue(issue));
|
|
88
91
|
}
|
|
89
92
|
return { Program: checkProgram };
|
|
@@ -94,17 +97,15 @@ exports.rules = {
|
|
|
94
97
|
create,
|
|
95
98
|
},
|
|
96
99
|
};
|
|
97
|
-
function logContext(context) {
|
|
98
|
-
log('
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
scope: ${context.getScope().type}
|
|
107
|
-
`);
|
|
100
|
+
function logContext(log, context) {
|
|
101
|
+
log('context: %o', {
|
|
102
|
+
id: context.id,
|
|
103
|
+
cwd: context.cwd,
|
|
104
|
+
filename: context.filename,
|
|
105
|
+
physicalFilename: context.physicalFilename,
|
|
106
|
+
scope: context.getScope().type,
|
|
107
|
+
options: context.options.length === 1 ? context.options[0] : context.options,
|
|
108
|
+
});
|
|
108
109
|
}
|
|
109
110
|
exports.configs = {
|
|
110
111
|
recommended: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Node } from 'estree';
|
|
2
2
|
import type { WorkerOptions } from '../common/options.cjs';
|
|
3
|
-
import type {
|
|
4
|
-
export declare function spellCheck(filename: string, text: string, root: Node, options: WorkerOptions): Promise<
|
|
3
|
+
import type { SpellCheckResults } from './types.cjs';
|
|
4
|
+
export declare function spellCheck(filename: string, text: string, root: Node, options: WorkerOptions): Promise<SpellCheckResults>;
|
|
5
5
|
//# sourceMappingURL=spellCheck.d.mts.map
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import assert from 'assert';
|
|
2
|
-
import { createTextDocument, DocumentValidator, refreshDictionaryCache } from 'cspell-lib';
|
|
2
|
+
import { createTextDocument, DocumentValidator, extractImportErrors, getDictionary, refreshDictionaryCache, } from 'cspell-lib';
|
|
3
3
|
import * as path from 'path';
|
|
4
4
|
import { format } from 'util';
|
|
5
|
+
import { getDefaultLogger } from '../common/logger.cjs';
|
|
5
6
|
import { walkTree } from './walkTree.mjs';
|
|
6
7
|
const defaultSettings = {
|
|
7
8
|
patterns: [
|
|
@@ -13,19 +14,28 @@ const defaultSettings = {
|
|
|
13
14
|
// },
|
|
14
15
|
],
|
|
15
16
|
};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if (!isDebugMode)
|
|
19
|
-
return;
|
|
20
|
-
console.log(...args);
|
|
21
|
-
}
|
|
17
|
+
const isDebugModeExtended = false;
|
|
18
|
+
const knownConfigErrors = new Set();
|
|
22
19
|
export async function spellCheck(filename, text, root, options) {
|
|
20
|
+
const logger = getDefaultLogger();
|
|
21
|
+
const debugMode = options.debugMode || false;
|
|
22
|
+
logger.enabled = options.debugMode ?? (logger.enabled || isDebugModeExtended);
|
|
23
|
+
const log = logger.log;
|
|
24
|
+
log('options: %o', options);
|
|
23
25
|
const toIgnore = new Set();
|
|
24
26
|
const importedIdentifiers = new Set();
|
|
25
|
-
isDebugMode = options.debugMode || false;
|
|
26
27
|
const validator = getDocValidator(filename, text, options);
|
|
27
28
|
await validator.prepare();
|
|
29
|
+
log('Settings: %o', validator.settings);
|
|
30
|
+
const errors = [...validator.errors];
|
|
28
31
|
const issues = [];
|
|
32
|
+
errors.push(...(await checkSettings()));
|
|
33
|
+
async function checkSettings() {
|
|
34
|
+
const finalSettings = validator.getFinalizedDocSettings();
|
|
35
|
+
const found = await reportConfigurationErrors(finalSettings, knownConfigErrors);
|
|
36
|
+
found.forEach((err) => (debugMode ? log(err) : log('Error: %s', err.message)));
|
|
37
|
+
return found;
|
|
38
|
+
}
|
|
29
39
|
function checkLiteral(node) {
|
|
30
40
|
if (node.type !== 'Literal')
|
|
31
41
|
return;
|
|
@@ -257,13 +267,13 @@ export async function spellCheck(filename, text, root, options) {
|
|
|
257
267
|
return isRequireCall(node.parent) || (node.parent?.type === 'ImportDeclaration' && node.parent.source === node);
|
|
258
268
|
}
|
|
259
269
|
function debugNode(node, value) {
|
|
260
|
-
if (!
|
|
270
|
+
if (!isDebugModeExtended)
|
|
261
271
|
return;
|
|
262
272
|
const val = format('%o', value);
|
|
263
273
|
log(`${inheritanceSummary(node)}: ${val}`);
|
|
264
274
|
}
|
|
265
275
|
walkTree(root, checkNode);
|
|
266
|
-
return issues;
|
|
276
|
+
return { issues, errors };
|
|
267
277
|
}
|
|
268
278
|
function tagLiteral(node) {
|
|
269
279
|
assert(node.type === 'Literal');
|
|
@@ -288,7 +298,6 @@ function getDocValidator(filename, text, options) {
|
|
|
288
298
|
cachedValidator.updateDocumentText(text);
|
|
289
299
|
return cachedValidator;
|
|
290
300
|
}
|
|
291
|
-
isDebugMode = options.debugMode || false;
|
|
292
301
|
const validator = new DocumentValidator(doc, options, settings);
|
|
293
302
|
docValCache.set(doc, validator);
|
|
294
303
|
return validator;
|
|
@@ -297,22 +306,35 @@ function calcInitialSettings(options) {
|
|
|
297
306
|
const { customWordListFile, cspell, cwd } = options;
|
|
298
307
|
const settings = {
|
|
299
308
|
...defaultSettings,
|
|
309
|
+
...cspell,
|
|
300
310
|
words: cspell?.words || [],
|
|
301
311
|
ignoreWords: cspell?.ignoreWords || [],
|
|
302
312
|
flagWords: cspell?.flagWords || [],
|
|
303
313
|
};
|
|
304
314
|
if (customWordListFile) {
|
|
305
315
|
const filePath = isCustomWordListFile(customWordListFile) ? customWordListFile.path : customWordListFile;
|
|
306
|
-
const
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
};
|
|
312
|
-
return customWordListSettings;
|
|
316
|
+
const { dictionaries = [], dictionaryDefinitions = [] } = settings;
|
|
317
|
+
dictionaries.push('eslint-plugin-custom-words');
|
|
318
|
+
dictionaryDefinitions.push({ name: 'eslint-plugin-custom-words', path: filePath });
|
|
319
|
+
settings.dictionaries = dictionaries;
|
|
320
|
+
settings.dictionaryDefinitions = dictionaryDefinitions;
|
|
313
321
|
}
|
|
322
|
+
resolveDictionaryPaths(settings.dictionaryDefinitions, cwd);
|
|
314
323
|
return settings;
|
|
315
324
|
}
|
|
325
|
+
const regexIsUrl = /^(https?|file|ftp):/i;
|
|
326
|
+
/** Patches the path of dictionary definitions. */
|
|
327
|
+
function resolveDictionaryPaths(defs, cwd) {
|
|
328
|
+
if (!defs)
|
|
329
|
+
return;
|
|
330
|
+
for (const def of defs) {
|
|
331
|
+
if (!def.path)
|
|
332
|
+
continue;
|
|
333
|
+
if (regexIsUrl.test(def.path))
|
|
334
|
+
continue;
|
|
335
|
+
def.path = path.resolve(cwd, def.path);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
316
338
|
function getTextDocument(filename, content) {
|
|
317
339
|
if (cache.lastDoc?.filename === filename) {
|
|
318
340
|
return cache.lastDoc.doc;
|
|
@@ -358,4 +380,29 @@ function deepEqual(a, b) {
|
|
|
358
380
|
return false;
|
|
359
381
|
}
|
|
360
382
|
}
|
|
383
|
+
async function reportConfigurationErrors(config, knownConfigErrors) {
|
|
384
|
+
const errors = [];
|
|
385
|
+
const importErrors = extractImportErrors(config);
|
|
386
|
+
importErrors.forEach((ref) => {
|
|
387
|
+
const key = ref.error.toString();
|
|
388
|
+
if (knownConfigErrors.has(key))
|
|
389
|
+
return;
|
|
390
|
+
knownConfigErrors.add(key);
|
|
391
|
+
errors.push(Error('Configuration Error: \n ' + ref.error.message));
|
|
392
|
+
});
|
|
393
|
+
const dictCollection = await getDictionary(config);
|
|
394
|
+
dictCollection.dictionaries.forEach((dict) => {
|
|
395
|
+
const dictErrors = dict.getErrors?.() || [];
|
|
396
|
+
const msg = `Dictionary Error with (${dict.name})`;
|
|
397
|
+
dictErrors.forEach((error) => {
|
|
398
|
+
const key = msg + error.toString();
|
|
399
|
+
if (knownConfigErrors.has(key))
|
|
400
|
+
return;
|
|
401
|
+
knownConfigErrors.add(key);
|
|
402
|
+
const errMsg = `${msg}: ${error.message}\n Source: ${dict.source}`;
|
|
403
|
+
errors.push(Error(errMsg));
|
|
404
|
+
});
|
|
405
|
+
});
|
|
406
|
+
return errors;
|
|
407
|
+
}
|
|
361
408
|
//# sourceMappingURL=spellCheck.mjs.map
|
package/dist/worker/types.d.cts
CHANGED
|
@@ -24,7 +24,11 @@ export interface Issue {
|
|
|
24
24
|
suggestions: Suggestions;
|
|
25
25
|
nodeType: NodeType;
|
|
26
26
|
}
|
|
27
|
-
|
|
27
|
+
export interface SpellCheckResults {
|
|
28
|
+
issues: Issue[];
|
|
29
|
+
errors?: Error[];
|
|
30
|
+
}
|
|
31
|
+
type SpellCheckFn = (filename: string, text: string, root: Node, options: WorkerOptions) => Promise<SpellCheckResults>;
|
|
28
32
|
export type SpellCheckSyncFn = (...p: Parameters<SpellCheckFn>) => Awaited<ReturnType<SpellCheckFn>>;
|
|
29
33
|
export {};
|
|
30
34
|
//# sourceMappingURL=types.d.cts.map
|
package/dist/worker/worker.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export type Node = import('estree').Node;
|
|
2
2
|
export type Issue = import('./types.cjs').Issue;
|
|
3
|
+
export type SpellCheckResults = import('./types.cjs').SpellCheckResults;
|
|
3
4
|
export type WorkerOptions = import('../common/options.cjs').WorkerOptions;
|
|
4
5
|
//# sourceMappingURL=worker.d.mts.map
|
package/dist/worker/worker.mjs
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
/**
|
|
5
5
|
* @typedef {import('estree').Node} Node
|
|
6
6
|
* @typedef {import('./types.cjs').Issue} Issue
|
|
7
|
+
* @typedef {import('./types.cjs').SpellCheckResults} SpellCheckResults
|
|
7
8
|
* @typedef {import('../common/options.cjs').WorkerOptions} WorkerOptions
|
|
8
9
|
*/
|
|
9
10
|
import { runAsWorker } from 'synckit';
|
|
@@ -17,7 +18,7 @@ runAsWorker(
|
|
|
17
18
|
* @param {string} text
|
|
18
19
|
* @param {Node} root
|
|
19
20
|
* @param {WorkerOptions} options
|
|
20
|
-
* @returns {Promise<
|
|
21
|
+
* @returns {Promise<SpellCheckResults>} The issues found.
|
|
21
22
|
*/
|
|
22
23
|
async (filename, text, root, options) => {
|
|
23
24
|
if (!spellChecker) {
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "7.3.
|
|
6
|
+
"version": "7.3.7",
|
|
7
7
|
"description": "CSpell ESLint plugin",
|
|
8
8
|
"keywords": [
|
|
9
9
|
"cspell",
|
|
@@ -17,10 +17,13 @@
|
|
|
17
17
|
"homepage": "https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell-eslint-plugin#readme",
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"exports": {
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
"./package.json": "./package.json",
|
|
21
|
+
".": {
|
|
22
|
+
"types": "./dist/plugin/index.d.cts",
|
|
23
|
+
"require": "./dist/plugin/index.cjs",
|
|
24
|
+
"import": "./dist/plugin/index.cjs",
|
|
25
|
+
"default": "./dist/plugin/index.cjs"
|
|
26
|
+
}
|
|
24
27
|
},
|
|
25
28
|
"type": "module",
|
|
26
29
|
"main": "dist/plugin/index.cjs",
|
|
@@ -38,7 +41,7 @@
|
|
|
38
41
|
"build": "pnpm build:schema && pnpm build:src",
|
|
39
42
|
"build:src": "tsc -b ./tsconfig.json",
|
|
40
43
|
"build:schema": "ts-json-schema-generator --no-top-ref --expose none --path src/common/options.cts --type Options -o ./assets/options.schema.json",
|
|
41
|
-
"watch": "tsc -
|
|
44
|
+
"watch": "tsc -b ./tsconfig.json --watch",
|
|
42
45
|
"clean": "shx rm -rf dist temp coverage \"*.tsbuildInfo\"",
|
|
43
46
|
"clean-build": "pnpm run clean && pnpm run build",
|
|
44
47
|
"coverage": "echo coverage",
|
|
@@ -56,23 +59,23 @@
|
|
|
56
59
|
"node": ">=16"
|
|
57
60
|
},
|
|
58
61
|
"devDependencies": {
|
|
59
|
-
"@types/eslint": "^8.44.
|
|
60
|
-
"@types/estree": "^1.0.
|
|
61
|
-
"@types/mocha": "^10.0.
|
|
62
|
+
"@types/eslint": "^8.44.3",
|
|
63
|
+
"@types/estree": "^1.0.2",
|
|
64
|
+
"@types/mocha": "^10.0.2",
|
|
62
65
|
"@typescript-eslint/parser": "^5.62.0",
|
|
63
|
-
"@typescript-eslint/types": "^6.7.
|
|
64
|
-
"@typescript-eslint/typescript-estree": "^
|
|
65
|
-
"eslint": "^8.
|
|
66
|
+
"@typescript-eslint/types": "^6.7.3",
|
|
67
|
+
"@typescript-eslint/typescript-estree": "^6.7.3",
|
|
68
|
+
"eslint": "^8.50.0",
|
|
66
69
|
"eslint-plugin-react": "^7.33.2",
|
|
67
70
|
"mocha": "^10.2.0",
|
|
68
71
|
"ts-json-schema-generator": "^1.3.0",
|
|
69
72
|
"typescript": "^5.2.2"
|
|
70
73
|
},
|
|
71
74
|
"dependencies": {
|
|
72
|
-
"@cspell/cspell-types": "7.3.
|
|
73
|
-
"cspell-lib": "7.3.
|
|
75
|
+
"@cspell/cspell-types": "7.3.7",
|
|
76
|
+
"cspell-lib": "7.3.7",
|
|
74
77
|
"estree-walker": "^3.0.3",
|
|
75
78
|
"synckit": "^0.8.5"
|
|
76
79
|
},
|
|
77
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "22246a7924b9ae27ae39f0d0217890a1c2736f68"
|
|
78
81
|
}
|