vscode 配置插件支持 react js 格式化

2019-03-18  本文已影响0人  闲看热闹的

0. 背景

近期有项目要使用 ant design pro 做开发,前端开发工具统一使用 vscode,大家提交的代码格式不太统一,为了方便开发,多方查找资料,找到了合适的插件进行代码的格式化。

1. 插件及相关配置

需安装插件列表

需添加文件配置
以下文件需要添加到项目根目录

# http://editorconfig.org
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false

[Makefile]
indent_style = tab
**/*.md
**/*.svg
package.json
.umi
.umi-production
{
  "singleQuote": false,
  "trailingComma": "es5",
  "printWidth": 100,
  "overrides": [
    {
      "files": ".prettierrc",
      "options": { "parser": "json" }
    }
  ]
}

需添加依赖

2. 使用方法

打开需要格式化的文件,使用如下快捷键
windows: CTRL + ALT + F
mac: SHIFT + ALT + F

上一篇 下一篇

猜你喜欢

热点阅读