eslint-plugin-svelte 3.0.0-next.9 → 3.0.1

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 (59) hide show
  1. package/README.md +169 -237
  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 +24 -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.js +7 -2
  30. package/lib/rules/no-useless-mustaches.js +7 -1
  31. package/lib/rules/require-each-key.js +1 -1
  32. package/lib/rules/require-event-dispatcher-types.js +7 -2
  33. package/lib/rules/require-store-reactive-access.js +15 -7
  34. package/lib/rules/require-stores-init.js +2 -0
  35. package/lib/rules/shorthand-attribute.js +1 -1
  36. package/lib/rules/valid-compile.js +39 -15
  37. package/lib/rules/valid-each-key.js +1 -2
  38. package/lib/rules/valid-prop-names-in-kit-pages.js +17 -12
  39. package/lib/rules/valid-style-parse.d.ts +2 -0
  40. package/lib/rules/valid-style-parse.js +38 -0
  41. package/lib/types-for-node.d.ts +395 -0
  42. package/lib/types.d.ts +20 -0
  43. package/lib/utils/ast-utils.d.ts +6 -0
  44. package/lib/utils/ast-utils.js +18 -0
  45. package/lib/utils/events.d.ts +1 -0
  46. package/lib/utils/events.js +349 -0
  47. package/lib/utils/get-node-module.d.ts +4 -0
  48. package/lib/utils/get-node-module.js +64 -0
  49. package/lib/utils/get-package-json.d.ts +1 -1
  50. package/lib/utils/get-package-json.js +15 -13
  51. package/lib/utils/index.d.ts +3 -1
  52. package/lib/utils/index.js +39 -1
  53. package/lib/utils/rules.js +7 -3
  54. package/lib/utils/svelte-context.d.ts +26 -0
  55. package/lib/utils/svelte-context.js +261 -0
  56. package/package.json +5 -5
  57. package/lib/utils/svelte-kit.d.ts +0 -10
  58. package/lib/utils/svelte-kit.js +0 -67
  59. /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,197 @@ 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?
17
+ <div align="center">
28
18
 
29
- [ESLint] plugin for [Svelte].
30
- It provides many unique check rules using the AST generated by [svelte-eslint-parser].
19
+ # eslint-plugin-svelte
31
20
 
32
- ### Attention
21
+ ## ESLint plugin for Svelte using AST
33
22
 
34
- #### Cannot be used with eslint-plugin-svelte3
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)
35
26
 
36
- The [svelte-eslint-parser] and the `eslint-plugin-svelte` can not be used with the [eslint-plugin-svelte3].
27
+ </div>
37
28
 
38
- [svelte-eslint-parser]: https://github.com/sveltejs/svelte-eslint-parser
39
- [eslint-plugin-svelte3]: https://github.com/sveltejs/eslint-plugin-svelte3
40
-
41
- #### Experimental support for Svelte v5
42
-
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.
44
-
45
- <!--DOCS_IGNORE_START-->
46
-
47
- ## Versioning policy
48
-
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';
88
- export default [
89
- // add more generic rule sets here, such as:
90
- // js.configs.recommended,
91
- ...eslintPluginSvelte.configs.recommended,
92
- {
93
- rules: {
94
- // override/add rules settings here, such as:
95
- // 'svelte/rule-name': 'error'
96
- }
97
- }
98
- ];
99
- ```
100
-
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.
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.
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';
115
67
 
116
- ```js
117
- import eslintPluginSvelte from 'eslint-plugin-svelte';
118
- import * as svelteParser from 'svelte-eslint-parser';
119
- import * as typescriptParser from '@typescript-eslint/parser';
68
+ /** @type {import('eslint').Linter.Config[]} */
120
69
  export default [
121
- ...js.configs.recommended,
122
- ...eslintPluginSvelte.configs.recommended,
70
+ js.configs.recommended,
71
+ ...svelte.configs.recommended,
123
72
  {
124
- files: ['**/*.svelte'],
125
73
  languageOptions: {
126
- parser: svelteParser,
127
- parserOptions: {
128
- parser: typescriptParser,
129
- project: './path/to/your/tsconfig.json',
130
- extraFileExtensions: ['.svelte']
74
+ globals: {
75
+ ...globals.browser,
76
+ ...globals.node // Add this if you are using SvelteKit in non-SPA mode
131
77
  }
132
78
  }
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,
79
+ },
147
80
  {
148
- files: ['**/*.svelte'],
81
+ files: ['**/*.svelte', '**/*.svelte.js'],
149
82
  languageOptions: {
150
- parser: svelteParser,
151
83
  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']
84
+ // We recommend importing and specifying svelte.config.js.
85
+ // By doing so, some rules in eslint-plugin-svelte will automatically read the configuration and adjust their behavior accordingly.
86
+ // While certain Svelte settings may be statically loaded from svelte.config.js even if you don’t specify it,
87
+ // explicitly specifying it ensures better compatibility and functionality.
88
+ svelteConfig
160
89
  }
161
90
  }
91
+ },
92
+ {
93
+ rules: {
94
+ // Override or add rule settings here, such as:
95
+ // 'svelte/rule-name': 'error'
96
+ }
162
97
  }
163
98
  ];
164
99
  ```
165
100
 
166
- See also <https://github.com/sveltejs/svelte-eslint-parser#readme>.
101
+ #### TypeScript project
167
102
 
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**:
103
+ ```shell
104
+ npm install --save-dev typescript-eslint
105
+ ```
186
106
 
187
107
  ```js
188
- import eslintPluginSvelte from 'eslint-plugin-svelte';
108
+ // eslint.config.js
109
+ import js from '@eslint/js';
110
+ import svelte from 'eslint-plugin-svelte';
111
+ import globals from 'globals';
112
+ import ts from 'typescript-eslint';
189
113
  import svelteConfig from './svelte.config.js';
190
- export default [
191
- ...eslintPluginSvelte.configs.recommended,
114
+
115
+ export default ts.config(
116
+ js.configs.recommended,
117
+ ...ts.configs.recommended,
118
+ ...svelte.configs.recommended,
119
+ {
120
+ languageOptions: {
121
+ globals: {
122
+ ...globals.browser,
123
+ ...globals.node
124
+ }
125
+ }
126
+ },
192
127
  {
193
- files: [
194
- '**/*.svelte',
195
- '*.svelte'
196
- // Add more files if you need.
197
- // '**/*.svelte.ts', '*.svelte.ts', '**/*.svelte.js', '*.svelte.js',
198
- ],
128
+ files: ['**/*.svelte', '**/*.svelte.ts', '**/*.svelte.js'],
129
+ // See more details at: https://typescript-eslint.io/packages/parser/
199
130
  languageOptions: {
200
131
  parserOptions: {
201
- // Specify the `svelte.config.js`.
132
+ projectService: true,
133
+ extraFileExtensions: ['.svelte'], // Add support for additional file extensions, such as .svelte
134
+ parser: ts.parser,
135
+ // Specify a parser for each language, if needed:
136
+ // parser: {
137
+ // ts: ts.parser,
138
+ // js: espree, // Use espree for .js files (add: import espree from 'espree')
139
+ // typescript: ts.parser
140
+ // },
141
+
142
+ // We recommend importing and specifying svelte.config.js.
143
+ // By doing so, some rules in eslint-plugin-svelte will automatically read the configuration and adjust their behavior accordingly.
144
+ // While certain Svelte settings may be statically loaded from svelte.config.js even if you don’t specify it,
145
+ // explicitly specifying it ensures better compatibility and functionality.
202
146
  svelteConfig
203
147
  }
204
148
  }
149
+ },
150
+ {
151
+ rules: {
152
+ // Override or add rule settings here, such as:
153
+ // 'svelte/rule-name': 'error'
154
+ }
205
155
  }
206
- ];
156
+ );
207
157
  ```
208
158
 
209
- #### settings.svelte
159
+ > [!WARNING]
160
+ > The TypeScript parser uses a singleton internally, meaning it only respects the options provided during its initial initialization.
161
+ > 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.
162
+ > For more context, see [typescript-eslint/typescript-eslint#6778](https://github.com/typescript-eslint/typescript-eslint/issues/6778).
163
+
164
+ ### Available Configurations
165
+
166
+ This plugin provides the following configurations:
210
167
 
211
- You can change the behavior of this plugin with some settings.
168
+ - **`eslintPluginSvelte.configs.base`** ... Enables correct Svelte parsing.
169
+ - **`eslintPluginSvelte.configs.recommended`** ... Includes `base` configuration, plus rules to prevent errors or unintended behavior.
170
+ - **`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).
171
+ - **`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.
212
172
 
213
- e.g.
173
+ For more details, see [the rule list](https://sveltejs.github.io/eslint-plugin-svelte/rules/) to explore the rules provided by this plugin.
174
+
175
+ ### settings.svelte
176
+
177
+ You can customize the behavior of this plugin using specific settings.
214
178
 
215
179
  ```js
180
+ // eslint.config.js
216
181
  export default [
217
182
  // ...
218
183
  {
219
184
  settings: {
220
185
  svelte: {
186
+ // Specifies an array of rules to ignore reports within the template.
187
+ // For example, use this to disable rules in the template that may produce unavoidable false positives.
221
188
  ignoreWarnings: [
222
189
  '@typescript-eslint/no-unsafe-assignment',
223
190
  '@typescript-eslint/no-unsafe-member-access'
224
191
  ],
192
+ // Specifies options for Svelte compilation.
193
+ // This affects rules that rely on Svelte compilation,
194
+ // such as svelte/valid-compile and svelte/no-unused-svelte-ignore.
195
+ // Note that this setting does not impact ESLint’s custom parser.
225
196
  compileOptions: {
197
+ // Specifies options related to PostCSS. You can disable the PostCSS processing by setting it to false.
226
198
  postcss: {
199
+ // Specifies the path to the directory that contains the PostCSS configuration.
227
200
  configFilePath: './path/to/my/postcss.config.js'
228
201
  }
229
202
  },
203
+ // Even if settings.svelte.kit is not specified, the rules will attempt to load information from svelte.config.js.
204
+ // However, if the default behavior does not work as expected, you should specify settings.svelte.kit explicitly.
205
+ // If you are using SvelteKit with a non-default configuration, you need to set the following options.
206
+ // The schema is a subset of SvelteKit’s configuration, so refer to the SvelteKit documentation for more details.
207
+ // https://svelte.dev/docs/kit/configuration
230
208
  kit: {
231
209
  files: {
232
210
  routes: 'src/routes'
@@ -239,59 +217,11 @@ export default [
239
217
  ];
240
218
  ```
241
219
 
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
287
-
288
- ### Visual Studio Code
220
+ ## Editor Integrations
289
221
 
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**:
222
+ **Visual Studio Code**
223
+ Install [dbaeumer.vscode-eslint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint).
224
+ Configure `.svelte` files in `.vscode/settings.json`:
295
225
 
296
226
  ```json
297
227
  {
@@ -302,7 +232,17 @@ Example **.vscode/settings.json**:
302
232
  <!--USAGE_GUIDE_END-->
303
233
  <!--USAGE_SECTION_END-->
304
234
 
305
- ## :white_check_mark: Rules
235
+ ## Migration Guide
236
+
237
+ 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/).
238
+
239
+ ## Versioning Policy
240
+
241
+ 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.
242
+
243
+ <!--DOCS_IGNORE_END-->
244
+
245
+ ## Rules
306
246
 
307
247
  <!-- prettier-ignore-start -->
308
248
  <!--RULES_SECTION_START-->
@@ -319,25 +259,23 @@ These rules relate to possible syntax or logic errors in Svelte code:
319
259
 
320
260
  | Rule ID | Description | |
321
261
  |:--------|:------------|:---|
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 | |
262
+ | [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: |
263
+ | [svelte/no-dom-manipulating](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-dom-manipulating/) | disallow DOM manipulating | :star: |
325
264
  | [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 | |
265
+ | [svelte/no-dupe-on-directives](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-dupe-on-directives/) | disallow duplicate `on:` directives | :star: |
327
266
  | [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. | |
267
+ | [svelte/no-dupe-use-directives](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-dupe-use-directives/) | disallow duplicate `use:` directives | :star: |
331
268
  | [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
269
  | [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 | |
270
+ | [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: |
271
+ | [svelte/no-reactive-reassign](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-reactive-reassign/) | disallow reassigning reactive values | :star: |
334
272
  | [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 | |
273
+ | [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
274
  | [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
275
  | [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. | |
276
+ | [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: |
277
+ | [svelte/valid-compile](https://sveltejs.github.io/eslint-plugin-svelte/rules/valid-compile/) | disallow warnings when compiling. | |
278
+ | [svelte/valid-style-parse](https://sveltejs.github.io/eslint-plugin-svelte/rules/valid-style-parse/) | require valid style element parsing | |
341
279
 
342
280
  ## Security Vulnerability
343
281
 
@@ -358,23 +296,23 @@ These rules relate to better ways of doing things to help you avoid problems:
358
296
  | [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
297
  | [svelte/no-at-debug-tags](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-at-debug-tags/) | disallow the use of `{@debug}` | :star: |
360
298
  | [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. | |
299
+ | [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
300
  | [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. | |
301
+ | [svelte/no-inspect](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-inspect/) | Warns against the use of `$inspect` directive | :star: |
302
+ | [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: |
303
+ | [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: |
304
+ | [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
305
  | [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
306
  | [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-children-snippet](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-useless-children-snippet/) | disallow explicit children snippet where it's not needed | |
370
- | [svelte/no-useless-mustaches](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-useless-mustaches/) | disallow unnecessary mustache interpolations | :wrench: |
307
+ | [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: |
308
+ | [svelte/no-useless-mustaches](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-useless-mustaches/) | disallow unnecessary mustache interpolations | :star::wrench: |
371
309
  | [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: |
372
310
  | [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: |
373
- | [svelte/require-each-key](https://sveltejs.github.io/eslint-plugin-svelte/rules/require-each-key/) | require keyed `{#each}` block | |
374
- | [svelte/require-event-dispatcher-types](https://sveltejs.github.io/eslint-plugin-svelte/rules/require-event-dispatcher-types/) | require type parameters for `createEventDispatcher` | |
311
+ | [svelte/require-each-key](https://sveltejs.github.io/eslint-plugin-svelte/rules/require-each-key/) | require keyed `{#each}` block | :star: |
312
+ | [svelte/require-event-dispatcher-types](https://sveltejs.github.io/eslint-plugin-svelte/rules/require-event-dispatcher-types/) | require type parameters for `createEventDispatcher` | :star: |
375
313
  | [svelte/require-optimized-style-attribute](https://sveltejs.github.io/eslint-plugin-svelte/rules/require-optimized-style-attribute/) | require style attributes that can be optimized | |
376
314
  | [svelte/require-stores-init](https://sveltejs.github.io/eslint-plugin-svelte/rules/require-stores-init/) | require initial value in store | |
377
- | [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 | |
315
+ | [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: |
378
316
 
379
317
  ## Stylistic Issues
380
318
 
@@ -382,6 +320,7 @@ These rules relate to style guidelines, and are therefore quite subjective:
382
320
 
383
321
  | Rule ID | Description | |
384
322
  |:--------|:------------|:---|
323
+ | [svelte/consistent-selector-style](https://sveltejs.github.io/eslint-plugin-svelte/rules/consistent-selector-style/) | enforce a consistent style for CSS selectors | |
385
324
  | [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 | |
386
325
  | [svelte/first-attribute-linebreak](https://sveltejs.github.io/eslint-plugin-svelte/rules/first-attribute-linebreak/) | enforce the location of first attribute | :wrench: |
387
326
  | [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: |
@@ -416,7 +355,9 @@ These rules relate to SvelteKit and its best Practices.
416
355
 
417
356
  | Rule ID | Description | |
418
357
  |:--------|:------------|:---|
358
+ | [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: |
419
359
  | [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 | |
360
+ | [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: |
420
361
 
421
362
  ## Experimental
422
363
 
@@ -444,6 +385,7 @@ These rules relate to this plugin works:
444
385
  | Rule ID | Replaced by |
445
386
  |:--------|:------------|
446
387
  | [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. |
388
+ | [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. |
447
389
  | [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/) |
448
390
 
449
391
  <!--RULES_TABLE_END-->
@@ -452,23 +394,13 @@ These rules relate to this plugin works:
452
394
 
453
395
  <!--DOCS_IGNORE_START-->
454
396
 
455
- ## :beers: Contributing
456
-
457
- Welcome contributing!
458
-
459
- Please use GitHub's Issues/PRs.
397
+ ## Contributing
460
398
 
461
- See also [CONTRIBUTING.md](./CONTRIBUTING.md)
462
-
463
- ### Working With Rules
464
-
465
- 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.
399
+ Contributions are welcome! Please open an issue or submit a PR. For more details, see [CONTRIBUTING.md](./CONTRIBUTING.md).
400
+ Refer to [svelte-eslint-parser](https://github.com/sveltejs/svelte-eslint-parser) for AST details.
466
401
 
467
402
  <!--DOCS_IGNORE_END-->
468
403
 
469
- ## :lock: License
470
-
471
- See the [LICENSE](LICENSE) file for license rights and limitations (MIT).
404
+ ## License
472
405
 
473
- [svelte]: https://svelte.dev/
474
- [eslint]: https://eslint.org/
406
+ 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.9";
17
+ version: "3.0.1";
18
18
  };
19
19
  export declare const processors: {
20
20
  '.svelte': typeof processor;
package/lib/meta.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  export declare const name = "eslint-plugin-svelte";
2
- export declare const version = "3.0.0-next.9";
2
+ export declare const version = "3.0.1";
package/lib/meta.js CHANGED
@@ -2,4 +2,4 @@
2
2
  // This file has been automatically generated,
3
3
  // in order to update its content execute "pnpm run update"
4
4
  export const name = 'eslint-plugin-svelte';
5
- export const version = '3.0.0-next.9';
5
+ export const version = '3.0.1';