Skip to content

Commit 1f9e69c

Browse files
h7mlsendya
authored andcommitted
feat(commitlint && stylelint && husky): git engineering submission && less lint
1 parent 24fe79d commit 1f9e69c

25 files changed

+289
-12291
lines changed

.husky/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
_

.husky/commit-msg

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
npx --no-install commitlint --edit "$1"

.husky/pre-commit

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
npm run lint

.lintstagedrc.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"*.js": "eslint --fix",
3+
"*.{css,less}": "stylelint --fix"
4+
}

.stylelintrc.js

+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
module.exports = {
2+
processors: [],
3+
plugins: ['stylelint-order'],
4+
extends: [
5+
'stylelint-config-standard',
6+
'stylelint-config-css-modules'
7+
],
8+
rules: {
9+
'selector-class-pattern': null,
10+
'string-quotes': 'single', // 单引号
11+
'at-rule-empty-line-before': null,
12+
'at-rule-no-unknown': null,
13+
'at-rule-name-case': 'lower', // 指定@规则名的大小写
14+
'length-zero-no-unit': true, // 禁止零长度的单位(可自动修复)
15+
'shorthand-property-no-redundant-values': true, // 简写属性
16+
'number-leading-zero': 'never', // 小数不带0
17+
'declaration-block-no-duplicate-properties': null, // 禁止声明快重复属性
18+
'no-descending-specificity': null, // 禁止在具有较高优先级的选择器后出现被其覆盖的较低优先级的选择器。
19+
'selector-max-id': 3, // 限制一个选择器中 ID 选择器的数量
20+
'max-nesting-depth': 4,
21+
'indentation': [2, { // 指定缩进 warning 提醒
22+
'severity': 'warning'
23+
}],
24+
'order/properties-order': [ // 规则顺序
25+
'position',
26+
'top',
27+
'right',
28+
'bottom',
29+
'left',
30+
'z-index',
31+
'display',
32+
'float',
33+
'width',
34+
'height',
35+
'max-width',
36+
'max-height',
37+
'min-width',
38+
'min-height',
39+
'padding',
40+
'padding-top',
41+
'padding-right',
42+
'padding-bottom',
43+
'padding-left',
44+
'margin',
45+
'margin-top',
46+
'margin-right',
47+
'margin-bottom',
48+
'margin-left',
49+
'margin-collapse',
50+
'margin-top-collapse',
51+
'margin-right-collapse',
52+
'margin-bottom-collapse',
53+
'margin-left-collapse',
54+
'overflow',
55+
'overflow-x',
56+
'overflow-y',
57+
'clip',
58+
'clear',
59+
'font',
60+
'font-family',
61+
'font-size',
62+
'font-smoothing',
63+
'osx-font-smoothing',
64+
'font-style',
65+
'font-weight',
66+
'line-height',
67+
'letter-spacing',
68+
'word-spacing',
69+
'color',
70+
'text-align',
71+
'text-decoration',
72+
'text-indent',
73+
'text-overflow',
74+
'text-rendering',
75+
'text-size-adjust',
76+
'text-shadow',
77+
'text-transform',
78+
'word-break',
79+
'word-wrap',
80+
'white-space',
81+
'vertical-align',
82+
'list-style',
83+
'list-style-type',
84+
'list-style-position',
85+
'list-style-image',
86+
'pointer-events',
87+
'cursor',
88+
'background',
89+
'background-color',
90+
'border',
91+
'border-radius',
92+
'content',
93+
'outline',
94+
'outline-offset',
95+
'opacity',
96+
'filter',
97+
'visibility',
98+
'size',
99+
'transform'
100+
]
101+
}
102+
}

commitlint.config.js

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/**
2+
* feat:新增功能
3+
* fix:bug 修复
4+
* docs:文档更新
5+
* style:不影响程序逻辑的代码修改(修改空白字符,格式缩进,补全缺失的分号等,没有改变代码逻辑)
6+
* refactor:重构代码(既没有新增功能,也没有修复 bug)
7+
* perf:性能, 体验优化
8+
* test:新增测试用例或是更新现有测试
9+
* build:主要目的是修改项目构建系统(例如 glup,webpack,rollup 的配置等)的提交
10+
* ci:主要目的是修改项目继续集成流程(例如 Travis,Jenkins,GitLab CI,Circle等)的提交
11+
* chore:不属于以上类型的其他类型,比如构建流程, 依赖管理
12+
* revert:回滚某个更早之前的提交
13+
*/
14+
15+
module.exports = {
16+
extends: ['@commitlint/config-conventional'],
17+
rules: {
18+
'type-enum': [
19+
2,
20+
'always',
21+
['feat', 'fix', 'docs', 'style', 'refactor', 'test', 'chore', 'revert'],
22+
],
23+
'subject-full-stop': [0, 'never'],
24+
'subject-case': [0, 'never'],
25+
},
26+
};

package.json

+30-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
"test:unit": "vue-cli-service test:unit",
99
"lint": "vue-cli-service lint",
1010
"build:preview": "vue-cli-service build --mode preview",
11-
"lint:nofix": "vue-cli-service lint --no-fix"
11+
"lint:nofix": "vue-cli-service lint --no-fix",
12+
"lint:js": "eslint src/**/*.js --fix",
13+
"lint:css": "stylelint src/**/*.*ss --fix --custom-syntax postcss-less",
14+
"prepare": "husky install"
1215
},
1316
"dependencies": {
1417
"@ant-design-vue/pro-layout": "^1.0.11",
@@ -38,6 +41,8 @@
3841
},
3942
"devDependencies": {
4043
"@ant-design/colors": "^3.2.2",
44+
"@commitlint/cli": "^12.1.4",
45+
"@commitlint/config-conventional": "^12.1.4",
4146
"@vue/babel-helper-vue-jsx-merge-props": "^1.2.1",
4247
"@vue/cli-plugin-babel": "^4.5.17",
4348
"@vue/cli-plugin-eslint": "^4.5.17",
@@ -50,16 +55,40 @@
5055
"babel-eslint": "^10.1.0",
5156
"babel-plugin-import": "^1.13.3",
5257
"babel-plugin-transform-remove-console": "^6.9.4",
58+
"commitizen": "^4.2.4",
59+
"cz-conventional-changelog": "^3.3.0",
5360
"eslint": "^5.16.0",
5461
"eslint-plugin-html": "^5.0.5",
5562
"eslint-plugin-vue": "^5.2.3",
5663
"file-loader": "^6.2.0",
5764
"git-revision-webpack-plugin": "^3.0.6",
65+
"husky": "^6.0.0",
5866
"less": "^3.13.1",
5967
"less-loader": "^5.0.0",
68+
"lint-staged": "^12.5.0",
69+
"postcss-less": "^6.0.0",
6070
"regenerator-runtime": "^0.13.9",
71+
"stylelint": "^14.8.5",
72+
"stylelint-config-css-modules": "^4.1.0",
73+
"stylelint-config-recess-order": "^3.0.0",
74+
"stylelint-config-recommended": "^7.0.0",
75+
"stylelint-config-standard": "^25.0.0",
76+
"stylelint-order": "^5.0.0",
6177
"vue-svg-icon-loader": "^2.1.1",
6278
"vue-template-compiler": "^2.6.14",
6379
"webpack-theme-color-replacer": "^1.3.26"
80+
},
81+
"config": {
82+
"commitizen": {
83+
"path": "./node_modules/cz-conventional-changelog"
84+
}
85+
},
86+
"husky": {
87+
"hooks": {
88+
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
89+
}
90+
},
91+
"gitHooks": {
92+
"pre-commit": "lint-staged"
6493
}
6594
}

0 commit comments

Comments
 (0)