# san/boolean-value
Enforce boolean attributes notation in template
- ⚙️ This rule is included in
"plugin:san/strongly-recommended". - 🔧 The
--fixoption on the command line (opens new window) can automatically fix some of the problems reported by this rule.
# 📖 Rule Details
Enforce boolean attributes notation in template
# 🔧 Options
{
"san/attribute-hyphenation": ["warn", "always" | "never", {
"always" | "never": []
}]
}
This rule takes two arguments. If the first argument is "always" then it warns whenever an attribute is missing its value. If "never" then it warns if an attribute has a true value. The default value of this option is "never".
The second argument is optional: if provided, it must be an object with a "never" property (if the first argument is "always"), or an "always" property (if the first argument is "never"). This property’s value must be an array of strings representing prop names.
# ["warn", "never"] (default)
<template>
<!-- ✓ GOOD -->
<x a on-click="fire('my-event')" />
<!-- ✗ BAD -->
<x a="{{true}}" on-click="fire('myEvent')" />
</template>
# ["warn", "never", {"always": ["c"]}]
<template>
<!-- ✓ GOOD -->
<x a c="{{false}}" on-click="fire('my-event')" />
<x a c="{{true}}" on-click="fire('my-event')" />
<x a="{{false}}" c="{{true}}" on-click="fire('my-event')" />
<!-- ✗ BAD -->
<x a="{{true}}" c="{{true}}" on-click="fire('myEvent')" />
<x a="{{true}}" c="{{false}}" on-click="fire('myEvent')" />
</template>
# ["warn", "always"]
<template>
<!-- ✓ GOOD -->
<x a="{{true}}" on-click="fire('myEvent')" />
<!-- ✗ BAD -->
<x a on-click="fire('my-event')" />
</template>
# ["warn", "always", {"never": ["c"]}]
<template>
<!-- ✓ GOOD -->
<x a="{{true}}" c on-click="fire('myEvent')" />
<!-- ✗ BAD -->
<x a="{{true}}" c="{{true}}" on-click="fire('myEvent')" />
</template>