class-spacing

Disallow extra spacing in class attribute values.

This rule aims to maintain consistent spacing in class attribute values by removing unnecessary leading, trailing, and extra spaces between class names.

How to use

.eslintrc.js
module.exports = {
  rules: {
    "@html-eslint/class-spacing": "error",
  },
};

Rule Details

This rule disallows the following:

  1. Leading spaces at the start of class attribute values
  2. Trailing spaces at the end of class attribute values
  3. Multiple consecutive spaces between class names

Examples of incorrect code for this rule:

<div class=" foo"></div>
<div class="foo "></div>
<div class=" foo "></div>
<div class="foo  bar"></div>
<div class="foo   bar"></div>

Examples of correct code for this rule:

<div class="foo"></div>
<div class="foo bar"></div>
<div class="foo bar baz"></div>