Webstorm格式化代码用VScode的配置

 

我在使用webstorm做开发几年后,碰见了喜欢使用vscode的同事一起开发,但是出现了代码格式化不一致问题,这里我记录了我解决webstorm格式化适用vscode

  • 禁用script标签后export缩进问题
    在 webstorm 配置中 找到 code style -> HTML -> other -> Do not indent children of 中添加 script 标签

  • 字符串使用双引号,以及分号结尾
    code style -> Javascript -> Punctuation ->

use semicolon to terminate statement always
use double quotes always
Trailing comma Remove
  • 定义方法后和括号之间无空格
    code style -> Javascript -> Space -> Before Parentheses -> 取消勾选 Function declaretion parentheses 和 In function expression

  • 对象花括号和中间键值需要有空格
    code style -> Javascript -> Space -> Within -> 勾选Object literal braces

我对应的eslint配置

{
  ...
  // add your custom rules here
  rules: {
    // allow async-await
    'generator-star-spacing': 'off',
    // allow debugger during development
    'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
    // script的下一行缩进2格
    // 'vue/script-indent': ['error', 0, {'baseIndent': 1, 'switchCase': 1}],
    // 允许空一行,为了阅读方便
    'no-trailing-spaces': [1, { 'skipBlankLines': true }],
    // 全等
    'eqeqeq': 0,
    // 关闭行末分号提示/报错
    'semi': 0,
    // 字符串尽可能使用双引号
    'quotes': [0, "double"],
    // 函数定义时括号前面要不要有空格
    "space-before-function-paren": [0, "always"]
  },
  overrides: [
    {
      'files': ['*.vue'],
      'rules': {
        'indent': 'off'
      }
    }
  ]
  ...
}

 

转载:
https://www.jianshu.com/p/7f448e90f72f

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值