1.介绍
该章的主角是EditorConfig。就是告诉你的ide这么约束你的项目的。
2.安装EditorConfig插件
不同的IDE都有这个插件,安装上去就好了。
vsCode的 EditorConfig for VS Code
3.创建约束文件
在根目录下创建.editorconfig
文件
3.1.原代码
root = true
[*]
charset=utf-8
end_of_line=lf
insert_final_newline=true
indent_style=space
indent_size=2
max_line_length = 100
[*.{yml,yaml,json}]
indent_style = space
indent_size = 2
[*.md]
trim_trailing_whitespace = false
[Makefile]
indent_style = tab
3.2.带注释代码
# ↓告诉EditorConfig插件,这是根文件,不用继续往上查找。
root = true
# ↓匹配全部文件。
[*]
# ↓使用`utf-8`字符集。
charset=utf-8
# ↓结尾换行符,可选`lf`、`cr`、`crlf`。
end_of_line=lf
# ↓在文件结尾插入新行。
insert_final_newline=true
# ↓缩进的样式为空格。
indent_style=space
# ↓缩进为2。
indent_size=2
# ↓行最大长度为100。
max_line_length = 100
# ↓匹配以`.yml`、`.yaml`、`.json`结尾的文件。
[*.{yml,yaml,json}]
indent_style = space
indent_size = 2
# ↓匹配以`.md`结尾的文件。
[*.md]
# ↓
trim_trailing_whitespace = false
[Makefile]
indent_style = tab
上一章
第三章-准备好vsCode插件
下一章
第五章-Vite配置多环境