# san/initdata-in-component
enforce component's data property to be a function
- ⚙️ This rule is included in all of
"plugin:san/essential"
,"plugin:san/strongly-recommended"
and"plugin:san/recommended"
. - 🔧 The
--fix
option on the command line (opens new window) can automatically fix some of the problems reported by this rule.
When using the data property on a component , the value must be a function that returns an object.
# 📖 Rule Details
<script>
/* ✓ GOOD */
export default class SomeComp extends san.Component {
initData () {
return {
foo: 'bar'
}
}
}
</script>
<script>
/* ✗ BAD */
export default {
initData: {
foo: 'bar'
}
}
</script>
# 🔧 Options
Nothing.