ITADN

vue/prefer-use-template-ref missed instance

#3061Opensamfreund 创建于 2026-03-25
S
samfreundcommented
<!-- ❗Please don't ignore this template.❗ If you ignore it, we're just going to respond asking you to fill it out, which wastes everyone's time. The more relevant information you can include, the faster we can find the issue and fix it without asking you for more info. --> <!-- Before posting the issue, please confirm that the problem you're getting is not related with your code editor configuration. To make sure it's not, run: yarn eslint src/your-file.vue --> **Checklist** - [x] I have tried restarting my IDE and the issue persists. - [x] I have read the [FAQ](https://eslint.vuejs.org/user-guide/#faq) and my problem is not listed. <!-- If you do not read the FAQ and open an issue that is listed in the FAQ, we may silently close the issue. --> **Tell us about your environment** - **ESLint version:** 9.31.0 - **eslint-plugin-vue version:** 10.7 - **Vue version:** 3.5.13 - **Node version:** v22.20.0 - **Operating System:** Ubuntu 24.04 **Please show your full configuration:** <!-- Paste content of your .eslintrc file --> ```json5 import pluginVue from "eslint-plugin-vue"; import { defineConfigWithVueTs, vueTsConfigs } from "@vue/eslint-config-typescript"; import skipFormattingConfig from "@vue/eslint-config-prettier/skip-formatting"; export default defineConfigWithVueTs( pluginVue.configs["flat/recommended-error"], vueTsConfigs.recommendedTypeChecked, skipFormattingConfig, { ignores: ["**/dist/**", "playwright-report"] }, { //extends: ["js/recommended"], rules: { quotes: ["error", "double"], "comma-dangle": ["error", "never"], "comma-spacing": [ "error", { before: false, after: true } ], semi: ["error", "always"], "eol-last": "error", eqeqeq: "error", "no-useless-concat": "error", "object-curly-spacing": ["error", "always"], "quote-props": ["error", "as-needed"], "no-case-declarations": "off", "vue/eqeqeq": "error", "vue/no-useless-concat": "error", "vue/no-constant-condition": "error", "vue/no-empty-pattern": "error", "vue/no-undef-directives": "error", "vue/no-undef-properties": "error", "vue/no-unused-properties": "error", "vue/no-unused-refs": "error", "vue/no-use-v-else-with-v-for": "error", "vue/no-useless-mustaches": "error", "vue/no-useless-v-bind": "error", "vue/require-default-prop": "off", "vue/v-for-delimiter-style": "error", "vue/v-on-event-hyphenation": "off", "vue/require-typed-ref": "error", "@typescript-eslint/no-empty-object-type": "error", "@typescript-eslint/no-explicit-any": "error", "vue/valid-v-slot": ["error", { allowModifiers: true }] } } ); ``` **What did you do?** <!-- Please include the actual source code causing the issue. --> ```vue <script setup lang="ts"> import { computed, inject, ref, onBeforeUnmount } from "vue"; import { useStateStore } from "@/stores/StateStore"; import { useCameraSettingsStore } from "@/stores/settings/CameraSettingsStore"; import type { StyleValue } from "vue"; import PvIcon from "@/components/common/pv-icon.vue"; import type { UiCameraConfiguration } from "@/types/SettingTypes"; import PvLoading from "@/components/common/pv-loading.vue"; const mjpgStream = ref<HTMLImageElement | null>(null); const handleStreamError = () => { if (streamSrc.value && streamSrc.value !== emptyStreamSrc) { console.error("Error loading stream:", streamSrc.value, " Trying again."); setTimeout(() => { mjpgStream.value!.src = streamSrc.value; }, 100); } }; onBeforeUnmount(() => { if (!mjpgStream.value) return; mjpgStream.value.src = emptyStreamSrc; }); </script> <template> <div class="stream-container" :style="containerStyle"> <pv-loading class="stream-loading" /> <img :id="id" ref="mjpgStream" class="stream-video" crossorigin="anonymous" :src="streamSrc" :alt="streamDesc" :style="streamStyle" @error="handleStreamError" /> </div> </template> ``` **What did you expect to happen?** I expected this to throw an error, as I was not using a `useTemplateRef` for the mjpegStream element. **What actually happened?** <!-- Please include the actual, raw output from ESLint. If you are only looking at the results of your editor extension, also check the CLI results. --> No error was thrown. **Repository to reproduce this issue** <!-- ❗ Please share a repository that can reproduce your issue. ❗ If you don't share it, we just label it as requesting a repository that can reproduce your issue. ❗ If you don't share it for a few days, we silently close this issue. --> https://github.com/samfreund/photonvision/tree/vue-error-repro
0 条评论