return-statement.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. function jsx() {
  2. return (
  3. // Comment
  4. <div />
  5. );
  6. }
  7. function unary() {
  8. return (
  9. // Comment
  10. !!x
  11. );
  12. }
  13. function numericLiteralNoParen() {
  14. return 1337; // Comment
  15. }
  16. function logical() {
  17. return (
  18. // Reason for 42
  19. 42
  20. ) && 84
  21. }
  22. function binary() {
  23. return (
  24. // Reason for 42
  25. 42
  26. ) * 84
  27. }
  28. function binaryInBinaryLeft() {
  29. return (
  30. // Reason for 42
  31. 42
  32. ) * 84 + 2
  33. }
  34. function binaryInBinaryRight() {
  35. return (
  36. // Reason for 42
  37. 42
  38. ) + 84 * 2
  39. }
  40. function conditional() {
  41. return (
  42. // Reason for 42
  43. 42
  44. ) ? 1 : 2
  45. }
  46. function binaryInConditional() {
  47. return (
  48. // Reason for 42
  49. 42
  50. ) * 3 ? 1 : 2
  51. }
  52. function call() {
  53. return (
  54. // Reason for a
  55. a
  56. )()
  57. }
  58. function memberInside() {
  59. return (
  60. // Reason for a.b
  61. a.b
  62. ).c
  63. }
  64. function memberOutside() {
  65. return (
  66. // Reason for a
  67. a
  68. ).b.c
  69. }
  70. function memberInAndOutWithCalls() {
  71. return (
  72. // Reason for a
  73. aFunction.b()
  74. ).c.d()
  75. }
  76. function excessiveEverything() {
  77. return (
  78. // Reason for stuff
  79. a.b() * 3 + 4 ? (a`hi`, 1) ? 1 : 1 : 1
  80. )
  81. }
  82. // See https://github.com/prettier/prettier/issues/2392
  83. // function sequenceExpression() {
  84. // return (
  85. // // Reason for a
  86. // a
  87. // ), b
  88. // }
  89. function sequenceExpressionInside() {
  90. return ( // Reason for a
  91. a, b
  92. );
  93. }
  94. function taggedTemplate() {
  95. return (
  96. // Reason for a
  97. a
  98. )`b`
  99. }
  100. function inlineComment() {
  101. return (
  102. /* hi */ 42
  103. ) || 42
  104. }