1.2.2 • Published 2 years ago

no-top-global v1.2.2

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

功能

校验样式文件中最外层:global并提示报错,以下bad情况插件会提示报错。:global文件应该放到嵌套语句中使用。

Bad ❌

:global {
  .ant-modal-content {
      padding-right: 10px;
      overflow-x: hidden;
    }
}

Good ✅

.modal_wrap{
  :global {
    .ant-modal-content {
        padding-right: 10px;
        overflow-x: hidden;
      }
  }
}

下载

yarn add no-top-global -D  

使用

no-top-global:在.stylelintrc文件中增添如下配置。whiteList为白名单,配置不需要校验的文件,glob格式。如果不需要白名单,

plugins:['no-top-global'],
rules: {
'moresec/no-top-global':[true,{whiteList:['src/global.less','src/styles/*/**']}]
//不需要白名单这么设置即可
//'moresec/no-top-global':true
},

Allowed-style:在.stylelintrc文件中增添如下配置。第一个参数为全局样式所在位置,第二个参数为允许的样式名称配置列表,不在其中的会在global.less中报错

plugins:['no-top-global'], 
rules: {
    'moresec/allowed-style':['lib/rules/allowed-style/global.less',['.ant-pro-sider-fixed','html','body','#root']]
  },

测试

npm run test
1.2.2

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago