css/no-v-bind-performance
Warn about performance cost of CSS v-bind().
| 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 stylesheet reads the changing offset through the SFC CSS v-bind() mechanism.
<style scoped>
.card {
transform: translateX(v-bind(offset));
}
</style>
Good
The element receives the changing transform directly through its style binding.
<template>
<article :style="{ transform: `translateX(${offset}px)` }" class="card" />
</template>
Configuration (Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({}).withVue({
linter: {
"preset": "incremental",
"rules": {
"css/no-v-bind-performance": "warn"
}
},
});
Then run vp run lint.