Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix declaration-block-no-redundant-longhand-properties autofix for border-width shorthand #6956

Merged
merged 1 commit into from Jun 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/sixty-lies-repair.md
@@ -0,0 +1,5 @@
---
"stylelint": patch
---

Fixed: `declaration-block-no-redundant-longhand-properties` autofix for `border-width` shorthand
2 changes: 1 addition & 1 deletion lib/reference/properties.js
Expand Up @@ -180,9 +180,9 @@ const longhandSubPropertiesOfShorthandProperties = new Map([
new Set([
// prettier-ignore
'border-top-width',
'border-right-width',
'border-bottom-width',
'border-left-width',
'border-right-width',
]),
],
[
Expand Down
Expand Up @@ -206,6 +206,12 @@ testRule({
description: 'autofixer should not mangle css functions with comma separated values',
message: messages.expected('transition'),
},
{
code: 'a { border-top-width: 0px; border-right-width: 1px; border-bottom-width: 2px; border-left-width: 3px; }',
fixed: 'a { border-width: 0px 1px 2px 3px; }',
description: 'explicit border-width test',
message: messages.expected('border-width'),
},
],
Copy link
Contributor

@Mouvedia Mouvedia Jun 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add an example for margin or border-width or padding for top | left/right | bottom.
If if it's not supported yet add skip: true,.
i.e. no need to do it in the same PR

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, a bit confused -- what do you mean by top | left/right | bottom? Do you mean when all four are specified, or when some of the values are inferred/collapsed? The latter isn't covered by this rule.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The latter isn't covered by this rule.

That's why I was proposing to add skip: true for now.
It could be an enhancement; it's expected by users.
cf #6947

});

Expand Down