diff --git a/tests/comments/__snapshots__/jsfmt.spec.js.snap b/tests/comments/__snapshots__/jsfmt.spec.js.snap
index 607a707cd..d8ce695d2 100644
--- a/tests/comments/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/comments/__snapshots__/jsfmt.spec.js.snap
@@ -82,7 +82,7 @@ const { a /* comment */ = 1 } = b
const { c = 1 /* comment */ } = d
let {
- d = b //comment
+ d = b, //comment
} = c
================================================================================
@@ -131,7 +131,7 @@ const foo = {
a: "a" /* comment for this line */,
/* Section B */
- b: "b"
+ b: "b",
}
================================================================================
@@ -1085,20 +1085,20 @@ export /* comment */{}
const foo = ""
export {
- foo // comment
+ foo, // comment
}
const bar = ""
export {
// comment
- bar
+ bar,
}
const fooo = ""
const barr = ""
export {
fooo, // comment
- barr // comment
+ barr, // comment
}
================================================================================
@@ -1185,7 +1185,7 @@ class C4 {
f/* f */(/* args */) /* returns */ {}
}
-function foo1()
+function foo1()
// this is a function
{
return 42
@@ -1320,7 +1320,7 @@ class C4 {
f/* f */(/* args */) /* returns */ {}
}
-function foo1()
+function foo1()
// this is a function
{
return 42
@@ -1362,7 +1362,7 @@ const obj = {
f1 /* f */() {},
f2(/* args */) {},
f3() /* returns */ {},
- f4 /* f */(/* args */) /* returns */ {}
+ f4 /* f */(/* args */) /* returns */ {},
}
;(function f /* f */() {})()
@@ -1725,36 +1725,84 @@ throw new ProcessSystemError({
originalError: acc.error, // Just in case.
});
-// Adding a comment stops the pretty printing process and everything is
-// squished in a single line afterward
-export type BuckWebSocketMessage =
- | {
- // Not actually from Buck - this is to let the receiver know that the socket is connected.
- type: "SocketConnected",
- }
- | {
- type: "BuildProgressUpdated",
- progressValue: number,
- }
- | {
- type: "BuildFinished",
- exitCode: number,
- }
- | {
- type: "BuildStarted",
- }
- | {
- type: "ParseStarted",
- }
- | {
- type: "ParseFinished",
- }
- | {
- type: "RunStarted",
- }
- | {
- type: "RunComplete",
- };
+// Missing one level of indentation because of the comment
+const rootEpic = (actions, store) => (
+ combineEpics(...epics)(actions, store)
+ // Log errors and continue.
+ .catch((err, stream) => {
+ getLogger().error(err);
+ return stream;
+ })
+);
+
+// optional trailing comma gets moved all the way to the beginning
+const regex = new RegExp(
+ '^\\\\s*' + // beginning of the line
+ 'name\\\\s*=\\\\s*' + // name =
+ '[\\'"]' + // opening quotation mark
+ escapeStringRegExp(target.name) + // target name
+ '[\\'"]' + // closing quotation mark
+ ',?$', // optional trailing comma
+);
+
+// The comment is moved and doesn't trigger the eslint rule anymore
+import path from 'path'; // eslint-disable-line nuclide-internal/prefer-nuclide-uri
+
+// Comments disappear in-between MemberExpressions
+Observable.of(process)
+ // Don't complete until we say so!
+ .merge(Observable.never())
+ // Get the errors.
+ .takeUntil(throwOnError ? errors.flatMap(Observable.throw) : errors)
+ .takeUntil(exit);
+
+// Comments disappear inside of JSX
+
+ {/* Some comment */}
+
;
+
+// Comments in JSX tag are placed in a non optimal way
+;
+
+// Comments disappear in empty blocks
+if (1) {
+ // Comment
+}
+
+// Comments trigger invalid JavaScript in-between else if
+if (1) {
+}
+// Comment
+else {
+
+}
+
+// The comment makes the line break in a weird way
+const result = asyncExecute('non_existing_command', /* args */ []);
+
+// The closing paren is printed on the same line as the comment
+foo({}
+ // Hi
+);
+
+=====================================output=====================================
+// Does not need to break as it fits in 80 columns
+this.call(a, /* comment */ b);
+
+function f(
+ someReallyLongArgument: WithSomeLongType,
+ someReallyLongArgument2: WithSomeLongType
+ // Trailing comment should stay after
+) {}
+
+// Comments should either stay at the end of the line or always before, but
+// not one before and one after.
+throw new ProcessSystemError({
+ code: acc.error.code, // Alias of errno
+ originalError: acc.error, // Just in case.
+});
// Missing one level of indentation because of the comment
const rootEpic = (actions, store) =>
@@ -1765,13 +1813,6 @@ const rootEpic = (actions, store) =>
return stream;
});
-// Two extra levels of indentation because of the comment
-export type AsyncExecuteOptions = child_process$execFileOpts & {
- // The contents to write to stdin.
- stdin?: ?string,
- dontLogInNuclide?: ?boolean,
-};
-
// optional trailing comma gets moved all the way to the beginning
const regex = new RegExp(
"^\\\\s*" + // beginning of the line
@@ -1924,7 +1965,7 @@ function f(
// not one before and one after.
throw new ProcessSystemError({
code: acc.error.code, // Alias of errno
- originalError: acc.error // Just in case.
+ originalError: acc.error, // Just in case.
})
// Missing one level of indentation because of the comment
@@ -2934,7 +2975,7 @@ var x = {
sectionMetaData: SectionMetaData
/* $FlowFixMe This error was exposed while converting keyMirror
* to keyMirrorRecursive */
- ): $Enum {}
+ ): $Enum {},
}
class X2 {
@@ -4104,11 +4145,11 @@ parsers: ["flow", "babel", "typescript"]
printWidth: 80
| printWidth
=====================================input======================================
-#!/there/is-space-here->
+#!/there/is-space-here->
// Do not trim trailing whitespace from this source file!
-// There is some space here ->
+// There is some space here ->
=====================================output=====================================
#!/there/is-space-here->
@@ -4127,11 +4168,11 @@ printWidth: 80
semi: false
| printWidth
=====================================input======================================
-#!/there/is-space-here->
+#!/there/is-space-here->
// Do not trim trailing whitespace from this source file!
-// There is some space here ->
+// There is some space here ->
=====================================output=====================================
#!/there/is-space-here->
@@ -4177,7 +4218,7 @@ const CONNECTION_STATUS = (exports.CONNECTION_STATUS = {
CLOSED: Object.freeze({ kind: "CLOSED" }),
CONNECTED: Object.freeze({ kind: "CONNECTED" }),
CONNECTING: Object.freeze({ kind: "CONNECTING" }),
- NOT_CONNECTED: Object.freeze({ kind: "NOT_CONNECTED" })
+ NOT_CONNECTED: Object.freeze({ kind: "NOT_CONNECTED" }),
});
/* A comment */
@@ -4240,7 +4281,7 @@ const CONNECTION_STATUS = (exports.CONNECTION_STATUS = {
CONNECTED: Object.freeze({ kind: "CONNECTED" }),
CONNECTING: Object.freeze({ kind: "CONNECTING" }),
NOT_CONNECTED: Object.freeze({ kind: "NOT_CONNECTED" }),
-});
+})
/* A comment */
/**
@@ -4573,23 +4614,23 @@ const foo3 = 123
let obj1 =
// Comment
{
- key: "val"
+ key: "val",
}
let obj2 =
// Comment
{
- key: "val"
+ key: "val",
}
let obj3 = {
// Comment
- key: "val"
+ key: "val",
}
let obj4 = {
// Comment
- key: "val"
+ key: "val",
}
let obj5 =
@@ -4602,12 +4643,12 @@ let obj6 =
let obj7 = [
// Comment
- "val"
+ "val",
]
let obj8 = [
// Comment
- "val"
+ "val",
]
let obj9 =
@@ -4671,7 +4712,7 @@ while(
while(true) {} // comment
-while(true) /* comment */ ++x;
+while(true) /* comment */ ++x;
=====================================output=====================================
while (
@@ -4727,7 +4768,7 @@ while(
while(true) {} // comment
-while(true) /* comment */ ++x;
+while(true) /* comment */ ++x;
=====================================output=====================================
while (
diff --git a/tests/flow_comments/__snapshots__/jsfmt.spec.js.snap b/tests/flow_comments/__snapshots__/jsfmt.spec.js.snap
index a3ec25cb8..d5abce83d 100644
--- a/tests/flow_comments/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/flow_comments/__snapshots__/jsfmt.spec.js.snap
@@ -166,37 +166,37 @@ export type AsyncExecuteOptions = child_process$execFileOpts & {
export type BuckWebSocketMessage =
| {
// Not actually from Buck - this is to let the receiver know that the socket is connected.
- type: "SocketConnected"
+ type: "SocketConnected",
}
| {
type: "BuildProgressUpdated",
- progressValue: number
+ progressValue: number,
}
| {
type: "BuildFinished",
- exitCode: number
+ exitCode: number,
}
| {
- type: "BuildStarted"
+ type: "BuildStarted",
}
| {
- type: "ParseStarted"
+ type: "ParseStarted",
}
| {
- type: "ParseFinished"
+ type: "ParseFinished",
}
| {
- type: "RunStarted"
+ type: "RunStarted",
}
| {
- type: "RunComplete"
+ type: "RunComplete",
};
// Two extra levels of indentation because of the comment
export type AsyncExecuteOptions = child_process$execFileOpts & {
// The contents to write to stdin.
stdin?: ?string,
- dontLogInNuclide?: ?boolean
+ dontLogInNuclide?: ?boolean,
};
================================================================================
diff --git a/tests/typescript_tuple/__snapshots__/jsfmt.spec.js.snap b/tests/typescript_tuple/__snapshots__/jsfmt.spec.js.snap
index f83084289..c76abb62a 100644
--- a/tests/typescript_tuple/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/typescript_tuple/__snapshots__/jsfmt.spec.js.snap
@@ -4,6 +4,7 @@ exports[`no-trailing-comma-after-rest.ts 1`] = `
====================================options=====================================
parsers: ["typescript"]
printWidth: 80
+trailingComma: "none"
| printWidth
=====================================input======================================
type ValidateArgs = [
@@ -32,7 +33,6 @@ exports[`no-trailing-comma-after-rest.ts 2`] = `
====================================options=====================================
parsers: ["typescript"]
printWidth: 80
-trailingComma: "es5"
| printWidth
=====================================input======================================
type ValidateArgs = [