You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you are using the `"@typescript-eslint/parser"`, and if you want to use TypeScript in `<script>` of `.svelte`, you need to add more `parserOptions` configuration.
154
129
155
130
For example in `eslint.config.js`:
@@ -183,32 +158,6 @@ export default [
183
158
];
184
159
```
185
160
186
-
For example in `.eslintrc.*`:
187
-
188
-
```js
189
-
module.exports= {
190
-
// ...
191
-
parser:"@typescript-eslint/parser",
192
-
parserOptions: {
193
-
// ...
194
-
project:"path/to/your/tsconfig.json",
195
-
extraFileExtensions: [".svelte"], // This is a required setting in `@typescript-eslint/parser` v4.24.0.
196
-
},
197
-
overrides: [
198
-
{
199
-
files: ["*.svelte"],
200
-
parser:"svelte-eslint-parser",
201
-
// Parse the `<script>` in `.svelte` as TypeScript by adding the following configuration.
202
-
parserOptions: {
203
-
parser:"@typescript-eslint/parser",
204
-
},
205
-
},
206
-
// ...
207
-
],
208
-
// ...
209
-
};
210
-
```
211
-
212
161
#### Multiple parsers
213
162
214
163
If you want to switch the parser for each lang, specify the object.
@@ -235,21 +184,6 @@ export default [
235
184
];
236
185
```
237
186
238
-
For example in `.eslintrc.*`:
239
-
240
-
```json
241
-
{
242
-
"parser": "svelte-eslint-parser",
243
-
"parserOptions": {
244
-
"parser": {
245
-
"ts": "@typescript-eslint/parser",
246
-
"js": "espree",
247
-
"typescript": "@typescript-eslint/parser"
248
-
}
249
-
}
250
-
}
251
-
```
252
-
253
187
### parserOptions.svelteConfig
254
188
255
189
If you are using `eslint.config.js`, you can provide a `svelte.config.js` in the `parserOptions.svelteConfig` property.
@@ -289,7 +223,6 @@ export default [
289
223
parser: svelteParser,
290
224
parserOptions: {
291
225
svelteFeatures: {
292
-
/* It may be changed or removed in minor versions without notice. */
293
226
// This option is for Svelte 5. The default value is `true`.
294
227
// If `false`, ESLint will not recognize rune symbols.
295
228
// If not configured this option, The parser will try to read the option from `compilerOptions.runes` from `svelte.config.js`.
@@ -302,28 +235,8 @@ export default [
302
235
];
303
236
```
304
237
305
-
For example in `.eslintrc.*`:
306
-
307
-
```jsonc
308
-
{
309
-
"parser":"svelte-eslint-parser",
310
-
"parserOptions": {
311
-
"svelteFeatures": {
312
-
/* It may be changed or removed in minor versions without notice. */
313
-
// This option is for Svelte 5. The default value is `true`.
314
-
// If `false`, ESLint will not recognize rune symbols.
315
-
// If not configured this option, The parser will try to read the option from `compilerOptions.runes` from `svelte.config.js`.
316
-
// If `parserOptions.svelteConfig` is not specified and the file cannot be parsed by static analysis, it will behave as `true`.
317
-
"runes":true,
318
-
},
319
-
},
320
-
}
321
-
```
322
-
323
238
### Runes support
324
239
325
-
**_This is an experimental feature. It may be changed or removed in minor versions without notice._**
326
-
327
240
If you install Svelte v5 the parser will be able to parse runes, and will also be able to parse `*.js` and `*.ts` files.
328
241
If you don't want to use Runes, you may need to configure. Please read [parserOptions.svelteFeatures](#parseroptionssveltefeatures) for more details.
329
242
@@ -369,38 +282,6 @@ export default [
369
282
];
370
283
```
371
284
372
-
For example in `.eslintrc.*`:
373
-
374
-
```jsonc
375
-
{
376
-
"overrides": [
377
-
{
378
-
"files": ["*.svelte"],
379
-
"parser":"svelte-eslint-parser",
380
-
"parserOptions": {
381
-
"parser":"...",
382
-
/* ... */
383
-
},
384
-
},
385
-
{
386
-
"files": ["*.svelte.js"],
387
-
"parser":"svelte-eslint-parser",
388
-
"parserOptions": {
389
-
/* ... */
390
-
},
391
-
},
392
-
{
393
-
"files": ["*.svelte.ts"],
394
-
"parser":"svelte-eslint-parser",
395
-
"parserOptions": {
396
-
"parser":"...(ts parser)...",
397
-
/* ... */
398
-
},
399
-
},
400
-
],
401
-
}
402
-
```
403
-
404
285
## :computer: Editor Integrations
405
286
406
287
### Visual Studio Code
@@ -439,4 +320,3 @@ See the [LICENSE](LICENSE) file for license rights and limitations (MIT).
0 commit comments