react-prop-types-parser

1.0.10 • Public • Published

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
}

Readme

Keywords

none

Package Sidebar

Install

npm i react-prop-types-parser

Weekly Downloads

1

Version

1.0.10

License

MIT

Unpacked Size

61.5 kB

Total Files

49

Last publish

Collaborators

  • anc95