issues.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. // Does not need to break as it fits in 80 columns
  2. this.call(a, /* comment */ b);
  3. function f(
  4. someReallyLongArgument: WithSomeLongType,
  5. someReallyLongArgument2: WithSomeLongType,
  6. // Trailing comment should stay after
  7. ) {}
  8. // Comments should either stay at the end of the line or always before, but
  9. // not one before and one after.
  10. throw new ProcessSystemError({
  11. code: acc.error.code, // Alias of errno
  12. originalError: acc.error, // Just in case.
  13. });
  14. // Adding a comment stops the pretty printing process and everything is
  15. // squished in a single line afterward
  16. export type BuckWebSocketMessage = {
  17. // Not actually from Buck - this is to let the receiver know that the socket is connected.
  18. type: 'SocketConnected',
  19. } | {
  20. type: 'BuildProgressUpdated',
  21. progressValue: number,
  22. } | {
  23. type: 'BuildFinished',
  24. exitCode: number,
  25. } | {
  26. type: 'BuildStarted',
  27. } | {
  28. type: 'ParseStarted',
  29. } | {
  30. type: 'ParseFinished',
  31. } | {
  32. type: 'RunStarted',
  33. } | {
  34. type: 'RunComplete',
  35. };
  36. // Missing one level of indentation because of the comment
  37. const rootEpic = (actions, store) => (
  38. combineEpics(...epics)(actions, store)
  39. // Log errors and continue.
  40. .catch((err, stream) => {
  41. getLogger().error(err);
  42. return stream;
  43. })
  44. );
  45. // Two extra levels of indentation because of the comment
  46. export type AsyncExecuteOptions = child_process$execFileOpts & {
  47. // The contents to write to stdin.
  48. stdin?: ?string,
  49. dontLogInNuclide?: ?boolean,
  50. };
  51. // optional trailing comma gets moved all the way to the beginning
  52. const regex = new RegExp(
  53. '^\\s*' + // beginning of the line
  54. 'name\\s*=\\s*' + // name =
  55. '[\'"]' + // opening quotation mark
  56. escapeStringRegExp(target.name) + // target name
  57. '[\'"]' + // closing quotation mark
  58. ',?$', // optional trailing comma
  59. );
  60. // The comment is moved and doesn't trigger the eslint rule anymore
  61. import path from 'path'; // eslint-disable-line nuclide-internal/prefer-nuclide-uri
  62. // Comments disappear in-between MemberExpressions
  63. Observable.of(process)
  64. // Don't complete until we say so!
  65. .merge(Observable.never())
  66. // Get the errors.
  67. .takeUntil(throwOnError ? errors.flatMap(Observable.throw) : errors)
  68. .takeUntil(exit);
  69. // Comments disappear inside of JSX
  70. <div>
  71. {/* Some comment */}
  72. </div>;
  73. // Comments in JSX tag are placed in a non optimal way
  74. <div
  75. // comment
  76. />;
  77. // Comments disappear in empty blocks
  78. if (1) {
  79. // Comment
  80. }
  81. // Comments trigger invalid JavaScript in-between else if
  82. if (1) {
  83. }
  84. // Comment
  85. else {
  86. }
  87. // The comment makes the line break in a weird way
  88. const result = asyncExecute('non_existing_command', /* args */ []);
  89. // The closing paren is printed on the same line as the comment
  90. foo({}
  91. // Hi
  92. );