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.
112
114
overrides: [
113
115
{
114
116
files: ["*.svelte"],
115
117
parser:"svelte-eslint-parser",
116
118
},
119
+
// ...
117
120
],
118
121
// ...
119
122
}
120
123
```
121
124
122
-
If you want to use TypeScript in `<script>` of `.svelte`, you need to add more `parserOptions` configuration.
125
+
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.
137
+
},
127
138
overrides: [
128
139
{
129
140
files: ["*.svelte"],
130
141
parser:"svelte-eslint-parser",
131
-
// Parse the script in `.svelte` as TypeScript by adding the following configuration.
142
+
// Parse the `<script>` in `.svelte` as TypeScript by adding the following configuration.
132
143
parserOptions: {
133
144
parser:"@typescript-eslint/parser",
134
145
},
135
146
},
147
+
// ...
136
148
],
149
+
// ...
137
150
}
138
151
```
139
152
140
153
If you have a mix of TypeScript and JavaScript in your project, use a multiple parser configuration.
141
154
142
155
```js
143
156
module.exports= {
144
-
parser:"@typescript-eslint/parser",
157
+
// ...
145
158
overrides: [
146
159
{
147
160
files: ["*.svelte"],
@@ -155,7 +168,9 @@ module.exports = {
155
168
},
156
169
},
157
170
},
171
+
// ...
158
172
],
173
+
// ...
159
174
}
160
175
```
161
176
@@ -224,19 +239,19 @@ The rules with the following star :star: are included in the configs.
224
239
225
240
<!--RULES_TABLE_START-->
226
241
227
-
| Rule ID | Description ||
228
-
|:--------|:------------|:---|
229
-
|[@ota-meshi/svelte/button-has-type](https://ota-meshi.github.io/eslint-plugin-svelte/rules/button-has-type.html)| disallow usage of button without an explicit type attribute ||
230
-
|[@ota-meshi/svelte/comment-directive](https://ota-meshi.github.io/eslint-plugin-svelte/rules/comment-directive.html)| support comment-directives in HTML template |:star:|
231
-
|[@ota-meshi/svelte/no-at-debug-tags](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-at-debug-tags.html)| disallow the use of `{@debug}`|:star:|
232
-
|[@ota-meshi/svelte/no-at-html-tags](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-at-html-tags.html)| disallow use of `{@html}` to prevent XSS attack |:star:|
|[@ota-meshi/svelte/no-inner-declarations](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-inner-declarations.html)| disallow variable or `function` declarations in nested blocks |:star:|
235
-
|[@ota-meshi/svelte/no-target-blank](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-target-blank.html)| disallow target="_blank" attribute without rel="noopener noreferrer" ||
|[@ota-meshi/svelte/prefer-class-directive](https://ota-meshi.github.io/eslint-plugin-svelte/rules/prefer-class-directive.html)| require class directives instead of ternary expressions |:wrench:|
238
-
|[@ota-meshi/svelte/spaced-html-comment](https://ota-meshi.github.io/eslint-plugin-svelte/rules/spaced-html-comment.html)| enforce consistent spacing after the `<!--` and before the `-->` in a HTML comment |:wrench:|
239
-
|[@ota-meshi/svelte/system](https://ota-meshi.github.io/eslint-plugin-svelte/rules/system.html)| system rule for working this plugin |:star:|
|[@ota-meshi/svelte/button-has-type](https://ota-meshi.github.io/eslint-plugin-svelte/rules/button-has-type.html)| disallow usage of button without an explicit type attribute ||
245
+
|[@ota-meshi/svelte/comment-directive](https://ota-meshi.github.io/eslint-plugin-svelte/rules/comment-directive.html)| support comment-directives in HTML template |:star:|
246
+
|[@ota-meshi/svelte/no-at-debug-tags](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-at-debug-tags.html)| disallow the use of `{@debug}`|:star:|
247
+
|[@ota-meshi/svelte/no-at-html-tags](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-at-html-tags.html)| disallow use of `{@html}` to prevent XSS attack |:star:|
|[@ota-meshi/svelte/no-inner-declarations](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-inner-declarations.html)| disallow variable or `function` declarations in nested blocks |:star:|
250
+
|[@ota-meshi/svelte/no-target-blank](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-target-blank.html)| disallow target="\_blank" attribute without rel="noopener noreferrer" ||
|[@ota-meshi/svelte/prefer-class-directive](https://ota-meshi.github.io/eslint-plugin-svelte/rules/prefer-class-directive.html)| require class directives instead of ternary expressions |:wrench:|
253
+
|[@ota-meshi/svelte/spaced-html-comment](https://ota-meshi.github.io/eslint-plugin-svelte/rules/spaced-html-comment.html)| enforce consistent spacing after the `<!--` and before the `-->` in a HTML comment |:wrench:|
254
+
|[@ota-meshi/svelte/system](https://ota-meshi.github.io/eslint-plugin-svelte/rules/system.html)| system rule for working this plugin |:star:|
// Add an `overrides` section to add a parser configuration for svelte.
71
73
overrides: [
72
74
{
73
75
files: ["*.svelte"],
74
76
parser:"svelte-eslint-parser",
75
77
},
78
+
// ...
76
79
],
77
80
// ...
78
81
}
79
82
```
80
83
81
-
If you want to use TypeScript in `<script>` of `.svelte`, you need to add more `parserOptions` configuration.
84
+
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.
0 commit comments