Eslint-plugin-react: React 15.5: Support `react-create-class` and `prop-types`

Created on 8 Apr 2017  路  7Comments  路  Source: yannickcr/eslint-plugin-react

To support React 15.5, we need the following changes asap:

  • [x] Everywhere we support React.createClass, we also need to support an import or require of react-create-class
  • [x] if we support PropTypes.* anywhere, we also need to support an import or require of prop-types
  • [x] we need to make no-deprecated warn on React.createClass and React.PropTypes usage and recommends the packages as well. It should apply to all versions of React since it's safe to migrate to the standalone packages on all versions.
accepted enhancement help wanted new rule

All 7 comments

For the third point we already have the no-deprecated rule that can be used.

I can take care of the no-unused-prop-types rule. Will look into it early next week.

After review, looks like the no-unused-prop-types and prop-types rules are not affected by the React 15.5 changes as they don't make any assumptions about where the PropTypes object comes from. No changes needed there.

In the README there's this section for the eslint config:

{
  "settings": {
    "react": {
      "createClass": "createClass", // Regex for Component Factory to use, default to "createClass"
      "pragma": "React",  // Pragma to use, default to "React"
      "version": "15.0" // React version, default to the latest React stable release
    }
  }
}

Changing "createClass": "createClass" to "createClass": "createReactClass" worked for the sort-comp rule for component detection. Haven't tested other rules...

@EvNaverniouk I think it's a flaw in the prop-types rule in particular that any validator named "shape", for example, assumes the semantics of PropTypes.shape - but you're right that that means it's not a blocker for React 15.5.

@kentor if that's the case, then perhaps we should default createClass to createReactClass when the version is 15.5+?

React 15.5.0 support seems to be complete.

  • Component factory now default to createReactClass (you still got the possibility to change it to createClass using the shared settings).
  • PropTypes detection is not affected by the changes in React 15.5.0.
  • React.PropTypes and React.createClass were added to no-deprecated.

I will publish a RC for the 7.0.0 (since there is some breaking changes here), you can test it with:

npm install eslint-plugin-react@next

Feedback welcome 馃槂

Thanks - we have more v7 PRs that need to be merged before a real v7 can go out, but as long as breaking changes can go in between RCs this is fine :-)

I'll close this for now.

Was this page helpful?
0 / 5 - 0 ratings