Print comment after key (#1131)

master
Lucas Duailibe 2017-04-05 17:10:10 -03:00 committed by Christopher Chedeau
parent 926f9c4dfb
commit 69879e23bc
3 changed files with 30 additions and 1 deletions

View File

@ -1985,7 +1985,10 @@ function printPropertyKey(path, options, print) {
(options.parser !== "flow" || key.value.match(/[a-zA-Z0-9$_]/))
) {
// 'a' -> a
return key.value;
return path.call(
keyPath => comments.printComments(keyPath, p => key.value, options),
"key"
);
}
return path.call(print, "key");
}

View File

@ -1,5 +1,24 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`after-key.js 1`] = `
"let a = {
a /* comment */: () => 1
};
let a = {
\\"a\\" /* comment */: () => 1
};
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
let a = {
a /* comment */: () => 1
};
let a = {
a /* comment */: () => 1
};
"
`;
exports[`comment.js 1`] = `
"o = {
name:

View File

@ -0,0 +1,7 @@
let a = {
a /* comment */: () => 1
};
let a = {
"a" /* comment */: () => 1
};