stylelint: declaration-block-no-redundant-longhand-properties
Ref: https://github.com/CSSLint/csslint/wiki/Require-shorthand-properties Ref: https://github.com/CSSLint/csslint/issues/668
I don’t know best name for rule 😄
Throw error if we use all 4 values, also throw errors if we use top and left, top and left and right. Example:
a {
padding-top: 1px;
padding-right: 2px;
padding-bottom: 3px;
padding-left: 4px; /* Throw error, need `padding: 1px 2px 3px 4px;` */
}
a {
padding-top: 5px;
padding-right: 5px;
padding-bottom: 5px; /* Throw error, need `padding: 1px 2px 3px;` */
}
a {
padding-top: 5px;
padding-right: 5px; /* Throw error, need `padding: 1px 2px;` */
}
Also add option minProperties(maybe rename) to control how many properties throw errors.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 19 (19 by maintainers)
@jeddy3 for compat with
csslintwe should add optionignoreProperties, becausecsslintsupport this only forpaddingandmarginPhew, I’m glad we got there in the end 😃 @davidtheclark Thanks for helping to clarify!
declaration-block-no-redundant-longhand-properties?declaration-blockbecause, likedeclaration-block-no-duplicate-properties,declaration-block-no-ignored-propertiesanddeclaration-block-no-shorthand-property-override, it’s scoped to declaration blocks.redundantbecause that’s aligned withshorthand-property-no-redundant-values.longhand-properties, well, because that’s the thing that’s redundant.I guess all the shorthand properties ought to be caught by this rule (e.g.
font,borderetc), rather than justmarginandpadding.Ha, I know what you mean. The implicit setting of values by shorthand properties can be a killer. including for properties like
font. Anyhow, lets create a separate issue for that discussion though 😃Ha, no problem! I think that quality of shorthand properties stands out to me because it’s bitten me so many times.