Repository: sveltejs/eslint-plugin-svelte
Pull request #1239 (2025-06-01 22:47:20)

fix(prefer-const): Use `additionalProperties` instead of `ignoreReadonly` to match the ESLint core rule option name
close: https://github.com/sveltejs/eslint-plugin-svelte/issues/1238

changeset-bot[bot]: ###  🦋  Changeset detected

Latest commit: 13c4adbe0c85db9c76d923f9b05ec69cf79a19ea

**The changes in this PR will be included in the next version bump.**

<details><summary>This PR includes changesets to release 1 package</summary>

  | Name                 | Type  |
| -------------------- | ----- |
| eslint-plugin-svelte | Patch |

</details>

Not sure what this means? [Click here  to learn what changesets are](https://github.com/changesets/changesets/blob/main/docs/adding-a-changeset.md).

[Click here if you're a maintainer who wants to add another changeset to this PR](https://github.com/sveltejs/eslint-plugin-svelte/new/fix/1238?filename=.changeset/fair-islands-count.md&value=---%0A%22eslint-plugin-svelte%22%3A%20patch%0A---%0A%0Afix(prefer-const)%3A%20allow%20ESLint%20core%20rule's%20properties%0A)



Patch:
diff --git a/.changeset/good-carrots-notice.md b/.changeset/good-carrots-notice.md
new file mode 100644
index 0000000..6a7f030
--- /dev/null
+++ b/.changeset/good-carrots-notice.md
@@ -0,0 +1,5 @@
+---
+'eslint-plugin-svelte': patch
+---
+
+fix(prefer-const): Use `additionalProperties` instead of `ignoreReadonly` to match the ESLint core rule option name.
diff --git a/docs/rules/prefer-const.md b/docs/rules/prefer-const.md
index 8029ea8..f158d47 100644
--- a/docs/rules/prefer-const.md
+++ b/docs/rules/prefer-const.md
@@ -46,7 +46,7 @@ This rule reports the same as the base ESLint `prefer-const` rule, except that i
     "error",
     {
       "destructuring": "any",
-      "ignoreReadonly": true,
+      "additionalProperties": false,
       "excludedRunes": ["$props", "$derived"]
     }
   ]
@@ -54,14 +54,14 @@ This rule reports the same as the base ESLint `prefer-const` rule, except that i
 ```
 
 - `destructuring`: The kind of the way to address variables in destructuring. There are 2 values:
-  - `any` (default): if any variables in destructuring should be const, this rule warns for those variables.
-  - `all`: if all variables in destructuring should be const, this rule warns the variables. Otherwise, ignores them.
-- `ignoreReadonly`: If `true`, this rule will ignore variables that are read between the declaration and the _first_ assignment.
+  - `any` (default) - If any variables in destructuring should be const, this rule warns for those variables.
+  - `all`: If all variables in destructuring should be const, this rule warns the variables. Otherwise, ignores them.
+- `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`.
 - `excludedRunes`: An array of rune names that should be ignored. Even if a rune is declared with `let`, it will still be ignored.
 
 ## :books: Further Reading
 
-- See [ESLint `prefer-const` rule](https://eslint.org/docs/latest/rules/prefer-const) for more information about the base rule.
+- See [ESLint prefer-const rule](https://eslint.org/docs/latest/rules/prefer-const) for more information about the base rule.
 
 ## :rocket: Version
 
diff --git a/packages/eslint-plugin-svelte/src/rule-types.ts b/packages/eslint-plugin-svelte/src/rule-types.ts
index 2fd9c7d..8165727 100644
--- a/packages/eslint-plugin-svelte/src/rule-types.ts
+++ b/packages/eslint-plugin-svelte/src/rule-types.ts
@@ -573,6 +573,7 @@ type SveltePreferConst = []|[{
   destructuring?: ("any" | "all")
   ignoreReadBeforeAssign?: boolean
   excludedRunes?: string[]
+  [k: string]: unknown | undefined
 }]
 // ----- svelte/require-event-prefix -----
 type SvelteRequireEventPrefix = []|[{
diff --git a/packages/eslint-plugin-svelte/src/rules/prefer-const.ts b/packages/eslint-plugin-svelte/src/rules/prefer-const.ts
index 842bbc9..e28765b 100644
--- a/packages/eslint-plugin-svelte/src/rules/prefer-const.ts
+++ b/packages/eslint-plugin-svelte/src/rules/prefer-const.ts
@@ -68,7 +68,8 @@ export default createRule('prefer-const', {
 						}
 					}
 				},
-				additionalProperties: false
+				// Allow ESLint core rule properties in case new options are added in the future.
+				additionalProperties: true
 			}
 		]
 	},


Test patch:
diff --git a/packages/eslint-plugin-svelte/tests/fixtures/rules/prefer-const/valid/1238/_config.json b/packages/eslint-plugin-svelte/tests/fixtures/rules/prefer-const/valid/1238/_config.json
new file mode 100644
index 0000000..88200a8
--- /dev/null
+++ b/packages/eslint-plugin-svelte/tests/fixtures/rules/prefer-const/valid/1238/_config.json
@@ -0,0 +1,8 @@
+{
+	"options": [
+		{
+			"destructuring": "all",
+			"additionalProperties": true
+		}
+	]
+}
diff --git a/packages/eslint-plugin-svelte/tests/fixtures/rules/prefer-const/valid/1238/input.svelte b/packages/eslint-plugin-svelte/tests/fixtures/rules/prefer-const/valid/1238/input.svelte
new file mode 100644
index 0000000..190a180
--- /dev/null
+++ b/packages/eslint-plugin-svelte/tests/fixtures/rules/prefer-const/valid/1238/input.svelte
@@ -0,0 +1,1 @@
+123