-
Notifications
You must be signed in to change notification settings - Fork 74
Open
Labels
Description
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: [email protected]
- Builder: -
- User Config: compatibilityDate, devtools, runtimeConfig, site, sitemap, app, css, plugins, modules, image, build, googleFonts, tailwindcss, vite, ignore, routeRules
- Runtime Modules: @nuxt/[email protected], @nuxt/[email protected], @nuxt/[email protected], @nuxtjs/[email protected], @nuxtjs/[email protected], @nuxtjs/[email protected], @pinia/[email protected], @vueuse/[email protected]
- 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 -->
>
</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 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?