jsx-eslint/eslint-plugin-react

react/prop-types doesn't work when mixing createReactClass with ES6 style prop types

開放

#1,663 建立於 2018年1月28日

 (5 則留言) (0 個反應) (0 位負責人)JavaScript (2,731 個分叉)batch import
bughelp wanted

倉庫指標

星標
 (9,293 顆星)
PR 合併指標
 (PR 指標待抓取)

描述

To facilitate moving to ES6 classes we're mixing createReactClass with ES6 style prop types.

react/prop-types doesn't seem to recognize prop types in this case and reports all used props as "missing in props validation".

File to reproduce:

'use strict';

const createReactClass = require('create-react-class');
const React = require('react');
const PropTypes = require('prop-types');

const Component = createReactClass({
  render: function () {
    return (<div>{this.props.prop}</div>);
  }
});

Component.propTypes = {
  prop: PropTypes.string
};

module.exports = Component;

貢獻者指南