Skip to content

Eslint rules are not working with .vue files #9962

@escaton

Description

@escaton

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions