Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] In require-optimization corrected test for function declaration #744

Merged
merged 2 commits into from
Aug 11, 2016
Merged

Conversation

Tom910
Copy link
Contributor

@Tom910 Tom910 commented Aug 6, 2016

There was a problem with the ad functions and methods in classes, sample code -

import React from "react";
class YourComponent extends React.Component {
  handleClick() {}
  render() {
     return <div onClick={this.handleClick}>123</div>;
  }
}
{
  "rules": {
    "react/require-optimization": 2  
  }
}

This code has been checked and is not output error, it is wrong

@Tom910 Tom910 changed the title [FIX] In require-optimization corrected test for function declaration [Fix] In require-optimization corrected test for function declaration Aug 6, 2016
'import React, {Component} from "react";',
'@reactMixin.decorate(PureRenderMixin)',
'class YourComponent extends Component {',
' componetnDidMount () {}',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be componentDidMount?

Copy link
Contributor Author

@Tom910 Tom910 Aug 6, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace on a new example

@ljharb
Copy link
Member

ljharb commented Aug 6, 2016

Sorry for my earlier confusion - I was confusing this with a "prefer SFCs" rule :-)

Afaik require-optimization should skip any createClass component with PureRenderMixin, and should skip any class component with a shouldComponentUpdate method, and should skip any SFC entirely.

If you have components that don't match these criteria, and require-optimization is not warning on them, then that seems like it might indeed be a bug.

@lencioni
Copy link
Collaborator

lencioni commented Aug 6, 2016

It should also skip classes that extend React.PureComponent.

@Tom910
Copy link
Contributor Author

Tom910 commented Aug 7, 2016

@lencioni Yes, I agree, but it has already been implemented @yannickcr commit 8b567a6

@ljharb Yes, it is =)

@yannickcr yannickcr merged commit 8661917 into jsx-eslint:master Aug 11, 2016
@yannickcr
Copy link
Member

Merged, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants