1

I'm using Prettier in VSCode, but it appears to be flagging mistakes that I think are ok.

Specifically, if I test a variable like:

if (myObject?.property1?.property2) {
  ....
}

(Not sure of the correct name for using questions marks like this) then it flags the question marks as invalid.

I can see there is an ecmaVersion setting in .prettierrc but this doesn't seem to do anything, and anyway, as I understand it, Node versions don't exactly follow ECMA versions anyway.

What can I do to make Prettier correctly lint my code?

user4893295
  • 533
  • 6
  • 25
  • What's the exact message Prettier prints? Maybe some of the question marks are not needed, which is a good reason for a linter warning. – Mike Lischke Dec 16 '21 at 08:01
  • It puts a wavy red line under the first question mark, but no explanation. If you delete that question mark, it moves on to the next, and so on. – user4893295 Dec 16 '21 at 22:50
  • You can hover with the mouse over the word with the wavy line and it will show a tooltip with more information. Also you probably have an entry in the PROBLEMS tab for each marked problem. – Mike Lischke Dec 17 '21 at 07:44
  • A restart brought up the explaination - but it just says `unexpected token '?'`. But it IS expected! Which is my point. It's valid syntax, I think... – user4893295 Dec 18 '21 at 21:51

0 Answers0