vue/no-content-outside-block
eslint-plugin-vue
Suggestion
eslint.config.js
import vue from "eslint-plugin-vue";
export default [
{
plugins: { vue },
rules: {
"vue/no-content-outside-block": "error",
},
},
];<template>
<div>Hello</div>
</template>
console.log('this never runs')
<script>
console.log('this runs')
</script>
hello world<template>
<div>Hello</div>
</template>
<script>
console.log('this runs')
</script>
<docs>
Custom blocks are not reported.
</docs>Examples from the ESLint documentation.
No tracked preset enables this rule, so it has no reach yet.
None of the tracked presets enable this rule. Turn it on with the config below.
vue/no-content-outside-block
eslint-plugin-vue
import vue from "eslint-plugin-vue";
export default [
{
plugins: { vue },
rules: {
"vue/no-content-outside-block": "error",
},
},
];Oxlint does not have this rule.
nursery/noVueContentOutsideBlock
nursery · since 2.6.10
{
"linter": {
"rules": {
"nursery": {
"noVueContentOutsideBlock": "error"
}
}
}
}Disallow constant expressions in conditions in <template>
Disallow shorthand type conversions in <template>
Require component name property to match its file name
Disallow passing multiple objects in an array to class