Skip to content

Commit 7596287

Browse files
authoredJan 16, 2025
breaking: deprecate the svelte/no-dynamic-slot-name rule (#1011)
1 parent 21989c1 commit 7596287

File tree

11 files changed

+38
-31
lines changed

11 files changed

+38
-31
lines changed
 

‎.changeset/real-birds-move.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'eslint-plugin-svelte': major
3+
---
4+
5+
breaking: deprecate the `svelte/no-dynamic-slot-name` rule

‎README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,6 @@ These rules relate to possible syntax or logic errors in Svelte code:
325325
| [svelte/no-dupe-on-directives](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-dupe-on-directives/) | disallow duplicate `on:` directives | |
326326
| [svelte/no-dupe-style-properties](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-dupe-style-properties/) | disallow duplicate style properties | :star: |
327327
| [svelte/no-dupe-use-directives](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-dupe-use-directives/) | disallow duplicate `use:` directives | |
328-
| [svelte/no-dynamic-slot-name](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-dynamic-slot-name/) | disallow dynamic slot name | :star::wrench: |
329328
| [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: |
330329
| [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: |
331330
| [svelte/no-raw-special-elements](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-raw-special-elements/) | Checks for invalid raw HTML elements | :wrench: |
@@ -445,6 +444,7 @@ These rules relate to this plugin works:
445444
| Rule ID | Replaced by |
446445
|:--------|:------------|
447446
| [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. |
447+
| [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. |
448448
| [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/) |
449449

450450
<!--RULES_TABLE_END-->

‎docs/rules.md

+19-19
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,24 @@ sidebarDepth: 0
1414

1515
These rules relate to possible syntax or logic errors in Svelte code:
1616

17-
| Rule ID | Description | |
18-
| :----------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------- | :------------- |
19-
| [svelte/infinite-reactive-loop](./rules/infinite-reactive-loop.md) | Svelte runtime prevents calling the same reactive statement twice in a microtask. But between different microtask, it doesn't prevent. | |
20-
| [svelte/no-dom-manipulating](./rules/no-dom-manipulating.md) | disallow DOM manipulating | |
21-
| [svelte/no-dupe-else-if-blocks](./rules/no-dupe-else-if-blocks.md) | disallow duplicate conditions in `{#if}` / `{:else if}` chains | :star: |
22-
| [svelte/no-dupe-on-directives](./rules/no-dupe-on-directives.md) | disallow duplicate `on:` directives | |
23-
| [svelte/no-dupe-style-properties](./rules/no-dupe-style-properties.md) | disallow duplicate style properties | :star: |
24-
| [svelte/no-dupe-use-directives](./rules/no-dupe-use-directives.md) | disallow duplicate `use:` directives | |
25-
| [svelte/no-dynamic-slot-name](./rules/no-dynamic-slot-name.md) | disallow dynamic slot name | :star::wrench: |
26-
| [svelte/no-not-function-handler](./rules/no-not-function-handler.md) | disallow use of not function in event handler | :star: |
27-
| [svelte/no-object-in-text-mustaches](./rules/no-object-in-text-mustaches.md) | disallow objects in text mustache interpolation | :star: |
28-
| [svelte/no-raw-special-elements](./rules/no-raw-special-elements.md) | Checks for invalid raw HTML elements | :wrench: |
29-
| [svelte/no-reactive-reassign](./rules/no-reactive-reassign.md) | disallow reassigning reactive values | |
30-
| [svelte/no-shorthand-style-property-overrides](./rules/no-shorthand-style-property-overrides.md) | disallow shorthand style properties that override related longhand properties | :star: |
31-
| [svelte/no-store-async](./rules/no-store-async.md) | disallow using async/await inside svelte stores because it causes issues with the auto-unsubscribing features | |
32-
| [svelte/no-unknown-style-directive-property](./rules/no-unknown-style-directive-property.md) | disallow unknown `style:property` | :star: |
33-
| [svelte/require-store-callbacks-use-set-param](./rules/require-store-callbacks-use-set-param.md) | store callbacks must use `set` param | |
34-
| [svelte/require-store-reactive-access](./rules/require-store-reactive-access.md) | disallow to use of the store itself as an operand. Need to use $ prefix or get function. | :wrench: |
35-
| [svelte/valid-compile](./rules/valid-compile.md) | disallow warnings when compiling. | :star: |
17+
| Rule ID | Description | |
18+
| :----------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------- | :------- |
19+
| [svelte/infinite-reactive-loop](./rules/infinite-reactive-loop.md) | Svelte runtime prevents calling the same reactive statement twice in a microtask. But between different microtask, it doesn't prevent. | |
20+
| [svelte/no-dom-manipulating](./rules/no-dom-manipulating.md) | disallow DOM manipulating | |
21+
| [svelte/no-dupe-else-if-blocks](./rules/no-dupe-else-if-blocks.md) | disallow duplicate conditions in `{#if}` / `{:else if}` chains | :star: |
22+
| [svelte/no-dupe-on-directives](./rules/no-dupe-on-directives.md) | disallow duplicate `on:` directives | |
23+
| [svelte/no-dupe-style-properties](./rules/no-dupe-style-properties.md) | disallow duplicate style properties | :star: |
24+
| [svelte/no-dupe-use-directives](./rules/no-dupe-use-directives.md) | disallow duplicate `use:` directives | |
25+
| [svelte/no-not-function-handler](./rules/no-not-function-handler.md) | disallow use of not function in event handler | :star: |
26+
| [svelte/no-object-in-text-mustaches](./rules/no-object-in-text-mustaches.md) | disallow objects in text mustache interpolation | :star: |
27+
| [svelte/no-raw-special-elements](./rules/no-raw-special-elements.md) | Checks for invalid raw HTML elements | :wrench: |
28+
| [svelte/no-reactive-reassign](./rules/no-reactive-reassign.md) | disallow reassigning reactive values | |
29+
| [svelte/no-shorthand-style-property-overrides](./rules/no-shorthand-style-property-overrides.md) | disallow shorthand style properties that override related longhand properties | :star: |
30+
| [svelte/no-store-async](./rules/no-store-async.md) | disallow using async/await inside svelte stores because it causes issues with the auto-unsubscribing features | |
31+
| [svelte/no-unknown-style-directive-property](./rules/no-unknown-style-directive-property.md) | disallow unknown `style:property` | :star: |
32+
| [svelte/require-store-callbacks-use-set-param](./rules/require-store-callbacks-use-set-param.md) | store callbacks must use `set` param | |
33+
| [svelte/require-store-reactive-access](./rules/require-store-reactive-access.md) | disallow to use of the store itself as an operand. Need to use $ prefix or get function. | :wrench: |
34+
| [svelte/valid-compile](./rules/valid-compile.md) | disallow warnings when compiling. | :star: |
3635

3736
## Security Vulnerability
3837

@@ -142,4 +141,5 @@ These rules relate to this plugin works:
142141
| Rule ID | Replaced by |
143142
| :----------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------- |
144143
| [svelte/@typescript-eslint/no-unnecessary-condition](./rules/@typescript-eslint/no-unnecessary-condition.md) | This rule is no longer needed when using svelte-eslint-parser>=v0.19.0. |
144+
| [svelte/no-dynamic-slot-name](./rules/no-dynamic-slot-name.md) | Now Svelte compiler itself throws an compile error. |
145145
| [svelte/no-goto-without-base](./rules/no-goto-without-base.md) | [svelte/no-navigation-without-base](./rules/no-navigation-without-base.md) |

‎docs/rules/no-dynamic-slot-name.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ since: 'v0.14.0'
1010

1111
> disallow dynamic slot name
1212
13-
- :gear: This rule is included in `"plugin:svelte/recommended"`.
13+
- :warning: This rule was **deprecated**. Now Svelte compiler itself throws an compile error.
1414
- :wrench: The `--fix` option on the [command line](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) can automatically fix some of the problems reported by this rule.
1515

1616
## :book: Rule Details

‎packages/eslint-plugin-svelte/src/configs/flat/recommended.ts

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ const config: Linter.Config[] = [
1414
'svelte/no-at-html-tags': 'error',
1515
'svelte/no-dupe-else-if-blocks': 'error',
1616
'svelte/no-dupe-style-properties': 'error',
17-
'svelte/no-dynamic-slot-name': 'error',
1817
'svelte/no-inner-declarations': 'error',
1918
'svelte/no-not-function-handler': 'error',
2019
'svelte/no-object-in-text-mustaches': 'error',

‎packages/eslint-plugin-svelte/src/rule-types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ export interface RuleOptions {
137137
/**
138138
* disallow dynamic slot name
139139
* @see https://sveltejs.github.io/eslint-plugin-svelte/rules/no-dynamic-slot-name/
140+
* @deprecated
140141
*/
141142
'svelte/no-dynamic-slot-name'?: Linter.RuleEntry<[]>
142143
/**

‎packages/eslint-plugin-svelte/src/rules/no-dynamic-slot-name.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,19 @@ export default createRule('no-dynamic-slot-name', {
1313
docs: {
1414
description: 'disallow dynamic slot name',
1515
category: 'Possible Errors',
16-
recommended: true
16+
recommended: false
1717
},
1818
fixable: 'code',
19+
deprecated: true,
1920
schema: [],
2021
messages: {
2122
unexpected: '`<slot>` name cannot be dynamic.',
2223
requireValue: '`<slot>` name requires a value.'
2324
},
24-
type: 'problem'
25+
type: 'problem',
26+
replacedBy: {
27+
note: 'Now Svelte compiler itself throws an compile error.'
28+
}
2529
},
2630
create(context) {
2731
const sourceCode = getSourceCode(context);

‎packages/eslint-plugin-svelte/src/rules/valid-compile.ts

+1-7
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,7 @@ import { getSvelteCompileWarnings } from '../shared/svelte-compile-warns/index.j
44
import { getSourceCode } from '../utils/compat.js';
55
import type { Position } from 'svelte-eslint-parser/lib/ast/common.js';
66

7-
const ignores: string[] = [
8-
'missing-declaration',
9-
// Svelte v4
10-
'dynamic-slot-name',
11-
// Svelte v5
12-
'invalid-slot-name'
13-
] as const;
7+
const ignores: string[] = ['missing-declaration'] as const;
148

159
const unusedSelectorWarnings: string[] = ['css_unused_selector', 'css-unused-selector'] as const;
1610

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
- message: <slot> name cannot be dynamic(dynamic-slot-name)
2+
line: 5
3+
column: 7
4+
suggestions: null

0 commit comments

Comments
 (0)