.editorconfig

摘要

是什么

EditorConfig是一套用于统一代码格式的解决方案,可以帮助开发者在不同的编辑器和IDE之间定义和维护一致的代码风格。

EditorConfig包含一个用于定义代码格式的文件和一批编辑器插件,这些插件可以让编辑器读取配置文件并依此格式化代码。

EditorConfig的配置文件十分易读,目前支持的属性非常少,且只局限于基本的文件缩进、换行等格式(当然这与其定位有关),虽然并不能满足团队里代码规范统一的要求,但是其简单易上手、跨编辑器且静默生效的特点,建议在项目中使用。

示例

# EditorConfig is awesome: http://EditorConfig.org
 
# top-most EditorConfig file
root = true
 
# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
 
# Matches multiple files with brace expansion notation
# Set default charset
[*.{js,py}]
charset = utf-8
 
# 4 space indentation
[*.py]
indent_style = space
indent_size = 4
 
# Tab indentation (no size specified)  
[*.js]  
indent_style = tab
 
# Indentation override for all JS under lib directory
[lib/**.js]
indent_style = space
indent_size = 2
 
# Matches the exact files either package.json or .travis.yml
[{package.json,.travis.yml}]
indent_style = space
indent_size = 2
posted @ 2017-07-26 15:50  空城夕  阅读(235)  评论(0编辑  收藏  举报