Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

no empty line after at-rule include #122

Open
iztsv opened this issue Jun 22, 2020 · 1 comment
Open

no empty line after at-rule include #122

iztsv opened this issue Jun 22, 2020 · 1 comment

Comments

@iztsv
Copy link

iztsv commented Jun 22, 2020

Hello!

I have the following config and dependencies:

"stylelint": "^13.6.1"
"stylelint-order": "^4.1.0",
"stylelint-scss": "^3.18.0"
module.exports = {
  plugins: ['stylelint-scss', 'stylelint-order'],
  rules: {
    'order/order': [
      [
        'custom-properties',
        'at-variables',
        'dollar-variables',
        {
          type: 'at-rule',
          name: 'include',
          hasBlock: false
        },
        'declarations',
        'rules',
        {
          type: 'at-rule',
          name: 'include',
          hasBlock: true
        }
      ]
    ],
    'order/properties-order': [
      [
        {
          emptyLineBefore: 'always',
          noEmptyLineBetween: true,
          properties: ['z-index', 'display']
        },
        {
          emptyLineBefore: 'always',
          noEmptyLineBetween: true,
          properties: ['font-weight', 'text-align']
        }
      ],
      {
        unspecified: 'bottom',
        emptyLineBeforeUnspecified: 'always'
      }
    ],
    'comment-empty-line-before': [
      'always',
      {
        except: ['first-nested'],
        ignore: ['stylelint-commands']
      }
    ],
    'custom-property-empty-line-before': [
      'always',
      {
        except: ['after-custom-property', 'first-nested'],
        ignore: ['after-comment', 'inside-single-line-block']
      }
    ],
    'rule-empty-line-before': [
      'always',
      {
        except: ['first-nested', 'after-rule'],
        ignore: ['after-comment']
      }
    ],
    'at-rule-empty-line-before': [
      'always',
      {
        except: ['after-same-name', 'first-nested'],
        ignore: ['after-comment']
      }
    ]
  }
};

and index.scss:

.test {


  display: block;
  text-align: left;

  @media screen {
    //
  }
  span {
    color: red;
  }
  /* comment1 */
  @include with-block() {
    // ...
  }

  font-weight: bold;
  z-index: 1;
  /* comment3 */
  @include no-block();
}

after lint with autofix I expect:

.test {
  /* comment3 */
  @include no-block();

  z-index: 1;
  display: block;

  font-weight: bold;
  text-align: left;

  span {
    color: red;
  }

  /* comment1 */
  @include with-block() {
    // ...
  }

  @media screen {
    //
  }
}

but get (no empty line after @include no-block();):

.test {
  /* comment3 */
  @include no-block();
  z-index: 1;
  display: block;

  font-weight: bold;
  text-align: left;

  span {
    color: red;
  }

  /* comment1 */
  @include with-block() {
    // ...
  }

  @media screen {
    //
  }
}

if I add

'declaration-empty-line-before': ['always', {
    	except: ['first-nested', 'after-comment', 'after-declaration'],
    }]

the result will be (no empty line between declarations groups):

.test {
  /* comment3 */
  @include no-block();

  z-index: 1;
  display: block;
  font-weight: bold;
  text-align: left;

  span {
    color: red;
  }

  /* comment1 */
  @include with-block() {
    // ...
  }

  @media screen {
    //
  }
}

Is the problem in my configuration or it's problem in stylelint-order?

@hudochenkov
Copy link
Owner

From documentation:

Rule will check empty lines between properties only.

It is expected behavior. I don't remember why it is like that.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants