Fix comment detection before comma (#1127)

We need to call the `skipToLineEnd` which skips `,` after an inline comment. So we have to put it inside of the while loop as you can have many comments, a comma and then many more comments.

Fixes #964
master
Christopher Chedeau 2017-04-10 11:03:35 -07:00 committed by GitHub
parent 0669160adc
commit f51c5daacb
3 changed files with 24 additions and 1 deletions

View File

@ -217,10 +217,10 @@ function isPreviousLineEmpty(text, node) {
function isNextLineEmpty(text, node) {
let oldIdx = null;
let idx = locEnd(node);
idx = skipToLineEnd(text, idx);
while (idx !== oldIdx) {
// We need to skip all the potential trailing inline comments
oldIdx = idx;
idx = skipToLineEnd(text, idx);
idx = skipInlineComment(text, idx);
idx = skipSpaces(text, idx);
}

View File

@ -18,6 +18,23 @@ let {
"
`;
exports[`before-comma.js 1`] = `
"const foo = {
a: 'a' /* comment for this line */,
/* Section B */
b: 'b',
};
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
const foo = {
a: \\"a\\" /* comment for this line */,
/* Section B */
b: \\"b\\"
};
"
`;
exports[`blank.js 1`] = `
"// This file only
// has comments. This comment

View File

@ -0,0 +1,6 @@
const foo = {
a: 'a' /* comment for this line */,
/* Section B */
b: 'b',
};