This rule reports a length with a unit that your project forbids for the
property, such as px for width. Zero lengths are not reported, because they
need no unit. The rule is off until you list properties and units.
Configuration
{
"lint": {
"rules": {
"no-restricted-length-units": {
"severity": "warn",
"rules": [
{
"properties": ["width"],
"disallow": ["px"]
}
]
}
}
}
}Reported
style("w-[20px]");no-restricted-length-units: unit `px` is forbidden for `width`Fixed
style("w-5");How to fix
Write the same size with an allowed unit. With the default --spacing of
0.25rem, w-5 is 1.25rem, which is 20px at the default font size, as in the
example.
Options
rules lists entries with properties patterns and the units to disallow.
When several entries match a property, the last one applies, so a later, more
specific entry can make an exception.
Rule settings
| Preset | Severity |
|---|---|
recommended | off |
strict | off |
stylistic | off |
| Option | Default |
|---|---|
checkImplementation | false |
rules | [] |
Configure lint to change the severity or options.