是什么
.editorconfig是 EditorConfig.org提出的規(guī)范,主要用于在不同編輯器及IDE中提供代碼一致性。例如縮進(jìn)、換行、編碼等
誰在用
常見于github上的項目,包括bootstrap、angular,html5-boilerplate 等明星項目都在使用。
有誰資瓷
包括WebStorm、Atom、Visual Studio(Code)、xcode等都支持,部分通過插件支持
怎么用
本質(zhì)上是一個配置文件,并且是基于ini。官網(wǎng)有一個簡單的例子,直接搬運過來
# EditorConfig is awesome: http://EditorConfig.org
# top-most EditorConfig file(會從目錄一級級查找,直到找到root=true的文件)
root = true
# Unix-style newlines with a newline ending every file(換行符,還有cr\crlf)
[*]
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)
[Makefile]
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