nuxt / eslint

Collection of ESLint-related packages for Nuxt
https://eslint.nuxt.com
MIT License
554 stars 66 forks source link

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

Open mbrocks1337 opened 1 month ago

mbrocks1337 commented 1 month ago

Environment


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

antfu commented 12 hours ago

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?

ota-meshi commented 7 hours ago

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