Rule proposition: `no-side-effects-in-computed-properties`
See original GitHub issueThis rule would check if there are no side effects inside computed properties.
So this example would throw an error:
export default {
computed: {
hello() {
this.lastName = 'Dolor' // <- error "Unexpected side effect in computed property 'hello'"
return `Hello ${this.firstName} ${this.lastName}`
}
},
data() {
return {
firstName: 'Lorem',
lastName: 'Ipsum'
}
}
}
What do you think @mysticatea @chrisvfritz ?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:5
- Comments:17 (14 by maintainers)
Top Results From Across the Web
vue/no-side-effects-in-computed-properties
This rule is aimed at preventing the code which makes side effects in computed properties and functions. It is considered a very bad...
Read more >How to fix vue/no-side-effects-in-computed-properties?
1. Remove the ESLint rule. Just add // eslint-disable-next-line vue/no-side-effects-in-computed-properties in the line above the line that ...
Read more >vue/no-side-effects-in-computed-properties | eslint-plugin-vue
This rule is aimed at preventing the code which makes side effects in computed properties. It is considered a very bad practice to...
Read more >How to fix vue/no-side-effects-in-computed-properties?-Vue.js
ESLint throws this warning (or error - depending on your setup), because an unwanted side-effect is there in your computed property, namely: you...
Read more >3 Anti-Patterns to avoid in Vue.js - Binarcode
Side effects inside computed properties ... We mutate the prop without letting the parent now about it; We might get unexpected behavior or...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Would this rule also check for things like:
Ready in
v3.6.0
🚀 Let’s leave such edge cases for further consideration, we need to be agile and constantly improve those rules starting with simple solutions. I’m going to move those ideas to separate issue and closing this one. Thanks for a great discussion here guys!