【问题标题】:vscode inserting parentheses in the constructor when i save js file当我保存js文件时,vscode在构造函数中插入括号
【发布时间】:2020-08-08 11:42:14
【问题描述】:

Prettier 或 Eslint 正在通过添加括号来格式化我的构造函数,我该如何阻止它?

这是我保存前的代码

function Person(name, first, second) {
    this.name = name,
    this.first = first,
    this.second = second,
    this.sum = function () {
        return this.frst + this.second
    }
}

这是保存后的。

    function Person(name, first, second) {
      (this.name = name),
        (this.first = first),
        (this.second = second),
        (this.sum = function () {
          return this.frst + this.second;
        });

}

【问题讨论】:

标签: visual-studio-code eslint prettier


【解决方案1】:

只是语法错误……

function Person(name, first, second) {
    this.name = name,
    this.first = first,
    this.second = second,
    this.sum = function () {
        return this.frst + this.second
    }
}

function Person(first, last, age, eye) {
  this.firstName = first
  this.lastName = last
  this.age = age
  this.eyeColor = eye
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-10-24
    • 1970-01-01
    • 2023-02-16
    • 1970-01-01
    • 2023-03-20
    • 1970-01-01
    • 1970-01-01
    • 2013-03-02
    相关资源
    最近更新 更多