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
// Add an `overrides` section to add a parser configuration for svelte.
75
+
overrides: [
76
+
{
77
+
files: ['*.svelte'],
78
+
parser:'svelte-eslint-parser'
79
+
}
80
+
// ...
81
+
]
82
+
// ...
83
+
}
84
+
```
85
+
86
+
For example, 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.
extraFileExtensions: ['.svelte'] // This is a required setting in `@typescript-eslint/parser` v4.24.0.
98
+
},
99
+
overrides: [
100
+
{
101
+
files: ['*.svelte'],
102
+
parser:'svelte-eslint-parser',
103
+
// Parse the `<script>` in `.svelte` as TypeScript by adding the following configuration.
104
+
parserOptions: {
105
+
parser:'@typescript-eslint/parser'
106
+
}
107
+
}
108
+
// ...
109
+
]
110
+
// ...
111
+
}
112
+
```
113
+
114
+
If you have a mix of TypeScript and JavaScript in your project, use a multiple parser configuration.
115
+
116
+
```js
117
+
module.exports= {
118
+
// ...
119
+
overrides: [
120
+
{
121
+
files: ['*.svelte'],
122
+
parser:'svelte-eslint-parser',
123
+
parserOptions: {
124
+
parser: {
125
+
// Specify a parser for each lang.
126
+
ts:'@typescript-eslint/parser',
127
+
js:'espree',
128
+
typescript:'@typescript-eslint/parser'
129
+
}
130
+
}
131
+
}
132
+
// ...
133
+
]
134
+
// ...
135
+
}
136
+
```
137
+
138
+
See also [https://github.com/ota-meshi/svelte-eslint-parser#readme](https://github.com/ota-meshi/svelte-eslint-parser#readme).
139
+
45
140
### Running ESLint from command line
46
141
47
142
If you want to run `eslint` from command line, make sure you include the `.svelte` extension using [the `--ext` option](https://eslint.org/docs/user-guide/configuring#specifying-file-extensions-to-lint) or a glob pattern because ESLint targets only `.js` files by default.
0 commit comments