-
Notifications
You must be signed in to change notification settings - Fork 118
allow object passed to description prop #87
Conversation
ericf
left a comment
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.
@mattkime this is great, I'm glad it was such a simple change! Thanks for adding the test too. I added a few minor comments about formatting stuff. If you don't have a change to make these changes, let me know and I can just make them.
scripts/build-fixtures.js
Outdated
| ['moduleSourceName', { | ||
| moduleSourceName: 'react-i18n', | ||
| }], | ||
| 'descriptionsAsObjects' |
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.
Can you move this right after defineMessages so the fixtures remain in alpha order?
src/index.js
Outdated
|
|
||
| // Always trim the Message Descriptor values. | ||
| return evaluatePath(path).trim(); | ||
| let descriptorValue = evaluatePath(path); |
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.
const
src/index.js
Outdated
| return evaluatePath(path).trim(); | ||
| let descriptorValue = evaluatePath(path); | ||
|
|
||
| if( typeof descriptorValue === 'string' ){ |
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.
Update formatting to match rest of file:
if (condition) {
src/index.js
Outdated
| let descriptorValue = evaluatePath(path); | ||
|
|
||
| if( typeof descriptorValue === 'string' ){ | ||
| descriptorValue = descriptorValue.trim(); |
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.
This can be an early return:
if (typeof descriptorValue === 'string') {
return descriptorValue.trim();
}
Follow up to #85 (comment)
Allows objects to be passed to the
descriptionprop.Only code change required was to check the description type before
.trim()Added test to verify this works.