Repository navigation
Closed
Labels
lang:css/scss/lessIssues affecting CSS, Less or SCSSlocked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.status:needs discussionIssues needing discussion and a decision to be made before action can be taken
Description
Prettier 1.17.0
Playground link
--parser scssInput:
@font-face {
@each $format in $formats {
@if $format == local {
$format-local: local(if($suffix == "Regular", "#{$name}", "#{$name $suffix}")), local("#{$full-name}");
} @else {
$format-url: url("#{$path}/#{$file-name}.#{$format}") format("#{$format}");
$format-src: append($format-src, $format-url, comma);
}
}
}
.class {
background: #eee linear-gradient(100deg, $color-theme 40%, adjust-color($color-theme, $lightness: -4%) 70%, adjust-color($color-theme, $lightness: -9%)) center/cover no-repeat;
}Output:
@font-face {
@each $format in $formats {
@if $format == local {
$format-local: local(
if($suffix == "Regular", "#{$name}", "#{$name $suffix}")
),
local("#{$full-name}");
} @else {
$format-url: url("#{$path}/#{$file-name}.#{$format}")
format("#{$format}");
$format-src: append($format-src, $format-url, comma);
}
}
}
.class {
background: #eee
linear-gradient(
100deg,
$color-theme 40%,
adjust-color($color-theme, $lightness: -4%) 70%,
adjust-color($color-theme, $lightness: -9%)
)
center/cover no-repeat;
}Expected behavior:
The first value should not be on the same line as the property.
This is also the default behavior with stylelint-config-recommended.
Which follows the common stylistic conventions found within a handful of CSS styleguides, including: The Idiomatic CSS Principles, Google's CSS Style Guide, Airbnb's Styleguide, and @mdo's Code Guide.
The stylelint rule affected by this.
@font-face {
@each $format in $formats {
@if $format == local {
$format-local:
local(if($suffix == "Regular", "#{$name}", "#{$name $suffix}")),
local("#{$full-name}");
} @else {
$format-url:
url("#{$path}/#{$file-name}.#{$format}")
format("#{$format}");
$format-src: append($format-src, $format-url, comma);
}
}
}
.class {
background:
#eee
linear-gradient(
100deg,
$color-theme 40%,
adjust-color($color-theme, $lightness: -4%) 70%,
adjust-color($color-theme, $lightness: -9%)
)
center/cover
no-repeat;
}Reacted by JounQin
Metadata
Metadata
Assignees
Labels
lang:css/scss/lessIssues affecting CSS, Less or SCSSlocked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.status:needs discussionIssues needing discussion and a decision to be made before action can be taken
Activity
alexander-akait commentedon Nov 18, 2019
Please provide provide full Expected behavior, i can't understand what is
first valuein your exampleGrimLink commentedon Nov 18, 2019
@evilebottnawi sorry, the expected output was also the input 😅
I changed the input to a unformated version and added Expected behavior code sample.
alexander-akait commentedon Nov 18, 2019
Unfortunately this is not heuristic and can lead to a very ugly code
GrimLink commentedon Nov 18, 2019
@evilebottnawi please explain why?
The only difference is the break at the property.
Output
Expected
alexander-akait commentedon Nov 18, 2019
should be
because it is heuristic, it is fit in 80 characters
GrimLink commentedon Nov 18, 2019
@evilebottnawi I get the feeling you are not understanding me.
You comment is correct for 80 characters or less.
But my issue lies when it is more.
Then the values should nest under the property.
Just as with stylelint and many css styleguides.
alexander-akait commentedon Nov 18, 2019
@GrimLink i.e. break only when it is more than 80 characters?
GrimLink commentedon Nov 18, 2019
@evilebottnawi yes!
Please checkout the https://stylelint.io/user-guide/rules/declaration-colon-newline-after rule to see the correct wrapping.
alexander-akait commentedon Nov 18, 2019
@GrimLink
Note:
is ugly and should be avoided, let's wait other answers
GrimLink commentedon Nov 18, 2019
@evilebottnawi again it's for multiline properties
So the second rule (always-multi-line) not the first rule!
First of the first example is also not used by styleguides.
JounQin commentedon Nov 19, 2019
@GrimLink You should always enable
stylelint-config-prettierandstylelint-prettierif you want to usestylelintwithprettiertogether IMO.prettiershould take care of all formats or styles.GrimLink commentedon Nov 19, 2019
@JounQin that is not the issue.
The way prettier formats multiline css properties is.
Please read issue text -> #6986 (comment) before giving me an answer like this.
JounQin commentedon Nov 19, 2019
@GrimLink Sorry, my English is not so good, I still can't get the point, didn't you complain about prettier not formatting your scss expected same as other formatters? Please point out if I'm wrong.
thorn0 commentedon Nov 19, 2019
The issue is not about tools and style guides. What
@GrimLinkwants sounds reasonable to me:Prettier 1.19.1
Playground link
Input:
Output:
Requested:
GrimLink commentedon Nov 19, 2019
@JounQin no problem 😉
Your not wrong.
The formatting used by Prettier is different from styleguides and the default from Stylelint, for multiline properties.
When Prettier formats css that is longer than the max line length the first value is placed before the property.
Instead being wrapped below, with the rest of the values.
Wrong:
Expected:
thorn0 commentedon Nov 19, 2019
@GrimLink Please stop mentioning those styleguides and tools. :)
GrimLink commentedon Nov 19, 2019
Yeah maybe you're right 😅
JounQin commentedon Nov 19, 2019
@GrimLink Maybe you can reorganize your issue description to make it shorter and clearer. It seems quite misleading?
thorn0 commentedon Nov 19, 2019
I'd say better to open a new issue instead of this.
GrimLink commentedon Nov 23, 2019
@thorn0 and @JounQin I followed your advice and moved it to a new issue here -> #7039
Hope it is better and simpler descripped there 😉