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
This plugin provides some predefined configs. You can use the following configs by adding them to `eslint.config.[c|m]js`. (All flat configs in this plugin are provided as arrays, so spread syntax is required when combining them with other configs.)
48
+
This plugin provides some predefined configs. You can use the following configs by adding them to `eslint.config.js`. (All configs in this plugin are provided as arrays, so spread syntax is required when combining them with other configs.)
51
49
52
-
-`*configs["flat/base"]`: Settings and rules to enable correct ESlint parsing.
53
-
-`*configs["flat/recommended"]`: Above, plus rules to enforce subjective community defaults to ensure consistency.
50
+
-`*.configs.base`: Settings and rules to enable correct ESlint parsing.
51
+
-`*.configs.recommended`: Above, plus rules to enforce subjective community defaults to ensure consistency.
54
52
55
53
### Configuration `.eslintrc.*`
56
54
57
-
Use the `.eslintrc.*` file to configure rules in ESLint < v9. See also:
58
-
https://eslint.org/docs/latest/use/configure/.
59
-
60
-
Example `.eslintrc.js`:
61
-
62
-
```js
63
-
module.export= {
64
-
overrides: [
65
-
{
66
-
files: ['*.svelte'],
67
-
extends: [
68
-
// Recommended
69
-
'plugin:@intlify/svelte/recommended'
70
-
],
71
-
rules: {
72
-
// Optional.
73
-
'@intlify/svelte/no-raw-text':'error'
74
-
// ...
75
-
}
76
-
}
77
-
]
78
-
}
79
-
```
80
-
81
-
See [the rule list](./rules/README.md)
82
-
83
-
#### Bundle Configurations `eslintrc.*`
84
-
85
-
This plugin provides some predefined configs. You can use the following configs by adding them to `eslintrc.*`.
86
-
87
-
-`plugin:@intlify/svelte/base`: Settings and rules to enable correct ESlint parsing.
88
-
-`plugin:@intlify/svelte/recommended`: Above, plus rules to enforce subjective community defaults to ensure consistency.
89
-
90
-
::: warning ❗ Attention
91
-
92
-
The `@intlify/eslint-plugin-svelte` can not be used with the [eslint-plugin-svelte3].
93
-
If you are using [eslint-plugin-svelte3] you need to remove it.
If you have specified a parser, you need to configure a parser for `.svelte`.
108
-
109
-
For example, if you are using the `"@babel/eslint-parser"`, configure it as follows:
59
+
If you are using TypeScript, see the documentation for [eslint-plugin-svelte], the official ESLint plugin from Svelte.
110
60
111
-
```js
112
-
module.exports= {
113
-
// ...
114
-
extends: ['plugin:svelte/recommended'],
115
-
// ...
116
-
parser:'@babel/eslint-parser',
117
-
// Add an `overrides` section to add a parser configuration for svelte.
118
-
overrides: [
119
-
{
120
-
files: ['*.svelte'],
121
-
parser:'svelte-eslint-parser'
122
-
}
123
-
// ...
124
-
]
125
-
// ...
126
-
}
127
-
```
128
-
129
-
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.
130
-
131
-
```js
132
-
module.exports= {
133
-
// ...
134
-
extends: ['plugin:svelte/recommended'],
135
-
// ...
136
-
parser:'@typescript-eslint/parser',
137
-
parserOptions: {
138
-
// ...
139
-
project:'path/to/your/tsconfig.json',
140
-
extraFileExtensions: ['.svelte'] // This is a required setting in `@typescript-eslint/parser` v4.24.0.
141
-
},
142
-
overrides: [
143
-
{
144
-
files: ['*.svelte'],
145
-
parser:'svelte-eslint-parser',
146
-
// Parse the `<script>` in `.svelte` as TypeScript by adding the following configuration.
147
-
parserOptions: {
148
-
parser:'@typescript-eslint/parser'
149
-
}
150
-
}
151
-
// ...
152
-
]
153
-
// ...
154
-
}
155
-
```
156
-
157
-
If you have a mix of TypeScript and JavaScript in your project, use a multiple parser configuration.
<!-- See also: "[Use together with custom parsers](#use-together-with-custom-parsers)" section. -->
202
-
203
-
### Why doesn't it work on .svelte file?
204
-
205
-
1. Make sure you don't have `eslint-plugin-svelte3` in your config. The `eslint-plugin-svelte3` extracts the content from `<script>` tags, but `@intlify/eslint-plugin-svelte` requires `<script>` tags and other element tags in order to distinguish template and script in `*.svelte`.
206
-
207
-
```diff
208
-
"plugins": [
209
-
"@intlify/svelte",
210
-
- "svelte3"
211
-
]
212
-
```
213
-
214
-
2. Make sure your tool is set to lint `.svelte` files.
215
-
216
-
- CLI targets only `.js` files by default. You have to specify additional extensions by `--ext` option or glob patterns. E.g. `eslint "src/**/*.{js,svelte}"` or `eslint src --ext .svelte`.
0 commit comments