prettier 1.13.1 → 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/README.md ADDED
@@ -0,0 +1,106 @@
1
+ ![Prettier Banner](https://raw.githubusercontent.com/prettier/prettier-logo/master/images/prettier-banner-light.png)
2
+
3
+ <h2 align="center">Opinionated Code Formatter</h2>
4
+
5
+ <p align="center">
6
+ <em>
7
+ JavaScript
8
+ · Flow
9
+ · TypeScript
10
+ · CSS
11
+ · SCSS
12
+ · Less
13
+ · JSX
14
+ · Vue
15
+ · GraphQL
16
+ · JSON
17
+ · Markdown
18
+ · <a href="https://prettier.io/docs/en/plugins.html">
19
+ Your favorite language?
20
+ </a>
21
+ </em>
22
+ </p>
23
+
24
+ <p align="center">
25
+ <a href="https://travis-ci.org/prettier/prettier">
26
+ <img alt="Travis CI Build Status" src="https://img.shields.io/travis/prettier/prettier/master.svg?style=flat-square&label=Travis+CI">
27
+ </a>
28
+ <a href="https://circleci.com/gh/prettier/prettier">
29
+ <img alt="CircleCI Build Status" src="https://img.shields.io/circleci/project/github/prettier/prettier/master.svg?style=flat-square&label=CircleCI">
30
+ </a>
31
+ <a href="https://ci.appveyor.com/project/azz/prettier">
32
+ <img alt="AppVeyor Build Status" src="https://img.shields.io/appveyor/ci/azz/prettier.svg?style=flat-square&label=AppVeyor">
33
+ </a>
34
+ <a href="https://codecov.io/gh/prettier/prettier">
35
+ <img alt="Codecov Coverage Status" src="https://img.shields.io/codecov/c/github/prettier/prettier.svg?style=flat-square">
36
+ </a>
37
+ <a href="https://twitter.com/acdlite/status/974390255393505280">
38
+ <img alt="Blazing Fast" src="https://img.shields.io/badge/speed-blazing%20%F0%9F%94%A5-brightgreen.svg?style=flat-square">
39
+ </a>
40
+ <br/>
41
+ <a href="https://www.npmjs.com/package/prettier">
42
+ <img alt="npm version" src="https://img.shields.io/npm/v/prettier.svg?style=flat-square">
43
+ </a>
44
+ <a href="https://www.npmjs.com/package/prettier">
45
+ <img alt="monthly downloads from npm" src="https://img.shields.io/npm/dm/prettier.svg?style=flat-square">
46
+ </a>
47
+ <a href="#badge">
48
+ <img alt="code style: prettier" src="https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square">
49
+ </a>
50
+ <a href="https://gitter.im/jlongster/prettier">
51
+ <img alt="Chat on Gitter" src="https://img.shields.io/gitter/room/jlongster/prettier.svg?style=flat-square">
52
+ </a>
53
+ <a href="https://twitter.com/PrettierCode">
54
+ <img alt="Follow Prettier on Twitter" src="https://img.shields.io/twitter/follow/prettiercode.svg?label=follow+prettier&style=flat-square">
55
+ </a>
56
+ </p>
57
+
58
+ ## Intro
59
+
60
+ Prettier is an opinionated code formatter. It enforces a consistent style by parsing your code and re-printing it with its own rules that take the maximum line length into account, wrapping code when necessary.
61
+
62
+ ### Input
63
+
64
+ <!-- prettier-ignore -->
65
+ ```js
66
+ foo(reallyLongArg(), omgSoManyParameters(), IShouldRefactorThis(), isThereSeriouslyAnotherOne());
67
+ ```
68
+
69
+ ### Output
70
+
71
+ ```js
72
+ foo(
73
+ reallyLongArg(),
74
+ omgSoManyParameters(),
75
+ IShouldRefactorThis(),
76
+ isThereSeriouslyAnotherOne()
77
+ );
78
+ ```
79
+
80
+ Prettier can be run [in your editor](http://prettier.io/docs/en/editors.html) on-save, in a [pre-commit hook](https://prettier.io/docs/en/precommit.html), or in [CI environments](https://prettier.io/docs/en/cli.html#list-different) to ensure your codebase has a consistent style without devs ever having to post a nit-picky comment on a code review ever again!
81
+
82
+ ---
83
+
84
+ **[Documentation](https://prettier.io/docs/en/)**
85
+
86
+ <!-- prettier-ignore -->
87
+ [Install](https://prettier.io/docs/en/install.html) ·
88
+ [Options](https://prettier.io/docs/en/options.html) ·
89
+ [CLI](https://prettier.io/docs/en/cli.html) ·
90
+ [API](https://prettier.io/docs/en/api.html)
91
+
92
+ **[Playground](https://prettier.io/playground/)**
93
+
94
+ ---
95
+
96
+ ## Badge
97
+
98
+ Show the world you're using _Prettier_ → [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
99
+
100
+ ```md
101
+ [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
102
+ ```
103
+
104
+ ## Contributing
105
+
106
+ See [CONTRIBUTING.md](CONTRIBUTING.md).
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.13.1";
17
+ var version$1 = "1.13.5";
18
18
  var description = "Prettier is an opinionated code formatter";
19
19
  var bin = {
20
20
  "prettier": "./bin/prettier.js"
@@ -69,7 +69,7 @@ var dependencies = {
69
69
  "semver": "5.4.1",
70
70
  "string-width": "2.1.1",
71
71
  "typescript": "2.9.0-dev.20180421",
72
- "typescript-eslint-parser": "eslint/typescript-eslint-parser#2960b002746c01fb9cb15bb5f4c1e7e925c6519a",
72
+ "typescript-eslint-parser": "16.0.0",
73
73
  "unicode-regex": "1.0.1",
74
74
  "unified": "6.1.6"
75
75
  };
@@ -88,7 +88,7 @@ var devDependencies = {
88
88
  "eslint-plugin-react": "7.7.0",
89
89
  "jest": "21.1.0",
90
90
  "mkdirp": "0.5.1",
91
- "prettier": "1.13.0",
91
+ "prettier": "1.13.4",
92
92
  "prettylint": "1.0.0",
93
93
  "rimraf": "2.6.2",
94
94
  "rollup": "0.47.6",
@@ -8829,8 +8829,7 @@ function printDocToString$1(doc, options) {
8829
8829
  out.pop();
8830
8830
  }
8831
8831
 
8832
- if (out.length && typeof out[out.length - 1] === "string" && (options.parser !== "markdown" || // preserve markdown's `break` node (two trailing spaces)
8833
- !/\S {2}$/.test(out[out.length - 1]))) {
8832
+ if (out.length && typeof out[out.length - 1] === "string") {
8834
8833
  out[out.length - 1] = out[out.length - 1].replace(/[^\S\n]*$/, "");
8835
8834
  }
8836
8835
  }
@@ -10188,6 +10187,13 @@ function attachComments(text, ast, opts) {
10188
10187
  }
10189
10188
 
10190
10189
  function coreFormat(text, opts, addAlignmentSize) {
10190
+ if (!text || !text.trim().length) {
10191
+ return {
10192
+ formatted: "",
10193
+ cursorOffset: 0
10194
+ };
10195
+ }
10196
+
10191
10197
  addAlignmentSize = addAlignmentSize || 0;
10192
10198
  var parsed = parser.parse(text, opts);
10193
10199
  var ast = parsed.ast;
@@ -10778,22 +10784,76 @@ typeof process !== 'undefined' && (process.env && process.env.IGNORE_TEST_WIN32
10778
10784
  };
10779
10785
  }
10780
10786
 
10781
- function createIgnorer(ignorePath, withNodeModules) {
10782
- var ignoreText = "";
10787
+ /**
10788
+ * @param {string} filename
10789
+ * @returns {Promise<null | string>}
10790
+ */
10783
10791
 
10784
- if (ignorePath) {
10785
- var resolvedIgnorePath = path.resolve(ignorePath);
10786
10792
 
10787
- try {
10788
- ignoreText = fs.readFileSync(resolvedIgnorePath, "utf8");
10789
- } catch (readError) {
10790
- if (readError.code !== "ENOENT") {
10791
- throw new Error(`Unable to read ${resolvedIgnorePath}: ${readError.message}`);
10793
+ function getFileContentOrNull(filename) {
10794
+ return new Promise(function (resolve, reject) {
10795
+ fs.readFile(filename, "utf8", function (error, data) {
10796
+ if (error && error.code !== "ENOENT") {
10797
+ reject(createError(filename, error));
10798
+ } else {
10799
+ resolve(error ? null : data);
10792
10800
  }
10801
+ });
10802
+ });
10803
+ }
10804
+ /**
10805
+ * @param {string} filename
10806
+ * @returns {null | string}
10807
+ */
10808
+
10809
+
10810
+ getFileContentOrNull.sync = function (filename) {
10811
+ try {
10812
+ return fs.readFileSync(filename, "utf8");
10813
+ } catch (error) {
10814
+ if (error && error.code === "ENOENT") {
10815
+ return null;
10793
10816
  }
10817
+
10818
+ throw createError(filename, error);
10794
10819
  }
10820
+ };
10821
+
10822
+ function createError(filename, error) {
10823
+ return new Error(`Unable to read ${filename}: ${error.message}`);
10824
+ }
10825
+
10826
+ var getFileContentOrNull_1 = getFileContentOrNull;
10827
+
10828
+ /**
10829
+ * @param {undefined | string} ignorePath
10830
+ * @param {undefined | boolean} withNodeModules
10831
+ */
10832
+
10795
10833
 
10796
- var ignorer = ignore().add(ignoreText);
10834
+ function createIgnorer(ignorePath, withNodeModules) {
10835
+ return (!ignorePath ? Promise.resolve(null) : getFileContentOrNull_1(path.resolve(ignorePath))).then(function (ignoreContent) {
10836
+ return _createIgnorer(ignoreContent, withNodeModules);
10837
+ });
10838
+ }
10839
+ /**
10840
+ * @param {undefined | string} ignorePath
10841
+ * @param {undefined | boolean} withNodeModules
10842
+ */
10843
+
10844
+
10845
+ createIgnorer.sync = function (ignorePath, withNodeModules) {
10846
+ var ignoreContent = !ignorePath ? null : getFileContentOrNull_1.sync(path.resolve(ignorePath));
10847
+ return _createIgnorer(ignoreContent, withNodeModules);
10848
+ };
10849
+ /**
10850
+ * @param {null | string} ignoreContent
10851
+ * @param {undefined | boolean} withNodeModules
10852
+ */
10853
+
10854
+
10855
+ function _createIgnorer(ignoreContent, withNodeModules) {
10856
+ var ignorer = ignore().add(ignoreContent || "");
10797
10857
 
10798
10858
  if (!withNodeModules) {
10799
10859
  ignorer.add("node_modules");
@@ -10804,9 +10864,15 @@ function createIgnorer(ignorePath, withNodeModules) {
10804
10864
 
10805
10865
  var createIgnorer_1 = createIgnorer;
10806
10866
 
10867
+ /**
10868
+ * @typedef {{ ignorePath?: string, withNodeModules?: boolean, plugins: object }} FileInfoOptions
10869
+ * @typedef {{ ignored: boolean, inferredParser: string | null }} FileInfoResult
10870
+ */
10871
+
10807
10872
  /**
10808
10873
  * @param {string} filePath
10809
- * @param {{ ignorePath?: string, withNodeModules?: boolean, plugins: object }} opts
10874
+ * @param {FileInfoOptions} opts
10875
+ * @returns {Promise<FileInfoResult>}
10810
10876
  *
10811
10877
  * Please note that prettier.getFileInfo() expects opts.plugins to be an array of paths,
10812
10878
  * not an object. A transformation from this array to an object is automatically done
@@ -10814,25 +10880,32 @@ var createIgnorer_1 = createIgnorer;
10814
10880
  */
10815
10881
 
10816
10882
 
10817
- function _getFileInfo(filePath, opts) {
10818
- var ignored = false;
10819
- var ignorer = createIgnorer_1(opts.ignorePath, opts.withNodeModules);
10820
- ignored = ignorer.ignores(filePath);
10821
- var inferredParser = options.inferParser(filePath, opts.plugins) || null;
10883
+ function getFileInfo(filePath, opts) {
10884
+ return createIgnorer_1(opts.ignorePath, opts.withNodeModules).then(function (ignorer) {
10885
+ return _getFileInfo(ignorer, filePath, opts.plugins);
10886
+ });
10887
+ }
10888
+ /**
10889
+ * @param {string} filePath
10890
+ * @param {FileInfoOptions} opts
10891
+ * @returns {FileInfoResult}
10892
+ */
10893
+
10894
+
10895
+ getFileInfo.sync = function (filePath, opts) {
10896
+ var ignorer = createIgnorer_1.sync(opts.ignorePath, opts.withNodeModules);
10897
+ return _getFileInfo(ignorer, filePath, opts.plugins);
10898
+ };
10899
+
10900
+ function _getFileInfo(ignorer, filePath, plugins) {
10901
+ var ignored = ignorer.ignores(filePath);
10902
+ var inferredParser = options.inferParser(filePath, plugins) || null;
10822
10903
  return {
10823
10904
  ignored,
10824
10905
  inferredParser
10825
10906
  };
10826
- } // the method has been implemented as asynchronous to avoid possible breaking changes in future
10827
-
10828
-
10829
- function getFileInfo(filePath, opts) {
10830
- return Promise.resolve().then(function () {
10831
- return _getFileInfo(filePath, opts);
10832
- });
10833
10907
  }
10834
10908
 
10835
- getFileInfo.sync = _getFileInfo;
10836
10909
  var getFileInfo_1 = getFileInfo;
10837
10910
 
10838
10911
  var lodash_uniqby = createCommonjsModule(function (module, exports) {
@@ -21640,28 +21713,17 @@ function shouldGroupFirstArg(args) {
21640
21713
  return (!firstArg.comments || !firstArg.comments.length) && (firstArg.type === "FunctionExpression" || firstArg.type === "ArrowFunctionExpression" && firstArg.body.type === "BlockStatement") && !couldGroupArg(secondArg);
21641
21714
  }
21642
21715
 
21643
- var functionCompositionFunctionNames = {
21644
- pipe: true,
21645
- // RxJS, Ramda
21646
- pipeP: true,
21647
- // Ramda
21648
- pipeK: true,
21649
- // Ramda
21650
- compose: true,
21651
- // Ramda, Redux
21652
- composeFlipped: true,
21653
- // Not from any library, but common in Haskell, so supported
21654
- composeP: true,
21655
- // Ramda
21656
- composeK: true,
21657
- // Ramda
21658
- flow: true,
21659
- // Lodash
21660
- flowRight: true,
21661
- // Lodash
21662
- connect: true // Redux
21663
-
21664
- };
21716
+ var functionCompositionFunctionNames = new Set(["pipe", // RxJS, Ramda
21717
+ "pipeP", // Ramda
21718
+ "pipeK", // Ramda
21719
+ "compose", // Ramda, Redux
21720
+ "composeFlipped", // Not from any library, but common in Haskell, so supported
21721
+ "composeP", // Ramda
21722
+ "composeK", // Ramda
21723
+ "flow", // Lodash
21724
+ "flowRight", // Lodash
21725
+ "connect" // Redux
21726
+ ]);
21665
21727
 
21666
21728
  function isFunctionCompositionFunction(node) {
21667
21729
  switch (node.type) {
@@ -21673,13 +21735,13 @@ function isFunctionCompositionFunction(node) {
21673
21735
 
21674
21736
  case "Identifier":
21675
21737
  {
21676
- return functionCompositionFunctionNames[node.name];
21738
+ return functionCompositionFunctionNames.has(node.name);
21677
21739
  }
21678
21740
 
21679
21741
  case "StringLiteral":
21680
21742
  case "Literal":
21681
21743
  {
21682
- return functionCompositionFunctionNames[node.value];
21744
+ return functionCompositionFunctionNames.has(node.value);
21683
21745
  }
21684
21746
  }
21685
21747
  }
@@ -22373,12 +22435,13 @@ function printMemberChain(path$$1, options, print) {
22373
22435
  // .map(x => x)
22374
22436
  //
22375
22437
  // In order to detect those cases, we use an heuristic: if the first
22376
- // node is an identifier with the name starting with a capital letter.
22377
- // The rationale is that they are likely to be factories.
22438
+ // node is an identifier with the name starting with a capital
22439
+ // letter or just a sequence of _$. The rationale is that they are
22440
+ // likely to be factories.
22378
22441
 
22379
22442
 
22380
22443
  function isFactory(name) {
22381
- return /^[A-Z]/.test(name);
22444
+ return /^[A-Z]|^[_$]+$/.test(name);
22382
22445
  } // In case the Identifier is shorter than tab width, we can keep the
22383
22446
  // first call in a single line, if it's an ExpressionStatement.
22384
22447
  //
@@ -23520,6 +23583,10 @@ function genericPrint$2(path$$1, options, print) {
23520
23583
 
23521
23584
  case "Identifier":
23522
23585
  return JSON.stringify(node.name);
23586
+
23587
+ default:
23588
+ /* istanbul ignore next */
23589
+ throw new Error("unknown type: " + JSON.stringify(node.type));
23523
23590
  }
23524
23591
  }
23525
23592
 
@@ -23833,6 +23900,8 @@ function cleanCSSStrings(value) {
23833
23900
 
23834
23901
  var clean_1$2 = clean$3;
23835
23902
 
23903
+ var colorAdjusterFunctions = ["red", "green", "blue", "alpha", "a", "rgb", "hue", "h", "saturation", "s", "lightness", "l", "whiteness", "w", "blackness", "b", "tint", "shade", "blend", "blenda", "contrast", "hsl", "hsla", "hwb", "hwba"];
23904
+
23836
23905
  function getAncestorCounter(path$$1, typeOrTypes) {
23837
23906
  var types = [].concat(typeOrTypes);
23838
23907
  var counter = -1;
@@ -24072,6 +24141,14 @@ function isMediaAndSupportsKeywords$1(node) {
24072
24141
  return node.value && ["not", "and", "or"].indexOf(node.value.toLowerCase()) !== -1;
24073
24142
  }
24074
24143
 
24144
+ function isColorAdjusterFuncNode$1(node) {
24145
+ if (node.type !== "value-func") {
24146
+ return false;
24147
+ }
24148
+
24149
+ return colorAdjusterFunctions.indexOf(node.value.toLowerCase()) !== -1;
24150
+ }
24151
+
24075
24152
  var utils$4 = {
24076
24153
  getAncestorCounter,
24077
24154
  getAncestorNode: getAncestorNode$1,
@@ -24115,7 +24192,8 @@ var utils$4 = {
24115
24192
  isRightCurlyBraceNode: isRightCurlyBraceNode$1,
24116
24193
  isWordNode: isWordNode$1,
24117
24194
  isColonNode: isColonNode$1,
24118
- isMediaAndSupportsKeywords: isMediaAndSupportsKeywords$1
24195
+ isMediaAndSupportsKeywords: isMediaAndSupportsKeywords$1,
24196
+ isColorAdjusterFuncNode: isColorAdjusterFuncNode$1
24119
24197
  };
24120
24198
 
24121
24199
  var printNumber$2 = util$1.printNumber;
@@ -24174,6 +24252,7 @@ var isRightCurlyBraceNode = utils$4.isRightCurlyBraceNode;
24174
24252
  var isWordNode = utils$4.isWordNode;
24175
24253
  var isColonNode = utils$4.isColonNode;
24176
24254
  var isMediaAndSupportsKeywords = utils$4.isMediaAndSupportsKeywords;
24255
+ var isColorAdjusterFuncNode = utils$4.isColorAdjusterFuncNode;
24177
24256
 
24178
24257
  function shouldPrintComma$1(options) {
24179
24258
  switch (options.trailingComma) {
@@ -24419,6 +24498,7 @@ function genericPrint$3(path$$1, options, print) {
24419
24498
  {
24420
24499
  var _parentNode2 = path$$1.getParentNode();
24421
24500
 
24501
+ var parentParentNode = path$$1.getParentNode(1);
24422
24502
  var declAncestorProp = getPropOfDeclNode(path$$1);
24423
24503
  var isGridValue = declAncestorProp && _parentNode2.type === "value-value" && (declAncestorProp === "grid" || declAncestorProp.startsWith("grid-template"));
24424
24504
  var atRuleAncestorNode = getAncestorNode(path$$1, "css-atrule");
@@ -24509,12 +24589,15 @@ function genericPrint$3(path$$1, options, print) {
24509
24589
 
24510
24590
  if (insideValueFunctionNode(path$$1, "calc") && (isAdditionNode(iNode) || isAdditionNode(iNextNode) || isSubtractionNode(iNode) || isSubtractionNode(iNextNode)) && hasEmptyRawBefore(iNextNode)) {
24511
24591
  continue;
24512
- }
24592
+ } // Print spaces after `+` and `-` in color adjuster functions as is (e.g. `color(red l(+ 20%))`)
24593
+ // Adjusters with signed numbers (e.g. `color(red l(+20%))`) output as-is.
24513
24594
 
24595
+
24596
+ var isColorAdjusterNode = (isAdditionNode(iNode) || isSubtractionNode(iNode)) && i === 0 && (iNextNode.type === "value-number" || iNextNode.isHex) && parentParentNode && isColorAdjusterFuncNode(parentParentNode) && !hasEmptyRawBefore(iNextNode);
24514
24597
  var requireSpaceBeforeOperator = iNextNextNode && iNextNextNode.type === "value-func" || iNextNextNode && isWordNode(iNextNextNode) || iNode.type === "value-func" || isWordNode(iNode);
24515
24598
  var requireSpaceAfterOperator = iNextNode.type === "value-func" || isWordNode(iNextNode) || iPrevNode && iPrevNode.type === "value-func" || iPrevNode && isWordNode(iPrevNode); // Formatting `/`, `+`, `-` sign
24516
24599
 
24517
- if (!(isMultiplicationNode(iNextNode) || isMultiplicationNode(iNode)) && !insideValueFunctionNode(path$$1, "calc") && (isDivisionNode(iNextNode) && !requireSpaceBeforeOperator || isDivisionNode(iNode) && !requireSpaceAfterOperator || isAdditionNode(iNextNode) && !requireSpaceBeforeOperator || isAdditionNode(iNode) && !requireSpaceAfterOperator || isSubtractionNode(iNextNode) || isSubtractionNode(iNode)) && (hasEmptyRawBefore(iNextNode) || isMathOperator && (!iPrevNode || iPrevNode && isMathOperatorNode(iPrevNode)))) {
24600
+ if (!(isMultiplicationNode(iNextNode) || isMultiplicationNode(iNode)) && !insideValueFunctionNode(path$$1, "calc") && !isColorAdjusterNode && (isDivisionNode(iNextNode) && !requireSpaceBeforeOperator || isDivisionNode(iNode) && !requireSpaceAfterOperator || isAdditionNode(iNextNode) && !requireSpaceBeforeOperator || isAdditionNode(iNode) && !requireSpaceAfterOperator || isSubtractionNode(iNextNode) || isSubtractionNode(iNode)) && (hasEmptyRawBefore(iNextNode) || isMathOperator && (!iPrevNode || iPrevNode && isMathOperatorNode(iPrevNode)))) {
24518
24601
  continue;
24519
24602
  } // Ignore inline comment, they already contain newline at end (i.e. `// Comment`)
24520
24603
  // Add `hardline` after inline comment (i.e. `// comment\n foo: bar;`)
@@ -25136,13 +25219,16 @@ function genericPrint$4(path$$1, options, print) {
25136
25219
  var parts = [];
25137
25220
  path$$1.map(function (pathChild, index) {
25138
25221
  parts.push(concat$9([pathChild.call(print)]));
25139
- parts.push(hardline$8);
25140
25222
 
25141
- if (index !== n.definitions.length - 1 && isNextLineEmpty$4(options.originalText, pathChild.getValue(), options)) {
25223
+ if (index !== n.definitions.length - 1) {
25142
25224
  parts.push(hardline$8);
25225
+
25226
+ if (isNextLineEmpty$4(options.originalText, pathChild.getValue(), options)) {
25227
+ parts.push(hardline$8);
25228
+ }
25143
25229
  }
25144
25230
  }, "definitions");
25145
- return concat$9(parts, hardline$8);
25231
+ return concat$9([concat$9(parts), hardline$8]);
25146
25232
  }
25147
25233
 
25148
25234
  case "OperationDefinition":
@@ -25447,9 +25533,9 @@ var languageGraphql = {
25447
25533
 
25448
25534
  var _require$$0$builders$6 = doc.builders;
25449
25535
  var hardline$10 = _require$$0$builders$6.hardline;
25450
- var literalline$3 = _require$$0$builders$6.literalline;
25536
+ var literalline$4 = _require$$0$builders$6.literalline;
25451
25537
  var concat$11 = _require$$0$builders$6.concat;
25452
- var markAsRoot$1 = _require$$0$builders$6.markAsRoot;
25538
+ var markAsRoot$2 = _require$$0$builders$6.markAsRoot;
25453
25539
  var mapDoc$4 = doc.utils.mapDoc;
25454
25540
 
25455
25541
  function embed$2(path$$1, print, textToDoc, options) {
@@ -25466,7 +25552,7 @@ function embed$2(path$$1, print, textToDoc, options) {
25466
25552
  var doc$$2 = textToDoc(node.value, {
25467
25553
  parser
25468
25554
  });
25469
- return markAsRoot$1(concat$11([style, node.lang, hardline$10, replaceNewlinesWithLiterallines(doc$$2), style]));
25555
+ return markAsRoot$2(concat$11([style, node.lang, hardline$10, replaceNewlinesWithLiterallines(doc$$2), style]));
25470
25556
  }
25471
25557
  }
25472
25558
 
@@ -25492,7 +25578,7 @@ function embed$2(path$$1, print, textToDoc, options) {
25492
25578
  function replaceNewlinesWithLiterallines(doc$$2) {
25493
25579
  return mapDoc$4(doc$$2, function (currentDoc) {
25494
25580
  return typeof currentDoc === "string" && currentDoc.includes("\n") ? concat$11(currentDoc.split(/(\n)/g).map(function (v, i) {
25495
- return i % 2 === 0 ? v : literalline$3;
25581
+ return i % 2 === 0 ? v : literalline$4;
25496
25582
  })) : currentDoc;
25497
25583
  });
25498
25584
  }
@@ -25556,6 +25642,8 @@ var _require$$0$builders$5 = doc.builders;
25556
25642
  var concat$10 = _require$$0$builders$5.concat;
25557
25643
  var join$8 = _require$$0$builders$5.join;
25558
25644
  var line$7 = _require$$0$builders$5.line;
25645
+ var literalline$3 = _require$$0$builders$5.literalline;
25646
+ var markAsRoot$1 = _require$$0$builders$5.markAsRoot;
25559
25647
  var hardline$9 = _require$$0$builders$5.hardline;
25560
25648
  var softline$6 = _require$$0$builders$5.softline;
25561
25649
  var fill$4 = _require$$0$builders$5.fill;
@@ -25688,7 +25776,9 @@ function genericPrint$5(path$$1, options, print) {
25688
25776
  {
25689
25777
  var _parentNode2 = path$$1.getParentNode();
25690
25778
 
25691
- return replaceNewlinesWithHardlines(_parentNode2.type === "root" && util$1.getLast(_parentNode2.children) === node ? node.value.trimRight() : node.value);
25779
+ var value = _parentNode2.type === "root" && util$1.getLast(_parentNode2.children) === node ? node.value.trimRight() : node.value;
25780
+ var isHtmlComment = /^<!--[\s\S]*-->$/.test(value);
25781
+ return replaceNewlinesWith(value, isHtmlComment ? hardline$9 : markAsRoot$1(literalline$3));
25692
25782
  }
25693
25783
 
25694
25784
  case "list":
@@ -25766,10 +25856,10 @@ function genericPrint$5(path$$1, options, print) {
25766
25856
  return printChildren(path$$1, options, print);
25767
25857
 
25768
25858
  case "break":
25769
- return concat$10([/\s/.test(options.originalText[node.position.start.offset]) ? " " : "\\", hardline$9]);
25859
+ return /\s/.test(options.originalText[node.position.start.offset]) ? concat$10([" ", markAsRoot$1(literalline$3)]) : concat$10(["\\", hardline$9]);
25770
25860
 
25771
25861
  case "liquidNode":
25772
- return replaceNewlinesWithHardlines(node.value);
25862
+ return replaceNewlinesWith(node.value, hardline$9);
25773
25863
 
25774
25864
  case "tableRow": // handled in "table"
25775
25865
 
@@ -25813,8 +25903,8 @@ function getNthListSiblingIndex(node, parentNode) {
25813
25903
  });
25814
25904
  }
25815
25905
 
25816
- function replaceNewlinesWithHardlines(str) {
25817
- return join$8(hardline$9, str.split("\n"));
25906
+ function replaceNewlinesWith(str, doc$$2) {
25907
+ return join$8(doc$$2, str.split("\n"));
25818
25908
  }
25819
25909
 
25820
25910
  function getNthSiblingIndex(node, parentNode, condition) {
@@ -26085,7 +26175,8 @@ function shouldPrePrintDoubleHardline(node, data) {
26085
26175
  var isInTightListItem = data.parentNode.type === "listItem" && !data.parentNode.loose;
26086
26176
  var isPrevNodeLooseListItem = data.prevNode && data.prevNode.type === "listItem" && data.prevNode.loose;
26087
26177
  var isPrevNodePrettierIgnore = isPrettierIgnore(data.prevNode) === "next";
26088
- return isPrevNodeLooseListItem || !(isSiblingNode || isInTightListItem || isPrevNodePrettierIgnore);
26178
+ var isBlockHtmlWithoutBlankLineBetweenPrevHtml = node.type === "html" && data.prevNode && data.prevNode.type === "html" && data.prevNode.position.end.line + 1 === node.position.start.line;
26179
+ return isPrevNodeLooseListItem || !(isSiblingNode || isInTightListItem || isPrevNodePrettierIgnore || isBlockHtmlWithoutBlankLineBetweenPrevHtml);
26089
26180
  }
26090
26181
 
26091
26182
  function shouldPrePrintTripleHardline(node, data) {
@@ -33040,11 +33131,11 @@ function logFileInfoOrDie(context) {
33040
33131
  }));
33041
33132
  }
33042
33133
 
33043
- function writeOutput(result, options$$2) {
33134
+ function writeOutput(context, result, options$$2) {
33044
33135
  // Don't use `console.log` here since it adds an extra newline at the end.
33045
- process.stdout.write(result.formatted);
33136
+ process.stdout.write(context.argv["debug-check"] ? result.filepath : result.formatted);
33046
33137
 
33047
- if (options$$2.cursorOffset >= 0) {
33138
+ if (options$$2 && options$$2.cursorOffset >= 0) {
33048
33139
  process.stderr.write(result.cursorOffset + "\n");
33049
33140
  }
33050
33141
  }
@@ -33114,7 +33205,8 @@ function format$1(context, input, opt) {
33114
33205
  }
33115
33206
 
33116
33207
  return {
33117
- formatted: opt.filepath || "(stdin)\n"
33208
+ formatted: pp,
33209
+ filepath: opt.filepath || "(stdin)\n"
33118
33210
  };
33119
33211
  }
33120
33212
 
@@ -33199,9 +33291,9 @@ function formatStdin(context) {
33199
33291
  var relativeFilepath = path.relative(process.cwd(), filepath);
33200
33292
  thirdParty$1.getStream(process.stdin).then(function (input) {
33201
33293
  if (relativeFilepath && ignorer.filter([relativeFilepath]).length === 0) {
33202
- writeOutput({
33294
+ writeOutput(context, {
33203
33295
  formatted: input
33204
- }, {});
33296
+ });
33205
33297
  return;
33206
33298
  }
33207
33299
 
@@ -33212,7 +33304,7 @@ function formatStdin(context) {
33212
33304
  return;
33213
33305
  }
33214
33306
 
33215
- writeOutput(format$1(context, input, options$$2), options$$2);
33307
+ writeOutput(context, format$1(context, input, options$$2), options$$2);
33216
33308
  } catch (error) {
33217
33309
  handleError(context, "stdin", error);
33218
33310
  }
@@ -33221,7 +33313,7 @@ function formatStdin(context) {
33221
33313
 
33222
33314
  function createIgnorerFromContextOrDie(context) {
33223
33315
  try {
33224
- return createIgnorer_1(context.argv["ignore-path"], context.argv["with-node-modules"]);
33316
+ return createIgnorer_1.sync(context.argv["ignore-path"], context.argv["with-node-modules"]);
33225
33317
  } catch (e) {
33226
33318
  context.logger.error(e.message);
33227
33319
  process.exit(2);
@@ -33293,7 +33385,7 @@ function formatFiles(context) {
33293
33385
  }
33294
33386
 
33295
33387
  if (fileIgnored) {
33296
- writeOutput({
33388
+ writeOutput(context, {
33297
33389
  formatted: input
33298
33390
  }, options$$2);
33299
33391
  return;
@@ -33345,13 +33437,13 @@ function formatFiles(context) {
33345
33437
  context.logger.log(`${chalk$2.grey(filename)} ${Date.now() - start}ms`);
33346
33438
  }
33347
33439
  } else if (context.argv["debug-check"]) {
33348
- if (output) {
33349
- context.logger.log(output);
33440
+ if (result.filepath) {
33441
+ context.logger.log(result.filepath);
33350
33442
  } else {
33351
33443
  process.exitCode = 2;
33352
33444
  }
33353
33445
  } else if (!context.argv["list-different"]) {
33354
- writeOutput(result, options$$2);
33446
+ writeOutput(context, result, options$$2);
33355
33447
  }
33356
33448
  });
33357
33449
  }