Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@typescript-eslint/no-unused-vars for variables used in template #219

Closed
jonnyparris opened this issue Jun 28, 2022 · 1 comment
Closed

Comments

@jonnyparris
Copy link

Hey Team Nuxt, I'm getting the above errors despite this eslint config and the latest version of @nuxtjs/eslint-config (10.0.0).

module.exports = {
  root: true,
  env: {
    browser: true,
    node: true,
  },
  extends: ['@nuxtjs/typescript', 'prettier'],
  plugins: ['prettier'],
  rules: {},
}

I thought that the vue-parser plugin should be providing the "script-setup-uses-var" functionality that handles this but somehow it doesn't seem to be coming through. Have I missed / misconfigured something?

Simple example page that's offending lint at the moment:

<template lang="pug">
main
  h1 Homepage Title #[Fa(v-show='loading', :icon='["fas", "gear"]', spin)]
</template>

<script setup>
const loading = 'cheese' // <-- lint is convinced this const is unused
</script>
@jonnyparris
Copy link
Author

Turns out this was related to the lack of pug parsing in vue-eslint-parser (issue).
Thankfully solved by installing https://github.com/rashfael/eslint-plugin-vue-pug and adding it to eslintrc like so:

module.exports = {
  root: true,
  env: {
    browser: true,
    node: true,
  },
  extends: ['plugin:vue-pug/vue3-recommended', '@nuxtjs/typescript', 'prettier'],
  plugins: ['prettier'],
  rules: {},
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant