1.2.2 • Published 10 months ago
no-top-global v1.2.2
功能
校验样式文件中最外层: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