prettier 1.13.4 → 1.13.5

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/standalone.js CHANGED
@@ -5,7 +5,7 @@
5
5
  }(this, (function () { 'use strict';
6
6
 
7
7
  var name = "prettier";
8
- var version$1 = "1.13.4";
8
+ var version$1 = "1.13.5";
9
9
  var description = "Prettier is an opinionated code formatter";
10
10
  var bin = {
11
11
  "prettier": "./bin/prettier.js"
@@ -60,7 +60,7 @@ var dependencies = {
60
60
  "semver": "5.4.1",
61
61
  "string-width": "2.1.1",
62
62
  "typescript": "2.9.0-dev.20180421",
63
- "typescript-eslint-parser": "eslint/typescript-eslint-parser#2960b002746c01fb9cb15bb5f4c1e7e925c6519a",
63
+ "typescript-eslint-parser": "16.0.0",
64
64
  "unicode-regex": "1.0.1",
65
65
  "unified": "6.1.6"
66
66
  };
@@ -79,7 +79,7 @@ var devDependencies = {
79
79
  "eslint-plugin-react": "7.7.0",
80
80
  "jest": "21.1.0",
81
81
  "mkdirp": "0.5.1",
82
- "prettier": "1.13.3",
82
+ "prettier": "1.13.4",
83
83
  "prettylint": "1.0.0",
84
84
  "rimraf": "2.6.2",
85
85
  "rollup": "0.47.6",
@@ -9148,8 +9148,7 @@ function printDocToString(doc, options) {
9148
9148
  out.pop();
9149
9149
  }
9150
9150
 
9151
- if (out.length && typeof out[out.length - 1] === "string" && (options.parser !== "markdown" || // preserve markdown's `break` node (two trailing spaces)
9152
- !/\S {2}$/.test(out[out.length - 1]))) {
9151
+ if (out.length && typeof out[out.length - 1] === "string") {
9153
9152
  out[out.length - 1] = out[out.length - 1].replace(/[^\S\n]*$/, "");
9154
9153
  }
9155
9154
  }
@@ -10507,6 +10506,13 @@ function attachComments(text, ast, opts) {
10507
10506
  }
10508
10507
 
10509
10508
  function coreFormat(text, opts, addAlignmentSize) {
10509
+ if (!text || !text.trim().length) {
10510
+ return {
10511
+ formatted: "",
10512
+ cursorOffset: 0
10513
+ };
10514
+ }
10515
+
10510
10516
  addAlignmentSize = addAlignmentSize || 0;
10511
10517
  var parsed = parser.parse(text, opts);
10512
10518
  var ast = parsed.ast;
@@ -15539,12 +15545,13 @@ function printMemberChain(path, options, print) {
15539
15545
  // .map(x => x)
15540
15546
  //
15541
15547
  // In order to detect those cases, we use an heuristic: if the first
15542
- // node is an identifier with the name starting with a capital letter.
15543
- // The rationale is that they are likely to be factories.
15548
+ // node is an identifier with the name starting with a capital
15549
+ // letter or just a sequence of _$. The rationale is that they are
15550
+ // likely to be factories.
15544
15551
 
15545
15552
 
15546
15553
  function isFactory(name) {
15547
- return /^[A-Z]/.test(name);
15554
+ return /^[A-Z]|^[_$]+$/.test(name);
15548
15555
  } // In case the Identifier is shorter than tab width, we can keep the
15549
15556
  // first call in a single line, if it's an ExpressionStatement.
15550
15557
  //
@@ -16686,6 +16693,10 @@ function genericPrint$2(path, options, print) {
16686
16693
 
16687
16694
  case "Identifier":
16688
16695
  return JSON.stringify(node.name);
16696
+
16697
+ default:
16698
+ /* istanbul ignore next */
16699
+ throw new Error("unknown type: " + JSON.stringify(node.type));
16689
16700
  }
16690
16701
  }
16691
16702
 
@@ -18340,9 +18351,9 @@ var languageGraphql = {
18340
18351
 
18341
18352
  var _require$$0$builders$5 = doc.builders;
18342
18353
  var hardline$9 = _require$$0$builders$5.hardline;
18343
- var literalline$3 = _require$$0$builders$5.literalline;
18354
+ var literalline$4 = _require$$0$builders$5.literalline;
18344
18355
  var concat$10 = _require$$0$builders$5.concat;
18345
- var markAsRoot$1 = _require$$0$builders$5.markAsRoot;
18356
+ var markAsRoot$2 = _require$$0$builders$5.markAsRoot;
18346
18357
  var mapDoc$4 = doc.utils.mapDoc;
18347
18358
 
18348
18359
  function embed$2(path, print, textToDoc, options) {
@@ -18359,7 +18370,7 @@ function embed$2(path, print, textToDoc, options) {
18359
18370
  var doc$$2 = textToDoc(node.value, {
18360
18371
  parser: parser
18361
18372
  });
18362
- return markAsRoot$1(concat$10([style, node.lang, hardline$9, replaceNewlinesWithLiterallines(doc$$2), style]));
18373
+ return markAsRoot$2(concat$10([style, node.lang, hardline$9, replaceNewlinesWithLiterallines(doc$$2), style]));
18363
18374
  }
18364
18375
  }
18365
18376
 
@@ -18385,7 +18396,7 @@ function embed$2(path, print, textToDoc, options) {
18385
18396
  function replaceNewlinesWithLiterallines(doc$$2) {
18386
18397
  return mapDoc$4(doc$$2, function (currentDoc) {
18387
18398
  return typeof currentDoc === "string" && currentDoc.includes("\n") ? concat$10(currentDoc.split(/(\n)/g).map(function (v, i) {
18388
- return i % 2 === 0 ? v : literalline$3;
18399
+ return i % 2 === 0 ? v : literalline$4;
18389
18400
  })) : currentDoc;
18390
18401
  });
18391
18402
  }
@@ -18449,6 +18460,8 @@ var _require$$0$builders$4 = doc.builders;
18449
18460
  var concat$9 = _require$$0$builders$4.concat;
18450
18461
  var join$7 = _require$$0$builders$4.join;
18451
18462
  var line$6 = _require$$0$builders$4.line;
18463
+ var literalline$3 = _require$$0$builders$4.literalline;
18464
+ var markAsRoot$1 = _require$$0$builders$4.markAsRoot;
18452
18465
  var hardline$8 = _require$$0$builders$4.hardline;
18453
18466
  var softline$5 = _require$$0$builders$4.softline;
18454
18467
  var fill$4 = _require$$0$builders$4.fill;
@@ -18581,7 +18594,9 @@ function genericPrint$5(path, options, print) {
18581
18594
  {
18582
18595
  var _parentNode2 = path.getParentNode();
18583
18596
 
18584
- return replaceNewlinesWithHardlines(_parentNode2.type === "root" && util.getLast(_parentNode2.children) === node ? node.value.trimRight() : node.value);
18597
+ var value = _parentNode2.type === "root" && util.getLast(_parentNode2.children) === node ? node.value.trimRight() : node.value;
18598
+ var isHtmlComment = /^<!--[\s\S]*-->$/.test(value);
18599
+ return replaceNewlinesWith(value, isHtmlComment ? hardline$8 : markAsRoot$1(literalline$3));
18585
18600
  }
18586
18601
 
18587
18602
  case "list":
@@ -18659,10 +18674,10 @@ function genericPrint$5(path, options, print) {
18659
18674
  return printChildren(path, options, print);
18660
18675
 
18661
18676
  case "break":
18662
- return concat$9([/\s/.test(options.originalText[node.position.start.offset]) ? " " : "\\", hardline$8]);
18677
+ return /\s/.test(options.originalText[node.position.start.offset]) ? concat$9([" ", markAsRoot$1(literalline$3)]) : concat$9(["\\", hardline$8]);
18663
18678
 
18664
18679
  case "liquidNode":
18665
- return replaceNewlinesWithHardlines(node.value);
18680
+ return replaceNewlinesWith(node.value, hardline$8);
18666
18681
 
18667
18682
  case "tableRow": // handled in "table"
18668
18683
 
@@ -18706,8 +18721,8 @@ function getNthListSiblingIndex(node, parentNode) {
18706
18721
  });
18707
18722
  }
18708
18723
 
18709
- function replaceNewlinesWithHardlines(str) {
18710
- return join$7(hardline$8, str.split("\n"));
18724
+ function replaceNewlinesWith(str, doc$$2) {
18725
+ return join$7(doc$$2, str.split("\n"));
18711
18726
  }
18712
18727
 
18713
18728
  function getNthSiblingIndex(node, parentNode, condition) {