Skip to content

Latest commit

 

History

History
38 lines (32 loc) · 728 Bytes

no-duplicate-vuex-properties.md

File metadata and controls

38 lines (32 loc) · 728 Bytes

Disallow duplicate properties from Vuex (no-duplicate-vuex-properties)

Vuex supports expanding specific functions and declaring properties for components via strings or object literals. However, it is possible for these properties to duplicate object properties at the expanded location, or to duplicate each other. This usually produces unintended results.

Fail

export default {
  computed: {
    ...mapState(['foo']),
    foo() {
      return this.bar
    },
  },
}
export default {
  computed: {
    ...mapState(['foo']),
    ...mapState('bar', ['foo', 'baz']),
  },
}

Pass

export default {
  computed: {
    ...mapState(['foo']),
    bar() {
      return this.baz
    },
  },
}