Skip to content

Commit

Permalink
Fix declaration-block-no-shorthand-property-overrides false negativ…
Browse files Browse the repository at this point in the history
…es for `border` (#7585)

Co-authored-by: Masafumi Koba <473530+ybiquitous@users.noreply.github.com>
  • Loading branch information
fpetrakov and ybiquitous committed Mar 30, 2024
1 parent a5965a0 commit e872ac1
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/mighty-cows-behave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"stylelint": minor
---

Fixed: `declaration-block-no-shorthand-property-overrides` false negatives for `border`
3 changes: 3 additions & 0 deletions lib/reference/properties.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ const longhandSubPropertiesOfShorthandProperties = new Map([
'border-right-color',
'border-bottom-color',
'border-left-color',
'border-width',
'border-style',
'border-color',
]),
],
[
Expand Down
3 changes: 3 additions & 0 deletions lib/reference/properties.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ export const longhandSubPropertiesOfShorthandProperties = new Map([
'border-right-color',
'border-bottom-color',
'border-left-color',
'border-width',
'border-style',
'border-color',
]),
],
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ testRule({
{
code: 'a { transition-property: opacity; -webkit-transition: opacity 1s linear; }',
},
{
code: 'a { border-block: 1px solid; border: 20px dashed black; }',
},
{
code: 'a { border-block-end: 1px solid; border: 20px dashed black; }',
},
{
code: 'a { border-block-start: 1px solid; border: 20px dashed black; }',
},
],

reject: [
Expand All @@ -47,6 +56,30 @@ testRule({
endLine: 1,
endColumn: 32,
},
{
code: 'a { border-width: 20px; border: 1px solid black; }',
message: messages.rejected('border', 'border-width'),
line: 1,
column: 25,
endLine: 1,
endColumn: 31,
},
{
code: 'a { border-color: red; border: 1px solid black; }',
message: messages.rejected('border', 'border-color'),
line: 1,
column: 24,
endLine: 1,
endColumn: 30,
},
{
code: 'a { border-style: dotted; border: 1px solid black; }',
message: messages.rejected('border', 'border-style'),
line: 1,
column: 27,
endLine: 1,
endColumn: 33,
},
{
code: 'a { pAdDiNg-lEfT: 10Px; pAdDiNg: 20Px; }',
message: messages.rejected('pAdDiNg', 'pAdDiNg-lEfT'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ const rule = (primary) => {
properties.longhandSubPropertiesOfShorthandProperties
).get(unprefixedProp);

if (!overrideables) {
declarations.set(prop.toLowerCase(), prop);
declarations.set(prop.toLowerCase(), prop);

if (!overrideables) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ const rule = (primary) => {
longhandSubPropertiesOfShorthandProperties
).get(unprefixedProp);

if (!overrideables) {
declarations.set(prop.toLowerCase(), prop);
declarations.set(prop.toLowerCase(), prop);

if (!overrideables) {
return;
}

Expand Down

0 comments on commit e872ac1

Please sign in to comment.