# No Property Shorthand Disallow the use of [shorthand properties](https://developer.mozilla.org/en-US/docs/Web/CSS/Shorthand_properties). Shorthand properties set multiple CSS properties at once, which can lead to unintended overrides of previously set values. See [CSS Shorthand Syntax Considered an Anti-Pattern](https://csswizardry.com/2016/12/css-shorthand-syntax-considered-an-anti-pattern/). ```css a { background: red; } /* ↑ * Shorthand property not allowed */ ``` The following are considered violations: ```css a { background: red; } ``` ```css a { border: 1px solid red; } ``` ```css a { font: bold 16px/1.5 sans-serif; } ``` ## Options ### `disallow: Array` Restricts the rule to only flag the specified shorthand properties. When set, all other shorthands are permitted. Accepts exact strings, regular expressions, or strings wrapped in `/` delimiters treated as regular expressions. This is the inverse of `ignore` — instead of listing every shorthand you want to allow, you list only the few you want to forbid. ```json [true, { "disallow": ["font", "animation", "transition"] }] ``` The following are _not_ considered violations when `disallow: ["font", "animation", "transition"]` is set: ```css a { background: red; } ``` ```css a { border: 1px solid red; } ``` The following _are_ still violations: ```css a { font: bold 16px/1.5 sans-serif; } ``` ```css a { animation: foo 1s ease; } ``` `disallow` can be combined with `ignore: ["single-value"]` to additionally exempt single-value declarations from the disallowed set: ```json [true, { "disallow": ["font"], "ignore": ["single-value"] }] ``` ### `ignore: Array` Allows specific shorthand properties or patterns to be used. Accepts exact strings, regular expressions, the special keyword `"single-value"`, or strings wrapped in `/` delimiters (e.g. `"/^border/"`) which are treated as regular expressions — enabling regex patterns in JSON config files. #### `"single-value"` When `"single-value"` is included, shorthand properties with a single value token are allowed. This covers keyword-only values like `inherit` and function calls like `var(--foo)`. ```json [true, { "ignore": ["single-value"] }] ``` The following are _not_ considered violations when `ignore: ["single-value"]` is set: ```css a { font: inherit; } ``` ```css a { margin-inline: var(--my-margin); } ``` The following _is_ still a violation (multiple value tokens): ```css a { font: bold 16px/1.5 sans-serif; } ``` #### Property names and patterns Allows specific shorthand properties by exact name or regular expression. ```json [true, { "ignore": ["background", "/^border-/"] }] ``` The following are _not_ considered violations when `ignore: ["background"]` is set: ```css a { background: red; } ``` Both `"single-value"` and property names can be combined: ```json [true, { "ignore": ["single-value", "background"] }] ``` ## Patterns The following patterns are _not_ considered violations: ```css a { background-color: red; } ``` ```css a { border-width: 1px; border-style: solid; border-color: red; } ``` ## Prior art - stylelint's [`shorthand-property-no-redundant-values`](https://stylelint.io/user-guide/rules/shorthand-property-no-redundant-values) rule