Skip to content

wrong indentation: SCSS map functions with !default;  #2799

Closed

Description

@liubiantao

Prettier Version: 1.6.1 / master

Code

$theme-checkbox-colors: (
  default: $theme-color-border,
  checked: $theme-color-checked,
  disabled: $theme-color-disabled,
  disabled-font: $theme-color-font-secondary,
) !default;

Expected behavior:

$theme-checkbox-colors: (
  default: $theme-color-border,
  checked: $theme-color-checked,
  disabled: $theme-color-disabled,
  disabled-font: $theme-color-font-secondary,
) !default;

Actual behavior:

$theme-checkbox-colors: (
    default: $theme-color-border,
    checked: $theme-color-checked,
    disabled: $theme-color-disabled,
    disabled-font: $theme-color-font-secondary
  )
  !default;

and stylelint will throw this error:

 38:3  ✖  Expected single space before "!"   declaration-bang-space-before
 42:5  ✖  Expected indentation of 2 spaces   indentation

I also found the usage in bootstrap:

$grid-breakpoints: (
  xs: 0,
  sm: 576px,
  md: 768px,
  lg: 992px,
  xl: 1200px
) !default;

https://github.com/twbs/bootstrap/blob/f7eb3c98b261930270c2f65c0e565c454d6cb647/scss/_variables.scss#L145-L151

Activity

  1. lydell commented on Sep 13, 2017

    @lydell
    Member

    Given that it formats like the expected case when you remove !default (or change to !important), I consider this a bug.

  2. added
    lang:css/scss/less
    on Sep 13, 2017
  3. JasonMSims commented on Oct 17, 2017

    @JasonMSims

    I've stumbled onto this same issue as well.

  4. hudochenkov commented on Jan 11, 2018

    @hudochenkov
    Contributor

    In similar situation valid CSS with !important works correctly.

    Prettier 1.10.2
    Playground link

    --parser css

    Input:

    a {
    	background: linear-gradient(to bottom, #abcdef 0%, #abcdef 20%, #abcdef 30%, #abcdef 40%, #abcdef 100%) !important;
    }

    Output:

    a {
      background: linear-gradient(
        to bottom,
        #abcdef 0%,
        #abcdef 20%,
        #abcdef 30%,
        #abcdef 40%,
        #abcdef 100%
      ) !important;
    }

    With anything different from !important output changes:

    Prettier 1.10.2
    Playground link

    --parser css

    Input:

    a {
    	background: linear-gradient(to bottom, #abcdef 0%, #abcdef 20%, #abcdef 30%, #abcdef 40%, #abcdef 100%) !importanT;
    }

    Output:

    a {
      background: linear-gradient(
          to bottom,
          #abcdef 0%,
          #abcdef 20%,
          #abcdef 30%,
          #abcdef 40%,
          #abcdef 100%
        )
        !importanT;
    }
  5. azz commented on Jan 12, 2018

    @azz
    Member

    Fixed in #3724

  6. added this to the 1.10.3 milestone on Jan 12, 2018
  7. added
    locked-due-to-inactivity
    on Jul 6, 2018
  8. locked as resolved and limited conversation to collaborators on Jul 6, 2018
  9. 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-inactivity

    Type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions