-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add RegExp option for hierarchySeparator #1545
Conversation
addons/options/src/preview/index.js
Outdated
@@ -7,14 +7,26 @@ export function init() { | |||
// NOTE nothing to do here | |||
} | |||
|
|||
function regExpStringify(exp) { | |||
if (!exp) return null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if(typeof exp === 'string') return exp;
if(Object.prototype.toString.call(exp) === '[object RegExp]') return exp.source;
return null;
Codecov Report
@@ Coverage Diff @@
## master #1545 +/- ##
==========================================
- Coverage 20.53% 20.52% -0.01%
==========================================
Files 241 241
Lines 5220 5222 +2
Branches 644 641 -3
==========================================
Hits 1072 1072
+ Misses 3660 3654 -6
- Partials 488 496 +8
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @joscha
@@ -266,7 +266,7 @@ storiesOf('component.Button', module) | |||
|
|||
// Atomic | |||
|
|||
storiesOf('Cells¯\\_(ツ)_/¯Molecules.Atoms/simple', module) | |||
storiesOf('Cells/Molecules.Atoms/simple', module) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😢 ok..
const channel = addons.getChannel(); | ||
if (!channel) { | ||
throw new Error( | ||
'Failed to find addon channel. This may be due to https://github.com/storybooks/storybook/issues/1192.' | ||
); | ||
} | ||
const options = { | ||
...newOptions, | ||
hierarchySeparator: regExpStringify(newOptions.hierarchySeparator), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what will happen if null will be passed here ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it will be ignored
so we can merge it if nobody objects? |
Issue: #151
hierarchySeparator
option allows only a string with RegExpWhat I did
hierarchySeparator
could take aRegular Expression
directly (as well as strings)How to test
run
cra-kitchen-sink