prettier 1.16.0 → 1.16.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin-prettier.js CHANGED
@@ -14,7 +14,7 @@ var thirdParty__default = thirdParty['default'];
14
14
  var readline = _interopDefault(require('readline'));
15
15
 
16
16
  var name = "prettier";
17
- var version$1 = "1.16.0";
17
+ var version$1 = "1.16.4";
18
18
  var description = "Prettier is an opinionated code formatter";
19
19
  var bin = {
20
20
  "prettier": "./bin/prettier.js"
@@ -56,6 +56,7 @@ var dependencies = {
56
56
  "html-styles": "1.0.0",
57
57
  "html-tag-names": "1.1.2",
58
58
  "ignore": "3.3.7",
59
+ "is-ci": "2.0.0",
59
60
  "jest-docblock": "23.2.0",
60
61
  "json-stable-stringify": "1.0.1",
61
62
  "leven": "2.1.0",
@@ -109,7 +110,7 @@ var devDependencies = {
109
110
  "jest-snapshot-serializer-raw": "1.1.0",
110
111
  "jest-watch-typeahead": "0.1.0",
111
112
  "mkdirp": "0.5.1",
112
- "prettier": "1.15.3",
113
+ "prettier": "1.16.3",
113
114
  "prettylint": "1.0.0",
114
115
  "rimraf": "2.6.2",
115
116
  "rollup": "0.47.6",
@@ -4139,6 +4140,7 @@ function getSupportInfo$2(version, opts) {
4139
4140
  });
4140
4141
  });
4141
4142
  var usePostCssParser = semver.lt(version, "1.7.1");
4143
+ var useBabylonParser = semver.lt(version, "1.16.0");
4142
4144
  var languages = plugins.reduce(function (all, plugin) {
4143
4145
  return all.concat(plugin.languages || []);
4144
4146
  }, []).filter(filterSince).map(function (language) {
@@ -4153,6 +4155,15 @@ function getSupportInfo$2(version, opts) {
4153
4155
  return Object.assign({}, language, {
4154
4156
  parsers: ["typescript"]
4155
4157
  });
4158
+ } // "babylon" was renamed to "babel" in 1.16.0
4159
+
4160
+
4161
+ if (useBabylonParser && language.parsers.indexOf("babel") !== -1) {
4162
+ return Object.assign({}, language, {
4163
+ parsers: language.parsers.map(function (parser) {
4164
+ return parser === "babel" ? "babylon" : parser;
4165
+ })
4166
+ });
4156
4167
  }
4157
4168
 
4158
4169
  if (usePostCssParser && (language.name === "CSS" || language.group === "CSS")) {
@@ -22826,9 +22837,62 @@ function hasClosureCompilerTypeCastComment(text, path$$1, locStart, locEnd) {
22826
22837
 
22827
22838
  function hasTypeCastComment(node) {
22828
22839
  return node.comments && node.comments.some(function (comment) {
22829
- return comment.leading && comments$3.isBlockComment(comment) && comment.value.match(/^\*\s*@type\s*{[^}]+}\s*$/) && util$1.getNextNonSpaceNonCommentCharacter(text, comment, locEnd) === "(";
22840
+ return comment.leading && comments$3.isBlockComment(comment) && isTypeCastComment(comment.value) && util$1.getNextNonSpaceNonCommentCharacter(text, comment, locEnd) === "(";
22830
22841
  });
22831
22842
  }
22843
+
22844
+ function isTypeCastComment(comment) {
22845
+ var trimmed = comment.trim();
22846
+
22847
+ if (!/^\*\s*@type\s*\{[^]+\}$/.test(trimmed)) {
22848
+ return false;
22849
+ }
22850
+
22851
+ var isCompletelyClosed = false;
22852
+ var unpairedBracketCount = 0;
22853
+ var _iteratorNormalCompletion = true;
22854
+ var _didIteratorError = false;
22855
+ var _iteratorError = undefined;
22856
+
22857
+ try {
22858
+ for (var _iterator = trimmed[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
22859
+ var char = _step.value;
22860
+
22861
+ if (char === "{") {
22862
+ if (isCompletelyClosed) {
22863
+ return false;
22864
+ }
22865
+
22866
+ unpairedBracketCount++;
22867
+ } else if (char === "}") {
22868
+ if (unpairedBracketCount === 0) {
22869
+ return false;
22870
+ }
22871
+
22872
+ unpairedBracketCount--;
22873
+
22874
+ if (unpairedBracketCount === 0) {
22875
+ isCompletelyClosed = true;
22876
+ }
22877
+ }
22878
+ }
22879
+ } catch (err) {
22880
+ _didIteratorError = true;
22881
+ _iteratorError = err;
22882
+ } finally {
22883
+ try {
22884
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
22885
+ _iterator.return();
22886
+ }
22887
+ } finally {
22888
+ if (_didIteratorError) {
22889
+ throw _iteratorError;
22890
+ }
22891
+ }
22892
+ }
22893
+
22894
+ return unpairedBracketCount === 0;
22895
+ }
22832
22896
  }
22833
22897
 
22834
22898
  function needsParens(path$$1, options) {
@@ -22885,6 +22949,42 @@ function needsParens(path$$1, options) {
22885
22949
  return true;
22886
22950
  }
22887
22951
 
22952
+ if (parent.type === "Decorator" && parent.expression === node) {
22953
+ var hasCallExpression = false;
22954
+ var hasMemberExpression = false;
22955
+ var current = node;
22956
+
22957
+ while (current) {
22958
+ switch (current.type) {
22959
+ case "MemberExpression":
22960
+ hasMemberExpression = true;
22961
+ current = current.object;
22962
+ break;
22963
+
22964
+ case "CallExpression":
22965
+ if (
22966
+ /** @(x().y) */
22967
+ hasMemberExpression ||
22968
+ /** @(x().y()) */
22969
+ hasCallExpression) {
22970
+ return true;
22971
+ }
22972
+
22973
+ hasCallExpression = true;
22974
+ current = current.callee;
22975
+ break;
22976
+
22977
+ case "Identifier":
22978
+ return false;
22979
+
22980
+ default:
22981
+ return true;
22982
+ }
22983
+ }
22984
+
22985
+ return true;
22986
+ }
22987
+
22888
22988
  if (parent.type === "ArrowFunctionExpression" && parent.body === node && node.type !== "SequenceExpression" && // these have parens added anyway
22889
22989
  util$1.startsWithNoLookaheadToken(node,
22890
22990
  /* forbidFunctionClassAndDoExpr */
@@ -23021,9 +23121,6 @@ function needsParens(path$$1, options) {
23021
23121
  case "AssignmentExpression":
23022
23122
  return parent.left === node && (node.type === "TSTypeAssertion" || node.type === "TSAsExpression");
23023
23123
 
23024
- case "Decorator":
23025
- return parent.expression === node && (node.type === "TSTypeAssertion" || node.type === "TSAsExpression");
23026
-
23027
23124
  case "BinaryExpression":
23028
23125
  case "LogicalExpression":
23029
23126
  {
@@ -23073,6 +23170,14 @@ function needsParens(path$$1, options) {
23073
23170
  case "TSParenthesizedType":
23074
23171
  {
23075
23172
  var grandParent = path$$1.getParentNode(1);
23173
+ /**
23174
+ * const foo = (): (() => void) => (): void => null;
23175
+ * ^ ^
23176
+ */
23177
+
23178
+ if (getUnparenthesizedNode(node).type === "TSFunctionType" && parent.type === "TSTypeAnnotation" && grandParent.type === "ArrowFunctionExpression" && grandParent.returnType === parent) {
23179
+ return true;
23180
+ }
23076
23181
 
23077
23182
  if ((parent.type === "TSTypeParameter" || parent.type === "TypeParameter" || parent.type === "TSTypeAliasDeclaration" || parent.type === "TSTypeAnnotation" || parent.type === "TSParenthesizedType" || parent.type === "TSTypeParameterInstantiation") && grandParent.type !== "TSTypeOperator" && grandParent.type !== "TSOptionalType") {
23078
23183
  return false;
@@ -23333,6 +23438,10 @@ function isStatement(node) {
23333
23438
  return node.type === "BlockStatement" || node.type === "BreakStatement" || node.type === "ClassBody" || node.type === "ClassDeclaration" || node.type === "ClassMethod" || node.type === "ClassProperty" || node.type === "ClassPrivateProperty" || node.type === "ContinueStatement" || node.type === "DebuggerStatement" || node.type === "DeclareClass" || node.type === "DeclareExportAllDeclaration" || node.type === "DeclareExportDeclaration" || node.type === "DeclareFunction" || node.type === "DeclareInterface" || node.type === "DeclareModule" || node.type === "DeclareModuleExports" || node.type === "DeclareVariable" || node.type === "DoWhileStatement" || node.type === "ExportAllDeclaration" || node.type === "ExportDefaultDeclaration" || node.type === "ExportNamedDeclaration" || node.type === "ExpressionStatement" || node.type === "ForAwaitStatement" || node.type === "ForInStatement" || node.type === "ForOfStatement" || node.type === "ForStatement" || node.type === "FunctionDeclaration" || node.type === "IfStatement" || node.type === "ImportDeclaration" || node.type === "InterfaceDeclaration" || node.type === "LabeledStatement" || node.type === "MethodDefinition" || node.type === "ReturnStatement" || node.type === "SwitchStatement" || node.type === "ThrowStatement" || node.type === "TryStatement" || node.type === "TSAbstractClassDeclaration" || node.type === "TSDeclareFunction" || node.type === "TSEnumDeclaration" || node.type === "TSImportEqualsDeclaration" || node.type === "TSInterfaceDeclaration" || node.type === "TSModuleDeclaration" || node.type === "TSNamespaceExportDeclaration" || node.type === "TypeAlias" || node.type === "VariableDeclaration" || node.type === "WhileStatement" || node.type === "WithStatement";
23334
23439
  }
23335
23440
 
23441
+ function getUnparenthesizedNode(node) {
23442
+ return node.type === "TSParenthesizedType" ? getUnparenthesizedNode(node.typeAnnotation) : node;
23443
+ }
23444
+
23336
23445
  function endsWithRightBracket(node) {
23337
23446
  switch (node.type) {
23338
23447
  case "ObjectExpression":
@@ -26246,7 +26355,7 @@ function printArgumentsList(path$$1, options, print) {
26246
26355
  } // useEffect(() => { ... }, [foo, bar, baz])
26247
26356
 
26248
26357
 
26249
- if (args.length === 2 && args[0].type === "ArrowFunctionExpression" && args[0].body.type === "BlockStatement" && args[1].type === "ArrayExpression" && !args.find(function (arg) {
26358
+ if (args.length === 2 && args[0].type === "ArrowFunctionExpression" && args[0].params.length === 0 && args[0].body.type === "BlockStatement" && args[1].type === "ArrayExpression" && !args.find(function (arg) {
26250
26359
  return arg.leadingComments || arg.trailingComments;
26251
26360
  })) {
26252
26361
  return concat$4(["(", path$$1.call(print, "arguments", 0), ", ", path$$1.call(print, "arguments", 1), ")"]);
@@ -30746,6 +30855,8 @@ var cjkPattern = json$6.cjkPattern;
30746
30855
  var kPattern = json$6.kPattern;
30747
30856
  var punctuationPattern$1 = json$6.punctuationPattern;
30748
30857
  var getLast$5 = util$1.getLast;
30858
+ var INLINE_NODE_TYPES$1 = ["liquidNode", "inlineCode", "emphasis", "strong", "delete", "link", "linkReference", "image", "imageReference", "footnote", "footnoteReference", "sentence", "whitespace", "word", "break", "inlineMath"];
30859
+ var INLINE_NODE_WRAPPER_TYPES$1 = INLINE_NODE_TYPES$1.concat(["tableCell", "paragraph", "heading"]);
30749
30860
  var kRegex = new RegExp(kPattern);
30750
30861
  var punctuationRegex = new RegExp(punctuationPattern$1);
30751
30862
  /**
@@ -30897,7 +31008,9 @@ var utils$8 = {
30897
31008
  splitText: splitText$1,
30898
31009
  punctuationPattern: punctuationPattern$1,
30899
31010
  getFencedCodeBlockValue: getFencedCodeBlockValue$2,
30900
- getOrderedListItemInfo: getOrderedListItemInfo$1
31011
+ getOrderedListItemInfo: getOrderedListItemInfo$1,
31012
+ INLINE_NODE_TYPES: INLINE_NODE_TYPES$1,
31013
+ INLINE_NODE_WRAPPER_TYPES: INLINE_NODE_WRAPPER_TYPES$1
30901
31014
  };
30902
31015
 
30903
31016
  var _require$$0$builders$7 = doc.builders;
@@ -31291,12 +31404,12 @@ var getFencedCodeBlockValue = utils$8.getFencedCodeBlockValue;
31291
31404
  var getOrderedListItemInfo = utils$8.getOrderedListItemInfo;
31292
31405
  var splitText = utils$8.splitText;
31293
31406
  var punctuationPattern = utils$8.punctuationPattern;
31407
+ var INLINE_NODE_TYPES = utils$8.INLINE_NODE_TYPES;
31408
+ var INLINE_NODE_WRAPPER_TYPES = utils$8.INLINE_NODE_WRAPPER_TYPES;
31294
31409
  var replaceEndOfLineWith$1 = util$1.replaceEndOfLineWith;
31295
31410
  var TRAILING_HARDLINE_NODES = ["importExport"];
31296
31411
  var SINGLE_LINE_NODE_TYPES = ["heading", "tableCell", "link"];
31297
31412
  var SIBLING_NODE_TYPES = ["listItem", "definition", "footnoteDefinition"];
31298
- var INLINE_NODE_TYPES = ["liquidNode", "inlineCode", "emphasis", "strong", "delete", "link", "linkReference", "image", "imageReference", "footnote", "footnoteReference", "sentence", "whitespace", "word", "break", "inlineMath"];
31299
- var INLINE_NODE_WRAPPER_TYPES = INLINE_NODE_TYPES.concat(["tableCell", "paragraph", "heading"]);
31300
31413
 
31301
31414
  function genericPrint$4(path$$1, options, print) {
31302
31415
  var node = path$$1.getValue();
@@ -34360,8 +34473,8 @@ function printClosingTagEndMarker(node, options) {
34360
34473
 
34361
34474
  function getTextValueParts(node) {
34362
34475
  var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : node.value;
34363
- return node.parent.isWhitespaceSensitive ? node.parent.isIndentationSensitive ? replaceEndOfLineWith$2(value, literalline$6) : replaceEndOfLineWith$2(dedentString(value.replace(/^\s*?\n|\n\s*?$/g, "")), hardline$12) : // non-breaking whitespace: 0xA0
34364
- join$10(line$9, value.split(/[^\S\xA0]+/)).parts;
34476
+ return node.parent.isWhitespaceSensitive ? node.parent.isIndentationSensitive ? replaceEndOfLineWith$2(value, literalline$6) : replaceEndOfLineWith$2(dedentString(value.replace(/^\s*?\n|\n\s*?$/g, "")), hardline$12) : // https://infra.spec.whatwg.org/#ascii-whitespace
34477
+ join$10(line$9, value.split(/[\t\n\f\r ]+/)).parts;
34365
34478
  }
34366
34479
 
34367
34480
  function printEmbeddedAttributeValue(node, originalTextToDoc, options) {
@@ -43421,6 +43534,14 @@ var constant = {
43421
43534
  usageSummary
43422
43535
  };
43423
43536
 
43537
+ // which causes unwanted lines in the output. An additional check for isCI() helps.
43538
+ // See https://github.com/prettier/prettier/issues/5801
43539
+
43540
+
43541
+ var isTty = function isTTY() {
43542
+ return process.stdout.isTTY && !thirdParty$1.isCI();
43543
+ };
43544
+
43424
43545
  var OPTION_USAGE_THRESHOLD = 25;
43425
43546
  var CHOICE_USAGE_MARGIN = 3;
43426
43547
  var CHOICE_USAGE_INDENTATION = 2;
@@ -43452,7 +43573,7 @@ function diff(a, b) {
43452
43573
 
43453
43574
  function handleError(context, filename, error) {
43454
43575
  if (error instanceof errors.UndefinedParserError) {
43455
- if (context.argv["write"] && process.stdout.isTTY) {
43576
+ if (context.argv["write"] && isTty()) {
43456
43577
  readline.clearLine(process.stdout, 0);
43457
43578
  readline.cursorTo(process.stdout, 0, null);
43458
43579
  }
@@ -43809,7 +43930,7 @@ function formatFiles(context) {
43809
43930
  return;
43810
43931
  }
43811
43932
 
43812
- if (process.stdout.isTTY) {
43933
+ if (isTty()) {
43813
43934
  // Don't use `console.log` here since we need to replace this line.
43814
43935
  context.logger.log(filename, {
43815
43936
  newline: false
@@ -43852,7 +43973,7 @@ function formatFiles(context) {
43852
43973
 
43853
43974
  var isDifferent = output !== input;
43854
43975
 
43855
- if (process.stdout.isTTY) {
43976
+ if (isTty()) {
43856
43977
  // Remove previously printed filename to log it with duration.
43857
43978
  readline.clearLine(process.stdout, 0);
43858
43979
  readline.cursorTo(process.stdout, 0, null);
package/index.js CHANGED
@@ -12,7 +12,7 @@ var thirdParty = require('./third-party');
12
12
  var thirdParty__default = thirdParty['default'];
13
13
 
14
14
  var name = "prettier";
15
- var version$1 = "1.16.0";
15
+ var version$1 = "1.16.4";
16
16
  var description = "Prettier is an opinionated code formatter";
17
17
  var bin = {
18
18
  "prettier": "./bin/prettier.js"
@@ -54,6 +54,7 @@ var dependencies = {
54
54
  "html-styles": "1.0.0",
55
55
  "html-tag-names": "1.1.2",
56
56
  "ignore": "3.3.7",
57
+ "is-ci": "2.0.0",
57
58
  "jest-docblock": "23.2.0",
58
59
  "json-stable-stringify": "1.0.1",
59
60
  "leven": "2.1.0",
@@ -107,7 +108,7 @@ var devDependencies = {
107
108
  "jest-snapshot-serializer-raw": "1.1.0",
108
109
  "jest-watch-typeahead": "0.1.0",
109
110
  "mkdirp": "0.5.1",
110
- "prettier": "1.15.3",
111
+ "prettier": "1.16.3",
111
112
  "prettylint": "1.0.0",
112
113
  "rimraf": "2.6.2",
113
114
  "rollup": "0.47.6",
@@ -4137,6 +4138,7 @@ function getSupportInfo$2(version, opts) {
4137
4138
  });
4138
4139
  });
4139
4140
  var usePostCssParser = semver.lt(version, "1.7.1");
4141
+ var useBabylonParser = semver.lt(version, "1.16.0");
4140
4142
  var languages = plugins.reduce(function (all, plugin) {
4141
4143
  return all.concat(plugin.languages || []);
4142
4144
  }, []).filter(filterSince).map(function (language) {
@@ -4151,6 +4153,15 @@ function getSupportInfo$2(version, opts) {
4151
4153
  return Object.assign({}, language, {
4152
4154
  parsers: ["typescript"]
4153
4155
  });
4156
+ } // "babylon" was renamed to "babel" in 1.16.0
4157
+
4158
+
4159
+ if (useBabylonParser && language.parsers.indexOf("babel") !== -1) {
4160
+ return Object.assign({}, language, {
4161
+ parsers: language.parsers.map(function (parser) {
4162
+ return parser === "babel" ? "babylon" : parser;
4163
+ })
4164
+ });
4154
4165
  }
4155
4166
 
4156
4167
  if (usePostCssParser && (language.name === "CSS" || language.group === "CSS")) {
@@ -22824,9 +22835,62 @@ function hasClosureCompilerTypeCastComment(text, path$$1, locStart, locEnd) {
22824
22835
 
22825
22836
  function hasTypeCastComment(node) {
22826
22837
  return node.comments && node.comments.some(function (comment) {
22827
- return comment.leading && comments$3.isBlockComment(comment) && comment.value.match(/^\*\s*@type\s*{[^}]+}\s*$/) && util$1.getNextNonSpaceNonCommentCharacter(text, comment, locEnd) === "(";
22838
+ return comment.leading && comments$3.isBlockComment(comment) && isTypeCastComment(comment.value) && util$1.getNextNonSpaceNonCommentCharacter(text, comment, locEnd) === "(";
22828
22839
  });
22829
22840
  }
22841
+
22842
+ function isTypeCastComment(comment) {
22843
+ var trimmed = comment.trim();
22844
+
22845
+ if (!/^\*\s*@type\s*\{[^]+\}$/.test(trimmed)) {
22846
+ return false;
22847
+ }
22848
+
22849
+ var isCompletelyClosed = false;
22850
+ var unpairedBracketCount = 0;
22851
+ var _iteratorNormalCompletion = true;
22852
+ var _didIteratorError = false;
22853
+ var _iteratorError = undefined;
22854
+
22855
+ try {
22856
+ for (var _iterator = trimmed[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
22857
+ var char = _step.value;
22858
+
22859
+ if (char === "{") {
22860
+ if (isCompletelyClosed) {
22861
+ return false;
22862
+ }
22863
+
22864
+ unpairedBracketCount++;
22865
+ } else if (char === "}") {
22866
+ if (unpairedBracketCount === 0) {
22867
+ return false;
22868
+ }
22869
+
22870
+ unpairedBracketCount--;
22871
+
22872
+ if (unpairedBracketCount === 0) {
22873
+ isCompletelyClosed = true;
22874
+ }
22875
+ }
22876
+ }
22877
+ } catch (err) {
22878
+ _didIteratorError = true;
22879
+ _iteratorError = err;
22880
+ } finally {
22881
+ try {
22882
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
22883
+ _iterator.return();
22884
+ }
22885
+ } finally {
22886
+ if (_didIteratorError) {
22887
+ throw _iteratorError;
22888
+ }
22889
+ }
22890
+ }
22891
+
22892
+ return unpairedBracketCount === 0;
22893
+ }
22830
22894
  }
22831
22895
 
22832
22896
  function needsParens(path$$1, options) {
@@ -22883,6 +22947,42 @@ function needsParens(path$$1, options) {
22883
22947
  return true;
22884
22948
  }
22885
22949
 
22950
+ if (parent.type === "Decorator" && parent.expression === node) {
22951
+ var hasCallExpression = false;
22952
+ var hasMemberExpression = false;
22953
+ var current = node;
22954
+
22955
+ while (current) {
22956
+ switch (current.type) {
22957
+ case "MemberExpression":
22958
+ hasMemberExpression = true;
22959
+ current = current.object;
22960
+ break;
22961
+
22962
+ case "CallExpression":
22963
+ if (
22964
+ /** @(x().y) */
22965
+ hasMemberExpression ||
22966
+ /** @(x().y()) */
22967
+ hasCallExpression) {
22968
+ return true;
22969
+ }
22970
+
22971
+ hasCallExpression = true;
22972
+ current = current.callee;
22973
+ break;
22974
+
22975
+ case "Identifier":
22976
+ return false;
22977
+
22978
+ default:
22979
+ return true;
22980
+ }
22981
+ }
22982
+
22983
+ return true;
22984
+ }
22985
+
22886
22986
  if (parent.type === "ArrowFunctionExpression" && parent.body === node && node.type !== "SequenceExpression" && // these have parens added anyway
22887
22987
  util$1.startsWithNoLookaheadToken(node,
22888
22988
  /* forbidFunctionClassAndDoExpr */
@@ -23019,9 +23119,6 @@ function needsParens(path$$1, options) {
23019
23119
  case "AssignmentExpression":
23020
23120
  return parent.left === node && (node.type === "TSTypeAssertion" || node.type === "TSAsExpression");
23021
23121
 
23022
- case "Decorator":
23023
- return parent.expression === node && (node.type === "TSTypeAssertion" || node.type === "TSAsExpression");
23024
-
23025
23122
  case "BinaryExpression":
23026
23123
  case "LogicalExpression":
23027
23124
  {
@@ -23071,6 +23168,14 @@ function needsParens(path$$1, options) {
23071
23168
  case "TSParenthesizedType":
23072
23169
  {
23073
23170
  var grandParent = path$$1.getParentNode(1);
23171
+ /**
23172
+ * const foo = (): (() => void) => (): void => null;
23173
+ * ^ ^
23174
+ */
23175
+
23176
+ if (getUnparenthesizedNode(node).type === "TSFunctionType" && parent.type === "TSTypeAnnotation" && grandParent.type === "ArrowFunctionExpression" && grandParent.returnType === parent) {
23177
+ return true;
23178
+ }
23074
23179
 
23075
23180
  if ((parent.type === "TSTypeParameter" || parent.type === "TypeParameter" || parent.type === "TSTypeAliasDeclaration" || parent.type === "TSTypeAnnotation" || parent.type === "TSParenthesizedType" || parent.type === "TSTypeParameterInstantiation") && grandParent.type !== "TSTypeOperator" && grandParent.type !== "TSOptionalType") {
23076
23181
  return false;
@@ -23331,6 +23436,10 @@ function isStatement(node) {
23331
23436
  return node.type === "BlockStatement" || node.type === "BreakStatement" || node.type === "ClassBody" || node.type === "ClassDeclaration" || node.type === "ClassMethod" || node.type === "ClassProperty" || node.type === "ClassPrivateProperty" || node.type === "ContinueStatement" || node.type === "DebuggerStatement" || node.type === "DeclareClass" || node.type === "DeclareExportAllDeclaration" || node.type === "DeclareExportDeclaration" || node.type === "DeclareFunction" || node.type === "DeclareInterface" || node.type === "DeclareModule" || node.type === "DeclareModuleExports" || node.type === "DeclareVariable" || node.type === "DoWhileStatement" || node.type === "ExportAllDeclaration" || node.type === "ExportDefaultDeclaration" || node.type === "ExportNamedDeclaration" || node.type === "ExpressionStatement" || node.type === "ForAwaitStatement" || node.type === "ForInStatement" || node.type === "ForOfStatement" || node.type === "ForStatement" || node.type === "FunctionDeclaration" || node.type === "IfStatement" || node.type === "ImportDeclaration" || node.type === "InterfaceDeclaration" || node.type === "LabeledStatement" || node.type === "MethodDefinition" || node.type === "ReturnStatement" || node.type === "SwitchStatement" || node.type === "ThrowStatement" || node.type === "TryStatement" || node.type === "TSAbstractClassDeclaration" || node.type === "TSDeclareFunction" || node.type === "TSEnumDeclaration" || node.type === "TSImportEqualsDeclaration" || node.type === "TSInterfaceDeclaration" || node.type === "TSModuleDeclaration" || node.type === "TSNamespaceExportDeclaration" || node.type === "TypeAlias" || node.type === "VariableDeclaration" || node.type === "WhileStatement" || node.type === "WithStatement";
23332
23437
  }
23333
23438
 
23439
+ function getUnparenthesizedNode(node) {
23440
+ return node.type === "TSParenthesizedType" ? getUnparenthesizedNode(node.typeAnnotation) : node;
23441
+ }
23442
+
23334
23443
  function endsWithRightBracket(node) {
23335
23444
  switch (node.type) {
23336
23445
  case "ObjectExpression":
@@ -26244,7 +26353,7 @@ function printArgumentsList(path$$1, options, print) {
26244
26353
  } // useEffect(() => { ... }, [foo, bar, baz])
26245
26354
 
26246
26355
 
26247
- if (args.length === 2 && args[0].type === "ArrowFunctionExpression" && args[0].body.type === "BlockStatement" && args[1].type === "ArrayExpression" && !args.find(function (arg) {
26356
+ if (args.length === 2 && args[0].type === "ArrowFunctionExpression" && args[0].params.length === 0 && args[0].body.type === "BlockStatement" && args[1].type === "ArrayExpression" && !args.find(function (arg) {
26248
26357
  return arg.leadingComments || arg.trailingComments;
26249
26358
  })) {
26250
26359
  return concat$4(["(", path$$1.call(print, "arguments", 0), ", ", path$$1.call(print, "arguments", 1), ")"]);
@@ -30744,6 +30853,8 @@ var cjkPattern = json$6.cjkPattern;
30744
30853
  var kPattern = json$6.kPattern;
30745
30854
  var punctuationPattern$1 = json$6.punctuationPattern;
30746
30855
  var getLast$5 = util$1.getLast;
30856
+ var INLINE_NODE_TYPES$1 = ["liquidNode", "inlineCode", "emphasis", "strong", "delete", "link", "linkReference", "image", "imageReference", "footnote", "footnoteReference", "sentence", "whitespace", "word", "break", "inlineMath"];
30857
+ var INLINE_NODE_WRAPPER_TYPES$1 = INLINE_NODE_TYPES$1.concat(["tableCell", "paragraph", "heading"]);
30747
30858
  var kRegex = new RegExp(kPattern);
30748
30859
  var punctuationRegex = new RegExp(punctuationPattern$1);
30749
30860
  /**
@@ -30895,7 +31006,9 @@ var utils$8 = {
30895
31006
  splitText: splitText$1,
30896
31007
  punctuationPattern: punctuationPattern$1,
30897
31008
  getFencedCodeBlockValue: getFencedCodeBlockValue$2,
30898
- getOrderedListItemInfo: getOrderedListItemInfo$1
31009
+ getOrderedListItemInfo: getOrderedListItemInfo$1,
31010
+ INLINE_NODE_TYPES: INLINE_NODE_TYPES$1,
31011
+ INLINE_NODE_WRAPPER_TYPES: INLINE_NODE_WRAPPER_TYPES$1
30899
31012
  };
30900
31013
 
30901
31014
  var _require$$0$builders$7 = doc.builders;
@@ -31289,12 +31402,12 @@ var getFencedCodeBlockValue = utils$8.getFencedCodeBlockValue;
31289
31402
  var getOrderedListItemInfo = utils$8.getOrderedListItemInfo;
31290
31403
  var splitText = utils$8.splitText;
31291
31404
  var punctuationPattern = utils$8.punctuationPattern;
31405
+ var INLINE_NODE_TYPES = utils$8.INLINE_NODE_TYPES;
31406
+ var INLINE_NODE_WRAPPER_TYPES = utils$8.INLINE_NODE_WRAPPER_TYPES;
31292
31407
  var replaceEndOfLineWith$1 = util$1.replaceEndOfLineWith;
31293
31408
  var TRAILING_HARDLINE_NODES = ["importExport"];
31294
31409
  var SINGLE_LINE_NODE_TYPES = ["heading", "tableCell", "link"];
31295
31410
  var SIBLING_NODE_TYPES = ["listItem", "definition", "footnoteDefinition"];
31296
- var INLINE_NODE_TYPES = ["liquidNode", "inlineCode", "emphasis", "strong", "delete", "link", "linkReference", "image", "imageReference", "footnote", "footnoteReference", "sentence", "whitespace", "word", "break", "inlineMath"];
31297
- var INLINE_NODE_WRAPPER_TYPES = INLINE_NODE_TYPES.concat(["tableCell", "paragraph", "heading"]);
31298
31411
 
31299
31412
  function genericPrint$4(path$$1, options, print) {
31300
31413
  var node = path$$1.getValue();
@@ -34358,8 +34471,8 @@ function printClosingTagEndMarker(node, options) {
34358
34471
 
34359
34472
  function getTextValueParts(node) {
34360
34473
  var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : node.value;
34361
- return node.parent.isWhitespaceSensitive ? node.parent.isIndentationSensitive ? replaceEndOfLineWith$2(value, literalline$6) : replaceEndOfLineWith$2(dedentString(value.replace(/^\s*?\n|\n\s*?$/g, "")), hardline$12) : // non-breaking whitespace: 0xA0
34362
- join$10(line$9, value.split(/[^\S\xA0]+/)).parts;
34474
+ return node.parent.isWhitespaceSensitive ? node.parent.isIndentationSensitive ? replaceEndOfLineWith$2(value, literalline$6) : replaceEndOfLineWith$2(dedentString(value.replace(/^\s*?\n|\n\s*?$/g, "")), hardline$12) : // https://infra.spec.whatwg.org/#ascii-whitespace
34475
+ join$10(line$9, value.split(/[\t\n\f\r ]+/)).parts;
34363
34476
  }
34364
34477
 
34365
34478
  function printEmbeddedAttributeValue(node, originalTextToDoc, options) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prettier",
3
- "version": "1.16.0",
3
+ "version": "1.16.4",
4
4
  "description": "Prettier is an opinionated code formatter",
5
5
  "bin": "./bin-prettier.js",
6
6
  "repository": "prettier/prettier",