Why do I have a prettier newline warning on every single line?

934 views Asked by At

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.

1

There are 1 answers

0
ArrayConstructor On

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 !