Skip to content

Latest commit

 

History

History
44 lines (32 loc) · 1023 Bytes

require-setup-store-properties-export.md

File metadata and controls

44 lines (32 loc) · 1023 Bytes

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

💼⚠️ This rule is enabled in the following configs: ✅ recommended, ✅ recommended-flat. This rule warns in the following configs: 🌐 all, 🌐 all-flat.

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 }
})