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 #6947

Closed
timkuehnlein opened this issue Jun 21, 2023 · 3 comments · Fixed by #6956
Closed
Labels
status: wip is being worked on by someone type: bug a problem with a feature or rule

Comments

@timkuehnlein
Copy link

What steps are needed to reproduce the bug?

This syntax will raise the warning Expected shorthand property "border-width" (declaration-block-no-redundant-longhand-properties)Stylelint[declaration-block-no-redundant-longhand-properties](https://stylelint.io/user-guide/rules/declaration-block-no-redundant-longhand-properties).

div {
    border-top-width: 0px;
    border-right-width: 1px;
    border-bottom-width: 2px;
    border-left-width: 3px;
}

It will be fixed to the following code. (The order of the original items is not relevant.)

div {
    border-width: 0 2px 3px 1px;
}

If two values should be combined, this leads to the same error:

div {
    border-top-width: 0px;
    border-right-width: 1px;
    border-bottom-width: 2px;
    border-left-width: 1px;
}

becomes:

div {
    border-width: 0 2px 1px 1px;
}

What Stylelint configuration is needed to reproduce the bug?

{
"extends": [
"stylelint-config-standard"
]
}

How did you run Stylelint?

Stylelint demo

Which version of Stylelint or dependencies are you using?

stylelint@15.8.0
stylelint-config-standard@33.0.0

What did you expect to happen?

div {
    border-top-width: 0px;
    border-right-width: 1px;
    border-bottom-width: 2px;
    border-left-width: 3px;
}

Should become:

div {
    border-width: 0 1px 2px 3px;
}

If two values should be combined, this leads to the same error:

div {
    border-top-width: 0px;
    border-right-width: 1px;
    border-bottom-width: 2px;
    border-left-width: 1px;
}

Should become:

div {
    border-width: 0 1px 2px;
}

What actually happened?

div {
    border-top-width: 0px;
    border-right-width: 1px;
    border-bottom-width: 2px;
    border-left-width: 3px;
}

Wrongly becomes:

div {
    border-width: 0 2px 3px 1px;
}

If two values should be combined, this leads to the same error:

div {
    border-top-width: 0px;
    border-right-width: 1px;
    border-bottom-width: 2px;
    border-left-width: 1px;
}

Wrongly becomes:

div {
    border-width: 0 2px 1px 1px;
}

Does the bug relate to non-standard syntax?

No response

Proposal to fix the bug

No response

@ybiquitous ybiquitous added status: ready to implement is ready to be worked on by someone type: bug a problem with a feature or rule labels Jun 21, 2023
@ybiquitous
Copy link
Member

@timkuehnlein Thanks for the report with reproducible examples! I can reproduce the bug with this demo. 👍🏼

I've labeled the issue as ready to implement. Please consider contributing if you have time.

There are steps on how to fix a bug in a rule in the Developer guide.

@ybiquitous ybiquitous changed the title border-width shorthand fix breaks CSS Fix declaration-block-no-redundant-longhand-properties autofix for border-width shorthand Jun 21, 2023
@mattxwang
Copy link
Member

@timkuehnlein a PR is welcome, but I will also likely add this to my own personal backlog of autofix issues to resolve. Let us know either way!

@Mouvedia
Copy link
Contributor

If the autofix really does top | bottom | left | right instead of top | right | bottom | left this is a major bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: wip is being worked on by someone type: bug a problem with a feature or rule
4 participants