Skip to content
Source
Sign inSign up
TanStack/query

Eslint rules are not working with .vue files #9962

Send to my agent
Closedescaton(GitHub profile, opens in a new tab) opened this issue 3 comments

Describe the bug

Rules that are using ASTUtils.getFunctionAncestor utility are not catching errors in .vue files, because in typical Vue file there will be no ancestor node of these types

<template>
...
</template>
<script setup>
import { useQuery } from '@tanstack/vue-query'

const param = ref('init')

const {data} = useQuery({
  queryKey: [],
  // ^ should error
  queryFn: () => fetch(param.value)
})
</script>

Your minimal, reproducible example

Steps to reproduce

From eslint rules perspective, vue files are only bodies of <script> blocks, so this is what actually got linted: https://astexplorer.net/#/gist/91045e1d61e58247f12cdde6f344a9a7/ab878660138f9633d607b0ee0298f8848dc395d4

Expected behavior

Should error:

The following dependencies are missing in your queryKey: param.value eslint[@tanstack/query/exhaustive-deps]

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

Tanstack Query adapter

vue-query

TanStack Query version

5.91.3

TypeScript version

No response

Additional context

No response

  1. 📝 CodeRabbit Plan Mode

    Generate an implementation plan and agent prompts for this issue.

    • Create Plan
    Examples

    TanStack/query#9687 - fix(eslint-plugin): exhaustive-deps with variables and type assertions (#9643) [merged] TanStack/query#9759 - fix(eslint-plugin): avoid imports from typescript [merged] TanStack/query#9813 - docs(solid-query): fix incorrect Vue.js code example in Suspense guide [merged] TanStack/query#9828 - fix(eslint-plugin): validate hook import [closed]

    👤 Suggested Assignees

    • Newbie012
    • fbieler
    • Varunchandrashekar05

    🧪 Issue enrichment is currently in early access.

    To disable automatic issue enrichment, add the following to your .coderabbit.yaml:

    issue_enrichment:
      auto_enrich:
        enabled: false
  2. TkDodo added labelspackage: eslint-plugin-query

  3. TkDodo added labelshelp wanted

  4. I’d appreciate a PR to fix this 🙏

  5. Raised a PR for the same @TkDodo 10011

  6. TkDodo closed this

Sign in to join this conversation.