Closed
Description
Please describe what the rule should do:
Should warn when accessing a computed property from the data()
function, as computed properties are not initialized at that point and returns undefined
.
Vue 2 demo: https://jsfiddle.net/hirokiosame/dunkzqL0/7/
Vue 3 demo: https://jsfiddle.net/hirokiosame/4qu8yxfo/2/
What category should the rule belong to?
[ ] Enforces code style (layout)
[x] Warns about a potential error (problem)
[ ] Suggests an alternate way of doing something (suggestion)
[ ] Other (please specify:)
Provide 2-3 code examples that this rule should warn about:
<script>
export default {
computed: {
defaultValue() {
return 123;
}
},
data() {
return {
// computed not initialized yet, so returns undefined
someValue: this.defaultValue,
};
},
};
</script>
Additional context