Appearance
不同系统下换行符CRLF与LF
linux和macOS默认为LF(\n),而window默认为CRLF(\r\n)
查看git配置:git config -l
vscode右下角可查看当前文件换行符的格式
当git的core.autocrlf设置不同值时:
true 提交时将
CRLF转化为LF,检出时将LF转化为CRLFfasle 不做处理
input 提交时将
CRLF转化为LF,检出时不做处理
衍生问题
git出现LF will be replaced by CRLF in xxxDelete ␍ eslint(prettier/prettier)
解决方案:统一使用LF
git config core.autocrlf falsevscode设置中搜搜files.eol,设置为\n(LF)vscode安装EditorConfig for VS Code,项目中新增.editorconfig文件,写入
# top-most EditorConfig file
root = true
# Unix-style newlines with a newline ending every file
[*]
# lf, cr, or crlf
end_of_line = lf
vscode设置中搜索@ext:esbenp.prettier-vscode设置end of line为LF
参考文档:
https://prettier.io/docs/en/options.html#end-of-line
http://www.kehuanxianshi.com/work/miniapp/miniapp-prettier-vscode.html