prettier: SCSS comments are broken in maps with values that include functions.

Prettier 1.13.5 Playground link

--parser scss

Input:

$my-map: (
  'foo': 1, // Foo
  'bar': 2, // Bar
  'buz': calc(1 + 2), // Buz
  'baz': 4, // Baz
);

Output:

$my-map: (
  "foo": 1,
  // Foo
    "bar": 2,
  // Bar
    "buz": calc(1 + 2),
  // Buz "baz": 4,
  // Baz
);

Expected behavior: Ideally:

$my-map: (
  "foo": 1, // Foo
  "bar": 2, // Bar
  "buz": calc(1 + 2), // Buz
  "baz": 4, // Baz
);

But at the very least, this would be most similar to the existing functionality without causing errors:

$my-map: (
  "foo": 1,
  // Foo
    "bar": 2,
  // Bar
    "buz": calc(1 + 2),
  // Buz
    "baz": 4,
  // Baz
);

Other example:

$spacers: map-merge(
  (
    0: 0,
    1: ($spacer * 0.25), // 4px
    2: ($spacer * 0.5), // 8px
  ),
  $spacers
);

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 7
  • Comments: 18 (11 by maintainers)

Commits related to this issue

Most upvoted comments

as https://github.com/prettier/prettier/pull/7591 is merged, this can be closed.