generated from storybookjs/addon-kit
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Use
prettier
to format Story children raw source slices
- Loading branch information
Showing
7 changed files
with
91 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import type { Identifier } from 'estree'; | ||
|
||
import { extractMetaPropertiesNodes } from '../../extract/meta-properties.js'; | ||
import type { SvelteASTNodes } from '../../extract/svelte/nodes.js'; | ||
|
||
interface Params { | ||
svelteASTNodes: SvelteASTNodes; | ||
filename?: string; | ||
} | ||
|
||
export function getDefineMetaComponentValue(params: Params): Identifier | undefined { | ||
const { svelteASTNodes, filename } = params; | ||
const { component } = extractMetaPropertiesNodes({ | ||
nodes: svelteASTNodes, | ||
properties: ['component'], | ||
}); | ||
|
||
if (!component) { | ||
return; | ||
} | ||
|
||
const { value } = component; | ||
|
||
if (value.type !== 'Identifier') { | ||
throw new Error( | ||
`Invalid schema. 'defineMeta's property 'component' value should be an identifier to Svelte's component import specifier. Stories file: ${filename}` | ||
); | ||
} | ||
|
||
return value; | ||
} |