formattingeslintvscode-extensionsprettiertslint

How to add tslint-disable and prettier-ignore both for a single line


How can I disable tslint/eslint and ignore the prettier for a single line, both rules at the same line?

I want to align all the properties of the object using vscode plugin but prettier reformats it and the whitespace is removed by the eslint rule.

const user = {
  id: 123456,
  name: "John Doe",
  user_email_id: "user@example.com",
};

I want the output as follows:

const user = {
  id            : 123456,
  name          : "John Doe",
  user_email_id : "user@example.com",
};

Solution

  • Tslint/eslint and prettier can be disabled by the following rule to align the properties:

    /* prettier-ignore */ // tslint:disable typedef-whitespace
    const user = {
      id            : 123456,
      name          : "John Doe",
      user_email_id : "user@example.com",
    };