Skip to content

Commit

Permalink
fix: adjust store regex (#441)
Browse files Browse the repository at this point in the history
Don't match in the case of $° or $§ or $\, these are not store variables

Fixes #433
  • Loading branch information
dummdidumm committed Dec 16, 2021
1 parent f6ef334 commit 85a86c8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/transformers/typescript.ts
Expand Up @@ -152,7 +152,8 @@ function injectVarsToCode({
// TODO investigate if it's possible to achieve this with a
// TS transformer (previous attemps have failed)
const codestores = Array.from(
contentForCodestores.match(/\$[^\s();:,[\]{}.?!+-=*/~|&%<>^`"']+/g) || [],
contentForCodestores.match(/\$[^\s();:,[\]{}.?!+-=*/\\~|&%<>^`"'°§]+/g) ||
[],
(name) => name.slice(1),
).filter((name) => !JAVASCRIPT_RESERVED_KEYWORD_SET.has(name));

Expand Down
5 changes: 5 additions & 0 deletions test/fixtures/TypeScriptImports.svelte
Expand Up @@ -39,6 +39,11 @@
}
$storeScriptOnly;
$storeModuleScriptOnly;
// These shouldn't count as store values:
// $\\; $$; $§; $%; $°; $(; $); $[; $]; $<; $>; $ ; $^; $`; $"; $';
// These don't need to be tested explicitly, the test will throw and error
// at the TypeScript parsing stage if they are part of the false positives
</script>

<style>
Expand Down

0 comments on commit 85a86c8

Please sign in to comment.