JS.VUE.BLOCK.LANG

Do not use languages other than those available in your application for the lang attribute of block elements

Rule Details

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

Options

Copy
{
  "vue/block-lang": ["error",
    {
      "script": {
        "lang": "ts"
      }
    }
  ]
}

{'vue/block-lang': ['error', { script: { lang: 'ts' } }]}

Copy
<!-- GOOD -->
<script lang="ts">
</script>

{'vue/block-lang': ['error', { script: { lang: 'ts' } }]}

Copy
<!-- BAD -->
<script>
</script>

Specify the block name for the key of the option object.
You can use the object as a value and use the following properties:

  • lang ... Specifies the available value for the lang attribute of the block. If multiple languages are available, specify them as an array. If you do not specify it, will disallow any language.
  • allowNoLang ... If true, allows the lang attribute not to be specified (allows the use of the default language of block).

If the default language is specified for lang option of <template>, <style> and <script>, it will be enforced to not specify lang attribute.
This is to prevent unintended problems with Vetur (https://vuejs.github.io/vetur/).

See also Vetur - Syntax Highlighting (https://vuejs.github.io/vetur/guide/highlighting.html).

{ script: { lang: 'js' } }

Same as { script: { allowNoLang: true } }.

{'vue/block-lang': ['error', { script: { lang: 'js' } }]}

Copy
<!-- GOOD -->
<script>
</script>

{'vue/block-lang': ['error', { script: { lang: 'js' } }]}

Copy
<!-- BAD -->
<script lang="js">
</script>

The content on this page is adapted from the ESLint User Guide. Copyright © OpenJS Foundation and other contributors, www.openjsf.org. All rights reserved. https://eslint.org/docs/rules/