2

I want to write a chrome extension, so I need to write manifest.json, unfortunately, the IDE will not recognize the comments.

The documentation said:

It is a JSON-formatted file, with one exception: it is allowed to contain "//"-style comments.

So I am pretty sure added a comment for it is OK.

Is there any way to make the editor recognize the comments of manifest.json?

Carson
  • 6,105
  • 2
  • 37
  • 45
  • It seems that this self-answering question is not welcome, and I hope that those who voted against it can explain why. The first one who vote down that tells me, "Needs details or clarity." I have already edited it, and then I got a negative vote again. I don't understand what the reason is for voting. If this question is inappropriate, please leave a message, and I will delete the question. – Carson Jul 21 '21 at 16:33
  • I personally like your question. The "documentation" you refer to is from Mozilla though, so it could be different than what is allowed by Chrome extensions. However, even https://developer.chrome.com/docs/extensions/mv3/intro/mv3-migration/ shows comments in manifest.json especially in the Manifest V3 examples. So it would be nice if someone could provide a documented/official answer about if comments are allowed in manifest.json files for Chrome extensions. – Jeff Baker Jul 11 '22 at 19:59

1 Answers1

3

You can use the way as below,

{
  "//1": "comment 1",
  "//2": "comment 2",
  "id": "123"
}

see: https://stackoverflow.com/a/44700108/9935654

But I think the best way is to change the Recognized File Types to the json5

enter image description here

Carson
  • 6,105
  • 2
  • 37
  • 45