jsx-eslint / jsx-eslint/eslint-plugin-react
react/prop-types doesn't work when mixing createReactClass with ES6 style prop types
Open
Nobody has claimed this yet.
bug
help wanted
- Dominant language
- JavaScript
- Stars
- 9.3k
- Forks
- 2.7k
- PR merge metrics
- No merged PRs in 30d
Description
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;
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the inline reproduction with the react/prop-types rule enabled, then trace the rule's handling of createReactClass and the subsequent Component.propTypes assignment. Done means the prop validation warning is no longer reported for the shown prop while existing missing-prop validation still works.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- eslint, javascript, react
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 42/100