vue/no-src-attribute
Discourage src attribute on SFC blocks.
| Default severity | Presets | Automatic fix | Options |
|---|---|---|---|
warning |
nuxt, opinionated |
No | None |
Applies to: Vue SFC templates and blocks, with script context where the rule requires it.
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>
Configuration (Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({}).withVue({
linter: {
"preset": "incremental",
"rules": {
"vue/no-src-attribute": "warn"
}
},
});
Then run vp run lint.