Stylelint Config for GSC Basic Team
DO NOT use it in your own project if you don't know what it's for
通过此拓展共享配置快速开始项目配置,内置支持Vue SFC
、Less
、HTML CSS
的检查。
Stylelint v16.9.0+ is now required.
pnpm i @gsc-basic/stylelint-config stylelint -D
// stylelint.config.mjs
export default {
root: true,
extends: ['@gsc-basic/stylelint-config'],
};
// package.json
{
"scripts": {
"lint:stylelint": "stylelint \"**/*.{vue,less,postcss,css}\" --fix"
}
}
将依赖项提升到根模块目录,保证命令可以正常执行
# .npmrc
public-hoist-pattern[]=*postcss*
项目根目录添加 .stylelintignore
dist
public
__tests__
coverage
pnpm i lint-staged -D
// package.json
{
"scripts": {
"lint-staged": "lint-staged"
},
"lint-staged": {
"*.{css,less,scss,postcss,vue}": [
"stylelint --fix"
]
}
}
# .husky/pre-commit
npm run lint-staged
echo Run pre-commit hook done.
// .vscode/settings.json
{
"stylelint.packageManager": "pnpm",
"stylelint.validate": ["vue", "css", "less", "postcss", "scss"]
}