forked from prettier/prettier
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed scss function arguments on different lines in maps prettier#9128 (
prettier#9184) Co-authored-by: agamkrbit <agamkrbit123@gmail.com> Co-authored-by: fisker Cheung <lionkay@gmail.com>
- Loading branch information
Showing
5 changed files
with
284 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#### Fix SCSS map in arguments (#9184 by @agamkrbit) | ||
|
||
<!-- prettier-ignore --> | ||
```scss | ||
// Input | ||
$display-breakpoints: map-deep-merge( | ||
( | ||
"print-only": "only print", | ||
"screen-only": "only screen", | ||
"xs-only": "only screen and (max-width: #{map-get($grid-breakpoints, "sm")-1})", | ||
), | ||
$display-breakpoints | ||
); | ||
|
||
// Prettier stable | ||
$display-breakpoints: map-deep-merge( | ||
( | ||
"print-only": "only print", | ||
"screen-only": "only screen", | ||
"xs-only": "only screen and (max-width: #{map-get($grid-breakpoints, " sm | ||
")-1})", | ||
), | ||
$display-breakpoints | ||
); | ||
|
||
// Prettier main | ||
$display-breakpoints: map-deep-merge( | ||
( | ||
"print-only": "only print", | ||
"screen-only": "only screen", | ||
"xs-only": "only screen and (max-width: #{map-get($grid-breakpoints, "sm")-1})", | ||
), | ||
$display-breakpoints | ||
); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
146 changes: 146 additions & 0 deletions
146
tests/format/scss/map/function-argument/__snapshots__/jsfmt.spec.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`functional-argument.scss format 1`] = ` | ||
====================================options===================================== | ||
parsers: ["scss"] | ||
printWidth: 80 | ||
| printWidth | ||
=====================================input====================================== | ||
//simple test | ||
$display-breakpoints: map-deep-merge( | ||
( | ||
"print-only": "only print", | ||
"screen-only": "only screen", | ||
"xs-only": "only screen and (max-width: #{map-get($grid-breakpoints, "sm") - 1})", | ||
"sm-only": "only screen and (min-width: #{map-get($grid-breakpoints, "sm")}) and (max-width: #{map-get($grid-breakpoints, "md") - 1})", | ||
), | ||
$display-breakpoints | ||
); | ||
//list test | ||
@each | ||
$size | ||
in | ||
$sizes { | ||
.icon | ||
#{$size} | ||
{ | ||
border | ||
: | ||
"#{$size + "px"}" | ||
solid | ||
red; | ||
} | ||
} | ||
@each | ||
$size | ||
in | ||
$sizes { | ||
.icon-#{$size} | ||
{ | ||
border | ||
: | ||
"#{$size + "px"}" | ||
solid | ||
red; | ||
} | ||
} | ||
//map test | ||
$font-weights | ||
: | ||
("regular": 400 | ||
, | ||
"medium": 500, | ||
"bold": | ||
700); | ||
@each | ||
$name, | ||
$boldness | ||
in | ||
$icons { | ||
.text | ||
#{ | ||
$name | ||
} { | ||
color: red; | ||
font-weight: | ||
"#{$boldness}" | ||
} | ||
} | ||
$font-weights | ||
: | ||
("regular": 400 | ||
, | ||
"medium": 500, | ||
"bold": | ||
700); | ||
@each | ||
$name, | ||
$boldness | ||
in | ||
$icons { | ||
.text-#{ | ||
$name | ||
} { | ||
color: red; | ||
font-weight: | ||
"#{$boldness}" | ||
} | ||
} | ||
=====================================output===================================== | ||
//simple test | ||
$display-breakpoints: map-deep-merge( | ||
( | ||
"print-only": "only print", | ||
"screen-only": "only screen", | ||
"xs-only": "only screen and (max-width: #{map-get($grid-breakpoints, "sm") - 1})", | ||
"sm-only": "only screen and (min-width: #{map-get($grid-breakpoints, "sm")}) and (max-width: #{map-get($grid-breakpoints, "md") - 1})", | ||
), | ||
$display-breakpoints | ||
); | ||
//list test | ||
@each $size in $sizes { | ||
.icon #{$size} { | ||
border: "#{$size + "px"}" solid red; | ||
} | ||
} | ||
@each $size in $sizes { | ||
.icon-#{$size} { | ||
border: "#{$size + "px"}" solid red; | ||
} | ||
} | ||
//map test | ||
$font-weights: ( | ||
"regular": 400, | ||
"medium": 500, | ||
"bold": 700, | ||
); | ||
@each $name, $boldness in $icons { | ||
.text #{ $name } { | ||
color: red; | ||
font-weight: "#{$boldness}"; | ||
} | ||
} | ||
$font-weights: ( | ||
"regular": 400, | ||
"medium": 500, | ||
"bold": 700, | ||
); | ||
@each $name, $boldness in $icons { | ||
.text-#{ $name } { | ||
color: red; | ||
font-weight: "#{$boldness}"; | ||
} | ||
} | ||
================================================================================ | ||
`; |
85 changes: 85 additions & 0 deletions
85
tests/format/scss/map/function-argument/functional-argument.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
//simple test | ||
$display-breakpoints: map-deep-merge( | ||
( | ||
"print-only": "only print", | ||
"screen-only": "only screen", | ||
"xs-only": "only screen and (max-width: #{map-get($grid-breakpoints, "sm") - 1})", | ||
"sm-only": "only screen and (min-width: #{map-get($grid-breakpoints, "sm")}) and (max-width: #{map-get($grid-breakpoints, "md") - 1})", | ||
), | ||
$display-breakpoints | ||
); | ||
|
||
|
||
//list test | ||
@each | ||
$size | ||
in | ||
$sizes { | ||
.icon | ||
#{$size} | ||
{ | ||
border | ||
: | ||
"#{$size + "px"}" | ||
solid | ||
red; | ||
} | ||
} | ||
|
||
@each | ||
$size | ||
in | ||
$sizes { | ||
.icon-#{$size} | ||
{ | ||
border | ||
: | ||
"#{$size + "px"}" | ||
solid | ||
red; | ||
} | ||
} | ||
|
||
//map test | ||
$font-weights | ||
: | ||
("regular": 400 | ||
, | ||
"medium": 500, | ||
"bold": | ||
700); | ||
@each | ||
$name, | ||
$boldness | ||
in | ||
$icons { | ||
.text | ||
#{ | ||
$name | ||
} { | ||
color: red; | ||
font-weight: | ||
"#{$boldness}" | ||
} | ||
} | ||
|
||
$font-weights | ||
: | ||
("regular": 400 | ||
, | ||
"medium": 500, | ||
"bold": | ||
700); | ||
@each | ||
$name, | ||
$boldness | ||
in | ||
$icons { | ||
.text-#{ | ||
$name | ||
} { | ||
color: red; | ||
font-weight: | ||
"#{$boldness}" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
run_spec(__dirname, ["scss"]); |