| 254 | }; |
| 255 | |
| 256 | const isGetInitialStateConstructorSafe = getInitialState => { |
| 257 | if (!getInitialState) { |
| 258 | return true; |
| 259 | } |
| 260 | |
| 261 | const collection = j(getInitialState); |
| 262 | let result = true; |
| 263 | |
| 264 | const propsVarDeclarationCount = collection.find(j.VariableDeclarator, { |
| 265 | id: {name: 'props'}, |
| 266 | }).size(); |
| 267 | |
| 268 | const contextVarDeclarationCount = collection.find(j.VariableDeclarator, { |
| 269 | id: {name: 'context'}, |
| 270 | }).size(); |
| 271 | |
| 272 | if ( |
| 273 | propsVarDeclarationCount && |
| 274 | propsVarDeclarationCount !== collection.find(j.VariableDeclarator, { |
| 275 | id: {name: 'props'}, |
| 276 | init: { |
| 277 | type: 'MemberExpression', |
| 278 | object: {type: 'ThisExpression'}, |
| 279 | property: {name: 'props'}, |
| 280 | } |
| 281 | }).size() |
| 282 | ) { |
| 283 | result = false; |
| 284 | } |
| 285 | |
| 286 | if ( |
| 287 | contextVarDeclarationCount && |
| 288 | contextVarDeclarationCount !== collection.find(j.VariableDeclarator, { |
| 289 | id: {name: 'context'}, |
| 290 | init: { |
| 291 | type: 'MemberExpression', |
| 292 | object: {type: 'ThisExpression'}, |
| 293 | property: {name: 'context'}, |
| 294 | } |
| 295 | }).size() |
| 296 | ) { |
| 297 | result = false; |
| 298 | } |
| 299 | |
| 300 | return result; |
| 301 | }; |
| 302 | |
| 303 | const isInitialStateConvertible = classPath => { |
| 304 | const specPath = ReactUtils.directlyGetCreateClassSpec(classPath); |
no outgoing calls
no test coverage detected