Skip to content

Latest commit

 

History

History
44 lines (32 loc) · 958 Bytes

require-setup-store-properties-export.md

File metadata and controls

44 lines (32 loc) · 958 Bytes

In setup stores all state properties must be exported (pinia/require-setup-store-properties-export)

💼⚠️ This rule is enabled in the ✅ recommended config. This rule warns in the 🌐 all config.

Rule Details

❌ Examples of incorrect code for this rule:

export const useCounterStore = defineStore('counter', () => {
  const count = ref(0)
  const doubleCount = computed(() => count.value * 2)
  function increment() {
    count.value++
  }

  return { doubleCount }
})
export const useCounterStore = defineStore('counter', () => {
  const count = ref(0)
})

✅ Examples of correct code for this rule:

export const useCounterStore = defineStore('counter', () => {
  const count = ref(0)
  const obj = reactive({ count })
  const doubleCount = computed(() => count.value * 2)
  function increment() {
    count.value++
  }

  return { count, obj }
})