question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SCSS Formatting: mixin/function close parens

See original GitHub issue

For background: I’m the lead designer of Sass, and also the tech lead of the CSS/Sass infrastructure team at Google. I’m considering adopting Prettier as the official recommended formatter for Sass, and as the internal formatter we use for all of Google’s CSS and Sass. If we decide to move forward with Prettier, we’d be happy to contribute some improvements and bug fixes upstream. However, we’d like its formatting to match the formatting we’ve historically recommended for Sass as well as the formatting in use within Google (and the formatting of similar constructs in other languages).

The biggest blocker for this is the way long mixin and function argument lists are formatted, with the closing ) on its own line rather than on the same line as the final argument. If this could be fixed, we’d be mostly fine with the rest of the formatting.


Prettier 1.19.1 Playground link

--parser scss

Input:

@mixin name($that-takes-a-very-long: argument list, $so-long-it-will-need-to: wrap to a new line) {
  // No content
}

@include name(with very long argument list, full of lots of things, that goes past the line length);

Output:

@mixin name(
  $that-takes-a-very-long: argument list,
  $so-long-it-will-need-to: wrap to a new line
) {
  // No content
}

@include name(
  with very long argument list,
  full of lots of things,
  that goes past the line length
);

I’d expect:

@mixin name(
  $that-takes-a-very-long: argument list,
  $so-long-it-will-need-to: wrap to a new line) {
  // No content
}

@include name(
  with very long argument list,
  full of lots of things,
  that goes past the line length);

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:39
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

11reactions
Threeoakgroovecommented, Nov 22, 2019

Where do you see the advantages in the formating as recommended by you, except that it fits your companys current practices?

For me the closing braket of the params on it’s own line improves readability compared to the solution sugested by you.

9reactions
thorn0commented, Nov 23, 2019

It’s like formatting function in JS (TS) this way

function name(
  thatTakesAVeryLong: ArgumentList,
  soLongItWillNeedTo: WrapToANewLine) {
  // No content
}

Looks awful honestly. Do you format functions like this in Google?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Sass Basics
This rule loads another Sass file as a module, which means you can refer to its variables, mixins, and functions in your Sass...
Read more >
Compass/Sass function & mixin syntax - css - Stack Overflow
I want to loop all the $gradients , and for each $gradient , assume the first item is a direction declaration, and the...
Read more >
Sass (Syntactically Awesome StyleSheets)
Fully CSS-compatible; Language extensions such as variables, nesting, and mixins; Many useful functions for manipulating colors and other values ...
Read more >
Sass Guidelines
I, myself, prefer SCSS over Sass because it is closer to CSS and friendlier ... Regarding variables, functions and mixins, we stick to...
Read more >
Unum Enterprise CSS Standards
Rule Formatting. Class and Variable Naming. Create variables when the value is repeated more than once, or the value is likely to be...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found