css/prefer-slotted
Recommend ::v-slotted() for styling slot content.
| Default severity | Presets | Automatic fix | Options |
|---|---|---|---|
warning |
opinionated, nuxt |
No | None |
Applies to: Plain CSS style blocks (scss, sass, less and stylus blocks are skipped).
Bad
The scoped stylesheet targets the slot outlet rather than the elements supplied through the slot.
<style scoped>
slot { color: red; }
</style>
Good
:slotted(.label) targets the supplied label element through the scoped slot selector.
<style scoped>
:slotted(.label) { color: red; }
</style>
Configuration (Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({}).withVue({
linter: {
"preset": "incremental",
"rules": {
"css/prefer-slotted": "warn"
}
},
});
Then run vp run lint.