-
-
Notifications
You must be signed in to change notification settings - Fork 204
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
Add new 'require-return-from-computed' rule #262
Conversation
e55b214
to
50737f1
Compare
@gmurphey please don't add rules to the recommended list directly. adding them means it is a breaking change and we would have to release a new major version each time. |
50737f1
to
fd1857c
Compare
Thanks for the heads up, @Turbo87. I've reverted those changes. |
fd1857c
to
a68c854
Compare
}] | ||
}, | ||
{ | ||
code: 'let foo = computed("test", function() { if (true) { return ""; } })', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this check invalid? it seems correct to me as there is a return
statement inside the function 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gmurphy any comments?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the long radio silence. Since not all paths return
, I thought this should be an invalid case. I've added a valid case for this example as well.
a68c854
to
517d65f
Compare
I've updated this to use some of the logic from the |
b2323a6
to
cad1aad
Compare
return-from-computed
rule
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add tests for the following;
let foo = computed({
get() {
return 'foo';
},
set() {
}
})
let foo = computed({
get() {
},
set() {
return 'foo';
}
})
Other than that, this seems good to me...
Suggestion: rename rule to |
Rename suggestion seems good to me... |
Hey everyone, |
I should have some time this week to make the requested changes. Sorry for the delay! |
Hey @gmurphey I can help you finish this up and merge it if you prefer. |
cad1aad
to
382e55c
Compare
Thanks for offering, @bmish! Was able to find a few minutes this morning to rename the rule and add the requested tests. This should be ready for another round of review. Thanks everyone for the feedback so far! |
// ------------------------------------------------------------------------------ | ||
|
||
const eslintTester = new RuleTester(); | ||
eslintTester.run('return-from-computed', rule, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update rule name here.
description: 'Warns about missing return statements in computed properties', | ||
category: 'Possible Errors', | ||
recommended: false, | ||
url: 'https://github.com/ember-cli/eslint-plugin-ember/tree/master/docs/rules/no-side-effects.md' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the wrong URL. I'm not sure if this url
property is actually used anywhere so you could just remove it.
Looks like you need to run |
return-from-computed
rule382e55c
to
557380e
Compare
Thank you! |
Fixes #247.