Skip to content

Commit

Permalink
Error out when story named export has __. Reserved for internal uses. (
Browse files Browse the repository at this point in the history
  • Loading branch information
tajo authored Aug 4, 2022
1 parent 46a6b97 commit e9c2318
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/polite-schools-sip.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ladle/react": patch
---

Error out when story named export has \_\_. We use it to encode sublevels internally and this would break the sidebar navigation.
6 changes: 6 additions & 0 deletions packages/ladle/lib/cli/vite-plugin/parse/get-named-exports.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ const getNamedExports = (
);
}

if (namedExport.includes("__")) {
throw new Error(
`Story named ${namedExport} can't contain "__". It's reserved for internal encoding. Please rename this export.`,
);
}

let storyNamespace = fileId;
if (exportDefaultProps && exportDefaultProps.title) {
storyNamespace = titleToFileId(exportDefaultProps.title);
Expand Down

0 comments on commit e9c2318

Please sign in to comment.