-
-
Notifications
You must be signed in to change notification settings - Fork 202
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 computed-property-getters
rule
#397
Conversation
#344 discussed making the rule configurable to allow it to be reversed. in that case, calling the rule |
Defaults to `never` allow getters in computed properties, has the option to `always` require them.
6674092
to
468661f
Compare
Thanks @Turbo87. I lost track of that requirement. I was able to figure out how to create the options and test them so now this rule supports both. |
@Turbo87 just checking in on this to see if there is anything I should change before I completely forget the context. |
|
||
String option: | ||
|
||
* `"never"` (default) getters are *never allowed* in computed properties |
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.
I think the default should be to only allow them if there is also a setter present. don't ask me how to call that option... 😅
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.
As I started working on the docs for a change to add always-with-setter
as an option here it strikes me as a strange thing to lint against. A property created like this would throw an error when accessed anyway since there is no way to get it's value.
Ember.Object.extend({
fullName: computed('firstName', 'lastName', {
set() {
//...
}
})
});
Am I confused about what your comment is asking for?
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.
what I mean is:
// good
Ember.Object.extend({
fullName: computed('firstName', 'lastName', function() {
//...
})
});
// bad
Ember.Object.extend({
fullName: computed('firstName', 'lastName', {
get() {
//...
}
})
});
// good
Ember.Object.extend({
fullName: computed('firstName', 'lastName', {
get() {
//...
},
set() {
//...
}
})
});
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.
Thanks for the clarification @Turbo87, I've captured that now and updated the default.
@jrjohnson it looks like CI is unhappy about the latest change 🤔 |
This defaults to requiring getters if there is a setter. It preserves the option to prevent getters entirely as a proxy for preventing setters as well.
bf2cb10
to
1dac868
Compare
Whoops, thanks @Turbo87. Fixed now. |
A setter should never be present when there are no getters no matter what other options are selected.
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.
👏 nice work!
Awesome work @jrjohnson Thank you so much |
🎉 thanks for all the great feedback. |
computed-property-getters
rule
Adds rule to fix #344
Which has options to
never
allow getters in computed properties oralways
require them.