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

sort-comp does not detect component declaration starting with return #1076

Closed
webOS101 opened this issue Feb 17, 2017 · 3 comments
Closed

sort-comp does not detect component declaration starting with return #1076

webOS101 opened this issue Feb 17, 2017 · 3 comments

Comments

@webOS101
Copy link
Contributor

webOS101 commented Feb 17, 2017

Similar to #174 a component is not detected if the declaration begins with return (Such as, in our case, where we're wrapping the component inside a HOC). Other react rules appear to be applied correctly to these cases, just not sort-comp.

Example code (does not show sort-comp warning):

let makeComp = () => {
	return class MyComponent extends React.Component {
		componentDidUpdate () { }
		componentDidMount () {}
		constructor () { super(); }
	};
};

Example code (correctly shows sort-comp warning):

let makeComp = () => {
	class MyComponent extends React.Component {
		componentDidUpdate () { }
		componentDidMount () {}
		constructor () { super(); }
	};
	return MyComponent;
};

As another note: The react lifecycle methods are out-of-order and yet generate no warning. Not sure why they are not, maybe that's another ticket.

@ljharb
Copy link
Member

ljharb commented Feb 17, 2017

Since makeComp is not a component, it's an HOC, are you saying that MyComponent isn't being treated as a React component in the second example?

@webOS101
Copy link
Contributor Author

webOS101 commented Feb 17, 2017

In the second example, it is correctly being interpreted as a React component. In the first example, it is not detected as a React component. I will clarify the notes.

@ljharb
Copy link
Member

ljharb commented Feb 17, 2017

aha, thank you.

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

No branches or pull requests

2 participants