vuejs / eslint-plugin-vue

Official ESLint plugin for Vue.js
https://eslint.vuejs.org/
MIT License
4.45k stars 665 forks source link

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

Closed fxzer closed 1 week ago

fxzer commented 1 week ago

Checklist

Tell us about your environment

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

FloEdelmann commented 1 week ago

Duplicate of #2547. This is already fixed but not yet released.