Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/dark-bees-crash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"stylelint": minor
---

Fixed: `shorthand-property-no-redundant-values` false negatives for additional radius
132 changes: 127 additions & 5 deletions lib/rules/shorthand-property-no-redundant-values/__tests__/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,19 @@ testRule({
},
{
code: 'a { border-radius: 1px / 1px; }',
description: 'ignore ellipse',
},
{
code: 'a { border-radius: 1px 1px / 1px; }',
description: 'ignore ellipse',
},
{
code: 'a { margin: var(--margin) var(--margin); }',
description: 'ignore variables',
},
{
code: 'a { border-radius: var(--foo) var(--foo) / var(--foo) var(--foo); }',
description: 'ignore variables with slash in shorthand',
},
{
code: 'a { border-radius: 1px 1px , 1px 1px; }',
description: 'ignore invalid divider in border-radius (comma)',
},
{
code: 'a { border-color: #FFFFFF transparent transparent; }',
description: 'ignore upper case value',
Expand Down Expand Up @@ -587,6 +590,125 @@ testRule({
endLine: 1,
endColumn: 62,
},
{
code: 'a { border-radius: 1px 1px / 1px; }',
fixed: 'a { border-radius: 1px / 1px; }',
fix: {
range: [23, 27],
text: '',
},
message: messages.expected('1px 1px / 1px', '1px / 1px'),
line: 1,
column: 20,
endLine: 1,
endColumn: 33,
},
{
code: 'a { border-radius: 1px 1px 1px 1px / 2px 2px 2px 2px; }',
fixed: 'a { border-radius: 1px / 2px; }',
fix: {
range: [23, 48],
text: '/',
},
message: messages.expected('1px 1px 1px 1px / 2px 2px 2px 2px', '1px / 2px'),
line: 1,
column: 20,
endLine: 1,
endColumn: 53,
},
{
code: 'a { border-radius: 1px 1px 1px 1px / 2px; }',
fixed: 'a { border-radius: 1px / 2px; }',
description: 'Horizontal side redundant - vertical already shortest',
fix: {
range: [23, 35],
text: '',
},
message: messages.expected('1px 1px 1px 1px / 2px', '1px / 2px'),
line: 1,
column: 20,
endLine: 1,
endColumn: 41,
},
{
code: 'a { border-radius: 1px 2px / 2px 2px 2px 2px; }',
fixed: 'a { border-radius: 1px 2px / 2px; }',
description: 'Vertical side redundant - horizontal mixed',
fix: {
range: [32, 44],
text: '',
},
message: messages.expected('1px 2px / 2px 2px 2px 2px', '1px 2px / 2px'),
line: 1,
column: 20,
endLine: 1,
endColumn: 45,
},
{
code: 'a { border-radius: calc(1px + 1px) calc(1px + 1px) / calc(1px + 1px) calc(1px + 1px); }',
fixed: 'a { border-radius: calc(1px + 1px) / calc(1px + 1px); }',
description: 'slash with value functions',
fix: {
range: [35, 68],
text: '/',
},
message: messages.expected(
'calc(1px + 1px) calc(1px + 1px) / calc(1px + 1px) calc(1px + 1px)',
'calc(1px + 1px) / calc(1px + 1px)',
),
line: 1,
column: 20,
endLine: 1,
endColumn: 85,
},
{
code: 'a { border-radius: 1px 1px / calc(1px + 1px) calc(1px + 1px); }',
fixed: 'a { border-radius: 1px / calc(1px + 1px); }',
description: 'slash with value words and value functions',
fix: {
range: [23, 44],
text: '/',
},
message: messages.expected(
'1px 1px / calc(1px + 1px) calc(1px + 1px)',
'1px / calc(1px + 1px)',
),
line: 1,
column: 20,
endLine: 1,
endColumn: 61,
},
{
code: 'a { border-radius: 1px 1px / var(--foo) var(--foo); }',
fixed: 'a { border-radius: 1px / var(--foo) var(--foo); }',
description: 'slash with value words and variable functions',
fix: {
range: [23, 27],
text: '',
},
message: messages.expected('1px 1px / var(--foo) var(--foo)', '1px / var(--foo) var(--foo)'),
line: 1,
column: 20,
endLine: 1,
endColumn: 51,
},
{
code: 'a { border-radius: var(--foo) var(--foo) / calc(1px + 1px) calc(1px + 1px); }',
fixed: 'a { border-radius: var(--foo) var(--foo) / calc(1px + 1px); }',
description: 'slash with value functions and variable functions',
fix: {
range: [58, 74],
text: '',
},
message: messages.expected(
'var(--foo) var(--foo) / calc(1px + 1px) calc(1px + 1px)',
'var(--foo) var(--foo) / calc(1px + 1px)',
),
line: 1,
column: 20,
endLine: 1,
endColumn: 75,
},
],
});

Expand Down
132 changes: 132 additions & 0 deletions lib/rules/shorthand-property-no-redundant-values/index.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading