@cspell/eslint-plugin 8.9.0 → 8.10.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
@@ -193,6 +193,22 @@ interface Options {
193
193
  dictionaryDefinitions?: DictionaryDefinition[];
194
194
  };
195
195
 
196
+ /**
197
+ * Specify the root path of the cspell configuration.
198
+ * It is used to resolve `imports` found in {@link cspell}.
199
+ *
200
+ * example:
201
+ * ```js
202
+ * cspellOptionsRoot: import.meta.url
203
+ * // or
204
+ * cspellOptionsRoot: __filename
205
+ * ```
206
+ *
207
+ * @default cwd
208
+ *
209
+ */
210
+ cspellOptionsRoot?: string | URL;
211
+
196
212
  /**
197
213
  * Specify a path to a custom word list file.
198
214
  *
@@ -282,22 +298,6 @@ export default [
282
298
  }
283
299
  ```
284
300
 
285
- ## `configFile` - Using a CSpell Configuration File
286
-
287
- **`eslint.config.mjs`**
288
-
289
- ```js
290
- rules: {
291
- '@cspell/spellchecker': [
292
- 'error',
293
- {
294
- //
295
- configFile: new URL('./cspell.config.yaml', import.meta.url).toString(),
296
- },
297
- ],
298
- },
299
- ```
300
-
301
301
  ## `autoFix`
302
302
 
303
303
  When enabled, `autoFix` corrects any spelling issues that have a single "preferred" suggestion. It attempts to match
@@ -324,6 +324,48 @@ When spell checking, if `colour` is not in one of the dictionaries, then `color`
324
324
 
325
325
  CSpell will match case, but not word stems. `blacklist` and `Blacklist` will get replaced, but not `blacklists`.
326
326
 
327
+ ## `configFile` - Using a CSpell Configuration File
328
+
329
+ **`eslint.config.mjs`**
330
+
331
+ ```js
332
+ rules: {
333
+ '@cspell/spellchecker': [
334
+ 'error',
335
+ {
336
+ configFile: new URL('./cspell.config.yaml', import.meta.url).toString(),
337
+ },
338
+ ],
339
+ },
340
+ ```
341
+
342
+ ## `cspell` and `cspellOptionsRoot` - CSpell Configuration
343
+
344
+ It is possible to send `cspell` configuration to the spell checker. Where possible, use a cspell configuration file and set `configFile`. But there are cases where this is not possible or desired (like fewer configuration files).
345
+
346
+ - Option `cspell` is used to pass along configuration to the spell checker.
347
+ - Option `cspellOptionsRoot` is used to tell the spell checker how to find `cspell.import`s.
348
+
349
+ Example: **`eslint.config.mjs`**
350
+
351
+ ```js
352
+ rules: {
353
+ '@cspell/spellchecker': [
354
+ 'warn',
355
+ {
356
+ cspell: {
357
+ import: ['./cspell.config.yaml', '@cspell/dict-de-de']
358
+ },
359
+ cspellOptionsRoot: import.meta.url,
360
+ },
361
+ ],
362
+ },
363
+ ```
364
+
365
+ Assuming `import.meta.url` is `file:///Users/ci/project/app/eslint.config.mjs`, this tells the spell checker to import `cspell.config.yaml` from `file:///Users/ci/project/app/cspell.config.yaml` and to search for package `@cspell/dict-de-de` starting at `file:///Users/ci/project/app/`.
366
+
367
+ If `cspellOptionsRoot` is not specified, the current working directory is used.
368
+
327
369
  ## Checking Custom AST Nodes
328
370
 
329
371
  The `checkScope` setting is used to enable / disable checking AST Nodes. ESLint uses parsers to generate the AST (Abstract Syntax Tree) to evaluate a document. Each PlugIn gets access to the AST. `checkScope` can be used to handle new AST nodes when a custom parser is added. Some knowledge of the AST output by the parser is necessary.
@@ -6,21 +6,25 @@
6
6
  "autoFix": {
7
7
  "default": false,
8
8
  "description": "Automatically fix common mistakes. This is only possible if a single preferred suggestion is available.",
9
+ "markdownDescription": "Automatically fix common mistakes.\nThis is only possible if a single preferred suggestion is available.",
9
10
  "type": "boolean"
10
11
  },
11
12
  "checkComments": {
12
13
  "default": true,
13
14
  "description": "Spell check comments",
15
+ "markdownDescription": "Spell check comments",
14
16
  "type": "boolean"
15
17
  },
16
18
  "checkIdentifiers": {
17
19
  "default": true,
18
20
  "description": "Spell check identifiers (variables names, function names, class names, etc.)",
21
+ "markdownDescription": "Spell check identifiers (variables names, function names, class names, etc.)",
19
22
  "type": "boolean"
20
23
  },
21
24
  "checkJSXText": {
22
25
  "default": true,
23
26
  "description": "Spell check JSX Text",
27
+ "markdownDescription": "Spell check JSX Text",
24
28
  "type": "boolean"
25
29
  },
26
30
  "checkScope": {
@@ -30,39 +34,47 @@
30
34
  "items": [
31
35
  {
32
36
  "description": "The scope selector is a string that defines the context in which a rule applies. Examples:\n- `YAMLPair[value] YAMLScalar` - check the value of a YAML pair.\n- `YAMLPair[key] YAMLScalar` - check the key of a YAML pair.",
37
+ "markdownDescription": "The scope selector is a string that defines the context in which a rule applies.\nExamples:\n- `YAMLPair[value] YAMLScalar` - check the value of a YAML pair.\n- `YAMLPair[key] YAMLScalar` - check the key of a YAML pair.",
33
38
  "type": "string"
34
39
  },
35
40
  {
36
41
  "type": "boolean"
37
42
  }
38
43
  ],
44
+ "markdownDescription": "A scope selector entry is a tuple that defines a scope selector and whether to spell check it.",
39
45
  "maxItems": 2,
40
46
  "minItems": 2,
41
47
  "type": "array"
42
48
  },
49
+ "markdownDescription": "Scope selectors to spell check.\nThis is a list of scope selectors to spell check.\n\nExample:\n```js\ncheckScope: [\n ['YAMLPair[key] YAMLScalar', true],\n ['YAMLPair[value] YAMLScalar', true],\n ['YAMLSequence[entries] YAMLScalar', true],\n ['JSONProperty[key] JSONLiteral', true],\n ['JSONProperty[value] JSONLiteral', true],\n ['JSONArrayExpression JSONLiteral', true],\n],\n```",
43
50
  "type": "array"
44
51
  },
45
52
  "checkStringTemplates": {
46
53
  "default": true,
47
54
  "description": "Spell check template strings",
55
+ "markdownDescription": "Spell check template strings",
48
56
  "type": "boolean"
49
57
  },
50
58
  "checkStrings": {
51
59
  "default": true,
52
60
  "description": "Spell check strings",
61
+ "markdownDescription": "Spell check strings",
53
62
  "type": "boolean"
54
63
  },
55
64
  "configFile": {
56
65
  "description": "Path to the cspell configuration file. Relative paths, will be relative to the current working directory.",
66
+ "markdownDescription": "Path to the cspell configuration file.\nRelative paths, will be relative to the current working directory.",
57
67
  "type": "string"
58
68
  },
59
69
  "cspell": {
60
70
  "additionalProperties": false,
61
71
  "description": "CSpell options to pass to the spell checker.",
72
+ "markdownDescription": "CSpell options to pass to the spell checker.",
62
73
  "properties": {
63
74
  "allowCompoundWords": {
64
75
  "default": false,
65
- "description": "True to enable compound word checking. See [Case Sensitivity](https://cspell.org/docs/case-sensitive/) for more details.",
76
+ "description": "True to enable compound word checking.",
77
+ "markdownDescription": "True to enable compound word checking.",
66
78
  "type": "boolean"
67
79
  },
68
80
  "dictionaries": {
@@ -71,17 +83,21 @@
71
83
  "anyOf": [
72
84
  {
73
85
  "description": "This a reference to a named dictionary. It is expected to match the name of a dictionary.",
86
+ "markdownDescription": "This a reference to a named dictionary.\nIt is expected to match the name of a dictionary.",
74
87
  "pattern": "^(?=[^!*,;{}[\\]~\\n]+$)(?=(.*\\w)).+$",
75
88
  "type": "string"
76
89
  },
77
90
  {
78
91
  "description": "This a negative reference to a named dictionary.\n\nIt is used to exclude or include a dictionary by name.\n\nThe reference starts with 1 or more `!`.\n- `!<dictionary_name>` - Used to exclude the dictionary matching `<dictionary_name>`.\n- `!!<dictionary_name>` - Used to re-include a dictionary matching `<dictionary_name>`. Overrides `!<dictionary_name>`.\n- `!!!<dictionary_name>` - Used to exclude a dictionary matching `<dictionary_name>`. Overrides `!!<dictionary_name>`.",
92
+ "markdownDescription": "This a negative reference to a named dictionary.\n\nIt is used to exclude or include a dictionary by name.\n\nThe reference starts with 1 or more `!`.\n- `!<dictionary_name>` - Used to exclude the dictionary matching `<dictionary_name>`.\n- `!!<dictionary_name>` - Used to re-include a dictionary matching `<dictionary_name>`.\n Overrides `!<dictionary_name>`.\n- `!!!<dictionary_name>` - Used to exclude a dictionary matching `<dictionary_name>`.\n Overrides `!!<dictionary_name>`.",
79
93
  "pattern": "^(?=!+[^!*,;{}[\\]~\\n]+$)(?=(.*\\w)).+$",
80
94
  "type": "string"
81
95
  }
82
96
  ],
83
- "description": "Reference to a dictionary by name. One of:\n- {@link DictionaryRef } \n- {@link DictionaryNegRef }"
97
+ "description": "Reference to a dictionary by name. One of:\n- {@link DictionaryRef } \n- {@link DictionaryNegRef }",
98
+ "markdownDescription": "Reference to a dictionary by name.\nOne of:\n- {@link DictionaryRef } \n- {@link DictionaryNegRef }"
84
99
  },
100
+ "markdownDescription": "Optional list of dictionaries to use. Each entry should match the name of the dictionary.\n\nTo remove a dictionary from the list, add `!` before the name.\n\nFor example, `!typescript` will turn off the dictionary with the name `typescript`.\n\nSee the [Dictionaries](https://cspell.org/docs/dictionaries/)\nand [Custom Dictionaries](https://cspell.org/docs/dictionaries-custom/) for more details.",
85
101
  "type": "array"
86
102
  },
87
103
  "dictionaryDefinitions": {
@@ -89,20 +105,24 @@
89
105
  "additionalProperties": false,
90
106
  "properties": {
91
107
  "description": {
92
- "description": "Optional description.",
108
+ "description": "Optional description of the contents / purpose of the dictionary.",
109
+ "markdownDescription": "Optional description of the contents / purpose of the dictionary.",
93
110
  "type": "string"
94
111
  },
95
112
  "name": {
96
113
  "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 `*`, `!`, `;`, `,`, `{`, `}`, `[`, `]`, `~`.",
114
+ "markdownDescription": "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 `*`, `!`, `;`, `,`, `{`, `}`, `[`, `]`, `~`.",
97
115
  "pattern": "^(?=[^!*,;{}[\\]~\\n]+$)(?=(.*\\w)).+$",
98
116
  "type": "string"
99
117
  },
100
118
  "noSuggest": {
101
119
  "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.",
120
+ "markdownDescription": "Indicate that suggestions should not come from this dictionary.\nWords in this dictionary are considered correct, but will not be\nused when making spell correction suggestions.\n\nNote: if a word is suggested by another dictionary, but found in\nthis dictionary, it will be removed from the set of\npossible suggestions.",
102
121
  "type": "boolean"
103
122
  },
104
123
  "path": {
105
124
  "description": "Path to the file.",
125
+ "markdownDescription": "Path to the file.",
106
126
  "type": "string"
107
127
  },
108
128
  "repMap": {
@@ -115,21 +135,24 @@
115
135
  "minItems": 2,
116
136
  "type": "array"
117
137
  },
138
+ "markdownDescription": "Replacement pairs.",
118
139
  "type": "array"
119
140
  },
120
141
  "type": {
121
142
  "default": "S",
122
- "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.",
143
+ "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.\n\nNote: this settings does not apply to inline dictionaries or `.trie` files.",
123
144
  "enum": [
124
145
  "S",
125
146
  "W",
126
147
  "C",
127
148
  "T"
128
149
  ],
150
+ "markdownDescription": "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.\n\nNote: this settings does not apply to inline dictionaries or `.trie` files.",
129
151
  "type": "string"
130
152
  },
131
153
  "useCompounds": {
132
154
  "description": "Use Compounds.",
155
+ "markdownDescription": "Use Compounds.",
133
156
  "type": "boolean"
134
157
  }
135
158
  },
@@ -144,6 +167,7 @@
144
167
  "enabled": {
145
168
  "default": true,
146
169
  "description": "Is the spell checker enabled.",
170
+ "markdownDescription": "Is the spell checker enabled.",
147
171
  "type": "boolean"
148
172
  },
149
173
  "flagWords": {
@@ -151,6 +175,7 @@
151
175
  "items": {
152
176
  "type": "string"
153
177
  },
178
+ "markdownDescription": "List of words to always be considered incorrect. Words found in `flagWords` override `words`.\n\nFormat of `flagWords`\n- single word entry - `word`\n- with suggestions - `word:suggestion` or `word->suggestion, suggestions`\n\nExample:\n```ts\n\"flagWords\": [\n \"color: colour\",\n \"incase: in case, encase\",\n \"canot->cannot\",\n \"cancelled->canceled\"\n]\n```",
154
179
  "type": "array"
155
180
  },
156
181
  "ignoreRegExpList": {
@@ -162,6 +187,7 @@
162
187
  },
163
188
  {
164
189
  "description": "This matches the name in a pattern definition.",
190
+ "markdownDescription": "This matches the name in a pattern definition.",
165
191
  "type": "string"
166
192
  },
167
193
  {
@@ -198,8 +224,10 @@
198
224
  "type": "string"
199
225
  }
200
226
  ],
201
- "description": "A PatternRef is a Pattern or PatternId."
227
+ "description": "A PatternRef is a Pattern or PatternId.",
228
+ "markdownDescription": "A PatternRef is a Pattern or PatternId."
202
229
  },
230
+ "markdownDescription": "List of regular expression patterns or pattern names to exclude from spell checking.\n\nExample: `[\"href\"]` - to exclude html href pattern.\n\nRegular expressions use JavaScript regular expression syntax.\n\nExample: to ignore ALL-CAPS words\n\nJSON\n```json\n\"ignoreRegExpList\": [\"/\\\\b[A-Z]+\\\\b/g\"]\n```\n\nYAML\n```yaml\nignoreRegExpList:\n - >-\n /\\b[A-Z]+\\b/g\n```\n\nBy default, several patterns are excluded. See\n[Configuration](https://cspell.org/configuration/patterns) for more details.\n\nWhile you can create your own patterns, you can also leverage several patterns that are\n[built-in to CSpell](https://cspell.org/types/cspell-types/types/PredefinedPatterns.html).",
203
231
  "type": "array"
204
232
  },
205
233
  "ignoreWords": {
@@ -207,23 +235,27 @@
207
235
  "items": {
208
236
  "type": "string"
209
237
  },
238
+ "markdownDescription": "List of words to be ignored. An ignored word will not show up as an error, even if it is\nalso in the `flagWords`.",
210
239
  "type": "array"
211
240
  },
212
241
  "import": {
213
242
  "anyOf": [
214
243
  {
215
244
  "description": "A File System Path. Relative paths are relative to the configuration file.",
245
+ "markdownDescription": "A File System Path. Relative paths are relative to the configuration file.",
216
246
  "type": "string"
217
247
  },
218
248
  {
219
249
  "items": {
220
250
  "description": "A File System Path. Relative paths are relative to the configuration file.",
251
+ "markdownDescription": "A File System Path. Relative paths are relative to the configuration file.",
221
252
  "type": "string"
222
253
  },
223
254
  "type": "array"
224
255
  }
225
256
  ],
226
- "description": "Allows this configuration to inherit configuration for one or more other files.\n\nSee [Importing / Extending Configuration](https://cspell.org/configuration/imports/) for more details."
257
+ "description": "Allows this configuration to inherit configuration for one or more other files.\n\nSee [Importing / Extending Configuration](https://cspell.org/configuration/imports/) for more details.",
258
+ "markdownDescription": "Allows this configuration to inherit configuration for one or more other files.\n\nSee [Importing / Extending Configuration](https://cspell.org/configuration/imports/) for more details."
227
259
  },
228
260
  "includeRegExpList": {
229
261
  "description": "List of regular expression patterns or defined pattern names to match for spell checking.\n\nIf this property is defined, only text matching the included patterns will be checked.\n\nWhile you can create your own patterns, you can also leverage several patterns that are [built-in to CSpell](https://cspell.org/types/cspell-types/types/PredefinedPatterns.html).",
@@ -234,6 +266,7 @@
234
266
  },
235
267
  {
236
268
  "description": "This matches the name in a pattern definition.",
269
+ "markdownDescription": "This matches the name in a pattern definition.",
237
270
  "type": "string"
238
271
  },
239
272
  {
@@ -270,13 +303,16 @@
270
303
  "type": "string"
271
304
  }
272
305
  ],
273
- "description": "A PatternRef is a Pattern or PatternId."
306
+ "description": "A PatternRef is a Pattern or PatternId.",
307
+ "markdownDescription": "A PatternRef is a Pattern or PatternId."
274
308
  },
309
+ "markdownDescription": "List of regular expression patterns or defined pattern names to match for spell checking.\n\nIf this property is defined, only text matching the included patterns will be checked.\n\nWhile you can create your own patterns, you can also leverage several patterns that are\n[built-in to CSpell](https://cspell.org/types/cspell-types/types/PredefinedPatterns.html).",
275
310
  "type": "array"
276
311
  },
277
312
  "language": {
278
313
  "default": "en",
279
314
  "description": "Current active spelling language. This specifies the language locale to use in choosing the general dictionary.\n\nFor example:\n\n- \"en-GB\" for British English.\n- \"en,nl\" to enable both English and Dutch.",
315
+ "markdownDescription": "Current active spelling language. This specifies the language locale to use in choosing the\ngeneral dictionary.\n\nFor example:\n\n- \"en-GB\" for British English.\n- \"en,nl\" to enable both English and Dutch.",
280
316
  "type": "string"
281
317
  },
282
318
  "words": {
@@ -284,15 +320,30 @@
284
320
  "items": {
285
321
  "type": "string"
286
322
  },
323
+ "markdownDescription": "List of words to be considered correct.",
287
324
  "type": "array"
288
325
  }
289
326
  },
290
327
  "type": "object"
291
328
  },
329
+ "cspellOptionsRoot": {
330
+ "anyOf": [
331
+ {
332
+ "type": "string"
333
+ },
334
+ {
335
+ "format": "uri",
336
+ "type": "string"
337
+ }
338
+ ],
339
+ "description": "Specify the root path of the cspell configuration. It is used to resolve `imports` found in {@link cspell } .\n\nexample: ```js cspellOptionsRoot: import.meta.url // or cspellOptionsRoot: __filename ```",
340
+ "markdownDescription": "Specify the root path of the cspell configuration.\nIt is used to resolve `imports` found in {@link cspell } .\n\nexample:\n```js\ncspellOptionsRoot: import.meta.url\n// or\ncspellOptionsRoot: __filename\n```"
341
+ },
292
342
  "customWordListFile": {
293
343
  "anyOf": [
294
344
  {
295
345
  "description": "Specify a path to a custom word list file",
346
+ "markdownDescription": "Specify a path to a custom word list file",
296
347
  "type": "string"
297
348
  },
298
349
  {
@@ -300,6 +351,7 @@
300
351
  "properties": {
301
352
  "path": {
302
353
  "description": "Path to word list file. File format: 1 word per line",
354
+ "markdownDescription": "Path to word list file.\nFile format: 1 word per line",
303
355
  "type": "string"
304
356
  }
305
357
  },
@@ -309,30 +361,36 @@
309
361
  "type": "object"
310
362
  }
311
363
  ],
312
- "description": "Specify a path to a custom word list file.\n\nexample: ```js customWordListFile: \"./myWords.txt\" ```"
364
+ "description": "Specify a path to a custom word list file.\n\nexample: ```js customWordListFile: \"./myWords.txt\" ```",
365
+ "markdownDescription": "Specify a path to a custom word list file.\n\nexample:\n```js\ncustomWordListFile: \"./myWords.txt\"\n```"
313
366
  },
314
367
  "debugMode": {
315
368
  "description": "Output debug logs to `.cspell-eslint-plugin.log` default false",
369
+ "markdownDescription": "Output debug logs to `.cspell-eslint-plugin.log`\ndefault false",
316
370
  "type": "boolean"
317
371
  },
318
372
  "generateSuggestions": {
319
373
  "default": true,
320
374
  "description": "Generate suggestions",
375
+ "markdownDescription": "Generate suggestions",
321
376
  "type": "boolean"
322
377
  },
323
378
  "ignoreImportProperties": {
324
379
  "default": true,
325
380
  "description": "Ignore the properties of imported variables, structures, and types.\n\nExample: ``` import { example } from 'third-party';\n\nconst msg = example.property; // `property` is not spell checked. ```",
381
+ "markdownDescription": "Ignore the properties of imported variables, structures, and types.\n\nExample:\n```\nimport { example } from 'third-party';\n\nconst msg = example.property; // `property` is not spell checked.\n```",
326
382
  "type": "boolean"
327
383
  },
328
384
  "ignoreImports": {
329
385
  "default": true,
330
386
  "description": "Ignore import and require names",
387
+ "markdownDescription": "Ignore import and require names",
331
388
  "type": "boolean"
332
389
  },
333
390
  "numSuggestions": {
334
391
  "default": 8,
335
392
  "description": "Number of spelling suggestions to make.",
393
+ "markdownDescription": "Number of spelling suggestions to make.",
336
394
  "type": "number"
337
395
  }
338
396
  },
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getDefaultLogger = exports.Logger = void 0;
6
+ exports.Logger = void 0;
7
+ exports.getDefaultLogger = getDefaultLogger;
7
8
  const node_fs_1 = __importDefault(require("node:fs"));
8
9
  const node_path_1 = __importDefault(require("node:path"));
9
10
  const node_util_1 = require("node:util");
@@ -45,7 +46,6 @@ function getDefaultLogger() {
45
46
  logger = new Logger({});
46
47
  return logger;
47
48
  }
48
- exports.getDefaultLogger = getDefaultLogger;
49
49
  function prefixLines(text, prefix, startIndex = 1) {
50
50
  return text
51
51
  .split('\n')
@@ -81,6 +81,18 @@ export interface Check {
81
81
  * CSpell options to pass to the spell checker.
82
82
  */
83
83
  cspell?: CSpellOptions;
84
+ /**
85
+ * Specify the root path of the cspell configuration.
86
+ * It is used to resolve `imports` found in {@link cspell}.
87
+ *
88
+ * example:
89
+ * ```js
90
+ * cspellOptionsRoot: import.meta.url
91
+ * // or
92
+ * cspellOptionsRoot: __filename
93
+ * ```
94
+ */
95
+ cspellOptionsRoot?: string | URL;
84
96
  /**
85
97
  * Specify a path to a custom word list file.
86
98
  *
@@ -91,7 +91,7 @@ function create(context) {
91
91
  const { issues, errors } = spellCheck(filename, sc.text, sc.ast, options);
92
92
  if (errors && errors.length) {
93
93
  log('errors: %o', errors.map((e) => e.message));
94
- errors.forEach((error) => console.error('%s', error.message));
94
+ errors.forEach((error) => context.report({ message: error.message, loc: { line: 1, column: 1 } }));
95
95
  }
96
96
  issues.forEach((issue) => reportIssue(issue));
97
97
  }
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.normalizeOptions = exports.defaultOptions = exports.defaultCheckOptions = void 0;
3
+ exports.defaultOptions = exports.defaultCheckOptions = void 0;
4
+ exports.normalizeOptions = normalizeOptions;
4
5
  exports.defaultCheckOptions = {
5
6
  checkComments: true,
6
7
  checkIdentifiers: true,
@@ -8,6 +9,7 @@ exports.defaultCheckOptions = {
8
9
  checkStrings: true,
9
10
  checkStringTemplates: true,
10
11
  configFile: '',
12
+ cspellOptionsRoot: '',
11
13
  cspell: {
12
14
  words: [],
13
15
  flagWords: [],
@@ -25,8 +27,8 @@ exports.defaultOptions = {
25
27
  autoFix: false,
26
28
  };
27
29
  function normalizeOptions(opts, cwd) {
28
- const options = Object.assign({}, exports.defaultOptions, opts || {}, { cwd });
30
+ const cspellOptionsRoot = opts?.cspellOptionsRoot || 'eslint-configuration-file';
31
+ const options = Object.assign({}, exports.defaultOptions, opts || {}, { cspellOptionsRoot, cwd });
29
32
  return options;
30
33
  }
31
- exports.normalizeOptions = normalizeOptions;
32
34
  //# sourceMappingURL=defaultCheckOptions.cjs.map
@@ -1,12 +1,14 @@
1
1
  // cspell:ignore TSESTree
2
2
  import assert from 'node:assert';
3
3
  import * as path from 'node:path';
4
+ import { toFileDirURL, toFileURL } from '@cspell/url';
4
5
  import { createTextDocument, DocumentValidator, extractImportErrors, getDictionary, refreshDictionaryCache, } from 'cspell-lib';
5
6
  import { getDefaultLogger } from '../common/logger.cjs';
6
7
  import { defaultCheckedScopes } from './customScopes.mjs';
7
8
  import { AstPathScope, AstScopeMatcher, astScopeToString, mapNodeToScope, scopeItem } from './scope.mjs';
8
9
  import { walkTree } from './walkTree.mjs';
9
10
  const defaultSettings = {
11
+ name: 'eslint-configuration-file',
10
12
  patterns: [
11
13
  // @todo: be able to use cooked / transformed strings.
12
14
  // {
@@ -316,7 +318,8 @@ function getDocValidator(filename, text, options) {
316
318
  cachedValidator.updateDocumentText(text).catch(() => undefined);
317
319
  return cachedValidator;
318
320
  }
319
- const validator = new DocumentValidator(doc, options, settings);
321
+ const resolveImportsRelativeTo = toFileURL(options.cspellOptionsRoot || import.meta.url, toFileDirURL(options.cwd));
322
+ const validator = new DocumentValidator(doc, { ...options, resolveImportsRelativeTo }, settings);
320
323
  docValCache.set(doc, validator);
321
324
  return validator;
322
325
  }
@@ -1,5 +1,5 @@
1
- export type Node = import('estree').Node;
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 type Node = import("estree").Node;
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;
5
5
  //# sourceMappingURL=worker.d.mts.map
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "8.9.0",
6
+ "version": "8.10.0",
7
7
  "description": "CSpell ESLint plugin",
8
8
  "keywords": [
9
9
  "cspell",
@@ -55,7 +55,8 @@
55
55
  "bt": "pnpm build && pnpm test",
56
56
  "build": "pnpm build:schema && pnpm build:src",
57
57
  "build:src": "tsc -b ./tsconfig.json -f",
58
- "build:schema": "ts-json-schema-generator --no-top-ref --expose none --path src/common/options.cts --type Options -o ./assets/options.schema.json",
58
+ "build:schema": "pnpm build-options-schema",
59
+ "build:schema:old": "ts-json-schema-generator --no-top-ref --expose none --path src/common/options.cts --type Options -o ./assets/options.schema.json",
59
60
  "watch": "tsc -b ./tsconfig.json --watch -f",
60
61
  "clean": "shx rm -rf dist temp coverage \"*.tsbuildInfo\"",
61
62
  "clean-build": "pnpm run clean && pnpm run build",
@@ -77,33 +78,37 @@
77
78
  },
78
79
  "devDependencies": {
79
80
  "@eslint/eslintrc": "^3.1.0",
80
- "@eslint/js": "^9.5.0",
81
+ "@eslint/js": "^9.6.0",
82
+ "@internal/cspell-eslint-plugin-scripts": "",
83
+ "@internal/fixture-test-dictionary": "",
84
+ "@types/eslint": "^8.56.10",
81
85
  "@types/estree": "^1.0.5",
82
- "@types/mocha": "^10.0.6",
83
- "@typescript-eslint/parser": "^7.13.1",
84
- "@typescript-eslint/types": "^7.13.1",
85
- "eslint": "^9.5.0",
86
+ "@types/mocha": "^10.0.7",
87
+ "@typescript-eslint/parser": "^7.15.0",
88
+ "@typescript-eslint/types": "^7.15.0",
89
+ "eslint": "^9.6.0",
86
90
  "eslint-plugin-jsonc": "^2.16.0",
87
91
  "eslint-plugin-mdx": "^3.1.5",
88
92
  "eslint-plugin-n": "^17.9.0",
89
- "eslint-plugin-react": "^7.34.2",
93
+ "eslint-plugin-react": "^7.34.3",
90
94
  "eslint-plugin-simple-import-sort": "^12.1.0",
91
95
  "eslint-plugin-yml": "^1.14.0",
92
- "globals": "^15.6.0",
96
+ "globals": "^15.8.0",
93
97
  "jsonc-eslint-parser": "^2.4.0",
94
- "mocha": "^10.4.0",
98
+ "mocha": "^10.5.2",
95
99
  "ts-json-schema-generator": "^2.3.0",
96
- "typescript": "^5.4.5",
97
- "typescript-eslint": "^7.13.1",
100
+ "typescript": "^5.5.3",
101
+ "typescript-eslint": "^7.15.0",
98
102
  "yaml-eslint-parser": "^1.2.3"
99
103
  },
100
104
  "dependencies": {
101
- "@cspell/cspell-types": "8.9.0",
102
- "cspell-lib": "8.9.0",
105
+ "@cspell/cspell-types": "8.10.0",
106
+ "@cspell/url": "8.10.0",
107
+ "cspell-lib": "8.10.0",
103
108
  "synckit": "^0.9.0"
104
109
  },
105
110
  "peerDependencies": {
106
111
  "eslint": "^7 || ^8 || ^9"
107
112
  },
108
- "gitHead": "33c513cf848a61fb1ebcea1b9c67505a31447411"
113
+ "gitHead": "a5dde6ae7e2ac86ac956220d4b8c39a0e58e1bc6"
109
114
  }