# svelte/block-lang
disallows the use of languages other than those specified in the configuration for the lang attribute of
<script>
and<style>
blocks.
# 📖 Rule Details
This rule enforces all svelte components to use the same set of languages for their scripts and styles.
<!-- ✓ GOOD -->
<script lang="ts">
/* eslint svelte/block-lang: ["error", { "script": "ts" }] */
</script>
<!-- ✓ GOOD -->
<script>
/* eslint svelte/block-lang: ["error", { "script": ["ts", null], "style": "scss" }] */
</script>
<style lang="scss">
</style>
<!-- ✗ BAD -->
<script>
/* eslint svelte/block-lang: ["error", { "script": ["ts"] }] */
</script>
# 🔧 Options
{
"svelte/block-lang": [
"error",
{
"enforceScriptPresent": true,
"enforceStylePresent": false,
"script": ["ts", null], // a list of languages or null to signify no language specified
"style": "scss" // same as for script, a single value can be used instead of an array.
}
]
}
enforceScriptPresent
… Whether to enforce the presence of a<script>
block with one of the given languages. This may be useful as for example TypeScript checks some uses of a component if it is defined as being TypeScript. Defaultfalse
.enforceStylePresent
… Whether to enforce the presence of a<style>
block with one of the given languages. Defaultfalse
.script
… A list of languages allowed for the<script>
block. Ifnull
is included, nolang
attribute is also allowed. A plain string ornull
can be used instead of one-item array. Defaultnull
.style
… A list of languages allowed for the<style>
block. Ifnull
is included, nolang
attribute is also allowed. A plain string ornull
can be used instead of one-item array. Defaultnull
.
# 🚀 Version
This rule was introduced in eslint-plugin-svelte v2.18.0