关于VScode编辑器Prettier插件格式化代码的样例
发布时间:2022-02-17
浏览量: 1435
文章分类: 前端相关
使用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,vue,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
这里也分享一下关于在vue项目中我的使用
{
"semi": false,
"singleQuote": true,
"trailingComma": "none",
"tabWidth": 4,
"printWidth": 180,
"useTabs": true
}