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 suggestion: no-state-in-constructor #1810
Comments
Since class fields are still stage 3, and not yet supported by default eslint, I'm not sure this is worth having as a rule yet - but this sounds like a great rule. |
Just today my workmate suggested a similar idea - forbidding The rationale for this is that it's easy to forget to call
Then we were wondering what are the usecases for constructors, and there it is:
So even with |
Note that there is a rule to catch omitted |
It doesn't enforce that you call |
That's true. Issue #626 in this repo suggests such a rule, but it hasn't happened yet. |
My employer happens to need this kind of rule as well. Is it okay for me to try working on this? My idea is that the rule name is The reason I omitted |
@lukyth that sounds reasonable to me! want to make the PR? |
Yeah. Let me try this out. I'll open a PR once I got something. |
INCORRECT
CORRECT
Why?
It may reduce boilerplate by not having to define a constructor just for initializing the state.
What do you think about this?
The text was updated successfully, but these errors were encountered: