刘勇虎的官方网站
网站内容包含大前端、服务器开发、Python开发、iOS开发、Android开发、网站维护等技术文章。专注于分享技术经验,职业心得体会,IT优秀文章与教程创作。
Stay hungry,Stay foolish,Stay young
"scripts": {
...,
"prepare": "husky install"
},
"lint-staged": {
"src/**/*.{vue,css,scss,sass}": "stylelint --fix"
},
"husky": "^8.0.3",
"lint-staged": "^13.2.0",
vue add eslint
or
"@babel/eslint-parser": "^7.12.16",
"@vue/cli-plugin-babel": "~5.0.0",
"@vue/cli-plugin-eslint": "~5.0.0",
"eslint": "^7.32.0",
"eslint-plugin-vue": "^8.0.3",
"postcss": "^8.4.13",
"postcss-html": "^1.5.0",
"stylelint": "^14.9.1",
"stylelint-config-recommended-scss": "^7.0.0",
"stylelint-config-recommended-vue": "^1.4.0",
"stylelint-config-standard": "^26.0.0",
"stylelint-config-standard-scss": "^5.0.0",
"postcss": "^8.4.13",
"postcss-html": "^1.5.0",
"postcss-less": "^6.0.0",
"stylelint": "^14.9.1",
"stylelint-config-recommended-less": "^1.0.4",
"stylelint-config-recommended-vue": "^1.4.0",
"stylelint-less": "^1.0.6",
"engines": {
"node": "^14.18.3"
}
输入命令行
npx husky add .husky/pre-commit
编辑文件 .husky/pre-commit
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
npx lint-staged
module.exports = {
root: true,
env: {
node: true,
},
extends: ["plugin:vue/essential", "eslint:recommended"],
parserOptions: {
parser: "@babel/eslint-parser",
},
rules: {
"no-debugger": process.env.NODE_ENV == "development" ? "off" : "error",
"no-console": process.env.NODE_ENV == "development" ? "off" : "error",
},
};
{
"extends": [
"stylelint-config-standard",
"stylelint-config-standard-scss",
"stylelint-config-recommended-vue/scss"
],
"rules": {
"declaration-block-no-redundant-longhand-properties": null,
"selector-class-pattern": "^[a-z]{1}[a-z-_]*[a-zA-Z]*$",
"selector-id-pattern": "^[a-z]{1}[a-z-_]*[a-zA-Z]*$",
"scss/at-function-pattern": null,
"scss/no-global-function-names": null,
"font-family-no-missing-generic-family-keyword": null,
"value-no-vendor-prefix": null,
"indentation": 2,
"selector-type-case": "lower"
}
}
{
"extends": ["stylelint-config-recommended-less"],
"overrides": [
{ "files": ["*.vue", "**/*.vue"], "customSyntax": "postcss-html" },
{ "files": ["*.less", "**/*.less"], "customSyntax": "postcss-less" }
],
"rules": {
"declaration-block-no-redundant-longhand-properties": null,
"selector-class-pattern": "^[a-z]{1}[a-z-_]*[a-zA-Z]*$",
"selector-id-pattern": "^[a-z]{1}[a-z-_]*[a-zA-Z]*$",
"font-family-no-missing-generic-family-keyword": null,
"value-no-vendor-prefix": null,
"indentation": 2,
"selector-type-case": "lower"
}
}
module.exports = {
...,
lintOnSave: "error",
}