astro/prefer-object-class-list
require use object instead of ternary expression 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 object elements than ternary expression in class:list
.
---
/* eslint astro/prefer-object-class-list: "error" */
---
{/* ✓ GOOD */}
<div class:list={["a", { b: num > 0, c }]}></div>
{/* ✗ BAD */}
<div class:list={"a " + (num > 0 ? 'b' : '') + ' ' + (c ? 'c' : '')}></div>
<div class:list={`a ${num > 0 ? 'b' : ''} ${c ? 'c' : ''}`}></div>
🔧 Options
Nothing.
👫 Related Rules
📚 Further Reading
🚀 Version
This rule was introduced in eslint-plugin-astro v0.4.0
🔍 Implementation
Edit this page
Back
← astro/prefer-class-list-directive Next Page
astro/prefer-split-class-list →
← astro/prefer-class-list-directive Next Page
astro/prefer-split-class-list →