Skip to content

useTemplateRef 'xxx' is defined as ref, but never used.eslintvue/no-unused-refs #2559

@fxzer

Description

@fxzer

Checklist

  • [-] I have tried restarting my IDE and the issue persists.
  • [-] I have read the FAQ and my problem is not listed.

Tell us about your environment

  • ESLint version: ^9.10.0
  • eslint-plugin-vue version: 9.28.0
  • Vue version: ^3.5.6
  • Node version: v20.14.0
  • Operating System: MacOS 14.6.1

Please show your full configuration:

{
  "name": "wukong-gamemap",
  "type": "module",
  "private": true,
  "packageManager": "pnpm@9.10.0",
  "description": "黑神话悟空·游戏地图(仿写游民星空)",
  "scripts": {
    "build": "vite build",
    "dev": "vite --port 3333 --open",
    "lint": "eslint .",
    "lintf": "eslint --fix .",
    "typecheck": "vue-tsc --noEmit",
    "preview": "vite preview",
    "up": "taze major -I",
    "postinstall": "npx simple-git-hooks"
  },
  "dependencies": {
    "@vueuse/core": "^11.1.0",
    "axios": "^1.7.7",
    "ejs": "^3.1.10",
    "leaflet": "^1.9.4",
    "pinia": "^2.2.2",
    "pinia-plugin-persistedstate": "^4.0.1",
    "vue": "^3.5.6"
  },
  "devDependencies": {
    "@antfu/eslint-config": "^3.6.2",
    "@iconify-json/carbon": "^1.2.1",
    "@types/ejs": "^3.1.5",
    "@types/leaflet": "^1.9.12",
    "@types/mockjs": "^1.0.10",
    "@types/node": "^22.5.5",
    "@unocss/eslint-config": "^0.62.4",
    "@unocss/eslint-plugin": "^0.62.4",
    "@unocss/reset": "^0.62.4",
    "@vitejs/plugin-vue": "^5.1.3",
    "@vue-macros/volar": "^0.30.2",
    "@vue/test-utils": "^2.4.6",
    "eslint": "^9.10.0",
    "eslint-plugin-format": "^0.1.2",
    "jsdom": "^25.0.0",
    "lint-staged": "^15.2.10",
    "mockjs": "^1.1.0",
    "pnpm": "^9.10.0",
    "simple-git-hooks": "^2.11.1",
    "taze": "^0.16.9",
    "typescript": "^5.6.2",
    "unocss": "^0.62.4",
    "unplugin-auto-import": "^0.18.3",
    "unplugin-vue-components": "^0.27.4",
    "unplugin-vue-macros": "^2.12.2",
    "vite": "^5.4.5",
    "vite-plugin-vue-devtools": "^7.4.5",
    "vue-tsc": "^2.1.6"
  },
  "simple-git-hooks": {
    "pre-commit": "pnpm lint-staged"
  },
  "lint-staged": {
    "*": "eslint --fix"
  }
}

What did you do?

<script setup lang='ts'>
// const map = useTemplateRef<HTMLElement>('map') ✅
const mapRef = useTemplateRef<HTMLElement>('map') // ❌ 'map' is defined as ref, but never used.eslintvue/no-unused-refs
// const map = ref<HTMLElement | null>(null) // ✅
</script>

<template>
  <div ref="map" class="absolute left-0 top-0 h-full w-full bg-transparent" />
</template>

What did you expect to happen?
no error

What actually happened?
'map' is defined as ref, but never used.eslintvue/no-unused-refs

Repository to reproduce this issue

wukong-gamemap

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions