Skip to content

SCSS function names are being inconsistently case-changed #3748

Closed

Description

@thedamon

Prettier 1.10.2
Playground link

--parser scss

Input:

@function getBp($key) {
  @if map-has-key($grid_breakpoints, $key) {
    @return map-get($grid_breakpoints, $key);
  }

  @warn "Unknown `#{$key}` in $grid_breakpoints.";
  @return null;
}

@function getbp($key) {
  @return getBp($key);
}


.card-column-simple {

  @include breakpoint( getBp( md ) ) {
    padding: $spacing_content-sm $spacing_content-md;
  }

  @include breakpoint (getBp(md)) {
    &:nth-child(2n + 3) {
      clear: both;
    }
  }

  @include breakpoint (getBp(xl)) {
    &:nth-child(2n + 3) {
      clear: none;
    }
    &:nth-child(3n + 4) {
      clear: both;
    }
  }
}


Output:

@function getBp($key) {
  @if map-has-key($grid_breakpoints, $key) {
    @return map-get($grid_breakpoints, $key);
  }

  @warn "Unknown `#{$key}` in $grid_breakpoints.";
  @return null;
}

@function getbp($key) {
  @return getBp($key);
}

.card-column-simple {
  @include breakpoint( getBp( md ) ) {
    padding: $spacing_content-sm $spacing_content-md;
  }

  @include breakpoint (getbp(md)) {
    &:nth-child(2n + 3) {
      clear: both;
    }
  }

  @include breakpoint (getbp(xl)) {
    &:nth-child(2n + 3) {
      clear: none;
    }
    &:nth-child(3n + 4) {
      clear: both;
    }
  }
}

Diff:

--- a/example.scss
+++ b/example.scss
@@ -11,20 +11,18 @@
   @return getBp($key);
 }
 
-
 .card-column-simple {
-
   @include breakpoint( getBp( md ) ) {
     padding: $spacing_content-sm $spacing_content-md;
   }
 
-  @include breakpoint (getBp(md)) {
+  @include breakpoint (getbp(md)) {
     &:nth-child(2n + 3) {
       clear: both;
     }
   }
 
-  @include breakpoint (getBp(xl)) {
+  @include breakpoint (getbp(xl)) {
     &:nth-child(2n + 3) {
       clear: none;
     }

Expected behavior:

The function calls being used as parameters get changed to lowercase... but not always. Based on everything I've read I would expect them to be left alone entirely.

Activity

  1. added
    lang:css/scss/less
    on Jan 15, 2018
  2. lydell commented on Jan 15, 2018

    @lydell
    Member

    Yes, function names should be left alone entirely. Labeling as "high priority" since it breaks code.

  3. added
    priority:high
    on Jan 15, 2018
  4. added
    locked-due-to-inactivity
    on Jul 6, 2018
  5. locked as resolved and limited conversation to collaborators on Jul 6, 2018
  6. added theissue type on Mar 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    lang:css/scss/lesslocked-due-to-inactivitypriority:high

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions