Skip to content

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

Open
@johannes-lindgren

Description

@johannes-lindgren

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

  • I have tried restarting my IDE and the issue persists.
  • 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions