-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Rule proposal: no reference to this.isMounted
in components
#37
Comments
It seems like this would be a feature in ESLint, not just this React plugin. Basically this is a warning/error when you reference a function instead of calling it. I tried searching the ESLint docs for it but I couldn't find anything. I don't know much about ESLint but is it even capable of knowing a variable's type? It seems like quite a challenge, esp. when you consider that we are concerned with object methods (eg. |
A general rule like that might be useful, but I think it would be difficult to implement. This request is specifically for |
Not sure it's worth to work on that one...
|
Indeed, it looks like Perhaps there should be a rule that prevents the use of it entirely? |
isMounted is an anti-pattern [0], is not available when using ES6 classes, and will eventually be officially deprecated. This commit adds a rule that prevents the use of this method. [0]: https://facebook.github.io/react/blog/2015/12/16/ismounted-antipattern.html Finishes jsx-eslint#37
isMounted is an anti-pattern [0], is not available when using ES6 classes, and will eventually be officially deprecated. This commit adds a rule that prevents the use of this method. [0]: https://facebook.github.io/react/blog/2015/12/16/ismounted-antipattern.html Finishes jsx-eslint#37
I've seen some people write code like
if (this.isMounted)
instead ofif (this.isMounted())
. It might be nice to have a rule that notices the former and encourages the latter.Good:
Bad:
The text was updated successfully, but these errors were encountered: