It turns that our hasNextLine logic needs to be tuned to skip all the trailing comments. The code is not pretty but it does the job. It looks like it fixes a bunch of things in the test cases :) I made sure that nested inline comments are NOT valid JavaScript ```js /* /* a */ */ Uncaught SyntaxError: Unexpected token * ``` so it is okay to do a dumb search for */ when you are in a comment
29 lines
359 B
JavaScript
29 lines
359 B
JavaScript
function a() {
|
|
const a = 5; // comment
|
|
|
|
return a;
|
|
}
|
|
|
|
function a() {
|
|
const a = 5; /* comment */
|
|
|
|
return a;
|
|
}
|
|
|
|
function a() {
|
|
const a = 5; /* comment */ /* comment */
|
|
|
|
return a;
|
|
}
|
|
|
|
function a() {
|
|
const a = 5; /* comment */ /* comment */ // comment
|
|
return a;
|
|
}
|
|
|
|
function a() {
|
|
const a = 5; /* comment */ /* comment */ // comment
|
|
|
|
return a;
|
|
}
|