-
Notifications
You must be signed in to change notification settings - Fork 1
✨ Extract proptypes of components with HOCs #49
Conversation
package.json
Outdated
@@ -39,7 +39,8 @@ | |||
"sass-loader": "^6.0.3", | |||
"style-loader": "^0.16.1", | |||
"webpack": "^2.3.3", | |||
"webpack-dev-middleware": "^1.10.1" | |||
"webpack-dev-middleware": "^1.10.1", | |||
"whatwg-fetch": "^2.0.3" |
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.
babel-polyfill
throw importType | ||
} | ||
recast.visit(ast, { | ||
visitFunctionDeclaration: false, |
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.
Try the default definition, if this is false
you could delete those lines
visitDoWhileStatement: false, | ||
visitForStatement: false, | ||
visitForInStatement: false, | ||
visitExportDeclaration: false, |
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.
What about this one ?
} | ||
return newpath | ||
} catch (e) { | ||
// file path not found |
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.
😨
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.
Ignore only 1 error, you have to throw the others
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.
I don't understand your last 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.
} else { | ||
const resolved = utils.resolveToValue(resolveHOC(definition)) | ||
if (resolved.node.type === 'ImportDeclaration') { | ||
// Manage imported components in HOC from different file |
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.
Why do you pass by an exception instead of recalling exportDeclaration(newPath)
try { | ||
const stats = await fs.statAsync(newpath) | ||
if (stats.isDirectory()) { | ||
return resolvePath(p.resolve(path, 'index.js')) |
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.
return resolvePath(p.resolve(path, 'index'))
|
||
const resolvePath = async (path) => { | ||
const extensions = ['.js', '.jsx', ''] | ||
for (let i = 0; i < extensions.length; i += 1) { |
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.
for of
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.
forbidden by the linter :
[eslint] iterators/generators require regenerator-runtime, which is too heavyweight for this guide to allow them. Separately, loops should be avoided in favor of array iterations. (no-restricted-syntax)
here the airbnb explanation :
airbnb/javascript#1271
const docgen = require('react-docgen') | ||
|
||
const utils = require('react-docgen/dist/utils') | ||
const resolveHOC = require('react-docgen/dist/utils/resolveHOC.js').default |
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.
you don't need that .js
const utils = require('react-docgen/dist/utils') | ||
const resolveHOC = require('react-docgen/dist/utils/resolveHOC.js').default | ||
|
||
const isComponentDefinition = (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.
Add the source (url) in a commentary in this file
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.
See above commentaries
@fabienjuif ready to review |
#48