@banyaner/prettier-custom

1.18.0 • Public • Published

Fork from prettier

在scss项目中使用了scss mixin来写BEM命名方式。 为了简化scss写法,我们使用如下的方式。但prettier会将这种代码格式化为不理想的格式。为了支持这种方式,所以修改了格式化规则。

/* scss写法*/

@include b(page-search) {
  width: 100%;
  @include e(header) {
    display: flex;
    @include m(title) {
      display: flex;
    }
    @include p(hover) {
      background: gray;
    }
    @include w(active) {
      font-weight: bold;
    }
  }
}

/* 简写方式*。修改前prettier格式化会在'@b'和'('之前加空格*/

@b(page-search) { 
  color: red;
  @e(header) {
    display: flex;
    @m(title) {
      display: flex;
    }
    @p(hover) {
      background: gray;
    }
    @w(active) {
      font-weight: bold;
    }
  }
}

/* 编译后的代码*/
.page-search {
  width: 100%; }
  .page-search__header {
    display: flex; }
    .page-search__header--title {
      display: flex; }
    .page-search__header:hover {
      background: gray; }
    .page-search__header.is-active {
      font-weight: bold; }

Readme

Keywords

none

Package Sidebar

Install

npm i @banyaner/prettier-custom

Homepage

prettier.io

Weekly Downloads

1

Version

1.18.0

License

MIT

Unpacked Size

9.25 MB

Total Files

18

Last publish

Collaborators

  • banyaner