You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
SCSS code is different with single line comments inside mixins using CRLF line endings #4143
Using prettier on our SCSS files we experience different behaviour under linux than under windows. Further investigation revealed that the line endings make the difference. It seems when using CRLF as line endings prettier produces different output than with normal LF as line endings.
Input (CRLF line endings):
@mixincreate-rules($padding) {
//// single line comment//.abc {
padding: $padding;
}
/** * multi line comment*/.def {
padding: $padding;
}
}
Output:
@mixincreate-rules($padding) {
$p// single line comment//.abc {
padding: $padding;
}
/* * * multi line comment */.def {
padding: $padding;
}
}
Expected behavior:
The file should not be changed as it already is properly formatted.
Issues:
single line comments produce invalid code after formatting
multi line comments are formatted incorrectly
a line break between the two code blocks gets stripped
Oh, I'm sorry, it seems I have changed and formatted my code too often when trying to provide a minimal example for the issue (our affected file is much bigger).
The problem occurs when the mixin parameter list too long and will be split into multiple lines.
Input (CRLF line endings):
@mixincreate-rules(
$padding,
$param2: 30px,
$param3: 1pxsolidblack,
$param4: 1,
$param5: 1
) {
//// single line comment//.abc {
padding: $padding;
}
/** * multi line comment*/.def {
padding: $padding;
}
}
I hope you can reproduce it with this code, otherwise I will provide a repo.
This issue isn't only for comments, have noticed that Prettier (SCSS) has all sorts of trouble with CRLF. Worth also noting that I haven't experienced this with JS, TS or JSON using the same config.
Input (CRLF) - Expected output should be unchanged
Activity
alexander-akait commentedon Mar 14, 2018
@aholtkamp i add tests #4145 and all works as expected, what editor you use and how you run prettier, looks something wrong with cursor
aholtkamp commentedon Mar 14, 2018
I'm using IntelliJ IDEA. It seems your tests do not use "@mixin" but media-queries. For media-queries everything works as expected.
alexander-akait commentedon Mar 14, 2018
@aholtkamp added you example, all fine
alexander-akait commentedon Mar 14, 2018
@aholtkamp maybe you can create minimum reproducible repo or describe instruction how you run prettier?
aholtkamp commentedon Mar 14, 2018
I will see if I can provide a repo, probably in the next few hours
aholtkamp commentedon Mar 14, 2018
Oh, I'm sorry, it seems I have changed and formatted my code too often when trying to provide a minimal example for the issue (our affected file is much bigger).
The problem occurs when the mixin parameter list too long and will be split into multiple lines.
Input (CRLF line endings):
I hope you can reproduce it with this code, otherwise I will provide a repo.
aholtkamp commentedon Mar 14, 2018
In addition to this the problem also occurs when the parameter list is rewritten:
Input (CRLF line endings):
Output:
Expected Output:
aholtkamp commentedon Mar 26, 2018
Could you reproduce the issue?
darekkay commentedon May 16, 2018
I can reproduce the issue in my project for
@mixinand@functiondeclarations and only on Windows (CRLF). On Linux/Mac there are no issues (LF).justrhysism commentedon Sep 6, 2018
This issue isn't only for comments, have noticed that Prettier (SCSS) has all sorts of trouble with CRLF. Worth also noting that I haven't experienced this with JS, TS or JSON using the same config.
Input (CRLF) - Expected output should be unchanged
Output
thorn0 commentedon Apr 25, 2020
Fixed at some point between versions 1.15 and 1.16.