-
Notifications
You must be signed in to change notification settings - Fork 9
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
Support for objects/functions defined outside of JSX but inside render #7
Comments
This rule is the one that is most often violated, I think, and it is unfortunate that it can be so easily defeated. I'm interested in getting this improved, but I'm totally new to eslint plugins. How would one go about contributing to this? Also, what would be the recommended way of correcting this violation in class-based components? Static declarations outside of component? Class properties? |
Trying to solve this using eslint-scope, but this will Violations:
Not Violations:
@n1313 - Yes, static or even instance variables would work. If you can point me to your component/violation, I could make a better recommendation if you like. :) |
Should this be a violation?
|
It's a performance hit, but I don't think that that can be a violation to a linter. |
That's possible but it seems unlikely. If that was the case, the lint rule could be disable for this line? I would prefer to err on the side of strictness—we have a lot of methods, called inside render, which return new objects used as props. |
Yes, it's unlikely. :) I just think it gets super tricky when you start mixing runtime with static code linting. Would this be a violation?
Or consider inheritance:
I don't think a linter could know how to look for all of the possible child classes to know exactly which If you can find an example of a linter making runtime decisions or "stepping into" other functions, I will happily give it a shot. :) But I think I can get something working in the "simple case", if you are willing to try it out before it ships, I would be very grateful, please let me know. |
We report on:
But it's easily defeated with:
#6 (comment)
The text was updated successfully, but these errors were encountered: