Skip to content

Rule Proposal: no-computed-in-data #958

@scyclops

Description

@scyclops

Please describe what the rule should do:

Ensure computed properties are not used in the data() function because data() runs before computed properties are calculated. So computed properties are undefined when used in data().

What category should the rule belong to?

  • Enforces code style
  • Warns about a potential error
  • Suggests an alternate way of doing something
  • Other (please specify:)

Provide 2-3 code examples that this rule should warn about:

<script>
export default {
    data(){
        return {
            value: 'hello ' + this.world
        }
    },
    computed: {
        world() {
            return 'world'
        }
    }
}
</script>

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions