Skip to content

Commit

Permalink
fix invalid name of snippet identifier transformation
Browse files Browse the repository at this point in the history
xeho91 committed Jul 20, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 89bd7f1 commit 50898d5
Showing 3 changed files with 12 additions and 4 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -65,10 +65,11 @@
"@storybook/node-logger": "^8.0.0",
"@storybook/types": "^8.0.0",
"dedent": "^1.5.3",
"es-toolkit": "^1.13.1",
"esrap": "^1.2.2",
"lodash-es": "^4.17.21",
"svelte-ast-print": "0.2.3",
"magic-string": "^0.30.10",
"svelte-ast-print": "0.2.3",
"zimmerframe": "^1.1.2"
},
"devDependencies": {
8 changes: 8 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions src/compiler/pre-transform/codemods/legacy-story.ts
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ import type {
LetDirective,
SnippetBlock,
} from 'svelte/compiler';
import { camelCase } from 'es-toolkit/string';

import {
createASTAttribute,
@@ -229,9 +230,7 @@ function templateToChildren(attribute: Attribute, filename?: string): Attribute
createASTExpressionTag({
type: 'Identifier',
name:
// NOTE: Transform name to be snakeCase or valid JavaScript syntax for naming variables
// TODO: change function name, because it does the same job?
storyNameToExportName(
camelCase(
value[0].type === 'Text'
? value[0].data
: ((value[0].expression as Literal).value as string)

0 comments on commit 50898d5

Please sign in to comment.