From b900c7b5b310fedfa96ca1ee79f80a84f28ea1ff Mon Sep 17 00:00:00 2001 From: Matthew Wang Date: Thu, 22 Jun 2023 11:09:12 -0700 Subject: [PATCH] Fix `declaration-block-no-redundant-longhand-properties` autofix for `border-width` shorthand --- .changeset/sixty-lies-repair.md | 5 +++++ lib/reference/properties.js | 2 +- .../__tests__/index.js | 6 ++++++ 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 .changeset/sixty-lies-repair.md diff --git a/.changeset/sixty-lies-repair.md b/.changeset/sixty-lies-repair.md new file mode 100644 index 0000000000..097422549a --- /dev/null +++ b/.changeset/sixty-lies-repair.md @@ -0,0 +1,5 @@ +--- +"stylelint": patch +--- + +Fixed: `declaration-block-no-redundant-longhand-properties` autofix for `border-width` shorthand diff --git a/lib/reference/properties.js b/lib/reference/properties.js index c873b8f8c7..b0eb13b963 100644 --- a/lib/reference/properties.js +++ b/lib/reference/properties.js @@ -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', ]), ], [ diff --git a/lib/rules/declaration-block-no-redundant-longhand-properties/__tests__/index.js b/lib/rules/declaration-block-no-redundant-longhand-properties/__tests__/index.js index 740fb7c7dd..5724525e42 100644 --- a/lib/rules/declaration-block-no-redundant-longhand-properties/__tests__/index.js +++ b/lib/rules/declaration-block-no-redundant-longhand-properties/__tests__/index.js @@ -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'), + }, ], });