astro/prefer-split-class-list
require use split array elements in
class:list
- 🔧 The
--fix
option on the command line can automatically fix some of the problems reported by this rule.
📖 Rule Details
This rule aims to use split array elements than string concatenation in class:list
.
---
/* eslint astro/prefer-split-class-list: "error" */
import clsx from "clsx"
---
{/* ✓ GOOD */}
<div class:list={["a", "b", c]}></div>
{/* ✗ BAD */}
<div class:list={"a b " + c}></div>
<div class:list={`a ${b} c`}></div>
<div class:list={clsx(["a", "b", c])}></div>
🔧 Options
{
"astro/prefer-split-class-list": [
"error",
{
"splitLiteral": false // or true
}
]
}
splitLiteral
… Iftrue
, it will also split string literals separated by whitespace. Default isfalse
.
👫 Related Rules
📚 Further Reading
🚀 Version
This rule was introduced in eslint-plugin-astro v0.4.0
🔍 Implementation
Edit this page
Back
← astro/prefer-object-class-list Next Page
astro/sort-attributes →
← astro/prefer-object-class-list Next Page
astro/sort-attributes →