| 318 | }; |
| 319 | |
| 320 | const canConvertToClass = classPath => { |
| 321 | const specPath = ReactUtils.directlyGetCreateClassSpec(classPath); |
| 322 | if (!specPath) { |
| 323 | return false; |
| 324 | } |
| 325 | const invalidProperties = specPath.properties.filter(prop => ( |
| 326 | !prop.key.name || ( |
| 327 | !STATIC_KEYS.hasOwnProperty(prop.key.name) && |
| 328 | STATIC_KEY != prop.key.name && |
| 329 | !filterDefaultPropsField(prop) && |
| 330 | !filterGetInitialStateField(prop) && |
| 331 | !isFunctionExpression(prop) && |
| 332 | !isPrimProperty(prop) && |
| 333 | !isPrimPropertyWithTypeAnnotation(prop) && |
| 334 | MIXIN_KEY != prop.key.name |
| 335 | ) |
| 336 | )); |
| 337 | |
| 338 | if (invalidProperties.length) { |
| 339 | const invalidText = invalidProperties |
| 340 | .map(prop => prop.key.name ? prop.key.name : prop.key) |
| 341 | .join(', '); |
| 342 | console.warn( |
| 343 | file.path + ': `' + ReactUtils.directlyGetComponentName(classPath) + '` ' + |
| 344 | 'was skipped because of invalid field(s) `' + invalidText + '` on ' + |
| 345 | 'the React component. Remove any right-hand-side expressions that ' + |
| 346 | 'are not simple, like: `componentWillUpdate: createWillUpdate()` or ' + |
| 347 | '`render: foo ? renderA : renderB`.' |
| 348 | ); |
| 349 | } |
| 350 | return !invalidProperties.length; |
| 351 | }; |
| 352 | |
| 353 | const areMixinsConvertible = (mixinIdentifierNames, classPath) => { |
| 354 | if ( |
no test coverage detected