Sha256: 656e20da4d0966d258ac7d43d278de3fcf2648da0ae768f8897265078eb551b0

Contents?: true

Size: 1.48 KB

Versions: 24

Compression:

Stored size: 1.48 KB

Contents

# length-zero-no-unit

Disallow units for zero lengths.

<!-- prettier-ignore -->
```css
a { top: 0px; }
/**      ↑↑
 * This zero and this type of length unit */
```

_Lengths_ refer to distance measurements. A length is a _dimension_, which is a _number_ immediately followed by a _unit identifier_. However, for zero lengths the unit identifier is optional. The length units are: `em`, `ex`, `ch`, `vw`, `vh`, `cm`, `mm`, `in`, `pt`, `pc`, `px`, `rem`, `vmin`, and `vmax`.

This rule ignores lengths within math functions (e.g. `calc`) in favor of the [`function-calc-no-invalid`](../function-calc-no-invalid/README.md) rule.

The [`fix` option](../../../docs/user-guide/usage/options.md#fix) can automatically fix all of the problems reported by this rule.

## Options

### `true`

The following patterns are considered violations:

<!-- prettier-ignore -->
```css
a { top: 0px }
```

<!-- prettier-ignore -->
```css
a { top: 0.000em }
```

The following patterns are _not_ considered violations:

<!-- prettier-ignore -->
```css
a { top: 0 } /* no unit */
```

<!-- prettier-ignore -->
```css
a { transition-delay: 0s; } /* dimension */
```

<!-- prettier-ignore -->
```css
a { top: 2in; }
```

<!-- prettier-ignore -->
```css
a { top: 1.001vh }
```

## Optional secondary options

### `ignore: ["custom-properties"]`

#### `"custom-properties"`

Ignore units for zero length in custom properties.

The following pattern is _not_ considered a violation:

<!-- prettier-ignore -->
```css
a { --x: 0px; }
```

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
trusty-cms-6.3.1 node_modules/stylelint/lib/rules/length-zero-no-unit/README.md
trusty-cms-5.0.7 node_modules/stylelint/lib/rules/length-zero-no-unit/README.md
trusty-cms-5.0.6 node_modules/stylelint/lib/rules/length-zero-no-unit/README.md
trusty-cms-5.0.5 node_modules/stylelint/lib/rules/length-zero-no-unit/README.md
trusty-cms-5.0.4 node_modules/stylelint/lib/rules/length-zero-no-unit/README.md
trusty-cms-5.0.3 node_modules/stylelint/lib/rules/length-zero-no-unit/README.md
trusty-cms-5.0.2 node_modules/stylelint/lib/rules/length-zero-no-unit/README.md
trusty-cms-5.0.1 node_modules/stylelint/lib/rules/length-zero-no-unit/README.md
trusty-cms-4.3.5 node_modules/stylelint/lib/rules/length-zero-no-unit/README.md
trusty-cms-5.0.0 node_modules/stylelint/lib/rules/length-zero-no-unit/README.md
trusty-cms-4.3.4 node_modules/stylelint/lib/rules/length-zero-no-unit/README.md
trusty-cms-4.3.3 node_modules/stylelint/lib/rules/length-zero-no-unit/README.md
trusty-cms-4.3.2 node_modules/stylelint/lib/rules/length-zero-no-unit/README.md
trusty-cms-4.3.1 node_modules/stylelint/lib/rules/length-zero-no-unit/README.md
trusty-cms-4.3 node_modules/stylelint/lib/rules/length-zero-no-unit/README.md
trusty-cms-4.2.3 node_modules/stylelint/lib/rules/length-zero-no-unit/README.md
trusty-cms-4.2.2 node_modules/stylelint/lib/rules/length-zero-no-unit/README.md
trusty-cms-4.2.1 node_modules/stylelint/lib/rules/length-zero-no-unit/README.md
trusty-cms-4.2 node_modules/stylelint/lib/rules/length-zero-no-unit/README.md
trusty-cms-4.1.9 node_modules/stylelint/lib/rules/length-zero-no-unit/README.md