Skip to content

Latest commit

 

History

History
41 lines (33 loc) · 611 Bytes

no-shared-vue-provide.md

File metadata and controls

41 lines (33 loc) · 611 Bytes

Enforce the provide option of Vue component to be a function (no-shared-vue-provide)

When using the provide option on a Vue component, the same object will be shared by reference across all instances created. By declaring it as a function, the instances can be kept independent of each other.

This rule is fixable.

Fail

export default {
  provide: {
    foo: 'bar',
  },
}

Pass

export default {
  provide() {
    return {
      foo: 'bar',
    }
  },
}
export default {
  provide: () => ({
    foo: 'bar',
  }),
}
export default {
  provide: foo,
}