prettier: CSS Multiline declaration should not be on the same line as the property
Prettier 1.17.0 Playground link
--parser scss
Input:
@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;
}
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 1
- Comments: 20 (11 by maintainers)
I’d say better to open a new issue instead of this.
The issue is not about tools and style guides. What
@GrimLink
wants sounds reasonable to me:Prettier 1.19.1 Playground link
Input:
Output:
Requested:
@JounQin that is not the issue. The way prettier formats multiline css properties is. Please read issue text -> https://github.com/prettier/prettier/issues/6986#issue-524003880 before giving me an answer like this.
@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.