@@ -218,15 +218,21 @@ export default function () {
218218
219219 CallExpression ( path , state ) {
220220 const moduleSourceName = getModuleSourceName ( state . opts ) ;
221+ const callee = path . get ( 'callee' ) ;
221222
222- function processMessageObject ( messageObj ) {
223- if ( ! ( messageObj && messageObj . isObjectExpression ( ) ) ) {
223+ function assertObjectExpression ( node ) {
224+ if ( ! ( node && node . isObjectExpression ( ) ) ) {
224225 throw path . buildCodeFrameError (
225226 `[React Intl] \`${ callee . node . name } ()\` must be ` +
226- 'called with message descriptors defined as ' +
227- 'object expressions.'
227+ 'called with an object expression with values ' +
228+ 'that are React Intl Message Descriptors, also ' +
229+ 'defined as object expressions.'
228230 ) ;
229231 }
232+ }
233+
234+ function processMessageObject ( messageObj ) {
235+ assertObjectExpression ( messageObj ) ;
230236
231237 let properties = messageObj . get ( 'properties' ) ;
232238
@@ -246,11 +252,11 @@ export default function () {
246252 storeMessage ( descriptor , path , state ) ;
247253 }
248254
249- let callee = path . get ( 'callee' ) ;
250-
251255 if ( referencesImport ( callee , moduleSourceName , FUNCTION_NAMES ) ) {
252256 let messagesObj = path . get ( 'arguments' ) [ 0 ] ;
253257
258+ assertObjectExpression ( messagesObj ) ;
259+
254260 messagesObj . get ( 'properties' )
255261 . map ( ( prop ) => prop . get ( 'value' ) )
256262 . forEach ( processMessageObject ) ;
0 commit comments