vue/no-src-attribute
Discourage src attribute on SFC blocks
Default severity: warning
Presets: nuxt, opinionated
Automatic fix: None; review the suggested change
Applies to: Vue SFC templates and blocks, with script context where the rule requires it
Options: No rule-specific options. Severity and preset selection are configurable.
Configuration (Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({
lint: {
vize: {
"preset": "incremental",
"rules": {
"vue/no-src-attribute": "warn"
}
},
},
});
vp run lint
Bad
The SFC blocks delegate their template, script, and style content to src files.
<template src="./template.html"></template>
<script src="./script.ts"></script>
<style src="./style.css"></style>
Good
Each SFC block contains its own content without an external src attribute.
<template>
<p>Hello</p>
</template>
<script setup lang="ts">
const label = "Hello";
</script>
<style scoped>
p {
color: red;
}
</style>
Good avoids this rule's finding under the configuration above; other rules may still report diagnostics.