eslint icon indicating copy to clipboard operation
eslint copied to clipboard

`vue/no-side-effects-in-computed-properties` does not work with `defineNuxtComponent()`

Open mbrocks1337 opened this issue 1 year ago • 2 comments

Environment


  • Operating System: Linux
  • Node Version: v18.19.1
  • Nuxt Version: 3.13.2
  • CLI Version: 3.14.0
  • Nitro Version: 2.9.7
  • Package Manager: [email protected]
  • Builder: -
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Package

@nuxt/eslint

Reproduction

https://stackblitz.com/edit/github-h9xb1n?file=components%2FComponentWithNuxtComponent.vue,components%2FComponentWithComponent.vue,app.vue,package.json

run "npm run lint"

Describe the bug

Using the Options API with the vue wrapper defineComponent gives you an eslint error: "ESLint: Unexpected side effect in "bar" computed property.(vue/no-side-effects-in-computed-properties)"

Consuming the same component with defineNuxtComponent disables this feature completly

Additional context

No response

Logs

No response

mbrocks1337 avatar Oct 17 '24 12:10 mbrocks1337

Yeah, this is a limitation of eslint-plugin-vue that hard-coded the support of defineComponent - it's not Nuxt aware.

/cc @ota-meshi do you think it makes sense for eslint-plugin-vue to support detecting defineNuxtComponent? If so, do you think it needs to be configurable, or it's fine we just hard-coded and have it always on?

antfu avatar Nov 16 '24 08:11 antfu

Yeah! We plan to do that in the next major version. But we don't have the time to work on a major version 😓 https://github.com/vuejs/eslint-plugin-vue/pull/2311

ota-meshi avatar Nov 16 '24 12:11 ota-meshi