eslint-plugin-svelte 3.0.0-next.8 → 3.0.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.
Files changed (60) hide show
  1. package/README.md +184 -231
  2. package/lib/configs/flat/base.js +10 -0
  3. package/lib/configs/flat/recommended.js +20 -2
  4. package/lib/main.d.ts +1 -1
  5. package/lib/meta.d.ts +1 -1
  6. package/lib/meta.js +1 -1
  7. package/lib/rule-types.d.ts +29 -6
  8. package/lib/rules/@typescript-eslint/no-unnecessary-condition.js +1 -1
  9. package/lib/rules/consistent-selector-style.js +227 -0
  10. package/lib/rules/html-self-closing.js +34 -14
  11. package/lib/rules/infinite-reactive-loop.js +12 -3
  12. package/lib/rules/no-dom-manipulating.js +1 -1
  13. package/lib/rules/no-dupe-on-directives.js +1 -1
  14. package/lib/rules/no-dupe-use-directives.js +1 -1
  15. package/lib/rules/no-dynamic-slot-name.js +6 -2
  16. package/lib/rules/no-export-load-in-svelte-module-in-kit-pages.js +8 -8
  17. package/lib/rules/no-immutable-reactive-statements.js +1 -2
  18. package/lib/rules/no-inspect.js +8 -3
  19. package/lib/rules/no-not-function-handler.js +14 -1
  20. package/lib/rules/no-object-in-text-mustaches.js +1 -1
  21. package/lib/rules/no-raw-special-elements.d.ts +2 -0
  22. package/lib/rules/{no-deprecated-raw-special-elements.js → no-raw-special-elements.js} +3 -4
  23. package/lib/rules/no-reactive-functions.js +11 -2
  24. package/lib/rules/no-reactive-literals.js +11 -2
  25. package/lib/rules/no-reactive-reassign.js +11 -3
  26. package/lib/rules/no-store-async.js +1 -3
  27. package/lib/rules/no-svelte-internal.js +1 -3
  28. package/lib/rules/no-unused-class-name.js +8 -19
  29. package/lib/rules/no-useless-children-snippet.d.ts +2 -0
  30. package/lib/rules/no-useless-children-snippet.js +31 -0
  31. package/lib/rules/no-useless-mustaches.js +4 -1
  32. package/lib/rules/require-each-key.js +1 -1
  33. package/lib/rules/require-event-dispatcher-types.js +7 -2
  34. package/lib/rules/require-store-reactive-access.js +15 -7
  35. package/lib/rules/require-stores-init.js +2 -0
  36. package/lib/rules/shorthand-attribute.js +1 -1
  37. package/lib/rules/valid-compile.js +39 -15
  38. package/lib/rules/valid-each-key.js +1 -2
  39. package/lib/rules/valid-prop-names-in-kit-pages.js +17 -12
  40. package/lib/rules/valid-style-parse.d.ts +2 -0
  41. package/lib/rules/valid-style-parse.js +38 -0
  42. package/lib/types-for-node.d.ts +395 -0
  43. package/lib/types.d.ts +20 -0
  44. package/lib/utils/ast-utils.d.ts +6 -0
  45. package/lib/utils/ast-utils.js +18 -0
  46. package/lib/utils/events.d.ts +1 -0
  47. package/lib/utils/events.js +349 -0
  48. package/lib/utils/get-node-module.d.ts +4 -0
  49. package/lib/utils/get-node-module.js +64 -0
  50. package/lib/utils/get-package-json.d.ts +1 -1
  51. package/lib/utils/get-package-json.js +15 -13
  52. package/lib/utils/index.d.ts +3 -1
  53. package/lib/utils/index.js +39 -1
  54. package/lib/utils/rules.js +9 -3
  55. package/lib/utils/svelte-context.d.ts +26 -0
  56. package/lib/utils/svelte-context.js +261 -0
  57. package/package.json +5 -5
  58. package/lib/utils/svelte-kit.d.ts +0 -10
  59. package/lib/utils/svelte-kit.js +0 -67
  60. /package/lib/rules/{no-deprecated-raw-special-elements.d.ts → consistent-selector-style.d.ts} +0 -0
package/README.md CHANGED
@@ -1,14 +1,4 @@
1
- # Introduction
2
-
3
- `eslint-plugin-svelte` is the official [ESLint] plugin for [Svelte].
4
- It provides many unique check rules by using the template AST.
5
- You can check on the [Online DEMO](https://eslint-online-playground.netlify.app/#eslint-plugin-svelte%20with%20typescript).
6
-
7
- > [!NOTE]
8
- > This document is in development.\
9
- > Please refer to the document for the version you are using.\
10
- > For example, <https://github.com/sveltejs/eslint-plugin-svelte/blob/eslint-plugin-svelte%402.46.0/README.md>
11
- > and <https://github.com/sveltejs/eslint-plugin-svelte/blob/eslint-plugin-svelte%402.46.0/docs>
1
+ <!--DOCS_IGNORE_START-->
12
2
 
13
3
  [![NPM license](https://img.shields.io/npm/l/eslint-plugin-svelte.svg)](https://www.npmjs.com/package/eslint-plugin-svelte)
14
4
  [![NPM version](https://img.shields.io/npm/v/eslint-plugin-svelte.svg)](https://www.npmjs.com/package/eslint-plugin-svelte)
@@ -24,209 +14,217 @@ You can check on the [Online DEMO](https://eslint-online-playground.netlify.app/
24
14
  [![Code Style: Prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
25
15
  [![changesets](https://img.shields.io/badge/maintained%20with-changesets-176de3.svg)](https://github.com/atlassian/changesets)
26
16
 
27
- ## :name_badge: What is this plugin?
28
-
29
- [ESLint] plugin for [Svelte].
30
- It provides many unique check rules using the AST generated by [svelte-eslint-parser].
31
-
32
- ### ❗ Attention
33
-
34
- #### Cannot be used with eslint-plugin-svelte3
35
-
36
- The [svelte-eslint-parser] and the `eslint-plugin-svelte` can not be used with the [eslint-plugin-svelte3].
17
+ <div align="center">
37
18
 
38
- [svelte-eslint-parser]: https://github.com/sveltejs/svelte-eslint-parser
39
- [eslint-plugin-svelte3]: https://github.com/sveltejs/eslint-plugin-svelte3
19
+ # eslint-plugin-svelte
40
20
 
41
- #### Experimental support for Svelte v5
21
+ ## ESLint plugin for Svelte using AST
42
22
 
43
- We are working on support for Svelte v5, but it is still an experimental feature. Please note that rules and features related to Svelte v5 may be changed or removed in minor versions without notice.
23
+ [Live Demo](https://eslint-online-playground.netlify.app/#eslint-plugin-svelte%20with%20typescript)
24
+ [Documentation](https://sveltejs.github.io/eslint-plugin-svelte/) •
25
+ [Discord](https://svelte.dev/chat)
44
26
 
45
- <!--DOCS_IGNORE_START-->
46
-
47
- ## Versioning policy
27
+ </div>
48
28
 
49
- This plugin follows [Semantic Versioning](https://semver.org/).
50
- However, unlike [ESLint’s Semantic Versioning Policy](https://github.com/eslint/eslint#semantic-versioning-policy), this plugin adds new rules to its configs even in minor releases. For example, if you are using the recommended config, a minor update may add new rules, which could cause new lint errors in your project.
51
- While [ESLint’s Semantic Versioning Policy](https://github.com/eslint/eslint#semantic-versioning-policy) only adds new rules to configs in major releases, most users (myself included) don’t regularly monitor new rules. This makes it challenging to manually add them to projects whenever they are introduced.
52
- By adding new rules to configs in minor releases, this plugin ensures users can adopt them more easily. If any new rules cause issues, you can simply disable them. I believe this approach helps maintain and improve code quality with minimal effort.
53
-
54
- ## Migration Guide
29
+ <!--DOCS_IGNORE_END-->
55
30
 
56
- To migrate from `eslint-plugin-svelte` v1, or [`@ota-meshi/eslint-plugin-svelte`](https://www.npmjs.com/package/@ota-meshi/eslint-plugin-svelte), please refer to the [migration guide](https://sveltejs.github.io/eslint-plugin-svelte/migration/).
31
+ ## Introduction
57
32
 
58
- ## :book: Documentation
33
+ `eslint-plugin-svelte` is the official [ESLint](https://eslint.org/) plugin for [Svelte](https://svelte.dev/).
34
+ It leverages the AST generated by [svelte-eslint-parser](https://github.com/sveltejs/svelte-eslint-parser) to provide custom linting for Svelte.
35
+ Note that `eslint-plugin-svelte` and `svelte-eslint-parser` cannot be used alongside [eslint-plugin-svelte3](https://github.com/sveltejs/eslint-plugin-svelte3).
59
36
 
60
- See [documents](https://sveltejs.github.io/eslint-plugin-svelte/).
37
+ <!--USAGE_SECTION_START-->
38
+ <!--USAGE_GUIDE_START-->
61
39
 
62
- ## :cd: Installation
40
+ ## Installation
63
41
 
64
42
  ```bash
65
- npm install --save-dev eslint eslint-plugin-svelte svelte
43
+ npm install --save-dev svelte eslint eslint-plugin-svelte globals
66
44
  ```
67
45
 
68
- > **Requirements**
46
+ > [!NOTE]
69
47
  >
70
- > - ESLint v8.57.1, v9.0.0 and above
71
- > - Node.js v18.20.4, v20.18.0, v22.10.0 and above
72
-
73
- <!--DOCS_IGNORE_END-->
48
+ > **Requirements:**
49
+ >
50
+ > - ESLint v8.57.1, v9.0.0, and above
51
+ > - Node.js v18.20.4, v20.18.0, v22.10.0, and above
74
52
 
75
- ## :book: Usage
53
+ ## Usage
76
54
 
77
- <!--USAGE_SECTION_START-->
78
- <!--USAGE_GUIDE_START-->
55
+ Use the `eslint.config.js` file to configure rules. For more details, see the [ESLint documentation](https://eslint.org/docs/latest/use/configure/configuration-files-new).
79
56
 
80
57
  ### Configuration
81
58
 
82
- Use `eslint.config.js` file to configure rules. See also: <https://eslint.org/docs/latest/use/configure/configuration-files-new>.
83
-
84
- Example **eslint.config.js**:
59
+ #### JavaScript project
85
60
 
86
61
  ```js
87
- import eslintPluginSvelte from 'eslint-plugin-svelte';
62
+ // eslint.config.js
63
+ import js from '@eslint/js';
64
+ import svelte from 'eslint-plugin-svelte';
65
+ import globals from 'globals';
66
+ import svelteConfig from './svelte.config.js';
67
+
68
+ /** @type {import('eslint').Linter.Config[]} */
88
69
  export default [
89
- // add more generic rule sets here, such as:
90
- // js.configs.recommended,
91
- ...eslintPluginSvelte.configs.recommended,
70
+ js.configs.recommended,
71
+ ...svelte.configs.recommended,
72
+ {
73
+ languageOptions: {
74
+ globals: {
75
+ ...globals.browser,
76
+ ...globals.node // Add this if you are using SvelteKit in non-SPA mode
77
+ }
78
+ }
79
+ },
80
+ {
81
+ files: [
82
+ '*.svelte',
83
+ '**/*.svelte',
84
+ '*.svelte.ts',
85
+ '**/*.svelte.ts',
86
+ '*.svelte.js',
87
+ '**/*.svelte.js'
88
+ ],
89
+ languageOptions: {
90
+ parserOptions: {
91
+ // We recommend importing and specifying svelte.config.js.
92
+ // By doing so, some rules in eslint-plugin-svelte will automatically read the configuration and adjust their behavior accordingly.
93
+ // While certain Svelte settings may be statically loaded from svelte.config.js even if you don’t specify it,
94
+ // explicitly specifying it ensures better compatibility and functionality.
95
+ svelteConfig
96
+ }
97
+ }
98
+ },
92
99
  {
93
100
  rules: {
94
- // override/add rules settings here, such as:
101
+ // Override or add rule settings here, such as:
95
102
  // 'svelte/rule-name': 'error'
96
103
  }
97
104
  }
98
105
  ];
99
106
  ```
100
107
 
101
- This plugin provides configs:
102
-
103
- - `eslintPluginSvelte.configs.base` ... Configuration to enable correct Svelte parsing.
104
- - `eslintPluginSvelte.configs.recommended` ... Above, plus rules to prevent errors or unintended behavior.
105
- - `eslintPluginSvelte.configs.prettier` ... Turns off rules that may conflict with [Prettier](https://prettier.io/) (You still need to configure prettier to work with svelte yourself, for example by using [prettier-plugin-svelte](https://github.com/sveltejs/prettier-plugin-svelte).).
106
- - `eslintPluginSvelte.configs.all` ... All rules. This configuration is not recommended for production use because it changes with every minor and major version of `eslint-plugin-svelte`. Use it at your own risk.
107
-
108
- See [the rule list](https://sveltejs.github.io/eslint-plugin-svelte/rules/) to get the `rules` that this plugin provides.
108
+ #### TypeScript project
109
109
 
110
- #### Parser Configuration
111
-
112
- If you have specified a parser, you need to configure a parser for `.svelte`.
113
-
114
- 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.
110
+ ```shell
111
+ npm install --save-dev typescript-eslint
112
+ ```
115
113
 
116
114
  ```js
117
- import eslintPluginSvelte from 'eslint-plugin-svelte';
118
- import * as svelteParser from 'svelte-eslint-parser';
119
- import * as typescriptParser from '@typescript-eslint/parser';
120
- export default [
121
- ...js.configs.recommended,
122
- ...eslintPluginSvelte.configs.recommended,
115
+ // eslint.config.js
116
+ import js from '@eslint/js';
117
+ import svelte from 'eslint-plugin-svelte';
118
+ import globals from 'globals';
119
+ import ts from 'typescript-eslint';
120
+ import svelteConfig from './svelte.config.js';
121
+
122
+ export default ts.config(
123
+ js.configs.recommended,
124
+ ...ts.configs.recommended,
125
+ ...svelte.configs.recommended,
123
126
  {
124
- files: ['**/*.svelte'],
125
127
  languageOptions: {
126
- parser: svelteParser,
127
- parserOptions: {
128
- parser: typescriptParser,
129
- project: './path/to/your/tsconfig.json',
130
- extraFileExtensions: ['.svelte']
128
+ globals: {
129
+ ...globals.browser,
130
+ ...globals.node
131
131
  }
132
132
  }
133
- }
134
- ];
135
- ```
136
-
137
- If you have a mix of TypeScript and JavaScript in your project, use a multiple parser configuration.
138
-
139
- ```js
140
- import eslintPluginSvelte from 'eslint-plugin-svelte';
141
- import * as svelteParser from 'svelte-eslint-parser';
142
- import * as typescriptParser from '@typescript-eslint/parser';
143
- import espree from 'espree';
144
- export default [
145
- ...js.configs.recommended,
146
- ...eslintPluginSvelte.configs.recommended,
133
+ },
147
134
  {
148
- files: ['**/*.svelte'],
135
+ files: ['*.svelte', '**/*.svelte'],
136
+ // See more details at: https://typescript-eslint.io/packages/parser/
149
137
  languageOptions: {
150
- parser: svelteParser,
151
138
  parserOptions: {
152
- parser: {
153
- // Specify a parser for each lang.
154
- ts: typescriptParser,
155
- js: espree,
156
- typescript: typescriptParser
157
- },
158
- project: './path/to/your/tsconfig.json',
159
- extraFileExtensions: ['.svelte']
139
+ projectService: true,
140
+ extraFileExtensions: ['.svelte'], // Add support for additional file extensions, such as .svelte
141
+ parser: ts.parser
142
+ // Specify a parser for each language, if needed:
143
+ // parser: {
144
+ // ts: ts.parser,
145
+ // js: espree, // Use espree for .js files (add: import espree from 'espree')
146
+ // typescript: ts.parser
147
+ // },
160
148
  }
161
149
  }
162
- }
163
- ];
164
- ```
165
-
166
- See also <https://github.com/sveltejs/svelte-eslint-parser#readme>.
167
-
168
- ::: warning ❗ Attention
169
-
170
- The TypeScript parser uses a singleton internally and it will only use the
171
- options given to it when it was first initialized. If trying to change the
172
- options for a different file or override, the parser will simply ignore the new
173
- options (which may result in an error). See
174
- [typescript-eslint/typescript-eslint#6778](https://github.com/typescript-eslint/typescript-eslint/issues/6778)
175
- for some context.
176
-
177
- :::
178
-
179
- #### Specify `svelte.config.js`
180
-
181
- If you are using `eslint.config.js`, we recommend that you import and specify `svelte.config.js`.
182
- By specifying it, some rules of `eslint-plugin-svelte` will read it and try to behave well for you by default.
183
- Some Svelte configurations will be statically loaded from `svelte.config.js` even if you don't specify it, but you need to specify it to make it work better.
184
-
185
- Example **eslint.config.js**:
186
-
187
- ```js
188
- import eslintPluginSvelte from 'eslint-plugin-svelte';
189
- import svelteConfig from './svelte.config.js';
190
- export default [
191
- ...eslintPluginSvelte.configs.recommended,
150
+ },
192
151
  {
193
152
  files: [
153
+ '*.svelte',
194
154
  '**/*.svelte',
195
- '*.svelte'
196
- // Add more files if you need.
197
- // '**/*.svelte.ts', '*.svelte.ts', '**/*.svelte.js', '*.svelte.js',
155
+ '*.svelte.ts',
156
+ '**/*.svelte.ts',
157
+ '*.svelte.js',
158
+ '**/*.svelte.js'
198
159
  ],
199
160
  languageOptions: {
200
161
  parserOptions: {
201
- // Specify the `svelte.config.js`.
162
+ // We recommend importing and specifying svelte.config.js.
163
+ // By doing so, some rules in eslint-plugin-svelte will automatically read the configuration and adjust their behavior accordingly.
164
+ // While certain Svelte settings may be statically loaded from svelte.config.js even if you don’t specify it,
165
+ // explicitly specifying it ensures better compatibility and functionality.
202
166
  svelteConfig
203
167
  }
204
168
  }
169
+ },
170
+ {
171
+ rules: {
172
+ // Override or add rule settings here, such as:
173
+ // 'svelte/rule-name': 'error'
174
+ }
205
175
  }
206
- ];
176
+ );
207
177
  ```
208
178
 
209
- #### settings.svelte
179
+ > [!WARNING]
180
+ > The TypeScript parser uses a singleton internally, meaning it only respects the options provided during its initial initialization.
181
+ > If you try to change the options for a different file or override them later, the parser will ignore the new options, which may lead to errors.
182
+ > For more context, see [typescript-eslint/typescript-eslint#6778](https://github.com/typescript-eslint/typescript-eslint/issues/6778).
183
+
184
+ ### Available Configurations
185
+
186
+ This plugin provides the following configurations:
187
+
188
+ - **`eslintPluginSvelte.configs.base`** ... Enables correct Svelte parsing.
189
+ - **`eslintPluginSvelte.configs.recommended`** ... Includes `base` configuration, plus rules to prevent errors or unintended behavior.
190
+ - **`eslintPluginSvelte.configs.prettier`** ... Disables rules that may conflict with [Prettier](https://prettier.io/). You still need to configure Prettier to work with Svelte manually, for example, by using [prettier-plugin-svelte](https://github.com/sveltejs/prettier-plugin-svelte).
191
+ - **`eslintPluginSvelte.configs.all`** ... Includes all available rules. **Note:** This configuration is not recommended for production use, as it changes with every minor and major version of `eslint-plugin-svelte`. Use at your own risk.
210
192
 
211
- You can change the behavior of this plugin with some settings.
193
+ For more details, see [the rule list](https://sveltejs.github.io/eslint-plugin-svelte/rules/) to explore the rules provided by this plugin.
212
194
 
213
- e.g.
195
+ ### settings.svelte
196
+
197
+ You can customize the behavior of this plugin using specific settings.
214
198
 
215
199
  ```js
200
+ // eslint.config.js
216
201
  export default [
217
202
  // ...
218
203
  {
219
204
  settings: {
220
205
  svelte: {
206
+ // Specifies an array of rules to ignore reports within the template.
207
+ // For example, use this to disable rules in the template that may produce unavoidable false positives.
221
208
  ignoreWarnings: [
222
209
  '@typescript-eslint/no-unsafe-assignment',
223
210
  '@typescript-eslint/no-unsafe-member-access'
224
211
  ],
212
+ // Specifies options for Svelte compilation.
213
+ // This affects rules that rely on Svelte compilation,
214
+ // such as svelte/valid-compile and svelte/no-unused-svelte-ignore.
215
+ // Note that this setting does not impact ESLint’s custom parser.
225
216
  compileOptions: {
217
+ // Specifies options related to PostCSS. You can disable the PostCSS processing by setting it to false.
226
218
  postcss: {
219
+ // Specifies the path to the directory that contains the PostCSS configuration.
227
220
  configFilePath: './path/to/my/postcss.config.js'
228
221
  }
229
222
  },
223
+ // Even if settings.svelte.kit is not specified, the rules will attempt to load information from svelte.config.js.
224
+ // However, if the default behavior does not work as expected, you should specify settings.svelte.kit explicitly.
225
+ // If you are using SvelteKit with a non-default configuration, you need to set the following options.
226
+ // The schema is a subset of SvelteKit’s configuration, so refer to the SvelteKit documentation for more details.
227
+ // https://svelte.dev/docs/kit/configuration
230
228
  kit: {
231
229
  files: {
232
230
  routes: 'src/routes'
@@ -239,59 +237,11 @@ export default [
239
237
  ];
240
238
  ```
241
239
 
242
- #### settings.svelte.ignoreWarnings
243
-
244
- Specifies an array of rules that ignore reports in the template.
245
- For example, set rules on the template that cannot avoid false positives.
246
-
247
- #### settings.svelte.compileOptions
248
-
249
- Specifies options for Svelte compile. Effects rules that use Svelte compile. The target rules are [svelte/valid-compile](https://sveltejs.github.io/eslint-plugin-svelte/rules/valid-compile/) and [svelte/no-unused-svelte-ignore](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-unused-svelte-ignore/). **Note that it has no effect on ESLint's custom parser**.
250
-
251
- - `postcss` ... Specifies options related to PostCSS. You can disable the PostCSS process by specifying `false`.
252
- - `configFilePath` ... Specifies the path of the directory containing the PostCSS configuration.
253
-
254
- #### settings.svelte.kit
255
-
256
- ::: warning
257
-
258
- Even if you don't specify `settings.svelte.kit`, the rules will try to load information from `svelte.config.js`, so specify `settings.svelte.kit` if the default doesn't work.
259
-
260
- :::
261
-
262
- If you use SvelteKit with not default configuration, you need to set below configurations.
263
- The schema is subset of SvelteKit's configuration.
264
- Therefore please check [SvelteKit docs](https://kit.svelte.dev/docs/configuration) for more details.
265
-
266
- e.g.
267
-
268
- ```js
269
- export default [
270
- // ...
271
- {
272
- settings: {
273
- svelte: {
274
- kit: {
275
- files: {
276
- routes: 'src/routes'
277
- }
278
- }
279
- }
280
- }
281
- }
282
- // ...
283
- ];
284
- ```
285
-
286
- ## :computer: Editor Integrations
240
+ ## Editor Integrations
287
241
 
288
- ### Visual Studio Code
289
-
290
- Use the [dbaeumer.vscode-eslint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) extension that Microsoft provides officially.
291
-
292
- You have to configure the `eslint.validate` option of the extension to check `.svelte` files, because the extension targets only `*.js` or `*.jsx` files by default.
293
-
294
- Example **.vscode/settings.json**:
242
+ **Visual Studio Code**
243
+ Install [dbaeumer.vscode-eslint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint).
244
+ Configure `.svelte` files in `.vscode/settings.json`:
295
245
 
296
246
  ```json
297
247
  {
@@ -302,7 +252,17 @@ Example **.vscode/settings.json**:
302
252
  <!--USAGE_GUIDE_END-->
303
253
  <!--USAGE_SECTION_END-->
304
254
 
305
- ## :white_check_mark: Rules
255
+ ## Migration Guide
256
+
257
+ If you’re migrating from `eslint-plugin-svelte` v1 or [`@ota-meshi/eslint-plugin-svelte`](https://www.npmjs.com/package/@ota-meshi/eslint-plugin-svelte), see the [migration guide](https://sveltejs.github.io/eslint-plugin-svelte/migration/).
258
+
259
+ ## Versioning Policy
260
+
261
+ This project follows [Semantic Versioning](https://semver.org/). Unlike [ESLint’s versioning policy](https://github.com/eslint/eslint#semantic-versioning-policy), new rules may be added in minor releases. If these new rules cause unwanted warnings, you can disable them.
262
+
263
+ <!--DOCS_IGNORE_END-->
264
+
265
+ ## Rules
306
266
 
307
267
  <!-- prettier-ignore-start -->
308
268
  <!--RULES_SECTION_START-->
@@ -319,25 +279,23 @@ These rules relate to possible syntax or logic errors in Svelte code:
319
279
 
320
280
  | Rule ID | Description | |
321
281
  |:--------|:------------|:---|
322
- | [svelte/infinite-reactive-loop](https://sveltejs.github.io/eslint-plugin-svelte/rules/infinite-reactive-loop/) | Svelte runtime prevents calling the same reactive statement twice in a microtask. But between different microtask, it doesn't prevent. | |
323
- | [svelte/no-deprecated-raw-special-elements](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-deprecated-raw-special-elements/) | Recommends not using raw special elements in Svelte versions previous to 5. | :wrench: |
324
- | [svelte/no-dom-manipulating](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-dom-manipulating/) | disallow DOM manipulating | |
282
+ | [svelte/infinite-reactive-loop](https://sveltejs.github.io/eslint-plugin-svelte/rules/infinite-reactive-loop/) | Svelte runtime prevents calling the same reactive statement twice in a microtask. But between different microtask, it doesn't prevent. | :star: |
283
+ | [svelte/no-dom-manipulating](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-dom-manipulating/) | disallow DOM manipulating | :star: |
325
284
  | [svelte/no-dupe-else-if-blocks](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-dupe-else-if-blocks/) | disallow duplicate conditions in `{#if}` / `{:else if}` chains | :star: |
326
- | [svelte/no-dupe-on-directives](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-dupe-on-directives/) | disallow duplicate `on:` directives | |
285
+ | [svelte/no-dupe-on-directives](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-dupe-on-directives/) | disallow duplicate `on:` directives | :star: |
327
286
  | [svelte/no-dupe-style-properties](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-dupe-style-properties/) | disallow duplicate style properties | :star: |
328
- | [svelte/no-dupe-use-directives](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-dupe-use-directives/) | disallow duplicate `use:` directives | |
329
- | [svelte/no-dynamic-slot-name](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-dynamic-slot-name/) | disallow dynamic slot name | :star::wrench: |
330
- | [svelte/no-export-load-in-svelte-module-in-kit-pages](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-export-load-in-svelte-module-in-kit-pages/) | disallow exporting load functions in `*.svelte` module in SvelteKit page components. | |
287
+ | [svelte/no-dupe-use-directives](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-dupe-use-directives/) | disallow duplicate `use:` directives | :star: |
331
288
  | [svelte/no-not-function-handler](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-not-function-handler/) | disallow use of not function in event handler | :star: |
332
289
  | [svelte/no-object-in-text-mustaches](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-object-in-text-mustaches/) | disallow objects in text mustache interpolation | :star: |
333
- | [svelte/no-reactive-reassign](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-reactive-reassign/) | disallow reassigning reactive values | |
290
+ | [svelte/no-raw-special-elements](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-raw-special-elements/) | Checks for invalid raw HTML elements | :star::wrench: |
291
+ | [svelte/no-reactive-reassign](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-reactive-reassign/) | disallow reassigning reactive values | :star: |
334
292
  | [svelte/no-shorthand-style-property-overrides](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-shorthand-style-property-overrides/) | disallow shorthand style properties that override related longhand properties | :star: |
335
- | [svelte/no-store-async](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-store-async/) | disallow using async/await inside svelte stores because it causes issues with the auto-unsubscribing features | |
293
+ | [svelte/no-store-async](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-store-async/) | disallow using async/await inside svelte stores because it causes issues with the auto-unsubscribing features | :star: |
336
294
  | [svelte/no-unknown-style-directive-property](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-unknown-style-directive-property/) | disallow unknown `style:property` | :star: |
337
295
  | [svelte/require-store-callbacks-use-set-param](https://sveltejs.github.io/eslint-plugin-svelte/rules/require-store-callbacks-use-set-param/) | store callbacks must use `set` param | |
338
- | [svelte/require-store-reactive-access](https://sveltejs.github.io/eslint-plugin-svelte/rules/require-store-reactive-access/) | disallow to use of the store itself as an operand. Need to use $ prefix or get function. | :wrench: |
339
- | [svelte/valid-compile](https://sveltejs.github.io/eslint-plugin-svelte/rules/valid-compile/) | disallow warnings when compiling. | :star: |
340
- | [svelte/valid-prop-names-in-kit-pages](https://sveltejs.github.io/eslint-plugin-svelte/rules/valid-prop-names-in-kit-pages/) | disallow props other than data or errors in SvelteKit page components. | |
296
+ | [svelte/require-store-reactive-access](https://sveltejs.github.io/eslint-plugin-svelte/rules/require-store-reactive-access/) | disallow to use of the store itself as an operand. Need to use $ prefix or get function. | :star::wrench: |
297
+ | [svelte/valid-compile](https://sveltejs.github.io/eslint-plugin-svelte/rules/valid-compile/) | disallow warnings when compiling. | |
298
+ | [svelte/valid-style-parse](https://sveltejs.github.io/eslint-plugin-svelte/rules/valid-style-parse/) | require valid style element parsing | |
341
299
 
342
300
  ## Security Vulnerability
343
301
 
@@ -358,22 +316,23 @@ These rules relate to better ways of doing things to help you avoid problems:
358
316
  | [svelte/button-has-type](https://sveltejs.github.io/eslint-plugin-svelte/rules/button-has-type/) | disallow usage of button without an explicit type attribute | |
359
317
  | [svelte/no-at-debug-tags](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-at-debug-tags/) | disallow the use of `{@debug}` | :star: |
360
318
  | [svelte/no-ignored-unsubscribe](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-ignored-unsubscribe/) | disallow ignoring the unsubscribe method returned by the `subscribe()` on Svelte stores. | |
361
- | [svelte/no-immutable-reactive-statements](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-immutable-reactive-statements/) | disallow reactive statements that don't reference reactive values. | |
319
+ | [svelte/no-immutable-reactive-statements](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-immutable-reactive-statements/) | disallow reactive statements that don't reference reactive values. | :star: |
362
320
  | [svelte/no-inline-styles](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-inline-styles/) | disallow attributes and directives that produce inline styles | |
363
- | [svelte/no-inspect](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-inspect/) | Warns against the use of `$inspect` directive | |
364
- | [svelte/no-reactive-functions](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-reactive-functions/) | it's not necessary to define functions in reactive statements | :bulb: |
365
- | [svelte/no-reactive-literals](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-reactive-literals/) | don't assign literal values in reactive statements | :bulb: |
366
- | [svelte/no-svelte-internal](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-svelte-internal/) | svelte/internal will be removed in Svelte 6. | |
321
+ | [svelte/no-inspect](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-inspect/) | Warns against the use of `$inspect` directive | :star: |
322
+ | [svelte/no-reactive-functions](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-reactive-functions/) | it's not necessary to define functions in reactive statements | :star::bulb: |
323
+ | [svelte/no-reactive-literals](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-reactive-literals/) | don't assign literal values in reactive statements | :star::bulb: |
324
+ | [svelte/no-svelte-internal](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-svelte-internal/) | svelte/internal will be removed in Svelte 6. | :star: |
367
325
  | [svelte/no-unused-class-name](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-unused-class-name/) | disallow the use of a class in the template without a corresponding style | |
368
326
  | [svelte/no-unused-svelte-ignore](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-unused-svelte-ignore/) | disallow unused svelte-ignore comments | :star: |
369
- | [svelte/no-useless-mustaches](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-useless-mustaches/) | disallow unnecessary mustache interpolations | :wrench: |
327
+ | [svelte/no-useless-children-snippet](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-useless-children-snippet/) | disallow explicit children snippet where it's not needed | :star: |
328
+ | [svelte/no-useless-mustaches](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-useless-mustaches/) | disallow unnecessary mustache interpolations | :star::wrench: |
370
329
  | [svelte/prefer-const](https://sveltejs.github.io/eslint-plugin-svelte/rules/prefer-const/) | Require `const` declarations for variables that are never reassigned after declared | :wrench: |
371
330
  | [svelte/prefer-destructured-store-props](https://sveltejs.github.io/eslint-plugin-svelte/rules/prefer-destructured-store-props/) | destructure values from object stores for better change tracking & fewer redraws | :bulb: |
372
- | [svelte/require-each-key](https://sveltejs.github.io/eslint-plugin-svelte/rules/require-each-key/) | require keyed `{#each}` block | |
373
- | [svelte/require-event-dispatcher-types](https://sveltejs.github.io/eslint-plugin-svelte/rules/require-event-dispatcher-types/) | require type parameters for `createEventDispatcher` | |
331
+ | [svelte/require-each-key](https://sveltejs.github.io/eslint-plugin-svelte/rules/require-each-key/) | require keyed `{#each}` block | :star: |
332
+ | [svelte/require-event-dispatcher-types](https://sveltejs.github.io/eslint-plugin-svelte/rules/require-event-dispatcher-types/) | require type parameters for `createEventDispatcher` | :star: |
374
333
  | [svelte/require-optimized-style-attribute](https://sveltejs.github.io/eslint-plugin-svelte/rules/require-optimized-style-attribute/) | require style attributes that can be optimized | |
375
334
  | [svelte/require-stores-init](https://sveltejs.github.io/eslint-plugin-svelte/rules/require-stores-init/) | require initial value in store | |
376
- | [svelte/valid-each-key](https://sveltejs.github.io/eslint-plugin-svelte/rules/valid-each-key/) | enforce keys to use variables defined in the `{#each}` block | |
335
+ | [svelte/valid-each-key](https://sveltejs.github.io/eslint-plugin-svelte/rules/valid-each-key/) | enforce keys to use variables defined in the `{#each}` block | :star: |
377
336
 
378
337
  ## Stylistic Issues
379
338
 
@@ -381,6 +340,7 @@ These rules relate to style guidelines, and are therefore quite subjective:
381
340
 
382
341
  | Rule ID | Description | |
383
342
  |:--------|:------------|:---|
343
+ | [svelte/consistent-selector-style](https://sveltejs.github.io/eslint-plugin-svelte/rules/consistent-selector-style/) | enforce a consistent style for CSS selectors | |
384
344
  | [svelte/derived-has-same-inputs-outputs](https://sveltejs.github.io/eslint-plugin-svelte/rules/derived-has-same-inputs-outputs/) | derived store should use same variable names between values and callback | |
385
345
  | [svelte/first-attribute-linebreak](https://sveltejs.github.io/eslint-plugin-svelte/rules/first-attribute-linebreak/) | enforce the location of first attribute | :wrench: |
386
346
  | [svelte/html-closing-bracket-new-line](https://sveltejs.github.io/eslint-plugin-svelte/rules/html-closing-bracket-new-line/) | Require or disallow a line break before tag's closing brackets | :wrench: |
@@ -415,7 +375,9 @@ These rules relate to SvelteKit and its best Practices.
415
375
 
416
376
  | Rule ID | Description | |
417
377
  |:--------|:------------|:---|
378
+ | [svelte/no-export-load-in-svelte-module-in-kit-pages](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-export-load-in-svelte-module-in-kit-pages/) | disallow exporting load functions in `*.svelte` module in SvelteKit page components. | :star: |
418
379
  | [svelte/no-navigation-without-base](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-navigation-without-base/) | disallow using navigation (links, goto, pushState, replaceState) without the base path | |
380
+ | [svelte/valid-prop-names-in-kit-pages](https://sveltejs.github.io/eslint-plugin-svelte/rules/valid-prop-names-in-kit-pages/) | disallow props other than data or errors in SvelteKit page components. | :star: |
419
381
 
420
382
  ## Experimental
421
383
 
@@ -443,6 +405,7 @@ These rules relate to this plugin works:
443
405
  | Rule ID | Replaced by |
444
406
  |:--------|:------------|
445
407
  | [svelte/@typescript-eslint/no-unnecessary-condition](https://sveltejs.github.io/eslint-plugin-svelte/rules/@typescript-eslint/no-unnecessary-condition/) | This rule is no longer needed when using svelte-eslint-parser>=v0.19.0. |
408
+ | [svelte/no-dynamic-slot-name](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-dynamic-slot-name/) | Now Svelte compiler itself throws an compile error. |
446
409
  | [svelte/no-goto-without-base](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-goto-without-base/) | [svelte/no-navigation-without-base](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-navigation-without-base/) |
447
410
 
448
411
  <!--RULES_TABLE_END-->
@@ -451,23 +414,13 @@ These rules relate to this plugin works:
451
414
 
452
415
  <!--DOCS_IGNORE_START-->
453
416
 
454
- ## :beers: Contributing
455
-
456
- Welcome contributing!
457
-
458
- Please use GitHub's Issues/PRs.
417
+ ## Contributing
459
418
 
460
- See also [CONTRIBUTING.md](./CONTRIBUTING.md)
461
-
462
- ### Working With Rules
463
-
464
- This plugin uses [svelte-eslint-parser](https://github.com/sveltejs/svelte-eslint-parser) for the parser. Check [here](https://sveltejs.github.io/svelte-eslint-parser/) to find out about AST.
419
+ Contributions are welcome! Please open an issue or submit a PR. For more details, see [CONTRIBUTING.md](./CONTRIBUTING.md).
420
+ Refer to [svelte-eslint-parser](https://github.com/sveltejs/svelte-eslint-parser) for AST details.
465
421
 
466
422
  <!--DOCS_IGNORE_END-->
467
423
 
468
- ## :lock: License
469
-
470
- See the [LICENSE](LICENSE) file for license rights and limitations (MIT).
424
+ ## License
471
425
 
472
- [svelte]: https://svelte.dev/
473
- [eslint]: https://eslint.org/
426
+ See [LICENSE](LICENSE) (MIT).
@@ -29,6 +29,16 @@ const config = [
29
29
  'svelte/system': 'error'
30
30
  },
31
31
  processor: 'svelte/svelte'
32
+ },
33
+ {
34
+ name: 'svelte:base:setup-for-svelte-script',
35
+ files: ['*.svelte.js', '*.svelte.ts', '**/*.svelte.js', '**/*.svelte.ts'],
36
+ languageOptions: {
37
+ parser
38
+ },
39
+ rules: {
40
+ // eslint-plugin-svelte rules
41
+ }
32
42
  }
33
43
  ];
34
44
  export default config;
@@ -6,19 +6,37 @@ const config = [
6
6
  rules: {
7
7
  // eslint-plugin-svelte rules
8
8
  'svelte/comment-directive': 'error',
9
+ 'svelte/infinite-reactive-loop': 'error',
9
10
  'svelte/no-at-debug-tags': 'warn',
10
11
  'svelte/no-at-html-tags': 'error',
12
+ 'svelte/no-dom-manipulating': 'error',
11
13
  'svelte/no-dupe-else-if-blocks': 'error',
14
+ 'svelte/no-dupe-on-directives': 'error',
12
15
  'svelte/no-dupe-style-properties': 'error',
13
- 'svelte/no-dynamic-slot-name': 'error',
16
+ 'svelte/no-dupe-use-directives': 'error',
17
+ 'svelte/no-export-load-in-svelte-module-in-kit-pages': 'error',
18
+ 'svelte/no-immutable-reactive-statements': 'error',
14
19
  'svelte/no-inner-declarations': 'error',
20
+ 'svelte/no-inspect': 'warn',
15
21
  'svelte/no-not-function-handler': 'error',
16
22
  'svelte/no-object-in-text-mustaches': 'error',
23
+ 'svelte/no-raw-special-elements': 'error',
24
+ 'svelte/no-reactive-functions': 'error',
25
+ 'svelte/no-reactive-literals': 'error',
26
+ 'svelte/no-reactive-reassign': 'error',
17
27
  'svelte/no-shorthand-style-property-overrides': 'error',
28
+ 'svelte/no-store-async': 'error',
29
+ 'svelte/no-svelte-internal': 'error',
18
30
  'svelte/no-unknown-style-directive-property': 'error',
19
31
  'svelte/no-unused-svelte-ignore': 'error',
32
+ 'svelte/no-useless-children-snippet': 'error',
33
+ 'svelte/no-useless-mustaches': 'error',
34
+ 'svelte/require-each-key': 'error',
35
+ 'svelte/require-event-dispatcher-types': 'error',
36
+ 'svelte/require-store-reactive-access': 'error',
20
37
  'svelte/system': 'error',
21
- 'svelte/valid-compile': 'error'
38
+ 'svelte/valid-each-key': 'error',
39
+ 'svelte/valid-prop-names-in-kit-pages': 'error'
22
40
  }
23
41
  }
24
42
  ];
package/lib/main.d.ts CHANGED
@@ -14,7 +14,7 @@ export declare const configs: {
14
14
  export declare const rules: Record<string, Rule.RuleModule>;
15
15
  export declare const meta: {
16
16
  name: "eslint-plugin-svelte";
17
- version: "3.0.0-next.8";
17
+ version: "3.0.0";
18
18
  };
19
19
  export declare const processors: {
20
20
  '.svelte': typeof processor;