Skip to content

Commit 86ca1c8

Browse files
committed
fix(prefer-const): remove ESLintCodeBlock
1 parent 99852a9 commit 86ca1c8

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@ These rules relate to better ways of doing things to help you avoid problems:
367367
| [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 | |
368368
| [svelte/no-unused-svelte-ignore](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-unused-svelte-ignore/) | disallow unused svelte-ignore comments | :star: |
369369
| [svelte/no-useless-mustaches](https://sveltejs.github.io/eslint-plugin-svelte/rules/no-useless-mustaches/) | disallow unnecessary mustache interpolations | :wrench: |
370+
| [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: |
370371
| [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: |
371372
| [svelte/require-each-key](https://sveltejs.github.io/eslint-plugin-svelte/rules/require-each-key/) | require keyed `{#each}` block | |
372373
| [svelte/require-event-dispatcher-types](https://sveltejs.github.io/eslint-plugin-svelte/rules/require-event-dispatcher-types/) | require type parameters for `createEventDispatcher` | |

docs/rules.md

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ These rules relate to better ways of doing things to help you avoid problems:
6464
| [svelte/no-unused-class-name](./rules/no-unused-class-name.md) | disallow the use of a class in the template without a corresponding style | |
6565
| [svelte/no-unused-svelte-ignore](./rules/no-unused-svelte-ignore.md) | disallow unused svelte-ignore comments | :star: |
6666
| [svelte/no-useless-mustaches](./rules/no-useless-mustaches.md) | disallow unnecessary mustache interpolations | :wrench: |
67+
| [svelte/prefer-const](./rules/prefer-const.md) | Require `const` declarations for variables that are never reassigned after declared | :wrench: |
6768
| [svelte/prefer-destructured-store-props](./rules/prefer-destructured-store-props.md) | destructure values from object stores for better change tracking & fewer redraws | :bulb: |
6869
| [svelte/require-each-key](./rules/require-each-key.md) | require keyed `{#each}` block | |
6970
| [svelte/require-event-dispatcher-types](./rules/require-event-dispatcher-types.md) | require type parameters for `createEventDispatcher` | |

docs/rules/prefer-const.md

-4
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ description: 'Require `const` declarations for variables that are never reassign
1616

1717
This rule reports the same as the base ESLint `prefer-const` rule, except that ignores Svelte reactive values such as `$state`, `$derived` and `$props`. If this rule is active, make sure to disable the base `prefer-const` rule, as it will conflict with this rule.
1818

19-
<ESLintCodeBlock fix>
20-
2119
<!--eslint-skip-->
2220

2321
```svelte
@@ -34,8 +32,6 @@ This rule reports the same as the base ESLint `prefer-const` rule, except that i
3432
</script>
3533
```
3634

37-
</ESLintCodeBlock>
38-
3935
## :wrench: Options
4036

4137
```json

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

+10
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,11 @@ export interface RuleOptions {
264264
* @see https://sveltejs.github.io/eslint-plugin-svelte/rules/prefer-class-directive/
265265
*/
266266
'svelte/prefer-class-directive'?: Linter.RuleEntry<SveltePreferClassDirective>
267+
/**
268+
* Require `const` declarations for variables that are never reassigned after declared
269+
* @see https://sveltejs.github.io/eslint-plugin-svelte/rules/prefer-const/
270+
*/
271+
'svelte/prefer-const'?: Linter.RuleEntry<SveltePreferConst>
267272
/**
268273
* destructure values from object stores for better change tracking & fewer redraws
269274
* @see https://sveltejs.github.io/eslint-plugin-svelte/rules/prefer-destructured-store-props/
@@ -485,6 +490,11 @@ type SvelteNoUselessMustaches = []|[{
485490
type SveltePreferClassDirective = []|[{
486491
prefer?: ("always" | "empty")
487492
}]
493+
// ----- svelte/prefer-const -----
494+
type SveltePreferConst = []|[{
495+
destructuring?: ("any" | "all")
496+
ignoreReadBeforeAssign?: boolean
497+
}]
488498
// ----- svelte/shorthand-attribute -----
489499
type SvelteShorthandAttribute = []|[{
490500
prefer?: ("always" | "never")

0 commit comments

Comments
 (0)