0

Prettier or Eslint is formatting my constructor by adding parentheses, how do I stop this?

It was my code before saving

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

This is the after saving.

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

}
CodeHada
  • 27
  • 4
  • Does this answer your question? [prettier convert multi line to single line in constructor function](https://stackoverflow.com/questions/65879046/prettier-convert-multi-line-to-single-line-in-constructor-function) – thorn0 Apr 08 '21 at 13:30

1 Answers1

0

It was only wrong grammer...

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

to

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