diff --git a/tests/css/case/__snapshots__/jsfmt.spec.js.snap b/tests/css/case/__snapshots__/jsfmt.spec.js.snap index 198f84a6f..2c40edf0a 100644 --- a/tests/css/case/__snapshots__/jsfmt.spec.js.snap +++ b/tests/css/case/__snapshots__/jsfmt.spec.js.snap @@ -137,645 +137,6 @@ x-panel { ================================================================================ `; -exports[`case.less format 1`] = ` -====================================options===================================== -parsers: ["css"] -printWidth: 80 - | printWidth -=====================================input====================================== -// Convention in this test file: -// - The case should be preserved for things prefixed with "Keep". -// - The case should always be preserved for element names and attribute names -// in selectors, as well as function names and property keywords. -// - Other things should mostly be lowercase. -// - The \`/*:*/\` comments are just to bust the \`isLikelySCSS\` check. - -@IMPORT Keep; - -HTML#KeepId.KeepClass, -a[HREF=KeepAttrValue]:HOVER::FIRST-letter, -svg[viewBox] linearGradient, -:Not(:NTH-child(2N+1)) { - COLOR: #AAbbCC; - BACKGROUND-image: URL("KeepString"); - Margin: 5PX .2E10Em; - --Keep-custom-Prop: red; - background: Var(--Keep-custom-Prop); - animation-name: KeepAnimationName; - important: something !IMPORTANT; - font-family: INITIAL; - padding: UNSET; - border: INHERIT; - all: REVERT; - -WEBKIT-USER-SELECT: none; - -MOZ-USER-SELECT: none; - -MS-USER-SELECT: none; - USER-SELECT: none; -} - -@keyframes KeepAnimationName { - FROM { - prop: val; - } - - @{KeepInterpolationVar} { - prop: val; - } - - TO { - prop: val; - } -} - -@custom-media --KeepCustomMedia screen and (width >= 768px); -@media (--KeepCustomMedia) {} - -@KeepDetachedRuleset: /*:*/ { - BACKGROUND: RED; -} - -%KeepScssPlaceholderSelector { - prop: val; -} - -@KeepTopLevelVar: val; -$KeepScssVar: val; - -.Keep(@Keep: 12e03PX) when (@Keep=Case) /*:*/ { - @KeepVar: KeepName; /*:*/ - @{KeepInterpolationVar}: val; - $KeepScssVar: val; - @extend %KeepScssPlaceholderSelector; - - @{Keep}[@{Keep}][@{Keep}^=@{Keep-1A}]:@{Keep} { - prop: val; - } - - &Keep & Element { - prop: val; - } - - @KeepDetachedRuleset(); - - &:extend(.Keep ALL); - &:EXTEND(.Keep ALL); - - .Keep; - .Keep(); - .Keep(4PX)!IMPORTANT; - .Keep() when (@Keep=Keep); - .Keep() when (@Keep=12PX); - .Keep() when (@Keep="12px"); - .Keep() when (@Keep="12PX"); - .Keep() when (@Keep=Keep12PX); -} - -.Keep (@Keep) when (lightness(@Keep) >= 12PX) and (@Keep > 0) {} -.Keep (@Keep) when (lightness(@Keep) != '12PX') and (@Keep != "12PX") {} -.Keep (@Keep) when (lightness(@Keep) >= Keep12PX) and (@Keep > @Keep12E5) {} - -.Keep(@Keep: 12PX; @Keep: @Keep12PX; ...) /*:*/ {} -.Keep(@Keep: '12PX'; @Keep: "12PX"; ...) /*:*/ {} - -@MEDIA (MIN-WIDTH: 700PX) /*:*/ {} - -@MEDIA (@{Keep}: @{Keep}) {} - -@KEYFRAMES identifier { - FROM { - margin-top: 50px; - } - 50% { - margin-top: 150px; - } - TO { - margin-top: 100px; - } -} - -@-WEBKIT-KEYFRAMES float-up { - FROM { - margin-top: 50px; - } - 50% { - margin-top: 150px; - } - TO { - margin-top: 100px; - } -} - -.foo { - color: hsl(0.75TURN, 60%, 70%); -} - -p:FIRST-CHILD { - color: lime; - background-color: black; - padding: 5px; -} - -a::AFTER { - content: "→"; -} - -a:AFTER { - content: "→"; -} - -::-WEBKIT-PROGRESS-BAR { - background-color: orange; -} - -TABLE {} - -.foo { &-KeepSelector {} &-KeepSelector & .KeepClassSelector {} &-100\\.200 {} } - -=====================================output===================================== -// Convention in this test file: -// - The case should be preserved for things prefixed with "Keep". -// - The case should always be preserved for element names and attribute names -// in selectors, as well as function names and property keywords. -// - Other things should mostly be lowercase. -// - The \`/*:*/\` comments are just to bust the \`isLikelySCSS\` check. - -@import Keep; - -HTML#KeepId.KeepClass, -a[HREF="KeepAttrValue"]:hover::first-letter, -svg[viewBox] linearGradient, -:not(:nth-child(2n + 1)) { - color: #aabbcc; - background-image: URL("KeepString"); - margin: 5px 0.2e10em; - --Keep-custom-Prop: red; - background: Var(--Keep-custom-Prop); - animation-name: KeepAnimationName; - important: something !important; - font-family: initial; - padding: unset; - border: inherit; - all: revert; - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; -} - -@keyframes KeepAnimationName { - from { - prop: val; - } - - @{KeepInterpolationVar} { - prop: val; - } - - to { - prop: val; - } -} - -@custom-media --KeepCustomMedia screen and (width >= 768px); -@media (--KeepCustomMedia) { -} - -@KeepDetachedRuleset: /*:*/ { - background: RED; -}; - -%KeepScssPlaceholderSelector { - prop: val; -} - -@KeepTopLevelVar: val; -$KeepScssVar: val; - -.Keep(@Keep: 12e03PX) when (@Keep=Case) /*:*/ { - @KeepVar: KeepName; /*:*/ - @{KeepInterpolationVar}: val; - $KeepScssVar: val; - @extend %KeepScssPlaceholderSelector; - - @{Keep}[@{Keep}][@{Keep}^=@{Keep-1A}]:@{Keep} { - prop: val; - }; - - &Keep & Element { - prop: val; - } - - @KeepDetachedRuleset(); - - &:extend(.Keep ALL); - &:EXTEND(.Keep ALL); - - .Keep; - .Keep(); - .Keep(4px) !important; - .Keep() when (@Keep=Keep); - .Keep() when (@Keep=12px); - .Keep() when (@Keep="12px"); - .Keep() when (@Keep="12PX"); - .Keep() when (@Keep=Keep12PX); -} - -.Keep (@Keep) when (lightness(@Keep) >= 12px) and (@Keep > 0) { -} -.Keep (@Keep) when (lightness(@Keep) != "12PX") and (@Keep != "12PX") { -} -.Keep (@Keep) when (lightness(@Keep) >= Keep12PX) and (@Keep > @Keep12E5) { -} - -.Keep(@Keep: 12PX; @Keep: @Keep12PX; ...) /*:*/ { -} -.Keep(@Keep: '12PX'; @Keep: "12PX"; ...) /*:*/ { -} - -@media (min-width: 700px) /*:*/ { -} - -@media (@{Keep}: @{Keep}) { -} - -@keyframes identifier { - from { - margin-top: 50px; - } - 50% { - margin-top: 150px; - } - to { - margin-top: 100px; - } -} - -@-webkit-keyframes float-up { - from { - margin-top: 50px; - } - 50% { - margin-top: 150px; - } - to { - margin-top: 100px; - } -} - -.foo { - color: hsl(0.75turn, 60%, 70%); -} - -p:first-child { - color: lime; - background-color: black; - padding: 5px; -} - -a::after { - content: "→"; -} - -a:after { - content: "→"; -} - -::-webkit-progress-bar { - background-color: orange; -} - -TABLE { -} - -.foo { - &-KeepSelector { - } - &-KeepSelector & .KeepClassSelector { - } - &-100\\.200 { - } -} - -================================================================================ -`; - -exports[`case.scss format 1`] = ` -====================================options===================================== -parsers: ["css"] -printWidth: 80 - | printWidth -=====================================input====================================== -// Convention in this test file: -// - The case should be preserved for things prefixed with "Keep". -// - The case should always be preserved for element names and attribute names -// in selectors, as well as function names and property keywords. -// - Other things should mostly be lowercase. - -@IMPORT Keep; - -HTML#KeepId.KeepClass, -a[HREF=KeepAttrValue]:HOVER::FIRST-letter, -svg[viewBox] linearGradient, -:Not(:NTH-child(2N+1)) { - COLOR: #AAbbCC; - BACKGROUND-image: URL("KeepString"); - Margin: 5PX .2E10Em; - --Keep-custom-Prop: red; - background: Var(--Keep-custom-Prop); - animation-name: KeepAnimationName; - important: something !IMPORTANT; - font-family: INITIAL; - padding: UNSET; - border: INHERIT; - all: REVERT; - -WEBKIT-USER-SELECT: none; - -MOZ-USER-SELECT: none; - -MS-USER-SELECT: none; - USER-SELECT: none; -} - -@keyframes KeepAnimationName { - FROM { - prop: val; - } - - #{$KeepInterpolationVar}, - #{$Keep + 15PX + Keep15PX + '15PX' + "15PX"}, - #{$Keep + $Keep15PX} { - prop: val; - } - - TO { - prop: val; - } -} - -@custom-media --KeepCustomMedia screen and (width >= 768px); -@media (--KeepCustomMedia) {} - -@function KeepFuncName() { - @return 12; -} - -%KeepPlaceholderSelector { - prop: val; -} - -$KeepTopLevelVar: val; -@KeepLessVar: val; - -@mixin KeepMixinName($Keep: 15IN, $Keep: $Keep15IN, $Keep: Keep-1E-2Em) { - $KeepVar: KeepFuncName(); - #{$KeepInterpolationVar}: val; - #{$Keep + 15PX}: val; - #{$Keep + $Keep15PX}: val; - @KeepLessVar: val; - @extend %KeepPlaceholderSelector; - - #{$Keep}[#{$Keep}][#{Keep}^=#{Keep-1A}]:#{$Keep} { - prop: val; - } - - &Keep & Element { - prop: val; - } - - BACKGROUND: { - COLOR: RED; - } - - BACKGROUND: Keep 15PX Keep15PX { - COLOR: RED; - } - - #{$Keep + 15PX + Keep15PX + '15PX' + "15PX"}: { - COLOR: RED; - } -} - -@mixin Keep($Keep: $Keep15IN, $Keep: Keepå1E1) {} - -@MEDIA (MIN-WIDTH: 700PX) { - @include Keep; - @include Keep(.12e+01cH); - @include Keep($Keep12E01cH); -} - -@MEDIA (#{$Keep}: #{$Keep}) {} - -@KEYFRAMES identifier { - FROM { - margin-top: 50px; - } - 50% { - margin-top: 150px; - } - TO { - margin-top: 100px; - } -} - -@-WEBKIT-KEYFRAMES float-up { - FROM { - margin-top: 50px; - } - 50% { - margin-top: 150px; - } - TO { - margin-top: 100px; - } -} - -.foo { - color: hsl(0.75TURN, 60%, 70%); -} - -p:FIRST-CHILD { - color: lime; - background-color: black; - padding: 5px; -} - -a::AFTER { - content: "→"; -} - -a:AFTER { - content: "→"; -} - -::-WEBKIT-PROGRESS-BAR { - background-color: orange; -} - -TABLE {} - -.foo { &-KeepSelector {} &-KeepSelector & .KeepClassSelector {} &-100\\.200 {} } - -=====================================output===================================== -// Convention in this test file: -// - The case should be preserved for things prefixed with "Keep". -// - The case should always be preserved for element names and attribute names -// in selectors, as well as function names and property keywords. -// - Other things should mostly be lowercase. - -@import Keep; - -HTML#KeepId.KeepClass, -a[HREF="KeepAttrValue"]:hover::first-letter, -svg[viewBox] linearGradient, -:not(:nth-child(2n + 1)) { - color: #aabbcc; - background-image: URL("KeepString"); - margin: 5px 0.2e10em; - --Keep-custom-Prop: red; - background: Var(--Keep-custom-Prop); - animation-name: KeepAnimationName; - important: something !important; - font-family: initial; - padding: unset; - border: inherit; - all: revert; - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; -} - -@keyframes KeepAnimationName { - from { - prop: val; - } - - #{$KeepInterpolationVar}, - #{$Keep + 15px + Keep15PX + "15PX" + "15PX"}, - #{$Keep + $Keep15PX} { - prop: val; - } - - to { - prop: val; - } -} - -@custom-media --KeepCustomMedia screen and (width >= 768px); -@media (--KeepCustomMedia) { -} - -@function KeepFuncName() { - @return 12; -} - -%KeepPlaceholderSelector { - prop: val; -} - -$KeepTopLevelVar: val; -@KeepLessVar: val; - -@mixin KeepMixinName($Keep: 15in, $Keep: $Keep15IN, $Keep: Keep-1E-2Em) { - $KeepVar: KeepFuncName(); - #{$KeepInterpolationVar}: val; - #{$Keep + 15PX}: val; - #{$Keep + $Keep15PX}: val; - @KeepLessVar: val; - @extend %KeepPlaceholderSelector; - - #{$Keep}[#{$Keep}][#{Keep}^="#{Keep-1A}"]:#{$Keep} { - prop: val; - } - - &Keep & Element { - prop: val; - } - - background: { - color: RED; - } - - background: Keep 15px Keep15PX { - color: RED; - } - - #{$Keep + 15px + Keep15PX + "15PX" + "15PX"}: { - color: RED; - } -} - -@mixin Keep($Keep: $Keep15IN, $Keep: Keepå1E1) { -} - -@media (min-width: 700px) { - @include Keep; - @include Keep(0.12e1ch); - @include Keep($Keep12E01cH); -} - -@media (#{$Keep}: #{$Keep}) { -} - -@keyframes identifier { - from { - margin-top: 50px; - } - 50% { - margin-top: 150px; - } - to { - margin-top: 100px; - } -} - -@-webkit-keyframes float-up { - from { - margin-top: 50px; - } - 50% { - margin-top: 150px; - } - to { - margin-top: 100px; - } -} - -.foo { - color: hsl(0.75turn, 60%, 70%); -} - -p:first-child { - color: lime; - background-color: black; - padding: 5px; -} - -a::after { - content: "→"; -} - -a:after { - content: "→"; -} - -::-webkit-progress-bar { - background-color: orange; -} - -TABLE { -} - -.foo { - &-KeepSelector { - } - &-KeepSelector & .KeepClassSelector { - } - &-100\\.200 { - } -} - -================================================================================ -`; - exports[`custom-selectors.css format 1`] = ` ====================================options===================================== parsers: ["css"] diff --git a/tests/css/comments/__snapshots__/jsfmt.spec.js.snap b/tests/css/comments/__snapshots__/jsfmt.spec.js.snap index 5271e3960..7b82e2966 100644 --- a/tests/css/comments/__snapshots__/jsfmt.spec.js.snap +++ b/tests/css/comments/__snapshots__/jsfmt.spec.js.snap @@ -50,191 +50,6 @@ printWidth: 80 ================================================================================ `; -exports[`CRLF.less format 1`] = ` -====================================options===================================== -parsers: ["css"] -printWidth: 80 - | printWidth -=====================================input====================================== -@nice-blue: #5B83AD; -@light-blue: @nice-blue + #111; - -// Comment 1 -/* - * Comment 2 - */ -#header { - // Comment 3 - /* - * Comment 4 - */ - color: @light-blue; -} - -@media only screen and (max-width: 600px) { - // Comment 1 - /* - * Comment 5 - */ - body { - background-color: lightblue; // Comment 6 - color: red; /* Comment 7 */ - } -} - -=====================================output===================================== -@nice-blue: #5B83AD; -@light-blue: @nice-blue + #111; - -// Comment 1 -/* - * Comment 2 - */ -#header { - // Comment 3 - /* - * Comment 4 - */ - color: @light-blue; -} - -@media only screen and (max-width: 600px) { - // Comment 1 - /* - * Comment 5 - */ - body { - background-color: lightblue; // Comment 6 - color: red; /* Comment 7 */ - } -} - -================================================================================ -`; - -exports[`CRLF.scss format 1`] = ` -====================================options===================================== -parsers: ["css"] -printWidth: 80 - | printWidth -=====================================input====================================== -$nice-blue: #5B83AD; -$light-blue: $nice-blue + #111; - -// Comment 1 -/* - * Comment 2 - */ -#header { - // Comment 3 - /* - * Comment 4 - */ - color: @light-blue; -} - -@media only screen and (max-width: 600px) { - // Comment 1 - /* - * Comment 5 - */ - body { - background-color: lightblue; // Comment 6 - color: red; /* Comment 7 */ - } -} - -@mixin create-rules($padding) { - // - // Comment 8 - // - .abc { - padding: $padding; - } - /** - * Comment 9 - */ - .def { - padding: $padding; - } -} - -=====================================output===================================== -$nice-blue: #5b83ad; -$light-blue: $nice-blue + #111; - -// Comment 1 -/* - * Comment 2 - */ -#header { - // Comment 3 - /* - * Comment 4 - */ - color: @light-blue; -} - -@media only screen and (max-width: 600px) { - // Comment 1 - /* - * Comment 5 - */ - body { - background-color: lightblue; // Comment 6 - color: red; /* Comment 7 */ - } -} - -@mixin create-rules($padding) { - // - // Comment 8 - // - .abc { - padding: $padding; - } - /** - * Comment 9 - */ - .def { - padding: $padding; - } -} - -================================================================================ -`; - -exports[`at-rule.scss format 1`] = ` -====================================options===================================== -parsers: ["css"] -printWidth: 80 - | printWidth -=====================================input====================================== -@at-root .foo -// .bar -{ - -} - -@at-root -// .bar -.foo -{ - -} -=====================================output===================================== -@at-root .foo -// .bar -{ -} - -@at-root // .bar -.foo { -} - -================================================================================ -`; - exports[`at-rules.css format 1`] = ` ====================================options===================================== parsers: ["css"] @@ -683,120 +498,6 @@ body { ================================================================================ `; -exports[`if-eslit-at-rule-decloration.scss format 1`] = ` -====================================options===================================== -parsers: ["css"] -printWidth: 80 - | printWidth -=====================================input====================================== -@function _normalize-include($section) { -// Check if $section is in the $include list. - @if index($_normalize-include, $section) { - @return true; - } -// If $include is set to (all), make sure $section is not in $exclude. - @else if not index($_normalize-exclude, $section) and index($_normalize-include, all) { - @return true; - } - @return false; -} - -=====================================output===================================== -@function _normalize-include($section) { - // Check if $section is in the $include list. - @if index($_normalize-include, $section) { - @return true; - } - // If $include is set to (all), make sure $section is not in $exclude. - @else if not - index($_normalize-exclude, $section) and - index($_normalize-include, all) - { - @return true; - } - @return false; -} - -================================================================================ -`; - -exports[`lists.scss format 1`] = ` -====================================options===================================== -parsers: ["css"] -printWidth: 80 - | printWidth -=====================================input====================================== -$my-list: - 'foo', // Foo - 'bar'; // Bar - -$my-list2: - a // a - b - c; - -=====================================output===================================== -$my-list: "foo", - // Foo - "bar"; // Bar - -$my-list2: a // a - b c; - -================================================================================ -`; - -exports[`maps.scss format 1`] = ` -====================================options===================================== -parsers: ["css"] -printWidth: 80 - | printWidth -=====================================input====================================== -$my-map: ( - 'foo': 1, // Foo - 'bar': 2, // Bar -); - -=====================================output===================================== -$my-map: ( - "foo": 1, - // Foo - "bar": 2, - // Bar -); - -================================================================================ -`; - -exports[`places.css format 1`] = ` -====================================options===================================== -parsers: ["css"] -printWidth: 80 - | printWidth -=====================================input====================================== -div { - // a - - margin-left: -@leftMargin; // b -} // c - -// d -div {} - -=====================================output===================================== -div { - // a - - margin-left: -@leftMargin; // b -} // c - -// d -div { -} - -================================================================================ -`; - exports[`prettier-ignore.css format 1`] = ` ====================================options===================================== parsers: ["css"] @@ -1226,145 +927,6 @@ article /* comment 168 */ :--heading /* comment 169 */ + /* comment 170 */ p /* ================================================================================ `; -exports[`selectors.scss format 1`] = ` -====================================options===================================== -parsers: ["css"] -printWidth: 80 - | printWidth -=====================================input====================================== -.powerPathNavigator .helm button.pressedButton, // comment 1 -.powerPathNavigator .helm button:active:not(.disabledButton), -.powerPathNavigator table.powerPathInfo th:active, -.powerPathNavigator table.powerPathInfo th:active + th:last-child { -} - -// comment 2 -.powerPathNavigator .helm button.pressedButton, -.powerPathNavigator .helm button:active:not(.disabledButton) { -} - -.foo, -// comment 3 -.bar { - display: block; -} - -.field - { - &[data-field-id="1"], // comment 4 - &[data-field-id="2"], // comment 5 - &[data-field-id="3"], // comment 6 - { - background: green; - } -} - -// comment 7 -.field -// comment 8 -{ // comment 9 - // comment 10 - &[data-field-id="1"], // comment 11 - // comment 12 - &[data-field-id="2"] // comment 13 - // comment 14 - , // comment 15 - // comment 16 - &[data-field-id="3"], // comment 17 - // comment 18 - { // comment 19 - // comment 20 - background: green; - // comment 21 - } // comment 22 - // comment 23 -} -// comment 24 - -.foo -// comment 25 -.bar -// comment 26 -{} - -.foo -// comment 27 -+ -// comment 28 -.bar -// comment 29 -{} - -=====================================output===================================== -.powerPathNavigator .helm button.pressedButton, // comment 1 -.powerPathNavigator .helm button:active:not(.disabledButton), -.powerPathNavigator table.powerPathInfo th:active, -.powerPathNavigator table.powerPathInfo th:active + th:last-child { -} - -// comment 2 -.powerPathNavigator .helm button.pressedButton, -.powerPathNavigator .helm button:active:not(.disabledButton) { -} - -.foo, -// comment 3 -.bar { - display: block; -} - -.field { - &[data-field-id="1"], // comment 4 - &[data-field-id="2"], // comment 5 - &[data-field-id="3"], // comment 6 - { - background: green; - } -} - -// comment 7 -.field -// comment 8 -{ - // comment 9 - // comment 10 - &[data-field-id="1"], // comment 11 - // comment 12 - &[data-field-id="2"] // comment 13 - // comment 14 - , // comment 15 - // comment 16 - &[data-field-id="3"], // comment 17 - // comment 18 - { - // comment 19 - // comment 20 - background: green; - // comment 21 - } // comment 22 - // comment 23 -} -// comment 24 - -.foo -// comment 25 -.bar -// comment 26 -{ -} - -.foo -// comment 27 -+ -// comment 28 -.bar -// comment 29 -{ -} - -================================================================================ -`; - exports[`source-map.css format 1`] = ` ====================================options===================================== parsers: ["css"] @@ -1387,27 +949,6 @@ printWidth: 80 ================================================================================ `; -exports[`trailing_star_slash.css format 1`] = ` -====================================options===================================== -parsers: ["css"] -printWidth: 80 - | printWidth -=====================================input====================================== -@media (max-width: 1) {} -a { - // element.style */ -} - -=====================================output===================================== -@media (max-width: 1) { -} -a { - // element.style */ -} - -================================================================================ -`; - exports[`types.css format 1`] = ` ====================================options===================================== parsers: ["css"] @@ -1509,45 +1050,3 @@ span { ================================================================================ `; - -exports[`variable-declaration.scss format 1`] = ` -====================================options===================================== -parsers: ["css"] -printWidth: 80 - | printWidth -=====================================input====================================== -$var: /* comment 1 */ all /* comment 2 */ !default /* comment 3 */ ; /* comment 4 */ - -@mixin text-color { - /* comment 5 */ - /* comment 6 */ $text-color /* comment 7 */ : /* comment 8 */ red /* comment 9 */ !default /* comment 10 */ ; /* comment 11 */ - /* comment 12 */ - color: $text-color; -} - -.error { - /* comment 13 */ - /* comment 14 */ $text-color /* comment 15 */ : /* comment 16 */ green /* comment 17 */ !global /* comment 18 */ ; /* comment 19 */ - /* comment 20 */ -} - -=====================================output===================================== -$var: /* comment 1 */ all /* comment 2 */ !default /* comment 3 */; /* comment 4 */ - -@mixin text-color { - /* comment 5 */ - /* comment 6 */ - $text-color/* comment 7 */ : /* comment 8 */ red /* comment 9 */ !default /* comment 10 */; /* comment 11 */ - /* comment 12 */ - color: $text-color; -} - -.error { - /* comment 13 */ - /* comment 14 */ - $text-color/* comment 15 */ : /* comment 16 */ green /* comment 17 */ !global /* comment 18 */; /* comment 19 */ - /* comment 20 */ -} - -================================================================================ -`; diff --git a/tests/css/variables/__snapshots__/jsfmt.spec.js.snap b/tests/css/variables/__snapshots__/jsfmt.spec.js.snap index f0d75e342..ea1a54c90 100644 --- a/tests/css/variables/__snapshots__/jsfmt.spec.js.snap +++ b/tests/css/variables/__snapshots__/jsfmt.spec.js.snap @@ -35,41 +35,3 @@ printWidth: 80 ================================================================================ `; - -exports[`variables.scss format 1`] = ` -====================================options===================================== -parsers: ["css"] -printWidth: 80 - | printWidth -=====================================input====================================== -.foo { - --#{$prop}: 10px; - #{$prop}: 10px; - prop1: var(--#{$var}); - prop2: var(#{$var}, --my-#{$var}, pink); - prop3: calc(var(--#{$var}) * 1px); -} - -@supports (--#{$prop}: green) { - body { - color: var(--#{$var}); - } -} - -=====================================output===================================== -.foo { - --#{$prop}: 10px; - #{$prop}: 10px; - prop1: var(--#{$var}); - prop2: var(#{$var}, --my-#{$var}, pink); - prop3: calc(var(--#{$var}) * 1px); -} - -@supports (--#{$prop}: green) { - body { - color: var(--#{$var}); - } -} - -================================================================================ -`; diff --git a/tests/less/case/__snapshots__/jsfmt.spec.js.snap b/tests/less/case/__snapshots__/jsfmt.spec.js.snap new file mode 100644 index 000000000..9bc7e9003 --- /dev/null +++ b/tests/less/case/__snapshots__/jsfmt.spec.js.snap @@ -0,0 +1,323 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`case.less format 1`] = ` +====================================options===================================== +parsers: ["less"] +printWidth: 80 + | printWidth +=====================================input====================================== +// Convention in this test file: +// - The case should be preserved for things prefixed with "Keep". +// - The case should always be preserved for element names and attribute names +// in selectors, as well as function names and property keywords. +// - Other things should mostly be lowercase. +// - The \`/*:*/\` comments are just to bust the \`isLikelySCSS\` check. + +@IMPORT Keep; + +HTML#KeepId.KeepClass, +a[HREF=KeepAttrValue]:HOVER::FIRST-letter, +svg[viewBox] linearGradient, +:Not(:NTH-child(2N+1)) { + COLOR: #AAbbCC; + BACKGROUND-image: URL("KeepString"); + Margin: 5PX .2E10Em; + --Keep-custom-Prop: red; + background: Var(--Keep-custom-Prop); + animation-name: KeepAnimationName; + important: something !IMPORTANT; + font-family: INITIAL; + padding: UNSET; + border: INHERIT; + all: REVERT; + -WEBKIT-USER-SELECT: none; + -MOZ-USER-SELECT: none; + -MS-USER-SELECT: none; + USER-SELECT: none; +} + +@keyframes KeepAnimationName { + FROM { + prop: val; + } + + @{KeepInterpolationVar} { + prop: val; + } + + TO { + prop: val; + } +} + +@custom-media --KeepCustomMedia screen and (width >= 768px); +@media (--KeepCustomMedia) {} + +@KeepDetachedRuleset: /*:*/ { + BACKGROUND: RED; +} + +%KeepScssPlaceholderSelector { + prop: val; +} + +@KeepTopLevelVar: val; +$KeepScssVar: val; + +.Keep(@Keep: 12e03PX) when (@Keep=Case) /*:*/ { + @KeepVar: KeepName; /*:*/ + @{KeepInterpolationVar}: val; + $KeepScssVar: val; + @extend %KeepScssPlaceholderSelector; + + @{Keep}[@{Keep}][@{Keep}^=@{Keep-1A}]:@{Keep} { + prop: val; + } + + &Keep & Element { + prop: val; + } + + @KeepDetachedRuleset(); + + &:extend(.Keep ALL); + &:EXTEND(.Keep ALL); + + .Keep; + .Keep(); + .Keep(4PX)!IMPORTANT; + .Keep() when (@Keep=Keep); + .Keep() when (@Keep=12PX); + .Keep() when (@Keep="12px"); + .Keep() when (@Keep="12PX"); + .Keep() when (@Keep=Keep12PX); +} + +.Keep (@Keep) when (lightness(@Keep) >= 12PX) and (@Keep > 0) {} +.Keep (@Keep) when (lightness(@Keep) != '12PX') and (@Keep != "12PX") {} +.Keep (@Keep) when (lightness(@Keep) >= Keep12PX) and (@Keep > @Keep12E5) {} + +.Keep(@Keep: 12PX; @Keep: @Keep12PX; ...) /*:*/ {} +.Keep(@Keep: '12PX'; @Keep: "12PX"; ...) /*:*/ {} + +@MEDIA (MIN-WIDTH: 700PX) /*:*/ {} + +@MEDIA (@{Keep}: @{Keep}) {} + +@KEYFRAMES identifier { + FROM { + margin-top: 50px; + } + 50% { + margin-top: 150px; + } + TO { + margin-top: 100px; + } +} + +@-WEBKIT-KEYFRAMES float-up { + FROM { + margin-top: 50px; + } + 50% { + margin-top: 150px; + } + TO { + margin-top: 100px; + } +} + +.foo { + color: hsl(0.75TURN, 60%, 70%); +} + +p:FIRST-CHILD { + color: lime; + background-color: black; + padding: 5px; +} + +a::AFTER { + content: "→"; +} + +a:AFTER { + content: "→"; +} + +::-WEBKIT-PROGRESS-BAR { + background-color: orange; +} + +TABLE {} + +.foo { &-KeepSelector {} &-KeepSelector & .KeepClassSelector {} &-100\\.200 {} } + +=====================================output===================================== +// Convention in this test file: +// - The case should be preserved for things prefixed with "Keep". +// - The case should always be preserved for element names and attribute names +// in selectors, as well as function names and property keywords. +// - Other things should mostly be lowercase. +// - The \`/*:*/\` comments are just to bust the \`isLikelySCSS\` check. + +@import Keep; + +HTML#KeepId.KeepClass, +a[HREF="KeepAttrValue"]:hover::first-letter, +svg[viewBox] linearGradient, +:not(:nth-child(2n + 1)) { + color: #aabbcc; + background-image: URL("KeepString"); + margin: 5px 0.2e10em; + --Keep-custom-Prop: red; + background: Var(--Keep-custom-Prop); + animation-name: KeepAnimationName; + important: something !important; + font-family: initial; + padding: unset; + border: inherit; + all: revert; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +@keyframes KeepAnimationName { + from { + prop: val; + } + + @{KeepInterpolationVar} { + prop: val; + } + + to { + prop: val; + } +} + +@custom-media --KeepCustomMedia screen and (width >= 768px); +@media (--KeepCustomMedia) { +} + +@KeepDetachedRuleset: /*:*/ { + background: RED; +}; + +%KeepScssPlaceholderSelector { + prop: val; +} + +@KeepTopLevelVar: val; +$KeepScssVar: val; + +.Keep(@Keep: 12e03PX) when (@Keep=Case) /*:*/ { + @KeepVar: KeepName; /*:*/ + @{KeepInterpolationVar}: val; + $KeepScssVar: val; + @extend %KeepScssPlaceholderSelector; + + @{Keep}[@{Keep}][@{Keep}^=@{Keep-1A}]:@{Keep} { + prop: val; + }; + + &Keep & Element { + prop: val; + } + + @KeepDetachedRuleset(); + + &:extend(.Keep ALL); + &:EXTEND(.Keep ALL); + + .Keep; + .Keep(); + .Keep(4px) !important; + .Keep() when (@Keep=Keep); + .Keep() when (@Keep=12px); + .Keep() when (@Keep="12px"); + .Keep() when (@Keep="12PX"); + .Keep() when (@Keep=Keep12PX); +} + +.Keep (@Keep) when (lightness(@Keep) >= 12px) and (@Keep > 0) { +} +.Keep (@Keep) when (lightness(@Keep) != "12PX") and (@Keep != "12PX") { +} +.Keep (@Keep) when (lightness(@Keep) >= Keep12PX) and (@Keep > @Keep12E5) { +} + +.Keep(@Keep: 12PX; @Keep: @Keep12PX; ...) /*:*/ { +} +.Keep(@Keep: '12PX'; @Keep: "12PX"; ...) /*:*/ { +} + +@media (min-width: 700px) /*:*/ { +} + +@media (@{Keep}: @{Keep}) { +} + +@keyframes identifier { + from { + margin-top: 50px; + } + 50% { + margin-top: 150px; + } + to { + margin-top: 100px; + } +} + +@-webkit-keyframes float-up { + from { + margin-top: 50px; + } + 50% { + margin-top: 150px; + } + to { + margin-top: 100px; + } +} + +.foo { + color: hsl(0.75turn, 60%, 70%); +} + +p:first-child { + color: lime; + background-color: black; + padding: 5px; +} + +a::after { + content: "→"; +} + +a:after { + content: "→"; +} + +::-webkit-progress-bar { + background-color: orange; +} + +TABLE { +} + +.foo { + &-KeepSelector { + } + &-KeepSelector & .KeepClassSelector { + } + &-100\\.200 { + } +} + +================================================================================ +`; diff --git a/tests/css/case/case.less b/tests/less/case/case.less similarity index 100% rename from tests/css/case/case.less rename to tests/less/case/case.less diff --git a/tests/less/case/jsfmt.spec.js b/tests/less/case/jsfmt.spec.js new file mode 100644 index 000000000..73b809901 --- /dev/null +++ b/tests/less/case/jsfmt.spec.js @@ -0,0 +1 @@ +run_spec(__dirname, ["less"]); diff --git a/tests/css/comments/CRLF.less b/tests/less/comments/CRLF.less similarity index 100% rename from tests/css/comments/CRLF.less rename to tests/less/comments/CRLF.less diff --git a/tests/less/comments/__snapshots__/jsfmt.spec.js.snap b/tests/less/comments/__snapshots__/jsfmt.spec.js.snap new file mode 100644 index 000000000..dbbfda8df --- /dev/null +++ b/tests/less/comments/__snapshots__/jsfmt.spec.js.snap @@ -0,0 +1,136 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`CRLF.less format 1`] = ` +====================================options===================================== +parsers: ["less"] +printWidth: 80 + | printWidth +=====================================input====================================== +@nice-blue: #5B83AD; +@light-blue: @nice-blue + #111; + +// Comment 1 +/* + * Comment 2 + */ +#header { + // Comment 3 + /* + * Comment 4 + */ + color: @light-blue; +} + +@media only screen and (max-width: 600px) { + // Comment 1 + /* + * Comment 5 + */ + body { + background-color: lightblue; // Comment 6 + color: red; /* Comment 7 */ + } +} + +=====================================output===================================== +@nice-blue: #5b83ad; +@light-blue: @nice-blue + #111; + +// Comment 1 +/* + * Comment 2 + */ +#header { + // Comment 3 + /* + * Comment 4 + */ + color: @light-blue; +} + +@media only screen and (max-width: 600px) { + // Comment 1 + /* + * Comment 5 + */ + body { + background-color: lightblue; // Comment 6 + color: red; /* Comment 7 */ + } +} + +================================================================================ +`; + +exports[`places.less format 1`] = ` +====================================options===================================== +parsers: ["less"] +printWidth: 80 + | printWidth +=====================================input====================================== +div { + // a + + margin-left: -@leftMargin; // b +} // c + +// d +div {} + +=====================================output===================================== +div { + // a + + margin-left: -@leftMargin; // b +} // c + +// d +div { +} + +================================================================================ +`; + +exports[`prettier-ignore.less format 1`] = ` +====================================options===================================== +parsers: ["less"] +printWidth: 80 + | printWidth +=====================================input====================================== + +foo { + /* prettier-ignore */ + thing: foo; + -ms-thing: foo; +} + +=====================================output===================================== +foo { + /* prettier-ignore */ + thing: foo; + -ms-thing: foo; +} + +================================================================================ +`; + +exports[`trailing_star_slash.scss format 1`] = ` +====================================options===================================== +parsers: ["less"] +printWidth: 80 + | printWidth +=====================================input====================================== +@media (max-width: 1) {} +a { + // element.style */ +} + +=====================================output===================================== +@media (max-width: 1) { +} +a { + // element.style */ +} + +================================================================================ +`; diff --git a/tests/less/comments/jsfmt.spec.js b/tests/less/comments/jsfmt.spec.js new file mode 100644 index 000000000..73b809901 --- /dev/null +++ b/tests/less/comments/jsfmt.spec.js @@ -0,0 +1 @@ +run_spec(__dirname, ["less"]); diff --git a/tests/css/comments/places.css b/tests/less/comments/places.less similarity index 100% rename from tests/css/comments/places.css rename to tests/less/comments/places.less diff --git a/tests/less/comments/prettier-ignore.less b/tests/less/comments/prettier-ignore.less new file mode 100644 index 000000000..429ae77b7 --- /dev/null +++ b/tests/less/comments/prettier-ignore.less @@ -0,0 +1,6 @@ + +foo { + /* prettier-ignore */ + thing: foo; + -ms-thing: foo; +} diff --git a/tests/css/comments/trailing_star_slash.css b/tests/less/comments/trailing_star_slash.scss similarity index 100% rename from tests/css/comments/trailing_star_slash.css rename to tests/less/comments/trailing_star_slash.scss diff --git a/tests/scss/case/__snapshots__/jsfmt.spec.js.snap b/tests/scss/case/__snapshots__/jsfmt.spec.js.snap new file mode 100644 index 000000000..4ebe6aa42 --- /dev/null +++ b/tests/scss/case/__snapshots__/jsfmt.spec.js.snap @@ -0,0 +1,318 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`case.scss format 1`] = ` +====================================options===================================== +parsers: ["scss"] +printWidth: 80 + | printWidth +=====================================input====================================== +// Convention in this test file: +// - The case should be preserved for things prefixed with "Keep". +// - The case should always be preserved for element names and attribute names +// in selectors, as well as function names and property keywords. +// - Other things should mostly be lowercase. + +@IMPORT Keep; + +HTML#KeepId.KeepClass, +a[HREF=KeepAttrValue]:HOVER::FIRST-letter, +svg[viewBox] linearGradient, +:Not(:NTH-child(2N+1)) { + COLOR: #AAbbCC; + BACKGROUND-image: URL("KeepString"); + Margin: 5PX .2E10Em; + --Keep-custom-Prop: red; + background: Var(--Keep-custom-Prop); + animation-name: KeepAnimationName; + important: something !IMPORTANT; + font-family: INITIAL; + padding: UNSET; + border: INHERIT; + all: REVERT; + -WEBKIT-USER-SELECT: none; + -MOZ-USER-SELECT: none; + -MS-USER-SELECT: none; + USER-SELECT: none; +} + +@keyframes KeepAnimationName { + FROM { + prop: val; + } + + #{$KeepInterpolationVar}, + #{$Keep + 15PX + Keep15PX + '15PX' + "15PX"}, + #{$Keep + $Keep15PX} { + prop: val; + } + + TO { + prop: val; + } +} + +@custom-media --KeepCustomMedia screen and (width >= 768px); +@media (--KeepCustomMedia) {} + +@function KeepFuncName() { + @return 12; +} + +%KeepPlaceholderSelector { + prop: val; +} + +$KeepTopLevelVar: val; +@KeepLessVar: val; + +@mixin KeepMixinName($Keep: 15IN, $Keep: $Keep15IN, $Keep: Keep-1E-2Em) { + $KeepVar: KeepFuncName(); + #{$KeepInterpolationVar}: val; + #{$Keep + 15PX}: val; + #{$Keep + $Keep15PX}: val; + @KeepLessVar: val; + @extend %KeepPlaceholderSelector; + + #{$Keep}[#{$Keep}][#{Keep}^=#{Keep-1A}]:#{$Keep} { + prop: val; + } + + &Keep & Element { + prop: val; + } + + BACKGROUND: { + COLOR: RED; + } + + BACKGROUND: Keep 15PX Keep15PX { + COLOR: RED; + } + + #{$Keep + 15PX + Keep15PX + '15PX' + "15PX"}: { + COLOR: RED; + } +} + +@mixin Keep($Keep: $Keep15IN, $Keep: Keepå1E1) {} + +@MEDIA (MIN-WIDTH: 700PX) { + @include Keep; + @include Keep(.12e+01cH); + @include Keep($Keep12E01cH); +} + +@MEDIA (#{$Keep}: #{$Keep}) {} + +@KEYFRAMES identifier { + FROM { + margin-top: 50px; + } + 50% { + margin-top: 150px; + } + TO { + margin-top: 100px; + } +} + +@-WEBKIT-KEYFRAMES float-up { + FROM { + margin-top: 50px; + } + 50% { + margin-top: 150px; + } + TO { + margin-top: 100px; + } +} + +.foo { + color: hsl(0.75TURN, 60%, 70%); +} + +p:FIRST-CHILD { + color: lime; + background-color: black; + padding: 5px; +} + +a::AFTER { + content: "→"; +} + +a:AFTER { + content: "→"; +} + +::-WEBKIT-PROGRESS-BAR { + background-color: orange; +} + +TABLE {} + +.foo { &-KeepSelector {} &-KeepSelector & .KeepClassSelector {} &-100\\.200 {} } + +=====================================output===================================== +// Convention in this test file: +// - The case should be preserved for things prefixed with "Keep". +// - The case should always be preserved for element names and attribute names +// in selectors, as well as function names and property keywords. +// - Other things should mostly be lowercase. + +@import Keep; + +HTML#KeepId.KeepClass, +a[HREF="KeepAttrValue"]:hover::first-letter, +svg[viewBox] linearGradient, +:not(:nth-child(2n + 1)) { + color: #aabbcc; + background-image: URL("KeepString"); + margin: 5px 0.2e10em; + --Keep-custom-Prop: red; + background: Var(--Keep-custom-Prop); + animation-name: KeepAnimationName; + important: something !important; + font-family: initial; + padding: unset; + border: inherit; + all: revert; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +@keyframes KeepAnimationName { + from { + prop: val; + } + + #{$KeepInterpolationVar}, + #{$Keep + 15px + Keep15PX + "15PX" + "15PX"}, + #{$Keep + $Keep15PX} { + prop: val; + } + + to { + prop: val; + } +} + +@custom-media --KeepCustomMedia screen and (width >= 768px); +@media (--KeepCustomMedia) { +} + +@function KeepFuncName() { + @return 12; +} + +%KeepPlaceholderSelector { + prop: val; +} + +$KeepTopLevelVar: val; +@KeepLessVar: val; + +@mixin KeepMixinName($Keep: 15in, $Keep: $Keep15IN, $Keep: Keep-1E-2Em) { + $KeepVar: KeepFuncName(); + #{$KeepInterpolationVar}: val; + #{$Keep + 15PX}: val; + #{$Keep + $Keep15PX}: val; + @KeepLessVar: val; + @extend %KeepPlaceholderSelector; + + #{$Keep}[#{$Keep}][#{Keep}^="#{Keep-1A}"]:#{$Keep} { + prop: val; + } + + &Keep & Element { + prop: val; + } + + background: { + color: RED; + } + + background: Keep 15px Keep15PX { + color: RED; + } + + #{$Keep + 15px + Keep15PX + "15PX" + "15PX"}: { + color: RED; + } +} + +@mixin Keep($Keep: $Keep15IN, $Keep: Keepå1E1) { +} + +@media (min-width: 700px) { + @include Keep; + @include Keep(0.12e1ch); + @include Keep($Keep12E01cH); +} + +@media (#{$Keep}: #{$Keep}) { +} + +@keyframes identifier { + from { + margin-top: 50px; + } + 50% { + margin-top: 150px; + } + to { + margin-top: 100px; + } +} + +@-webkit-keyframes float-up { + from { + margin-top: 50px; + } + 50% { + margin-top: 150px; + } + to { + margin-top: 100px; + } +} + +.foo { + color: hsl(0.75turn, 60%, 70%); +} + +p:first-child { + color: lime; + background-color: black; + padding: 5px; +} + +a::after { + content: "→"; +} + +a:after { + content: "→"; +} + +::-webkit-progress-bar { + background-color: orange; +} + +TABLE { +} + +.foo { + &-KeepSelector { + } + &-KeepSelector & .KeepClassSelector { + } + &-100\\.200 { + } +} + +================================================================================ +`; diff --git a/tests/css/case/case.scss b/tests/scss/case/case.scss similarity index 100% rename from tests/css/case/case.scss rename to tests/scss/case/case.scss diff --git a/tests/scss/case/jsfmt.spec.js b/tests/scss/case/jsfmt.spec.js new file mode 100644 index 000000000..539bde086 --- /dev/null +++ b/tests/scss/case/jsfmt.spec.js @@ -0,0 +1 @@ +run_spec(__dirname, ["scss"]); diff --git a/tests/css/comments/CRLF.scss b/tests/scss/comments/CRLF.scss similarity index 100% rename from tests/css/comments/CRLF.scss rename to tests/scss/comments/CRLF.scss diff --git a/tests/scss/comments/__snapshots__/jsfmt.spec.js.snap b/tests/scss/comments/__snapshots__/jsfmt.spec.js.snap new file mode 100644 index 000000000..17161cee3 --- /dev/null +++ b/tests/scss/comments/__snapshots__/jsfmt.spec.js.snap @@ -0,0 +1,434 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`CRLF.scss format 1`] = ` +====================================options===================================== +parsers: ["scss"] +printWidth: 80 + | printWidth +=====================================input====================================== +$nice-blue: #5B83AD; +$light-blue: $nice-blue + #111; + +// Comment 1 +/* + * Comment 2 + */ +#header { + // Comment 3 + /* + * Comment 4 + */ + color: @light-blue; +} + +@media only screen and (max-width: 600px) { + // Comment 1 + /* + * Comment 5 + */ + body { + background-color: lightblue; // Comment 6 + color: red; /* Comment 7 */ + } +} + +@mixin create-rules($padding) { + // + // Comment 8 + // + .abc { + padding: $padding; + } + /** + * Comment 9 + */ + .def { + padding: $padding; + } +} + +=====================================output===================================== +$nice-blue: #5b83ad; +$light-blue: $nice-blue + #111; + +// Comment 1 +/* + * Comment 2 + */ +#header { + // Comment 3 + /* + * Comment 4 + */ + color: @light-blue; +} + +@media only screen and (max-width: 600px) { + // Comment 1 + /* + * Comment 5 + */ + body { + background-color: lightblue; // Comment 6 + color: red; /* Comment 7 */ + } +} + +@mixin create-rules($padding) { + // + // Comment 8 + // + .abc { + padding: $padding; + } + /** + * Comment 9 + */ + .def { + padding: $padding; + } +} + +================================================================================ +`; + +exports[`at-rule.scss format 1`] = ` +====================================options===================================== +parsers: ["scss"] +printWidth: 80 + | printWidth +=====================================input====================================== +@at-root .foo +// .bar +{ + +} + +@at-root +// .bar +.foo +{ + +} +=====================================output===================================== +@at-root .foo +// .bar +{ +} + +@at-root // .bar +.foo { +} + +================================================================================ +`; + +exports[`if-eslit-at-rule-decloration.scss format 1`] = ` +====================================options===================================== +parsers: ["scss"] +printWidth: 80 + | printWidth +=====================================input====================================== +@function _normalize-include($section) { +// Check if $section is in the $include list. + @if index($_normalize-include, $section) { + @return true; + } +// If $include is set to (all), make sure $section is not in $exclude. + @else if not index($_normalize-exclude, $section) and index($_normalize-include, all) { + @return true; + } + @return false; +} + +=====================================output===================================== +@function _normalize-include($section) { + // Check if $section is in the $include list. + @if index($_normalize-include, $section) { + @return true; + } + // If $include is set to (all), make sure $section is not in $exclude. + @else if not + index($_normalize-exclude, $section) and + index($_normalize-include, all) + { + @return true; + } + @return false; +} + +================================================================================ +`; + +exports[`lists.scss format 1`] = ` +====================================options===================================== +parsers: ["scss"] +printWidth: 80 + | printWidth +=====================================input====================================== +$my-list: + 'foo', // Foo + 'bar'; // Bar + +$my-list2: + a // a + b + c; + +=====================================output===================================== +$my-list: "foo", + // Foo + "bar"; // Bar + +$my-list2: a // a + b c; + +================================================================================ +`; + +exports[`maps.scss format 1`] = ` +====================================options===================================== +parsers: ["scss"] +printWidth: 80 + | printWidth +=====================================input====================================== +$my-map: ( + 'foo': 1, // Foo + 'bar': 2, // Bar +); + +=====================================output===================================== +$my-map: ( + "foo": 1, + // Foo + "bar": 2, + // Bar +); + +================================================================================ +`; + +exports[`prettier-ignore.scss format 1`] = ` +====================================options===================================== +parsers: ["scss"] +printWidth: 80 + | printWidth +=====================================input====================================== + +foo { + /* prettier-ignore */ + thing: foo; + -ms-thing: foo; +} + +=====================================output===================================== +foo { + /* prettier-ignore */ + thing: foo; + -ms-thing: foo; +} + +================================================================================ +`; + +exports[`selectors.scss format 1`] = ` +====================================options===================================== +parsers: ["scss"] +printWidth: 80 + | printWidth +=====================================input====================================== +.powerPathNavigator .helm button.pressedButton, // comment 1 +.powerPathNavigator .helm button:active:not(.disabledButton), +.powerPathNavigator table.powerPathInfo th:active, +.powerPathNavigator table.powerPathInfo th:active + th:last-child { +} + +// comment 2 +.powerPathNavigator .helm button.pressedButton, +.powerPathNavigator .helm button:active:not(.disabledButton) { +} + +.foo, +// comment 3 +.bar { + display: block; +} + +.field + { + &[data-field-id="1"], // comment 4 + &[data-field-id="2"], // comment 5 + &[data-field-id="3"], // comment 6 + { + background: green; + } +} + +// comment 7 +.field +// comment 8 +{ // comment 9 + // comment 10 + &[data-field-id="1"], // comment 11 + // comment 12 + &[data-field-id="2"] // comment 13 + // comment 14 + , // comment 15 + // comment 16 + &[data-field-id="3"], // comment 17 + // comment 18 + { // comment 19 + // comment 20 + background: green; + // comment 21 + } // comment 22 + // comment 23 +} +// comment 24 + +.foo +// comment 25 +.bar +// comment 26 +{} + +.foo +// comment 27 ++ +// comment 28 +.bar +// comment 29 +{} + +=====================================output===================================== +.powerPathNavigator .helm button.pressedButton, // comment 1 +.powerPathNavigator .helm button:active:not(.disabledButton), +.powerPathNavigator table.powerPathInfo th:active, +.powerPathNavigator table.powerPathInfo th:active + th:last-child { +} + +// comment 2 +.powerPathNavigator .helm button.pressedButton, +.powerPathNavigator .helm button:active:not(.disabledButton) { +} + +.foo, +// comment 3 +.bar { + display: block; +} + +.field { + &[data-field-id="1"], // comment 4 + &[data-field-id="2"], // comment 5 + &[data-field-id="3"], // comment 6 + { + background: green; + } +} + +// comment 7 +.field +// comment 8 +{ + // comment 9 + // comment 10 + &[data-field-id="1"], // comment 11 + // comment 12 + &[data-field-id="2"] // comment 13 + // comment 14 + , // comment 15 + // comment 16 + &[data-field-id="3"], // comment 17 + // comment 18 + { + // comment 19 + // comment 20 + background: green; + // comment 21 + } // comment 22 + // comment 23 +} +// comment 24 + +.foo +// comment 25 +.bar +// comment 26 +{ +} + +.foo +// comment 27 ++ +// comment 28 +.bar +// comment 29 +{ +} + +================================================================================ +`; + +exports[`trailing_star_slash.scss format 1`] = ` +====================================options===================================== +parsers: ["scss"] +printWidth: 80 + | printWidth +=====================================input====================================== +@media (max-width: 1) {} +a { + // element.style */ +} + +=====================================output===================================== +@media (max-width: 1) { +} +a { + // element.style */ +} + +================================================================================ +`; + +exports[`variable-declaration.scss format 1`] = ` +====================================options===================================== +parsers: ["scss"] +printWidth: 80 + | printWidth +=====================================input====================================== +$var: /* comment 1 */ all /* comment 2 */ !default /* comment 3 */ ; /* comment 4 */ + +@mixin text-color { + /* comment 5 */ + /* comment 6 */ $text-color /* comment 7 */ : /* comment 8 */ red /* comment 9 */ !default /* comment 10 */ ; /* comment 11 */ + /* comment 12 */ + color: $text-color; +} + +.error { + /* comment 13 */ + /* comment 14 */ $text-color /* comment 15 */ : /* comment 16 */ green /* comment 17 */ !global /* comment 18 */ ; /* comment 19 */ + /* comment 20 */ +} + +=====================================output===================================== +$var: /* comment 1 */ all /* comment 2 */ !default /* comment 3 */; /* comment 4 */ + +@mixin text-color { + /* comment 5 */ + /* comment 6 */ + $text-color/* comment 7 */ : /* comment 8 */ red /* comment 9 */ !default /* comment 10 */; /* comment 11 */ + /* comment 12 */ + color: $text-color; +} + +.error { + /* comment 13 */ + /* comment 14 */ + $text-color/* comment 15 */ : /* comment 16 */ green /* comment 17 */ !global /* comment 18 */; /* comment 19 */ + /* comment 20 */ +} + +================================================================================ +`; diff --git a/tests/css/comments/at-rule.scss b/tests/scss/comments/at-rule.scss similarity index 100% rename from tests/css/comments/at-rule.scss rename to tests/scss/comments/at-rule.scss diff --git a/tests/css/comments/if-eslit-at-rule-decloration.scss b/tests/scss/comments/if-eslit-at-rule-decloration.scss similarity index 100% rename from tests/css/comments/if-eslit-at-rule-decloration.scss rename to tests/scss/comments/if-eslit-at-rule-decloration.scss diff --git a/tests/scss/comments/jsfmt.spec.js b/tests/scss/comments/jsfmt.spec.js new file mode 100644 index 000000000..539bde086 --- /dev/null +++ b/tests/scss/comments/jsfmt.spec.js @@ -0,0 +1 @@ +run_spec(__dirname, ["scss"]); diff --git a/tests/css/comments/lists.scss b/tests/scss/comments/lists.scss similarity index 100% rename from tests/css/comments/lists.scss rename to tests/scss/comments/lists.scss diff --git a/tests/css/comments/maps.scss b/tests/scss/comments/maps.scss similarity index 100% rename from tests/css/comments/maps.scss rename to tests/scss/comments/maps.scss diff --git a/tests/scss/comments/prettier-ignore.scss b/tests/scss/comments/prettier-ignore.scss new file mode 100644 index 000000000..429ae77b7 --- /dev/null +++ b/tests/scss/comments/prettier-ignore.scss @@ -0,0 +1,6 @@ + +foo { + /* prettier-ignore */ + thing: foo; + -ms-thing: foo; +} diff --git a/tests/css/comments/selectors.scss b/tests/scss/comments/selectors.scss similarity index 100% rename from tests/css/comments/selectors.scss rename to tests/scss/comments/selectors.scss diff --git a/tests/scss/comments/trailing_star_slash.scss b/tests/scss/comments/trailing_star_slash.scss new file mode 100644 index 000000000..694f0a2db --- /dev/null +++ b/tests/scss/comments/trailing_star_slash.scss @@ -0,0 +1,4 @@ +@media (max-width: 1) {} +a { + // element.style */ +} diff --git a/tests/css/comments/variable-declaration.scss b/tests/scss/comments/variable-declaration.scss similarity index 100% rename from tests/css/comments/variable-declaration.scss rename to tests/scss/comments/variable-declaration.scss diff --git a/tests/scss/trailing-comma/__snapshots__/jsfmt.spec.js.snap b/tests/scss/trailing-comma/__snapshots__/jsfmt.spec.js.snap index 3223d1613..4b14ed88b 100644 --- a/tests/scss/trailing-comma/__snapshots__/jsfmt.spec.js.snap +++ b/tests/scss/trailing-comma/__snapshots__/jsfmt.spec.js.snap @@ -2,7 +2,7 @@ exports[`at-rules.css - {"trailingComma":"none"} format 1`] = ` ====================================options===================================== -parsers: ["css"] +parsers: ["scss"] printWidth: 80 trailingComma: "none" | printWidth @@ -153,7 +153,7 @@ a { exports[`declaration.css - {"trailingComma":"none"} format 1`] = ` ====================================options===================================== -parsers: ["css"] +parsers: ["scss"] printWidth: 80 trailingComma: "none" | printWidth @@ -190,7 +190,7 @@ a { exports[`list.css - {"trailingComma":"none"} format 1`] = ` ====================================options===================================== -parsers: ["css"] +parsers: ["scss"] printWidth: 80 trailingComma: "none" | printWidth @@ -401,7 +401,7 @@ $breakpoint-map: ( exports[`map.css - {"trailingComma":"none"} format 1`] = ` ====================================options===================================== -parsers: ["css"] +parsers: ["scss"] printWidth: 80 trailingComma: "none" | printWidth @@ -490,7 +490,7 @@ $map: ( exports[`selector_list.css - {"trailingComma":"none"} format 1`] = ` ====================================options===================================== -parsers: ["css"] +parsers: ["scss"] printWidth: 80 trailingComma: "none" | printWidth @@ -553,7 +553,7 @@ asdasldaskdhjkashdahsdkjahskdjhakjsdkjahsdhkasdhkajsdhakjsdhkajsdhjkahskjdkjahsj exports[`variable.css - {"trailingComma":"none"} format 1`] = ` ====================================options===================================== -parsers: ["css"] +parsers: ["scss"] printWidth: 80 trailingComma: "none" | printWidth diff --git a/tests/scss/trailing-comma/jsfmt.spec.js b/tests/scss/trailing-comma/jsfmt.spec.js index c9fbdf77d..f2558a4a9 100644 --- a/tests/scss/trailing-comma/jsfmt.spec.js +++ b/tests/scss/trailing-comma/jsfmt.spec.js @@ -1,2 +1,2 @@ -run_spec(__dirname, ["css"], { trailingComma: "none" }); +run_spec(__dirname, ["scss"], { trailingComma: "none" }); run_spec(__dirname, ["scss"]); diff --git a/tests/scss/variables/__snapshots__/jsfmt.spec.js.snap b/tests/scss/variables/__snapshots__/jsfmt.spec.js.snap new file mode 100644 index 000000000..6f19d50c0 --- /dev/null +++ b/tests/scss/variables/__snapshots__/jsfmt.spec.js.snap @@ -0,0 +1,39 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`variables.scss format 1`] = ` +====================================options===================================== +parsers: ["scss"] +printWidth: 80 + | printWidth +=====================================input====================================== +.foo { + --#{$prop}: 10px; + #{$prop}: 10px; + prop1: var(--#{$var}); + prop2: var(#{$var}, --my-#{$var}, pink); + prop3: calc(var(--#{$var}) * 1px); +} + +@supports (--#{$prop}: green) { + body { + color: var(--#{$var}); + } +} + +=====================================output===================================== +.foo { + --#{$prop}: 10px; + #{$prop}: 10px; + prop1: var(--#{$var}); + prop2: var(#{$var}, --my-#{$var}, pink); + prop3: calc(var(--#{$var}) * 1px); +} + +@supports (--#{$prop}: green) { + body { + color: var(--#{$var}); + } +} + +================================================================================ +`; diff --git a/tests/scss/variables/jsfmt.spec.js b/tests/scss/variables/jsfmt.spec.js new file mode 100644 index 000000000..539bde086 --- /dev/null +++ b/tests/scss/variables/jsfmt.spec.js @@ -0,0 +1 @@ +run_spec(__dirname, ["scss"]); diff --git a/tests/css/variables/variables.scss b/tests/scss/variables/variables.scss similarity index 100% rename from tests/css/variables/variables.scss rename to tests/scss/variables/variables.scss diff --git a/tests/stylefmt-repo/inline-comment/__snapshots__/jsfmt.spec.js.snap b/tests/stylefmt-repo/inline-comment/__snapshots__/jsfmt.spec.js.snap index 2d66ff1bd..f8ca001fb 100644 --- a/tests/stylefmt-repo/inline-comment/__snapshots__/jsfmt.spec.js.snap +++ b/tests/stylefmt-repo/inline-comment/__snapshots__/jsfmt.spec.js.snap @@ -2,7 +2,7 @@ exports[`inline-comment.css format 1`] = ` ====================================options===================================== -parsers: ["css"] +parsers: ["scss"] printWidth: 80 | printWidth =====================================input====================================== diff --git a/tests/stylefmt-repo/inline-comment/jsfmt.spec.js b/tests/stylefmt-repo/inline-comment/jsfmt.spec.js index 7d3726c81..539bde086 100644 --- a/tests/stylefmt-repo/inline-comment/jsfmt.spec.js +++ b/tests/stylefmt-repo/inline-comment/jsfmt.spec.js @@ -1 +1 @@ -run_spec(__dirname, ["css"]); +run_spec(__dirname, ["scss"]); diff --git a/tests/stylefmt-repo/readme/__snapshots__/jsfmt.spec.js.snap b/tests/stylefmt-repo/readme/__snapshots__/jsfmt.spec.js.snap index 3f8ae9d15..20262486a 100644 --- a/tests/stylefmt-repo/readme/__snapshots__/jsfmt.spec.js.snap +++ b/tests/stylefmt-repo/readme/__snapshots__/jsfmt.spec.js.snap @@ -2,7 +2,7 @@ exports[`readme.css format 1`] = ` ====================================options===================================== -parsers: ["css"] +parsers: ["scss"] printWidth: 80 | printWidth =====================================input====================================== diff --git a/tests/stylefmt-repo/readme/jsfmt.spec.js b/tests/stylefmt-repo/readme/jsfmt.spec.js index 7d3726c81..539bde086 100644 --- a/tests/stylefmt-repo/readme/jsfmt.spec.js +++ b/tests/stylefmt-repo/readme/jsfmt.spec.js @@ -1 +1 @@ -run_spec(__dirname, ["css"]); +run_spec(__dirname, ["scss"]); diff --git a/tests_config/utils/check-parsers.js b/tests_config/utils/check-parsers.js index 8939d598b..fcf8aefa1 100644 --- a/tests_config/utils/check-parsers.js +++ b/tests_config/utils/check-parsers.js @@ -11,7 +11,7 @@ const getCategory = (dirname) => const categoryParsers = new Map( [ ["angular", ["angular", "__ng_interpolation"]], - ["css", ["css" /* ,"less", "scss" These may allow, but not using */]], + ["css", ["css"]], ["flow", ["babel", "flow", "babel-flow"]], ["flow-repo", ["babel", "flow", "babel-flow"]], ["graphql", ["graphql"]], @@ -20,12 +20,12 @@ const categoryParsers = new Map( ["js", ["babel", "flow", "babel-flow", "typescript", "babel-ts"]], ["json", ["json", "json5", "json-stringify"]], ["jsx", ["babel", "flow", "babel-flow", "typescript", "babel-ts"]], - ["less", ["css", "less"]], + ["less", ["less"]], ["lwc", ["lwc"]], ["markdown", ["markdown"]], ["mdx", ["mdx"]], - ["scss", ["css", "scss"]], - ["stylefmt-repo", ["css"]], + ["scss", ["scss"]], + ["stylefmt-repo", ["css", "scss"]], ["typescript", ["typescript", "babel-ts"]], ["vue", ["vue"]], ["yaml", ["yaml"]],