0

The problem is I am getting a prettier error on every single line in my file.

Prettier Screenshot

I created a blank new Typescript file in an already existing code for a client and that's the only file with this issue.

There's nothing wrong with any of the code itself (no errors.) Has anyone seen this before?

I have tried closing and reopening the PowerShell, VScode, and restarting my pc. Reopened and its still got the same list. It suggests // eslint-disable-next-line to fix it. But I would have to paste it at the end of all 100 lines which wouldn't be practical.

My company uses azure devops and it wont allow code to go through with prettier errors.

  • Possibly it has something to do with Windows and Linux using different EOL. Check Prettier configuration https://prettier.io/docs/en/options.html#end-of-line or change the default EOL in VScode for all your files. – eventHandler Jun 10 '23 at 17:38
  • [Please do not upload images of code/data/errors.](//meta.stackoverflow.com/q/285551) – Heretic Monkey Jun 16 '23 at 15:18

1 Answers1

1

it's probably the endOfLine of your files that isn't well configured. I think your files are in clrf and vscode by default is in lf.

  1. What you can do is add this setting in your prettierrc or eslintrc.

    'prettier/prettier': [
      'error',
      {
        singleQuote: true,
        tabWidth: 2,
        semi: true,
        singleAttributePerLine: true,
        bracketSpacing: true,
        bracketSameLine: false,
        vueIndentScriptAndStyle: true,
        trailingComma: 'all',
        endOfLine: 'crlf', // Here !!!!!
        printWidth: 100,
      },
    ],
    
  2. You can modify the endOfline in vscode of single File like here in the down bar :

enter image description here

enter image description here

Or you can activate it on all your files by adding this in your .vscode/settings.json. (For all your files already created you will steel have to change them, but all your new files will be put in clrf or lf)

"files.eol": "\r\n",

Hope it works for you !

Samuel
  • 464
  • 5