Vize

css/no-v-bind-performance

CSS v-bind() の実行時コストを検討するための警告です。

既定の重大度 プリセット 自動修正 オプション
warning opinionated, nuxt なし なし

適用範囲:プレーン CSS の style ブロック(scss・sass・less・stylus のブロックは対象外)。

悪い例

変化する offset を SFC の CSS の v-bind() で参照しています。

<style scoped>
.card {
  transform: translateX(v-bind(offset));
}
</style>

良い例

変化する transform を要素の style バインディングに直接指定します。

<template>
  <article :style="{ transform: `translateX(${offset}px)` }" class="card" />
</template>

設定(Vite+)

import { defineConfig } from "@vizejs/vite-plugin/vite-plus";

export default defineConfig({}).withVue({
  linter: {
    "preset": "incremental",
    "rules": {
      "css/no-v-bind-performance": "warn"
    }
  },
});

設定したら vp run lint を実行します。

関連ページ