This repository was archived by the owner on Jun 8, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +17
-8
lines changed
test/fixtures/descriptionsAsObjects Expand file tree Collapse file tree 3 files changed +17
-8
lines changed Original file line number Diff line number Diff line change @@ -54,9 +54,10 @@ export default function ({types: t}) {
54
54
// Always trim the Message Descriptor values.
55
55
const descriptorValue = evaluatePath ( path ) ;
56
56
57
- if ( typeof descriptorValue === 'string' ) {
57
+ if ( typeof descriptorValue === 'string' ) {
58
58
return descriptorValue . trim ( ) ;
59
59
}
60
+
60
61
return descriptorValue ;
61
62
}
62
63
@@ -135,10 +136,15 @@ export default function ({types: t}) {
135
136
}
136
137
}
137
138
138
- if ( opts . enforceDescriptions && ! description ) {
139
- throw path . buildCodeFrameError (
140
- '[React Intl] Message must have a `description`.'
141
- ) ;
139
+ if ( opts . enforceDescriptions ) {
140
+ if (
141
+ ! description ||
142
+ ( typeof description === 'object' && Object . keys ( description ) . length < 1 )
143
+ ) {
144
+ throw path . buildCodeFrameError (
145
+ '[React Intl] Message must have a `description`.'
146
+ ) ;
147
+ }
142
148
}
143
149
144
150
let loc ;
Original file line number Diff line number Diff line change @@ -7,7 +7,10 @@ export default class Foo extends Component {
7
7
< FormattedMessage
8
8
id = 'foo.bar.baz'
9
9
defaultMessage = 'Hello World!'
10
- description = { { text :'The default message.' , metadata :'metadata content' } }
10
+ description = { {
11
+ text : 'Something for the translator.' ,
12
+ metadata : 'Additional metadata content.' ,
13
+ } }
11
14
/>
12
15
) ;
13
16
}
Original file line number Diff line number Diff line change 2
2
{
3
3
"id" : " foo.bar.baz" ,
4
4
"description" : {
5
- "text" : " The default message ." ,
6
- "metadata" : " metadata content"
5
+ "text" : " Something for the translator ." ,
6
+ "metadata" : " Additional metadata content. "
7
7
},
8
8
"defaultMessage" : " Hello World!"
9
9
}
You can’t perform that action at this time.
0 commit comments