@cspell/eslint-plugin 8.15.7 → 8.16.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 +1 -1
- package/dist/common/logger.cjs +1 -2
- package/dist/plugin/configs.d.cts +1 -1
- package/dist/plugin/cspell-eslint-plugin.cjs +0 -1
- package/dist/worker/{ASTNode.d.cts → ASTNode.d.mts} +1 -1
- package/dist/worker/ASTNode.mjs +2 -0
- package/dist/worker/ASTPath.d.mts +1 -1
- package/dist/worker/spellCheck.d.mts +1 -1
- package/dist/worker/spellCheck.mjs +34 -4
- package/dist/worker/{types.d.cts → types.d.mts} +3 -2
- package/dist/worker/types.mjs +2 -0
- package/dist/worker/walkTree.d.mts +1 -1
- package/dist/worker/walkTree.mjs +3 -1
- package/dist/worker/worker.d.mts +1 -4
- package/dist/worker/worker.mjs +1 -19
- package/package.json +12 -10
- package/dist/worker/ASTNode.cjs +0 -3
- package/dist/worker/types.cjs +0 -3
package/README.md
CHANGED
package/dist/common/logger.cjs
CHANGED
|
@@ -31,10 +31,9 @@ class Logger {
|
|
|
31
31
|
if (!this.logToFile)
|
|
32
32
|
return console.log(...p);
|
|
33
33
|
const message = new Date().toISOString() + ' ' + prefixLines((0, node_util_1.format)(...p), ' ') + '\n';
|
|
34
|
-
this.useAsync
|
|
34
|
+
return this.useAsync
|
|
35
35
|
? node_fs_1.default.appendFile(this.logFile, message, (err) => err && console.error(err))
|
|
36
36
|
: node_fs_1.default.appendFileSync(this.logFile, message);
|
|
37
|
-
return;
|
|
38
37
|
}
|
|
39
38
|
log = this._log.bind(this);
|
|
40
39
|
}
|
|
@@ -9,7 +9,6 @@ const logger_cjs_1 = require("../common/logger.cjs");
|
|
|
9
9
|
const defaultCheckOptions_cjs_1 = require("./defaultCheckOptions.cjs");
|
|
10
10
|
const optionsSchema = JSON.parse((0, node_fs_1.readFileSync)((0, node_path_1.join)(__dirname, '../../assets/options.schema.json'), 'utf8'));
|
|
11
11
|
const schema = optionsSchema;
|
|
12
|
-
// eslint-disable-next-line n/no-missing-require
|
|
13
12
|
const spellCheck = (0, synckit_1.createSyncFn)(require.resolve('../worker/worker.mjs'));
|
|
14
13
|
const messages = {
|
|
15
14
|
wordUnknown: 'Unknown word: "{{word}}"',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Node } from 'estree';
|
|
2
2
|
import type { WorkerOptions } from '../common/options.cjs';
|
|
3
|
-
import type { SpellCheckResults } from './types.
|
|
3
|
+
import type { SpellCheckResults } from './types.mjs';
|
|
4
4
|
export declare function spellCheck(filename: string, text: string, root: Node, options: WorkerOptions): Promise<SpellCheckResults>;
|
|
5
5
|
//# sourceMappingURL=spellCheck.d.mts.map
|
|
@@ -50,7 +50,7 @@ export async function spellCheck(filename, text, root, options) {
|
|
|
50
50
|
return;
|
|
51
51
|
if (typeof node.value === 'string') {
|
|
52
52
|
debugNode(path, node.value);
|
|
53
|
-
if (options.ignoreImports && isImportOrRequired(node))
|
|
53
|
+
if (options.ignoreImports && (isImportOrRequired(node) || isExportNamedDeclaration(node)))
|
|
54
54
|
return;
|
|
55
55
|
if (options.ignoreImportProperties && isImportedProperty(node))
|
|
56
56
|
return;
|
|
@@ -97,6 +97,13 @@ export async function spellCheck(filename, text, root, options) {
|
|
|
97
97
|
else if (options.ignoreImportProperties && isImportedProperty(node)) {
|
|
98
98
|
return;
|
|
99
99
|
}
|
|
100
|
+
if (isExportIdentifier(node)) {
|
|
101
|
+
importedIdentifiers.add(node.name);
|
|
102
|
+
if (isLocalExportIdentifierUnique(node)) {
|
|
103
|
+
checkNodeText(path, node.name);
|
|
104
|
+
}
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
100
107
|
}
|
|
101
108
|
if (!options.checkIdentifiers)
|
|
102
109
|
return;
|
|
@@ -123,7 +130,7 @@ export async function spellCheck(filename, text, root, options) {
|
|
|
123
130
|
const range = [node.range[0] + adj, node.range[1] - adj];
|
|
124
131
|
const scope = calcScope(path);
|
|
125
132
|
const result = validator.checkText(range, text, scope);
|
|
126
|
-
result.forEach((issue) => reportIssue(issue, node
|
|
133
|
+
result.forEach((issue) => reportIssue(issue, node));
|
|
127
134
|
}
|
|
128
135
|
function calcScope(_path) {
|
|
129
136
|
// inheritance(node);
|
|
@@ -138,6 +145,12 @@ export async function spellCheck(filename, text, root, options) {
|
|
|
138
145
|
parent.type === 'ImportDefaultSpecifier') &&
|
|
139
146
|
parent.local === node);
|
|
140
147
|
}
|
|
148
|
+
function isExportIdentifier(node) {
|
|
149
|
+
const parent = getExportParent(node);
|
|
150
|
+
if (node.type !== 'Identifier' || !parent)
|
|
151
|
+
return false;
|
|
152
|
+
return parent.type === 'ExportSpecifier' && parent.exported === node;
|
|
153
|
+
}
|
|
141
154
|
function isRawImportIdentifier(node) {
|
|
142
155
|
const parent = node.parent;
|
|
143
156
|
if (node.type !== 'Identifier' || !parent)
|
|
@@ -154,10 +167,23 @@ export async function spellCheck(filename, text, root, options) {
|
|
|
154
167
|
return true;
|
|
155
168
|
return imported.range?.[0] !== local.range?.[0] && imported.range?.[1] !== local.range?.[1];
|
|
156
169
|
}
|
|
170
|
+
function isLocalExportIdentifierUnique(node) {
|
|
171
|
+
const parent = getExportParent(node);
|
|
172
|
+
if (!parent)
|
|
173
|
+
return true;
|
|
174
|
+
const { exported, local } = parent;
|
|
175
|
+
if (exported.type === 'Identifier' && exported.name !== local.name)
|
|
176
|
+
return true;
|
|
177
|
+
return exported.range?.[0] !== local.range?.[0] && exported.range?.[1] !== local.range?.[1];
|
|
178
|
+
}
|
|
157
179
|
function getImportParent(node) {
|
|
158
180
|
const parent = node.parent;
|
|
159
181
|
return parent?.type === 'ImportSpecifier' ? parent : undefined;
|
|
160
182
|
}
|
|
183
|
+
function getExportParent(node) {
|
|
184
|
+
const parent = node.parent;
|
|
185
|
+
return parent?.type === 'ExportSpecifier' ? parent : undefined;
|
|
186
|
+
}
|
|
161
187
|
function skipCheckForRawImportIdentifiers(node) {
|
|
162
188
|
if (options.ignoreImports)
|
|
163
189
|
return false;
|
|
@@ -171,13 +197,14 @@ export async function spellCheck(filename, text, root, options) {
|
|
|
171
197
|
function isObjectProperty(node) {
|
|
172
198
|
return node.parent?.type === 'MemberExpression';
|
|
173
199
|
}
|
|
174
|
-
function reportIssue(issue,
|
|
200
|
+
function reportIssue(issue, node) {
|
|
201
|
+
const nodeType = node.type;
|
|
175
202
|
const word = issue.text;
|
|
176
203
|
const start = issue.offset;
|
|
177
204
|
const end = issue.offset + (issue.length || issue.text.length);
|
|
178
205
|
const suggestions = normalizeSuggestions(issue.suggestionsEx, nodeType);
|
|
179
206
|
const severity = issue.isFlagged ? 'Forbidden' : 'Unknown';
|
|
180
|
-
issues.push({ word, start, end, nodeType, suggestions, severity });
|
|
207
|
+
issues.push({ word, start, end, nodeType, node, suggestions, severity });
|
|
181
208
|
}
|
|
182
209
|
const processors = {
|
|
183
210
|
Line: checkComment,
|
|
@@ -270,6 +297,9 @@ export async function spellCheck(filename, text, root, options) {
|
|
|
270
297
|
function isImportOrRequired(node) {
|
|
271
298
|
return isRequireCall(node.parent) || (node.parent?.type === 'ImportDeclaration' && node.parent.source === node);
|
|
272
299
|
}
|
|
300
|
+
function isExportNamedDeclaration(node) {
|
|
301
|
+
return node.parent?.type === 'ExportNamedDeclaration' && node.parent.source === node;
|
|
302
|
+
}
|
|
273
303
|
function debugNode(path, value) {
|
|
274
304
|
log(`${inheritanceSummary(path)}: %o`, value);
|
|
275
305
|
if (debugMode)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Node } from 'estree';
|
|
2
2
|
import type { WorkerOptions } from '../common/options.cjs';
|
|
3
|
-
import type { NodeType } from './ASTNode.
|
|
3
|
+
import type { ASTNode, NodeType } from './ASTNode.mjs';
|
|
4
4
|
interface ExtendedSuggestion {
|
|
5
5
|
/**
|
|
6
6
|
* The suggestion.
|
|
@@ -23,6 +23,7 @@ export interface Issue {
|
|
|
23
23
|
severity: 'Forbidden' | 'Unknown' | 'Hint';
|
|
24
24
|
suggestions: Suggestions;
|
|
25
25
|
nodeType: NodeType;
|
|
26
|
+
node: ASTNode | undefined;
|
|
26
27
|
}
|
|
27
28
|
export interface SpellCheckResults {
|
|
28
29
|
issues: Issue[];
|
|
@@ -31,4 +32,4 @@ export interface SpellCheckResults {
|
|
|
31
32
|
export type SpellCheckFn = (filename: string, text: string, root: Node, options: WorkerOptions) => Promise<SpellCheckResults>;
|
|
32
33
|
export type SpellCheckSyncFn = (...p: Parameters<SpellCheckFn>) => Awaited<ReturnType<SpellCheckFn>>;
|
|
33
34
|
export {};
|
|
34
|
-
//# sourceMappingURL=types.d.
|
|
35
|
+
//# sourceMappingURL=types.d.mts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ASTNode } from './ASTNode.
|
|
1
|
+
import type { ASTNode } from './ASTNode.mjs';
|
|
2
2
|
import type { ASTPath } from './ASTPath.mjs';
|
|
3
3
|
export declare function walkTree(node: ASTNode, enter: (path: ASTPath) => void): void;
|
|
4
4
|
//# sourceMappingURL=walkTree.d.mts.map
|
package/dist/worker/walkTree.mjs
CHANGED
|
@@ -44,7 +44,9 @@ function walk(root, enter) {
|
|
|
44
44
|
if (Array.isArray(v)) {
|
|
45
45
|
for (let i = 0; i < v.length; ++i) {
|
|
46
46
|
const vv = v[i];
|
|
47
|
-
isNode(vv)
|
|
47
|
+
if (!isNode(vv))
|
|
48
|
+
continue;
|
|
49
|
+
walkNodes(fx, vv, node, key, i);
|
|
48
50
|
}
|
|
49
51
|
}
|
|
50
52
|
else if (isNode(v)) {
|
package/dist/worker/worker.d.mts
CHANGED
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
export type Issue = import("./types.cjs").Issue;
|
|
3
|
-
export type SpellCheckResults = import("./types.cjs").SpellCheckResults;
|
|
4
|
-
export type WorkerOptions = import("../common/options.cjs").WorkerOptions;
|
|
1
|
+
export {};
|
|
5
2
|
//# sourceMappingURL=worker.d.mts.map
|
package/dist/worker/worker.mjs
CHANGED
|
@@ -1,24 +1,6 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
/**
|
|
3
|
-
* @typedef {import('estree').Node} Node
|
|
4
|
-
* @typedef {import('./types.cjs').Issue} Issue
|
|
5
|
-
* @typedef {import('./types.cjs').SpellCheckResults} SpellCheckResults
|
|
6
|
-
* @typedef {import('../common/options.cjs').WorkerOptions} WorkerOptions
|
|
7
|
-
*/
|
|
8
1
|
import { runAsWorker } from 'synckit';
|
|
9
|
-
/**
|
|
10
|
-
* @type {typeof import('./spellCheck.mjs')}
|
|
11
|
-
*/
|
|
12
2
|
let spellChecker;
|
|
13
|
-
runAsWorker(
|
|
14
|
-
/**
|
|
15
|
-
* @param {string} filename
|
|
16
|
-
* @param {string} text
|
|
17
|
-
* @param {Node} root
|
|
18
|
-
* @param {WorkerOptions} options
|
|
19
|
-
* @returns {Promise<SpellCheckResults>} The issues found.
|
|
20
|
-
*/
|
|
21
|
-
async (filename, text, root, options) => {
|
|
3
|
+
runAsWorker(async (filename, text, root, options) => {
|
|
22
4
|
if (!spellChecker) {
|
|
23
5
|
spellChecker = await import('./spellCheck.mjs');
|
|
24
6
|
}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public",
|
|
5
5
|
"provenance": true
|
|
6
6
|
},
|
|
7
|
-
"version": "8.
|
|
7
|
+
"version": "8.16.0",
|
|
8
8
|
"description": "CSpell ESLint plugin",
|
|
9
9
|
"keywords": [
|
|
10
10
|
"cspell",
|
|
@@ -64,7 +64,9 @@
|
|
|
64
64
|
"coverage": "echo coverage",
|
|
65
65
|
"test-watch": "pnpm run test -- --watch",
|
|
66
66
|
"test-yaml": "npx mocha --timeout 10000 \"dist/**/yaml.test.mjs\"",
|
|
67
|
-
"test": "npx mocha --timeout 10000 \"dist/**/*.test.mjs\""
|
|
67
|
+
"test-eslint": "npx mocha --timeout 10000 \"dist/**/*.test.mjs\"",
|
|
68
|
+
"test-samples": "pnpm -r --filter @internal/eslint-plugin-fixtures-simple test",
|
|
69
|
+
"test": "pnpm run test-eslint && pnpm run test-samples"
|
|
68
70
|
},
|
|
69
71
|
"repository": {
|
|
70
72
|
"type": "git",
|
|
@@ -83,8 +85,8 @@
|
|
|
83
85
|
"@types/eslint": "^8.56.12",
|
|
84
86
|
"@types/estree": "^1.0.6",
|
|
85
87
|
"@types/mocha": "^10.0.9",
|
|
86
|
-
"@typescript-eslint/parser": "^8.
|
|
87
|
-
"@typescript-eslint/types": "^8.
|
|
88
|
+
"@typescript-eslint/parser": "^8.13.0",
|
|
89
|
+
"@typescript-eslint/types": "^8.13.0",
|
|
88
90
|
"eslint": "^9.14.0",
|
|
89
91
|
"eslint-plugin-jsonc": "^2.16.0",
|
|
90
92
|
"eslint-plugin-mdx": "^3.1.5",
|
|
@@ -92,22 +94,22 @@
|
|
|
92
94
|
"eslint-plugin-react": "^7.37.2",
|
|
93
95
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
94
96
|
"eslint-plugin-yml": "^1.15.0",
|
|
95
|
-
"globals": "^15.
|
|
97
|
+
"globals": "^15.12.0",
|
|
96
98
|
"jsonc-eslint-parser": "^2.4.0",
|
|
97
99
|
"mocha": "^10.8.2",
|
|
98
100
|
"ts-json-schema-generator": "^2.3.0",
|
|
99
101
|
"typescript": "~5.6.3",
|
|
100
|
-
"typescript-eslint": "^8.
|
|
102
|
+
"typescript-eslint": "^8.13.0",
|
|
101
103
|
"yaml-eslint-parser": "^1.2.3"
|
|
102
104
|
},
|
|
103
105
|
"dependencies": {
|
|
104
|
-
"@cspell/cspell-types": "8.
|
|
105
|
-
"@cspell/url": "8.
|
|
106
|
-
"cspell-lib": "8.
|
|
106
|
+
"@cspell/cspell-types": "8.16.0",
|
|
107
|
+
"@cspell/url": "8.16.0",
|
|
108
|
+
"cspell-lib": "8.16.0",
|
|
107
109
|
"synckit": "^0.9.2"
|
|
108
110
|
},
|
|
109
111
|
"peerDependencies": {
|
|
110
112
|
"eslint": "^7 || ^8 || ^9"
|
|
111
113
|
},
|
|
112
|
-
"gitHead": "
|
|
114
|
+
"gitHead": "41cd50f9ba34033b6da32408855d7fc3b888c5e0"
|
|
113
115
|
}
|
package/dist/worker/ASTNode.cjs
DELETED
package/dist/worker/types.cjs
DELETED