Print comment after key (#1131)

This commit is contained in:
Lucas Duailibe authored and Christopher Chedeau committed 2017-04-05 13:10:10 -07:00
1 parent 926f9c4dfb
commit 69879e23bc
3 files changed
+30 -1

No files matched your search

+4 -1
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");
}
@@ -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:
@@ -0,0 +1,7 @@
let a = {
a /* comment */: () => 1
};
let a = {
"a" /* comment */: () => 1
};