ITADN

ESLint rules not enforced in Vue template sections (only in script tags)

#619Openmgambella 创建于 2025-10-04
pending triage
M
mgambellacommented
### Environment ------------------------------ - Operating System: Darwin - Node Version: v22.19.0 - Nuxt Version: 4.1.2 - CLI Version: 3.28.0 - Nitro Version: 2.12.6 - Package Manager: pnpm@10.16.0 - Builder: - - User Config: compatibilityDate, devtools, runtimeConfig, site, sitemap, app, css, plugins, modules, image, build, googleFonts, tailwindcss, vite, ignore, routeRules - Runtime Modules: @nuxt/devtools@2.6.5, @nuxt/eslint@1.9.0, @nuxt/image@1.11.0, @nuxtjs/google-fonts@3.2.0, @nuxtjs/sitemap@7.4.7, @nuxtjs/tailwindcss@6.14.0, @pinia/nuxt@0.11.2, @vueuse/nuxt@13.9.0 - Build Modules: - ------------------------------ ### Package @nuxt/eslint ### Reproduction ## Configuration `eslint.config.mjs `: ``` js // @ts-check import withNuxt from './.nuxt/eslint.config.mjs' export default withNuxt() ``` **Example File** In `ColorPicker.vue`: ``` vue <script setup lang="ts"> // ... other code ... // ✅ This IS detected by ESLint when running `pnpm lint:fix` const aVar = 'pol' as any // Line 119 </script> <template> <div> <!-- ... other template code ... --> <!-- ❌ This is NOT detected by ESLint when running `pnpm lint:fix` --> <div class="ml-3 block h-full w-28 rounded-full sm:w-36" :class="optionValue(option as any) ? '' : 'border'" <!-- Line 188 --> > &nbsp; </div> </div> </template> ``` ## Steps to Reproduce 1. Create a Vue component with TypeScript 2. Add as any type assertion in the <script> section 3. Add as any type assertion in the <template> section (e.g., in a binding expression) 4. Run pnpm lint:fix or eslint . 5. Observe that only the script violation is caught ## 🤔 Expected Behavior ESLint should enforce TypeScript rules (like @typescript-eslint/no-explicit-any) in both <script> and <template> sections of Vue SFC files. ## 📊 Current Behavior - TypeScript ESLint rules work in <script> tags ✅ - TypeScript ESLint rules are ignored in <template> tags ❌ ### Describe the bug ## 🐛 Bug Report ESLint rules are not being enforced in Vue template sections, while they work correctly in <script> tags. Specifically, the `@typescript-eslint/no-explicit-any` rule (or similar TypeScript rules) is not catching violations in template expressions. ### Additional context ## ❓ Questions - Is this expected behavior, or is there additional configuration needed to enable TypeScript linting in Vue templates? - Should I configure something specific in eslint.config.mjs, and/or nuxt.config.ts, to enable template expression linting? - Are there any known limitations with the flat config format and Vue template linting?, ### Logs ```shell-script ```
0 条评论