react-prop-types-parser
v1.0.10
Published
![](https://api.travis-ci.org/anc95/prop-types-parser.svg?branch=master) ![](https://img.shields.io/npm/dm/react-prop-types-parser.svg)
Downloads
14
Readme
prop-types-parser
parse prop-types to analysize react components props data stucture
why not react-docgen
react-docgen is based on ast, and only based ast, so it is hard to analysize some runtime code, such as ONECOMPONENT.PropTypes
is imported form a module or is produced by a runtime function
prop-types-parser
, combines ast and runtime code, it is more flexible and stronger
install
npm install react-prop-types-parser
ussage
import { parse, parseSeries } from 'react-prop-types-parser'
parse(file, options)
options
interface ParserConfig {
/**
* @desciption alias in code
* @example {'@module', path.join(__dirname, ''../lib/@module'')}
*/
alias?: Object,
/**
* @description global object will be injected to runtime code, and removed when finished excuting
* @example { a: function () {return 'i was injected'}
}
*/
globalObject?: Object,
/**
* @description replace the third module with your module, so we have the effort to support more prop-types-like library
* @example {'prop-types', path.join(__dirname, '../lib/prop-types')}
*/
resolveModule?: Object,
/**
* @description babel config used to run the code depended by the main component entry
*
*/
babelConfig?: Object
}