Vize

ecosystem/tailwind-no-unnecessary-whitespace

Tailwind CSS のクラスリストにある不要な空白を検出します。

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

適用範囲:Vue SFC のテンプレートと各ブロック。ルールに必要な script の文脈も例に含めています。

悪い例

class の値が空白で始まって空白で終わり、2 つのクラスの間に空白が 2 つあります。

<template>
  <div class=" flex  items-center ">Tailwind</div>
</template>

良い例

クラスの間を 1 つの空白で区切り、値の先頭と末尾には空白を置きません。

<template>
  <div class="flex items-center">Tailwind</div>
</template>

設定(Vite+)

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

export default defineConfig({}).withVue({
  linter: {
    "preset": "incremental",
    "rules": {
      "ecosystem/tailwind-no-unnecessary-whitespace": "warn"
    }
  },
});

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

関連ページ