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
no pure functions inside of es6 classes #5139
Comments
@pwmckenna Thanks for the issue! If you're reporting a bug, please be sure to include:
Requesting a new rule? Please see Proposing a New Rule for instructions. |
👍 That would be great. |
Hmmm.. It seems to be a fairly limiting rule. I'm also not sure what would be a good reason to discourage using pure functions. @pwmckenna could you provide more information about why you are looking for this rule and follow our new rule proposal template? |
@ilyavolodin If it doesn't mention |
I would definitely use such a rule 👍. |
Ok, sounds good to me, in that case. Thanks @michaelficarra |
@ilyavolodin I'll definitely use that template next time, thanks for linking. I'd be happy to make a first pass at implementing this, though I suspect I'll need to ask for help along the way. I'll have something up in the next couple of days. |
@pwmckenna I'd still like to see the info from the rule proposal posted to this issue. It really helps both with the evaluation and communicating to others the intention of this rule. |
@nzakas definitely! When the rules will warn. Include a description as well as sample code.This rule will warn whenever Good:
Bad:
Whether the rule prevents an error or is stylistic.This rule is stylistic, but has performance implications. If a function is not using Why the rule should be in the core instead of creating a custom rule.Totally up to the maintainers. I think its a pretty fundamental thing, making a distinction between class members and static functions, but again, its mostly a style issue, so I can make it a custom rule as well. Are you willing to create the rule yourself?I went ahead and wrote it because its interesting, so I'm happy even if it doesn't make it in. Great project. Thanks for all the hard work! |
@michaelficarra if there is a reason not to use |
@pwmckenna Would you like to open a PR? Looks like you did a lot of work on this already! |
Just my 2 cents, but this rule may make more sense as a part of eslint-plugin-react. The use-case for React makes sense, but I'm not sure how often this would be desirable with typical ES6 classes. As an example, a developer might create a class with a method that doesn't use class Foo {
doSomething() {
// some code here
this.onSomething();
}
onSomething() {
console.log('foo');
}
}
var foo = new Foo();
// Consumer can override
foo.onSomething = () => console.log('bar'); With this rule enabled, it would encourage the developer of the |
Sounds like it should be named |
There's been no progress on this issue for months. Unless someone steps forward to implement, it's time to close this issue. |
working on this |
I'd like to write a rule that complains if a class method does not use this. Sort of the opposite of no-invalid-this.
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
The text was updated successfully, but these errors were encountered: