Open
Description
Style guide:
https://vuejs.org/v2/style-guide/#Simple-computed-properties-strongly-recommended
Description:
This rule would enforce creating simple computed properties with just a return statement, without too much logic around it.
Bad:
computed: {
price: function () {
var basePrice = this.manufactureCost / (1 - this.profitMargin)
return (
basePrice -
basePrice * (this.discountPercent || 0)
)
}
}
Good:
computed: {
basePrice: function () {
return this.manufactureCost / (1 - this.profitMargin)
},
discount: function () {
return this.basePrice * (this.discountPercent || 0)
},
finalPrice: function () {
return this.basePrice - this.discount
}
}