From 6d151ce44416bdc4270ea4c21ea891c0546d3315 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Wed, 29 Nov 2023 05:47:50 -0500 Subject: [PATCH] remove state-not-mutated warning, which is no longer valid --- .../src/compiler/phases/2-analyze/index.js | 18 ------------------ packages/svelte/src/compiler/warnings.js | 3 --- .../runes-state-rune-not-mutated/_config.js | 3 --- .../runes-state-rune-not-mutated/input.svelte | 10 ---------- .../runes-state-rune-not-mutated/warnings.json | 14 -------------- 5 files changed, 48 deletions(-) delete mode 100644 packages/svelte/tests/validator/samples/runes-state-rune-not-mutated/_config.js delete mode 100644 packages/svelte/tests/validator/samples/runes-state-rune-not-mutated/input.svelte delete mode 100644 packages/svelte/tests/validator/samples/runes-state-rune-not-mutated/warnings.json diff --git a/packages/svelte/src/compiler/phases/2-analyze/index.js b/packages/svelte/src/compiler/phases/2-analyze/index.js index 71295b7059..d8864268d3 100644 --- a/packages/svelte/src/compiler/phases/2-analyze/index.js +++ b/packages/svelte/src/compiler/phases/2-analyze/index.js @@ -215,15 +215,6 @@ export function analyze_module(ast, options) { merge(set_scope(scopes), validation_runes_js, runes_scope_js_tweaker) ); - // If we are in runes mode, then check for possible misuses of state runes - for (const [, scope] of scopes) { - for (const [name, binding] of scope.declarations) { - if (binding.kind === 'state' && !binding.mutated) { - warn(warnings, binding.node, [], 'state-not-mutated', name); - } - } - } - return { module: { ast, scope, scopes }, name: options.filename || 'module', @@ -376,15 +367,6 @@ export function analyze_component(root, options) { merge(set_scope(scopes), validation_runes, runes_scope_tweaker, common_visitors) ); } - - // If we are in runes mode, then check for possible misuses of state runes - for (const [, scope] of instance.scopes) { - for (const [name, binding] of scope.declarations) { - if (binding.kind === 'state' && !binding.mutated) { - warn(warnings, binding.node, [], 'state-not-mutated', name); - } - } - } } else { instance.scope.declare(b.id('$$props'), 'prop', 'synthetic'); instance.scope.declare(b.id('$$restProps'), 'rest_prop', 'synthetic'); diff --git a/packages/svelte/src/compiler/warnings.js b/packages/svelte/src/compiler/warnings.js index 6c38b1e052..c2a9a2ad98 100644 --- a/packages/svelte/src/compiler/warnings.js +++ b/packages/svelte/src/compiler/warnings.js @@ -22,9 +22,6 @@ const runes = { `It looks like you're using the $${name} rune, but there is a local binding called ${name}. ` + `Referencing a local variable with a $ prefix will create a store subscription. Please rename ${name} to avoid the ambiguity.`, /** @param {string} name */ - 'state-not-mutated': (name) => - `${name} is declared with $state(...) but is never updated. Did you mean to create a function that changes its value?`, - /** @param {string} name */ 'non-state-reference': (name) => `${name} is updated, but is not declared with $state(...). Changing its value will not correctly trigger updates.` }; diff --git a/packages/svelte/tests/validator/samples/runes-state-rune-not-mutated/_config.js b/packages/svelte/tests/validator/samples/runes-state-rune-not-mutated/_config.js deleted file mode 100644 index f47bee71df..0000000000 --- a/packages/svelte/tests/validator/samples/runes-state-rune-not-mutated/_config.js +++ /dev/null @@ -1,3 +0,0 @@ -import { test } from '../../test'; - -export default test({}); diff --git a/packages/svelte/tests/validator/samples/runes-state-rune-not-mutated/input.svelte b/packages/svelte/tests/validator/samples/runes-state-rune-not-mutated/input.svelte deleted file mode 100644 index eb4e709f4d..0000000000 --- a/packages/svelte/tests/validator/samples/runes-state-rune-not-mutated/input.svelte +++ /dev/null @@ -1,10 +0,0 @@ - diff --git a/packages/svelte/tests/validator/samples/runes-state-rune-not-mutated/warnings.json b/packages/svelte/tests/validator/samples/runes-state-rune-not-mutated/warnings.json deleted file mode 100644 index 5d2b639c8d..0000000000 --- a/packages/svelte/tests/validator/samples/runes-state-rune-not-mutated/warnings.json +++ /dev/null @@ -1,14 +0,0 @@ -[ - { - "code": "state-not-mutated", - "end": { - "column": 11, - "line": 3 - }, - "message": "count is declared with $state(...) but is never updated. Did you mean to create a function that changes its value?", - "start": { - "column": 6, - "line": 3 - } - } -]