Fix printing of SCSS selector() function (#12213)

This commit is contained in:
Lucas Duailibe authored and GitHub committed 2022-02-03 12:54:10 -03:00
1 parent e22c4911f8
commit 543aa9abf1
4 files changed
+25 -2

No files matched your search

+16
View File
@@ -0,0 +1,16 @@
#### Fixes printing parameters of a mixin named `selector()` (#12213 by @duailibe)
<!-- prettier-ignore -->
```css
/* Input */
@mixin selector($param: 'value') {
}
/* Prettier stable */
@mixin selector($param: 'value) {
}
/* Prettier main */
@mixin selector($param: 'value') {
}
```
+2 -2
View File
@@ -493,8 +493,8 @@ function genericPrint(path, options, print) {
grandParent.type === "value-func" &&
grandParent.value === "selector"
) {
const start = locStart(parentNode.open) + 1;
const end = locEnd(parentNode.close) - 1;
const start = locEnd(parentNode.open) + 1;
const end = locStart(parentNode.close);
const selector = options.originalText.slice(start, end).trim();
return lastLineHasInlineComment(selector)
@@ -3482,6 +3482,8 @@ $background
@mixin button-variant($foo: " ... ") {}
@mixin sexy-border($color, $width, $foo: (color: red)) {}
@mixin selector($param: "value") {}
=====================================output=====================================
@mixin clearfix {
}
@@ -3551,6 +3553,9 @@ $background
@mixin sexy-border($color, $width, $foo: (color: red)) {
}
@mixin selector($param: "value") {
}
================================================================================
`;
+2
View File
@@ -105,3 +105,5 @@ $background
@mixin button-variant($foo: " ... ") {}
@mixin button-variant($foo: " ... ") {}
@mixin sexy-border($color, $width, $foo: (color: red)) {}
@mixin selector($param: "value") {}