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

Emits error using $fetch() in composables #371

Closed
yabe-diverta opened this issue Mar 30, 2024 · 1 comment
Closed

Emits error using $fetch() in composables #371

yabe-diverta opened this issue Mar 30, 2024 · 1 comment

Comments

@yabe-diverta
Copy link

Environment

  • Operating System: Darwin
  • Node Version: v18.18.2
  • Nuxt Version: 3.11.1
  • CLI Version: 3.11.1
  • Nitro Version: 2.9.5
  • Package Manager: npm@9.8.1
  • Builder: -
  • User Config: ssr, app, modules, googleFonts, eslint, devtools, css, nitro, vite
  • Runtime Modules: @nuxtjs/google-fonts@3.1.3, @nuxt/eslint@0.3.0-beta.7
  • Build Modules: -

Package

@nuxt/eslint

Reproduction

https://stackblitz.com/edit/github-11bgm1?file=eslint.config.mjs
make sure running npx eslint composables/*.js will reproduce this.

スクリーンショット 2024-03-30 11 58 56

Describe the bug

emits no-undef error when composables using $fetch().

Additional context

using $fetch() in .vue file does not output lint error.

additionally it's workaround is below, adding globals into eslint config, can resolve this.

import withNuxt from './.nuxt/eslint.config.mjs';

export default withNuxt({
    languageOptions: {
        globals: {
            $fetch: 'readonly'
        }
    },
});

Logs

No response

@antfu
Copy link
Member

antfu commented Apr 18, 2024

Awesome reproduction, thanks :)

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

No branches or pull requests

2 participants