Indeed, as you correctly guessed, the comments at the top of the file are not taken into account for the comment metrics. This is a default behavior of the JavaScript analyzer. The reason is that we assume that every source file generally starts with a license header as a comment. In your case, what’s happening is that line 4 and line 5 are considered to be such a source file header. That’s the reason why the comment count is 4 rather than 6.
Having said that, you can disable this behavior by configuring your SonarQube setup with the property sonar.javascript.ignoreHeaderComments set to false (default is true). Here is where you would do that in SonarQube’s UI: