Maurici Abad
Maurici Abad

Reputation: 1728

How to enforce lang="ts" in script tags with an ESLint rule in Vue

I'm looking for a way to enforce that everyone working on our code base use TypeScript for Single File Components. All the components use TypeScript, so disabling JavaScript is also an option.

I thought that this could be done with an ESLint rule, but I can’t find it.

Upvotes: 2

Views: 1941

Answers (1)

Script_Coded
Script_Coded

Reputation: 710

This feature is now available in eslint-plugin-vue. Use the vue/block-lang rule.

// .eslintrc.json
{
  "vue/block-lang": ["error",
    {
      "script": {
        "lang": "ts"
      }
    }
  ]
}

https://eslint.vuejs.org/rules/block-lang.html#vue-block-lang

Upvotes: 8

Related Questions