0

I have an issue with prettier + eslint in a Vue project with Typescript. Everything is working as expected except one thing, insert new line at the end of the file.

Insert `␍⏎`eslintprettier/prettier
Newline required at end of file but not found.eslinteol-last

I am using VSCode. These are my settings:

I have vetur as default formatter for vue files:

"[vue]": {
        "editor.defaultFormatter": "octref.vetur"
}

In vetur, I have the formatters this way:

  • Default formatter for JS: prettier-eslint
  • Default formatter for TS: prettier-tslint

But when I save the `.vue file, everything is formatted but no new line is at the end of the file. Why not? I can enable this settings in VSCode:

Insert final new line and trim final new lines settings unchecked in VSCode

But I think it should not be necessary, prettier should do it.

Am I missing anything?

javifm
  • 705
  • 4
  • 9
  • 20
  • You're linting with prettier-eslint, but your formatter is prettier-tslint. TSLint !== ESLint, the former got deprecated a while ago. Maybe the two formatters have conflicting ideas over whether a newline should be added or not. I suggest using prettier-eslint as eslint supports TypeScript. – Excalibaard May 21 '21 at 13:19
  • No prettier-eslint option for TS, just prettier. Prettier resolves the issue, but I changed it I don´t remember why. Thanks for your response. – javifm May 21 '21 at 17:50

0 Answers0