From f6ba6f234f6671cc7aa9db966a0ff30fc4f2e5dd Mon Sep 17 00:00:00 2001 From: David A Kondrad Date: Tue, 10 Dec 2019 13:09:59 -0500 Subject: [PATCH 1/3] compiler: tag auto-subscribe stores in vars as referenced Fixes unused variable warnings thrown by ESLint when using auto-subscribe stores in templates. --- src/compiler/compile/Component.ts | 6 +++++- test/vars/samples/store-referenced/_config.js | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/compiler/compile/Component.ts b/src/compiler/compile/Component.ts index 4402a4a94749..aee214602dc7 100644 --- a/src/compiler/compile/Component.ts +++ b/src/compiler/compile/Component.ts @@ -203,7 +203,11 @@ export default class Component { const subscribable_name = name.slice(1); const variable = this.var_lookup.get(subscribable_name); - if (variable) variable.subscribable = true; + if (variable) + { + variable.referenced = true; + variable.subscribable = true; + } } else { this.used_names.add(name); } diff --git a/test/vars/samples/store-referenced/_config.js b/test/vars/samples/store-referenced/_config.js index cb92b67ea473..bac35d1dbabf 100644 --- a/test/vars/samples/store-referenced/_config.js +++ b/test/vars/samples/store-referenced/_config.js @@ -8,7 +8,7 @@ export default { module: false, mutated: false, reassigned: false, - referenced: false, + referenced: true, referenced_from_script: false, writable: true }, From 298a1e387708e2f12b5786a9f25530b79731a596 Mon Sep 17 00:00:00 2001 From: David A Kondrad Date: Tue, 10 Dec 2019 15:43:14 -0500 Subject: [PATCH 2/3] tests: component-store-access-invalidate: add foo to context Update test case to put it back to the way it was before bitmask commits. Note the order of names is different; however, the code does the right thing. --- test/js/samples/component-store-access-invalidate/expected.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/js/samples/component-store-access-invalidate/expected.js b/test/js/samples/component-store-access-invalidate/expected.js index 151bd6ed0e87..4c7bfd7009c3 100644 --- a/test/js/samples/component-store-access-invalidate/expected.js +++ b/test/js/samples/component-store-access-invalidate/expected.js @@ -43,7 +43,7 @@ function instance($$self, $$props, $$invalidate) { let $foo; const foo = writable(0); component_subscribe($$self, foo, value => $$invalidate(0, $foo = value)); - return [$foo]; + return [$foo, foo]; } class Component extends SvelteComponent { From 8076170cabb493fa9ce5791fa4e5323628a2a1e8 Mon Sep 17 00:00:00 2001 From: David A Kondrad Date: Tue, 10 Dec 2019 15:51:35 -0500 Subject: [PATCH 3/3] cosmetic: fix ws --- src/compiler/compile/Component.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/compiler/compile/Component.ts b/src/compiler/compile/Component.ts index aee214602dc7..2c7fb64b676b 100644 --- a/src/compiler/compile/Component.ts +++ b/src/compiler/compile/Component.ts @@ -203,8 +203,7 @@ export default class Component { const subscribable_name = name.slice(1); const variable = this.var_lookup.get(subscribable_name); - if (variable) - { + if (variable) { variable.referenced = true; variable.subscribable = true; }