eslint-plugin-vue icon indicating copy to clipboard operation
eslint-plugin-vue copied to clipboard

Warn on non-reactive dependencies in computed

Open privatenumber opened this issue 5 years ago • 3 comments

Please describe what the rule should do: Warn if a computed property references non-reactive VM properties, such as $slots or $refs.

What category should the rule belong to?

  • [ ] Enforces code style
  • [x] 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: I see this mistake frequently, but doesn't actually work because slots aren't reactive.

computed: {
  hasContentSlot() {
    return !!this.$slots.content;
  }
}

Additional context

privatenumber avatar May 28 '20 18:05 privatenumber

Bumping this since it seems like it was missed

privatenumber avatar Feb 15 '23 01:02 privatenumber

Sorry, I missed it. That rule sounds good to me :+1:

ota-meshi avatar Feb 15 '23 05:02 ota-meshi

+1!

I can't count how many times I had to mention this in code reviews and give practical examples to showcase: in conditional slot rendering context, there might be an illusion of reactivity when the computed value starts truthy.

renatodeleao avatar Nov 22 '23 11:11 renatodeleao