关于VScode编辑器Prettier插件格式化代码的样例
发布时间:2022-02-17
浏览量: 357
文章分类: 前端相关
使用vscode
开发一些基于react
的前端页面也有一段时间了,我自己觉得最恶心的就是代码的格式化问题了。
这里记录一下我日常使用的方法。目前整体感觉还不错。
我使用的格式化插件是Prettier
插件。
在安装以后还需要在项目的根目录创建.editorconfig
文件,同时进行如下的配置。
# EditorConfig is awesome: http://EditorConfig.org
root = true
[*]
charset = utf-8
end_of_line = lf
indent_style = space
insert_final_newline = true
[*.{js,jsx,ts,tsx,mjs,mjsx,cjs,cjsx,sh,rb}]
indent_size = 4
max_line_length = 80
trim_trailing_whitespace = true
[*.py]
indent_size = 4
max_line_length = 80
trim_trailing_whitespace = true
[*.{css,scss,less,html,hbs,ejs,json,code-workspace,yml,yaml,gql}]
indent_size = 4
trim_trailing_whitespace = true