0

I am trying to format a js file with prettier but it seems prettier is breaking the code syntax. I want to achieve this (expectated result) but the red lines appear. On save I get the following result. While running the code I get the following error TypeError: {} is not a function (error image). I tried the following but none seems to work in my case.

  1. Why do I keep getting Delete 'cr' [prettier/prettier]?
  2. Visual Studio Code [eslint] Delete 'CR' [prettier/prettier] on windows

I am using the following .prettierrc.js

module.exports = {
  tabWidth: 2,
  bracketSpacing: true,
  endOfLine: "auto",
  jsxBracketSameLine: true,
  printWidth: 100,
  semi: false,
  singleQuote: false,
  trailingComma: "none"
}

In my .eslintrc.json file I have the following rules set for prettier

"prettier/prettier": [
      "error",
      {
        "bracketSpacing": true,
        "endOfLine": "auto",
        "jsxBracketSameLine": true,
        "printWidth": 100,
        "semi": false,
        "singleQuote": false,
        "trailingComma": "none"
      }
    ],

I have tried changing LF to CRLF and vice versa that appears in the bottom section of vscode but no success. What else am I missing?

Gopal Dahale
  • 13
  • 1
  • 1
  • https://stackoverflow.com/questions/66149802/is-there-a-way-to-stop-prettier-prettier-now-from-breaking-function-arguments/66182235#66182235 – Dpk Jul 18 '21 at 15:04
  • Thanks. This works but it's a workaround and not a good practice in my opinion. – Gopal Dahale Jul 18 '21 at 15:26
  • Still, the error persists. – Gopal Dahale Jul 18 '21 at 15:39
  • prettier follows all good practices and format the code accordinglly however sometimes users want different formating style in that case we have to ignour some block of codes – Dpk Jul 18 '21 at 17:09

0 Answers0