eslint-plugin-vue icon indicating copy to clipboard operation
eslint-plugin-vue copied to clipboard

vue/block-lang with `"lang": "ts"` is skipped when script tag is omitted

Open johannes-lindgren opened this issue 8 months ago • 0 comments

The vue/block-lang rule says

disallow use other than available lang

However, the rule doesn't perform a check if the script tag is missing.

It also says:

This rule disallows the use of languages other than those available in the your application for the lang attribute of block elements.

Which could imply that the check shouldn't be performed if the script tag is omitted. However, then the rule is not fulfilling its purpose, which is to force TypeScript (or another language) in all Vue SFCs.

I am using TypeScript with

  • tsconfig.json > vueCompilerOptions.strictTemplates: true
  • @typescript-eslint

And so I want linting and type checking in all templates. This only happens if I specify <script lang="ts"> in all my .vue files. But my team is able to circumvent this in some components where the <script> tag is not otherwise needed.

Checklist

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

Tell us about your environment

  • ESLint version: 9.12.0
  • eslint-plugin-vue version: 10.1.1
  • Vue version: 3.5.13
  • Node version: 22.9.0
  • Operating System: MacOS

Please show your full configuration:

Simplified version:

export default tseslint.config(
  {
    rules: {
      'vue/block-lang': [
        'error',
        {
          script: {
            lang: 'ts',
          },
        },
      ],
  }
}

What did you do?

<template>
  <div>
</template>

What did you expect to happen? An ESLint error, because I am not using lang="ts"

What actually happened? There was no ESLint error

Repository to reproduce this issue https://github.com/johannes-lindgren/eslint-plugin-vue_issue_block-lang

johannes-lindgren avatar Mar 21 '25 11:03 johannes-lindgren