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 false negatives for overflow, overscroll-behavior, scroll-margin, scroll-padding, and new Box Alignment shorthands #7213

Merged
merged 6 commits into from
Oct 7, 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/thirty-spiders-dance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"stylelint": patch
---

Fixed: `declaration-block-no-redundant-longhand-properties` false negatives for `overflow`, `overscroll-behavior`, `scroll-margin`, `scroll-padding`, and new Box Alignment shorthands
68 changes: 68 additions & 0 deletions lib/reference/properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,14 @@ const longhandSubPropertiesOfShorthandProperties = new Map([
'font-family',
]),
],
[
'gap',
new Set([
// prettier-ignore
'row-gap',
'column-gap',
]),
],
[
'grid',
new Set([
Expand Down Expand Up @@ -391,6 +399,22 @@ const longhandSubPropertiesOfShorthandProperties = new Map([
'outline-width',
]),
],
[
'overflow',
new Set([
// prettier-ignore
'overflow-x',
'overflow-y',
]),
],
[
'overscroll-behavior',
new Set([
// prettier-ignore
'overscroll-behavior-x',
'overscroll-behavior-y',
]),
],
[
'padding',
new Set([
Expand All @@ -417,6 +441,40 @@ const longhandSubPropertiesOfShorthandProperties = new Map([
'padding-inline-end',
]),
],
[
'place-content',
new Set([
// prettier-ignore
'align-content',
'justify-content',
]),
],
[
'place-items',
new Set([
// prettier-ignore
'align-items',
'justify-items',
]),
],
[
'place-self',
new Set([
// prettier-ignore
'align-self',
'justify-self',
]),
],
[
'scroll-margin',
new Set([
// prettier-ignore
'scroll-margin-top',
'scroll-margin-right',
'scroll-margin-bottom',
'scroll-margin-left',
]),
],
[
'scroll-margin-block',
new Set([
Expand All @@ -433,6 +491,16 @@ const longhandSubPropertiesOfShorthandProperties = new Map([
'scroll-margin-inline-end',
]),
],
[
'scroll-padding',
new Set([
// prettier-ignore
'scroll-padding-top',
'scroll-padding-right',
'scroll-padding-bottom',
'scroll-padding-left',
]),
],
[
'scroll-padding-block',
new Set([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ This rule complains when the following shorthand properties can be used:
- `flex`
- `flex-flow`
- `font`
- `gap`
- `grid`
- `grid-area`
- `grid-column`
Expand All @@ -64,11 +65,18 @@ This rule complains when the following shorthand properties can be used:
- `margin-inline`
- `mask`
- `outline`
- `overflow`
- `overscroll-behavior`
- `padding`
- `padding-block`
- `padding-inline`
- `place-content`
- `place-items`
- `place-self`
- `scroll-margin`
- `scroll-margin-block`
- `scroll-margin-inline`
- `scroll-padding`
- `scroll-padding-block`
- `scroll-padding-inline`
- `text-decoration`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ testRule({

reject: [
{
code: 'a { margin-left: 10px; margin-right: 10px; margin-top: 20px; margin-bottom: 30px; }',
fixed: 'a { margin: 20px 10px 30px 10px; }',
code: 'a { margin-left: 40px; margin-right: 10px; margin-top: 20px; margin-bottom: 30px; }',
fixed: 'a { margin: 20px 10px 30px 40px; }',
message: messages.expected('margin'),
line: 1,
column: 62,
Expand Down Expand Up @@ -301,6 +301,54 @@ testRule({
description: 'explicit border-inline test',
message: messages.expected('border-inline'),
},
{
code: 'div { overflow-y: visible; overflow-x: hidden; }',
fixed: 'div { overflow: hidden visible; }',
description: 'explicit overflow test',
message: messages.expected('overflow'),
},
{
code: 'div { overscroll-behavior-y: contain; overscroll-behavior-x: auto; }',
fixed: 'div { overscroll-behavior: auto contain; }',
description: 'explicit overscroll-behavior test',
message: messages.expected('overscroll-behavior'),
},
{
code: 'div { column-gap: 20px; row-gap: 10px; }',
fixed: 'div { gap: 10px 20px; }',
description: 'explicit gap test',
message: messages.expected('gap'),
},
{
code: 'div { justify-content: center; align-content: end; }',
fixed: 'div { place-content: end center; }',
description: 'explicit place-content test',
message: messages.expected('place-content'),
},
{
code: 'div { justify-items: center; align-items: end; }',
fixed: 'div { place-items: end center; }',
description: 'explicit place-items test',
message: messages.expected('place-items'),
},
{
code: 'div { justify-self: center; align-self: end; }',
fixed: 'div { place-self: end center; }',
description: 'explicit place-self test',
message: messages.expected('place-self'),
},
{
code: 'a { scroll-margin-left: 40px; scroll-margin-right: 10px; scroll-margin-top: 20px; scroll-margin-bottom: 30px; }',
fixed: 'a { scroll-margin: 20px 10px 30px 40px; }',
description: 'explicit scroll-margin test',
message: messages.expected('scroll-margin'),
},
{
code: 'a { scroll-padding-left: 40px; scroll-padding-right: 10px; scroll-padding-top: 20px; scroll-padding-bottom: 30px; }',
fixed: 'a { scroll-padding: 20px 10px 30px 40px; }',
description: 'explicit scroll-padding test',
message: messages.expected('scroll-padding'),
},
],
});

Expand Down
8 changes: 8 additions & 0 deletions types/stylelint/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@ declare namespace stylelint {
| 'flex'
| 'flex-flow'
| 'font'
| 'gap'
| 'grid'
| 'grid-area'
| 'grid-column'
Expand All @@ -477,11 +478,18 @@ declare namespace stylelint {
| 'margin-inline'
| 'mask'
| 'outline'
| 'overflow'
| 'overscroll-behavior'
| 'padding'
| 'padding-block'
| 'padding-inline'
| 'place-content'
| 'place-items'
| 'place-self'
| 'scroll-margin'
| 'scroll-margin-block'
| 'scroll-margin-inline'
| 'scroll-padding'
| 'scroll-padding-block'
| 'scroll-padding-inline'
| 'text-decoration'
Expand Down