@banyaner/prettier-custom
v1.18.0
Published
Prettier is an opinionated code formatter
Downloads
1
Readme
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; }