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
Fixed scss function arguments on different lines in maps #9128 #9184
Merged
fisker
merged 13 commits into
prettier:main
from
agamkrbit:fixed-SCSS-function-arguments-on-different-lines-in-maps-#9128
Nov 24, 2022
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
e8d88ea
fixed-SCSS-function-arguments-on-different-lines-in-maps-#9128
agamkr123 dea1878
removed unwanted files
agamkr123 9e2dbfd
list issue fixed
agamkr123 f19e2dc
added test case
agamkr123 f04f623
fomated the files
agamkr123 4b842ad
upate snapshot
agamkr123 9a666b2
added space
agamkr123 2e76a1a
added new testcases
agamkr123 56e605f
added new testcases
agamkr123 4db2fae
Merge branch 'main' into fixed-SCSS-function-arguments-on-different-l…
fisker a3b690b
Move tests
fisker 270325b
Add changelog
fisker 97449b6
Update tests
fisker File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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"]); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure it is safe to trim here, why we do it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stringify was adding extra '\n', so I am using trim