Skip to content
This repository was archived by the owner on Aug 11, 2021. It is now read-only.

Commit 263b515

Browse files
committed
更新文档
1 parent 54b48c1 commit 263b515

File tree

2 files changed

+48
-2
lines changed

2 files changed

+48
-2
lines changed

.eslintrc.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ module.exports = {
66
},
77
globals: {
88
process: true,
9-
require: true
9+
require: true,
10+
module: true
1011
},
1112
extends: [
1213
'plugin:vue/strongly-recommended',

docs/coding-standard.md

+46-1
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,49 @@
2929

3030
> 可通过修改 `.eslintignore``.stylelintignore` 忽略无需做代码规范的文件,例如在项目中引用了一些第三方的插件或组件,我们就可以将其忽略
3131
32-
如果 `git init` 仓库初始化是在依赖包安装之后执行的,则无法初始化 Git 钩子,建议在 `git init` 之后再执行一遍 `yarn` 或者 `npm i` ,重新安装一遍依赖包。
32+
如果 `git init` 仓库初始化是在依赖包安装之后执行的,则无法初始化 Git 钩子,建议在 `git init` 之后再执行一遍 `yarn` 或者 `npm i` ,重新安装一遍依赖包。
33+
34+
## 配置代码规范
35+
36+
配置文件主要有 3 处,分别为 IDE 配置(`.editorconfig`)、ESLint 配置(`.eslintrc.js``.eslintignore`)、StyleLint 配置(`.stylelintrc``.stylelintignore`)。
37+
38+
已代码缩进举例,模版默认是以 4 空格为缩进,如果要调整为 2 空格,则分别在 `.editorconfig` 里修改:
39+
40+
```
41+
indent_size = 2
42+
```
43+
44+
`.eslintrc.js` 里修改:
45+
46+
```
47+
'indent': [2, 2, {
48+
'SwitchCase': 1
49+
}],
50+
51+
...
52+
53+
'vue/html-indent': [2, 2],
54+
55+
...
56+
57+
'vue/script-indent': [2, 2, {
58+
'switchCase': 1
59+
}]
60+
```
61+
62+
`.stylelintrc` 里修改:
63+
64+
```
65+
"indentation": 2
66+
```
67+
68+
修改完毕后,分别执行:
69+
70+
```bash
71+
yarn run lint
72+
yarn run stylelint
73+
```
74+
75+
该操作会将代码进行一次格式校验,如果规则支持自动修复,则会将不符合规则的代码自动进行格式化。
76+
77+
以上面的例子,当缩进规则调整后,我们无需手动去每个文件调整,通过命令可以自动应用新的缩进规则。

0 commit comments

Comments
 (0)