Skip to content

Commit a3d4224

Browse files
authored
fix(prefer-const): Use additionalProperties instead of ignoreReadonly to match the ESLint core rule option name (#1239)
1 parent d8e0724 commit a3d4224

File tree

6 files changed

+22
-6
lines changed

6 files changed

+22
-6
lines changed

.changeset/good-carrots-notice.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'eslint-plugin-svelte': patch
3+
---
4+
5+
fix(prefer-const): Use `additionalProperties` instead of `ignoreReadonly` to match the ESLint core rule option name.

docs/rules/prefer-const.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,22 +46,22 @@ This rule reports the same as the base ESLint `prefer-const` rule, except that i
4646
"error",
4747
{
4848
"destructuring": "any",
49-
"ignoreReadonly": true,
49+
"additionalProperties": false,
5050
"excludedRunes": ["$props", "$derived"]
5151
}
5252
]
5353
}
5454
```
5555

5656
- `destructuring`: The kind of the way to address variables in destructuring. There are 2 values:
57-
- `any` (default): if any variables in destructuring should be const, this rule warns for those variables.
58-
- `all`: if all variables in destructuring should be const, this rule warns the variables. Otherwise, ignores them.
59-
- `ignoreReadonly`: If `true`, this rule will ignore variables that are read between the declaration and the _first_ assignment.
57+
- `any` (default) - If any variables in destructuring should be const, this rule warns for those variables.
58+
- `all`: If all variables in destructuring should be const, this rule warns the variables. Otherwise, ignores them.
59+
- `ignoreReadBeforeAssign`: This is an option to avoid conflicting with `no-use-before-define` rule (without "nofunc" option). If `true` is specified, this rule will ignore variables that are read between the declaration and the first assignment. Default is `false`.
6060
- `excludedRunes`: An array of rune names that should be ignored. Even if a rune is declared with `let`, it will still be ignored.
6161

6262
## :books: Further Reading
6363

64-
- See [ESLint `prefer-const` rule](https://eslint.org/docs/latest/rules/prefer-const) for more information about the base rule.
64+
- See [ESLint prefer-const rule](https://eslint.org/docs/latest/rules/prefer-const) for more information about the base rule.
6565

6666
## :rocket: Version
6767

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,7 @@ type SveltePreferConst = []|[{
573573
destructuring?: ("any" | "all")
574574
ignoreReadBeforeAssign?: boolean
575575
excludedRunes?: string[]
576+
[k: string]: unknown | undefined
576577
}]
577578
// ----- svelte/require-event-prefix -----
578579
type SvelteRequireEventPrefix = []|[{

packages/eslint-plugin-svelte/src/rules/prefer-const.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ export default createRule('prefer-const', {
6868
}
6969
}
7070
},
71-
additionalProperties: false
71+
// Allow ESLint core rule properties in case new options are added in the future.
72+
additionalProperties: true
7273
}
7374
]
7475
},
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"options": [
3+
{
4+
"destructuring": "all",
5+
"additionalProperties": true
6+
}
7+
]
8+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
123

0 commit comments

Comments
 (0)