prettier 1.12.0 → 1.12.1

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
@@ -15,7 +15,7 @@ var events = _interopDefault(require('events'));
15
15
  var readline = _interopDefault(require('readline'));
16
16
 
17
17
  var name = "prettier";
18
- var version$1 = "1.12.0";
18
+ var version$1 = "1.12.1";
19
19
  var description = "Prettier is an opinionated code formatter";
20
20
  var bin = {"prettier":"./bin/prettier.js"};
21
21
  var repository = "prettier/prettier";
@@ -25,7 +25,7 @@ var license = "MIT";
25
25
  var main = "./index.js";
26
26
  var engines = {"node":">=4"};
27
27
  var dependencies = {"@babel/code-frame":"7.0.0-beta.40","@glimmer/syntax":"0.30.3","babylon":"7.0.0-beta.34","camelcase":"4.1.0","chalk":"2.1.0","cjk-regex":"1.0.2","cosmiconfig":"3.1.0","dashify":"0.2.2","dedent":"0.7.0","diff":"3.2.0","editorconfig":"0.15.0","editorconfig-to-prettier":"0.0.6","emoji-regex":"6.5.1","escape-string-regexp":"1.0.5","esutils":"2.0.2","find-project-root":"1.1.1","flow-parser":"0.69","get-stream":"3.0.0","globby":"6.1.0","graphql":"0.13.2","gray-matter":"3.1.1","html-tag-names":"1.1.2","ignore":"3.3.7","jest-docblock":"22.2.2","json-stable-stringify":"1.0.1","leven":"2.1.0","mem":"1.1.0","minimatch":"3.0.4","minimist":"1.2.0","parse5":"3.0.3","postcss-less":"1.1.5","postcss-media-query-parser":"0.2.3","postcss-scss":"1.0.5","postcss-selector-parser":"2.2.3","postcss-values-parser":"1.5.0","read-pkg-up":"3.0.0","remark-frontmatter":"1.1.0","remark-parse":"5.0.0","resolve":"1.5.0","semver":"5.4.1","string-width":"2.1.1","typescript":"2.8.0-rc","typescript-eslint-parser":"14.0.0","unicode-regex":"1.0.1","unified":"6.1.6"};
28
- var devDependencies = {"babel-cli":"6.24.1","babel-preset-es2015":"6.24.1","codecov":"2.2.0","cross-env":"5.0.5","eslint":"4.18.2","eslint-config-prettier":"2.9.0","eslint-friendly-formatter":"3.0.0","eslint-plugin-import":"2.9.0","eslint-plugin-prettier":"2.6.0","eslint-plugin-react":"7.7.0","jest":"21.1.0","mkdirp":"0.5.1","prettier":"1.11.1","prettylint":"1.0.0","rimraf":"2.6.2","rollup":"0.47.6","rollup-plugin-commonjs":"8.2.6","rollup-plugin-json":"2.1.1","rollup-plugin-node-builtins":"2.0.0","rollup-plugin-node-globals":"1.1.0","rollup-plugin-node-resolve":"2.0.0","rollup-plugin-replace":"1.2.1","shelljs":"0.8.1","snapshot-diff":"0.2.2","strip-ansi":"4.0.0","tempy":"0.2.1","uglify-es":"3.3.9","webpack":"2.6.1"};
28
+ var devDependencies = {"babel-cli":"6.24.1","babel-preset-es2015":"6.24.1","codecov":"2.2.0","cross-env":"5.0.5","eslint":"4.18.2","eslint-config-prettier":"2.9.0","eslint-friendly-formatter":"3.0.0","eslint-plugin-import":"2.9.0","eslint-plugin-prettier":"2.6.0","eslint-plugin-react":"7.7.0","jest":"21.1.0","mkdirp":"0.5.1","prettier":"1.12.0","prettylint":"1.0.0","rimraf":"2.6.2","rollup":"0.47.6","rollup-plugin-commonjs":"8.2.6","rollup-plugin-json":"2.1.1","rollup-plugin-node-builtins":"2.0.0","rollup-plugin-node-globals":"1.1.0","rollup-plugin-node-resolve":"2.0.0","rollup-plugin-replace":"1.2.1","shelljs":"0.8.1","snapshot-diff":"0.2.2","strip-ansi":"4.0.0","tempy":"0.2.1","uglify-es":"3.3.9","webpack":"2.6.1"};
29
29
  var scripts = {"prepublishOnly":"echo \"Error: must publish from dist/\" && exit 1","prepare-release":"yarn && yarn build && yarn test:dist","test":"jest","test:dist":"node ./scripts/test-dist.js","test-integration":"jest tests_integration","lint":"cross-env EFF_NO_LINK_RULES=true eslint . --format node_modules/eslint-friendly-formatter","lint-docs":"prettylint {.,docs,website,website/blog}/*.md","build":"node ./scripts/build/build.js","build-docs":"node ./scripts/build/build-docs.js","check-deps":"node ./scripts/check-deps.js"};
30
30
  var _package = {
31
31
  name: name,
@@ -812,7 +812,9 @@ function printString(raw, options, isDirectiveLiteral) {
812
812
  const enclosingQuote =
813
813
  options.parser === "json"
814
814
  ? double.quote
815
- : shouldUseAlternateQuote ? alternate.quote : preferred.quote;
815
+ : shouldUseAlternateQuote
816
+ ? alternate.quote
817
+ : preferred.quote;
816
818
 
817
819
  // Directives are exact code unit sequences, which means that you can't
818
820
  // change the escape sequences they use.
@@ -910,20 +912,6 @@ function getMaxContinuousCount(str, target) {
910
912
  );
911
913
  }
912
914
 
913
- function mapDoc(doc, callback) {
914
- if (doc.parts) {
915
- const parts = doc.parts.map(part => mapDoc(part, callback));
916
- return callback(Object.assign({}, doc, { parts }));
917
- }
918
-
919
- if (doc.contents) {
920
- const contents = mapDoc(doc.contents, callback);
921
- return callback(Object.assign({}, doc, { contents }));
922
- }
923
-
924
- return callback(doc);
925
- }
926
-
927
915
  /**
928
916
  * split text into whitespaces and words
929
917
  * @param {string} text
@@ -1105,7 +1093,6 @@ var util$1 = {
1105
1093
  punctuationCharRange,
1106
1094
  getStringWidth,
1107
1095
  splitText,
1108
- mapDoc,
1109
1096
  getMaxContinuousCount,
1110
1097
  getPrecedence,
1111
1098
  shouldFlatten,
@@ -1144,6 +1131,196 @@ var util$1 = {
1144
1131
  addTrailingComment
1145
1132
  };
1146
1133
 
1134
+ function traverseDoc(doc, onEnter, onExit, shouldTraverseConditionalGroups) {
1135
+ function traverseDocRec(doc) {
1136
+ let shouldRecurse = true;
1137
+ if (onEnter) {
1138
+ if (onEnter(doc) === false) {
1139
+ shouldRecurse = false;
1140
+ }
1141
+ }
1142
+
1143
+ if (shouldRecurse) {
1144
+ if (doc.type === "concat" || doc.type === "fill") {
1145
+ for (let i = 0; i < doc.parts.length; i++) {
1146
+ traverseDocRec(doc.parts[i]);
1147
+ }
1148
+ } else if (doc.type === "if-break") {
1149
+ if (doc.breakContents) {
1150
+ traverseDocRec(doc.breakContents);
1151
+ }
1152
+ if (doc.flatContents) {
1153
+ traverseDocRec(doc.flatContents);
1154
+ }
1155
+ } else if (doc.type === "group" && doc.expandedStates) {
1156
+ if (shouldTraverseConditionalGroups) {
1157
+ doc.expandedStates.forEach(traverseDocRec);
1158
+ } else {
1159
+ traverseDocRec(doc.contents);
1160
+ }
1161
+ } else if (doc.contents) {
1162
+ traverseDocRec(doc.contents);
1163
+ }
1164
+ }
1165
+
1166
+ if (onExit) {
1167
+ onExit(doc);
1168
+ }
1169
+ }
1170
+
1171
+ traverseDocRec(doc);
1172
+ }
1173
+
1174
+ function mapDoc(doc, cb) {
1175
+ if (doc.type === "concat" || doc.type === "fill") {
1176
+ const parts = doc.parts.map(part => mapDoc(part, cb));
1177
+ return cb(Object.assign({}, doc, { parts }));
1178
+ } else if (doc.type === "if-break") {
1179
+ const breakContents = doc.breakContents && mapDoc(doc.breakContents, cb);
1180
+ const flatContents = doc.flatContents && mapDoc(doc.flatContents, cb);
1181
+ return cb(Object.assign({}, doc, { breakContents, flatContents }));
1182
+ } else if (doc.contents) {
1183
+ const contents = mapDoc(doc.contents, cb);
1184
+ return cb(Object.assign({}, doc, { contents }));
1185
+ }
1186
+ return cb(doc);
1187
+ }
1188
+
1189
+ function findInDoc(doc, fn, defaultValue) {
1190
+ let result = defaultValue;
1191
+ let hasStopped = false;
1192
+ traverseDoc(doc, doc => {
1193
+ const maybeResult = fn(doc);
1194
+ if (maybeResult !== undefined) {
1195
+ hasStopped = true;
1196
+ result = maybeResult;
1197
+ }
1198
+ if (hasStopped) {
1199
+ return false;
1200
+ }
1201
+ });
1202
+ return result;
1203
+ }
1204
+
1205
+ function isEmpty(n) {
1206
+ return typeof n === "string" && n.length === 0;
1207
+ }
1208
+
1209
+ function isLineNext(doc) {
1210
+ return findInDoc(
1211
+ doc,
1212
+ doc => {
1213
+ if (typeof doc === "string") {
1214
+ return false;
1215
+ }
1216
+ if (doc.type === "line") {
1217
+ return true;
1218
+ }
1219
+ },
1220
+ false
1221
+ );
1222
+ }
1223
+
1224
+ function willBreak(doc) {
1225
+ return findInDoc(
1226
+ doc,
1227
+ doc => {
1228
+ if (doc.type === "group" && doc.break) {
1229
+ return true;
1230
+ }
1231
+ if (doc.type === "line" && doc.hard) {
1232
+ return true;
1233
+ }
1234
+ if (doc.type === "break-parent") {
1235
+ return true;
1236
+ }
1237
+ },
1238
+ false
1239
+ );
1240
+ }
1241
+
1242
+ function breakParentGroup(groupStack) {
1243
+ if (groupStack.length > 0) {
1244
+ const parentGroup = groupStack[groupStack.length - 1];
1245
+ // Breaks are not propagated through conditional groups because
1246
+ // the user is expected to manually handle what breaks.
1247
+ if (!parentGroup.expandedStates) {
1248
+ parentGroup.break = true;
1249
+ }
1250
+ }
1251
+ return null;
1252
+ }
1253
+
1254
+ function propagateBreaks(doc) {
1255
+ const alreadyVisited = new Map();
1256
+ const groupStack = [];
1257
+ traverseDoc(
1258
+ doc,
1259
+ doc => {
1260
+ if (doc.type === "break-parent") {
1261
+ breakParentGroup(groupStack);
1262
+ }
1263
+ if (doc.type === "group") {
1264
+ groupStack.push(doc);
1265
+ if (alreadyVisited.has(doc)) {
1266
+ return false;
1267
+ }
1268
+ alreadyVisited.set(doc, true);
1269
+ }
1270
+ },
1271
+ doc => {
1272
+ if (doc.type === "group") {
1273
+ const group = groupStack.pop();
1274
+ if (group.break) {
1275
+ breakParentGroup(groupStack);
1276
+ }
1277
+ }
1278
+ },
1279
+ /* shouldTraverseConditionalGroups */ true
1280
+ );
1281
+ }
1282
+
1283
+ function removeLines(doc) {
1284
+ // Force this doc into flat mode by statically converting all
1285
+ // lines into spaces (or soft lines into nothing). Hard lines
1286
+ // should still output because there's too great of a chance
1287
+ // of breaking existing assumptions otherwise.
1288
+ return mapDoc(doc, d => {
1289
+ if (d.type === "line" && !d.hard) {
1290
+ return d.soft ? "" : " ";
1291
+ } else if (d.type === "if-break") {
1292
+ return d.flatContents || "";
1293
+ }
1294
+ return d;
1295
+ });
1296
+ }
1297
+
1298
+ function stripTrailingHardline(doc) {
1299
+ // HACK remove ending hardline, original PR: #1984
1300
+ if (
1301
+ doc.type === "concat" &&
1302
+ doc.parts.length === 2 &&
1303
+ doc.parts[1].type === "concat" &&
1304
+ doc.parts[1].parts.length === 2 &&
1305
+ doc.parts[1].parts[0].hard &&
1306
+ doc.parts[1].parts[1].type === "break-parent"
1307
+ ) {
1308
+ return doc.parts[0];
1309
+ }
1310
+ return doc;
1311
+ }
1312
+
1313
+ var docUtils = {
1314
+ isEmpty,
1315
+ willBreak,
1316
+ isLineNext,
1317
+ traverseDoc,
1318
+ mapDoc,
1319
+ propagateBreaks,
1320
+ removeLines,
1321
+ stripTrailingHardline
1322
+ };
1323
+
1147
1324
  function isNextLineEmpty$1(text, node, options) {
1148
1325
  return util$1.isNextLineEmpty(text, node, options.locEnd);
1149
1326
  }
@@ -1160,7 +1337,7 @@ var utilShared = {
1160
1337
  isNextLineEmpty: isNextLineEmpty$1,
1161
1338
  isNextLineEmptyAfterIndex: util$1.isNextLineEmptyAfterIndex,
1162
1339
  getNextNonSpaceNonCommentCharacterIndex: getNextNonSpaceNonCommentCharacterIndex$1,
1163
- mapDoc: util$1.mapDoc,
1340
+ mapDoc: docUtils.mapDoc, // TODO: remove in 2.0, we already exposed it in docUtils
1164
1341
  makeString: util$1.makeString,
1165
1342
  addLeadingComment: util$1.addLeadingComment,
1166
1343
  addDanglingComment: util$1.addDanglingComment,
@@ -7461,204 +7638,6 @@ function printDocToString$1(doc, options) {
7461
7638
 
7462
7639
  var docPrinter = { printDocToString: printDocToString$1 };
7463
7640
 
7464
- function traverseDoc(doc, onEnter, onExit, shouldTraverseConditionalGroups) {
7465
- function traverseDocRec(doc) {
7466
- let shouldRecurse = true;
7467
- if (onEnter) {
7468
- if (onEnter(doc) === false) {
7469
- shouldRecurse = false;
7470
- }
7471
- }
7472
-
7473
- if (shouldRecurse) {
7474
- if (doc.type === "concat" || doc.type === "fill") {
7475
- for (let i = 0; i < doc.parts.length; i++) {
7476
- traverseDocRec(doc.parts[i]);
7477
- }
7478
- } else if (doc.type === "if-break") {
7479
- if (doc.breakContents) {
7480
- traverseDocRec(doc.breakContents);
7481
- }
7482
- if (doc.flatContents) {
7483
- traverseDocRec(doc.flatContents);
7484
- }
7485
- } else if (doc.type === "group" && doc.expandedStates) {
7486
- if (shouldTraverseConditionalGroups) {
7487
- doc.expandedStates.forEach(traverseDocRec);
7488
- } else {
7489
- traverseDocRec(doc.contents);
7490
- }
7491
- } else if (doc.contents) {
7492
- traverseDocRec(doc.contents);
7493
- }
7494
- }
7495
-
7496
- if (onExit) {
7497
- onExit(doc);
7498
- }
7499
- }
7500
-
7501
- traverseDocRec(doc);
7502
- }
7503
-
7504
- function mapDoc$1(doc, func) {
7505
- doc = func(doc);
7506
-
7507
- if (doc.type === "concat" || doc.type === "fill") {
7508
- return Object.assign({}, doc, {
7509
- parts: doc.parts.map(d => mapDoc$1(d, func))
7510
- });
7511
- } else if (doc.type === "if-break") {
7512
- return Object.assign({}, doc, {
7513
- breakContents: doc.breakContents && mapDoc$1(doc.breakContents, func),
7514
- flatContents: doc.flatContents && mapDoc$1(doc.flatContents, func)
7515
- });
7516
- } else if (doc.contents) {
7517
- return Object.assign({}, doc, { contents: mapDoc$1(doc.contents, func) });
7518
- }
7519
- return doc;
7520
- }
7521
-
7522
- function findInDoc(doc, fn, defaultValue) {
7523
- let result = defaultValue;
7524
- let hasStopped = false;
7525
- traverseDoc(doc, doc => {
7526
- const maybeResult = fn(doc);
7527
- if (maybeResult !== undefined) {
7528
- hasStopped = true;
7529
- result = maybeResult;
7530
- }
7531
- if (hasStopped) {
7532
- return false;
7533
- }
7534
- });
7535
- return result;
7536
- }
7537
-
7538
- function isEmpty$1(n) {
7539
- return typeof n === "string" && n.length === 0;
7540
- }
7541
-
7542
- function isLineNext$1(doc) {
7543
- return findInDoc(
7544
- doc,
7545
- doc => {
7546
- if (typeof doc === "string") {
7547
- return false;
7548
- }
7549
- if (doc.type === "line") {
7550
- return true;
7551
- }
7552
- },
7553
- false
7554
- );
7555
- }
7556
-
7557
- function willBreak$1(doc) {
7558
- return findInDoc(
7559
- doc,
7560
- doc => {
7561
- if (doc.type === "group" && doc.break) {
7562
- return true;
7563
- }
7564
- if (doc.type === "line" && doc.hard) {
7565
- return true;
7566
- }
7567
- if (doc.type === "break-parent") {
7568
- return true;
7569
- }
7570
- },
7571
- false
7572
- );
7573
- }
7574
-
7575
- function breakParentGroup(groupStack) {
7576
- if (groupStack.length > 0) {
7577
- const parentGroup = groupStack[groupStack.length - 1];
7578
- // Breaks are not propagated through conditional groups because
7579
- // the user is expected to manually handle what breaks.
7580
- if (!parentGroup.expandedStates) {
7581
- parentGroup.break = true;
7582
- }
7583
- }
7584
- return null;
7585
- }
7586
-
7587
- function propagateBreaks(doc) {
7588
- const alreadyVisited = new Map();
7589
- const groupStack = [];
7590
- traverseDoc(
7591
- doc,
7592
- doc => {
7593
- if (doc.type === "break-parent") {
7594
- breakParentGroup(groupStack);
7595
- }
7596
- if (doc.type === "group") {
7597
- groupStack.push(doc);
7598
- if (alreadyVisited.has(doc)) {
7599
- return false;
7600
- }
7601
- alreadyVisited.set(doc, true);
7602
- }
7603
- },
7604
- doc => {
7605
- if (doc.type === "group") {
7606
- const group = groupStack.pop();
7607
- if (group.break) {
7608
- breakParentGroup(groupStack);
7609
- }
7610
- }
7611
- },
7612
- /* shouldTraverseConditionalGroups */ true
7613
- );
7614
- }
7615
-
7616
- function removeLines(doc) {
7617
- // Force this doc into flat mode by statically converting all
7618
- // lines into spaces (or soft lines into nothing). Hard lines
7619
- // should still output because there's too great of a chance
7620
- // of breaking existing assumptions otherwise.
7621
- return mapDoc$1(doc, d => {
7622
- if (d.type === "line" && !d.hard) {
7623
- return d.soft ? "" : " ";
7624
- } else if (d.type === "if-break") {
7625
- return d.flatContents || "";
7626
- }
7627
- return d;
7628
- });
7629
- }
7630
-
7631
- function stripTrailingHardline(doc) {
7632
- // HACK remove ending hardline, original PR: #1984
7633
- if (
7634
- doc.type === "concat" &&
7635
- doc.parts.length === 2 &&
7636
- doc.parts[1].type === "concat" &&
7637
- doc.parts[1].parts.length === 2 &&
7638
- doc.parts[1].parts[0].hard &&
7639
- doc.parts[1].parts[1].type === "break-parent"
7640
- ) {
7641
- return doc.parts[0];
7642
- }
7643
- return doc;
7644
- }
7645
-
7646
- function rawText$1(node) {
7647
- return node.extra ? node.extra.raw : node.raw;
7648
- }
7649
-
7650
- var docUtils$1 = {
7651
- isEmpty: isEmpty$1,
7652
- willBreak: willBreak$1,
7653
- isLineNext: isLineNext$1,
7654
- traverseDoc,
7655
- mapDoc: mapDoc$1,
7656
- propagateBreaks,
7657
- removeLines,
7658
- stripTrailingHardline,
7659
- rawText: rawText$1
7660
- };
7661
-
7662
7641
  function flattenDoc(doc) {
7663
7642
  if (doc.type === "concat") {
7664
7643
  const res = [];
@@ -7791,7 +7770,7 @@ var docDebug = {
7791
7770
  var doc = {
7792
7771
  builders: docBuilders$2,
7793
7772
  printer: docPrinter,
7794
- utils: docUtils$1,
7773
+ utils: docUtils,
7795
7774
  debug: docDebug
7796
7775
  };
7797
7776
 
@@ -8810,7 +8789,7 @@ var utils$2 = createCommonjsModule(function (module, exports) {
8810
8789
  });
8811
8790
 
8812
8791
  const doc$2 = doc;
8813
- const docUtils$3 = doc$2.utils;
8792
+ const docUtils$4 = doc$2.utils;
8814
8793
  const docBuilders$5 = doc$2.builders;
8815
8794
  const indent$3 = docBuilders$5.indent;
8816
8795
  const join$3 = docBuilders$5.join;
@@ -8919,7 +8898,7 @@ function embed(path$$1, print, textToDoc /*, options */) {
8919
8898
  doc$$2 = printGraphqlComments(lines);
8920
8899
  } else {
8921
8900
  try {
8922
- doc$$2 = docUtils$3.stripTrailingHardline(
8901
+ doc$$2 = docUtils$4.stripTrailingHardline(
8923
8902
  textToDoc(text, { parser: "graphql" })
8924
8903
  );
8925
8904
  } catch (error) {
@@ -8997,7 +8976,7 @@ function embed(path$$1, print, textToDoc /*, options */) {
8997
8976
 
8998
8977
  function printMarkdown(text) {
8999
8978
  const doc$$2 = textToDoc(text, { parser: "markdown", __inJsTemplate: true });
9000
- return docUtils$3.stripTrailingHardline(escapeBackticks(doc$$2));
8979
+ return docUtils$4.stripTrailingHardline(escapeBackticks(doc$$2));
9001
8980
  }
9002
8981
  }
9003
8982
 
@@ -9007,7 +8986,7 @@ function getIndentation(str) {
9007
8986
  }
9008
8987
 
9009
8988
  function escapeBackticks(doc$$2) {
9010
- return util$1.mapDoc(doc$$2, currentDoc => {
8989
+ return docUtils$4.mapDoc(doc$$2, currentDoc => {
9011
8990
  if (!currentDoc.parts) {
9012
8991
  return currentDoc;
9013
8992
  }
@@ -9045,7 +9024,7 @@ function transformCssDoc(quasisDoc, path$$1, print) {
9045
9024
  }
9046
9025
  return concat$4([
9047
9026
  "`",
9048
- indent$3(concat$4([hardline$3, docUtils$3.stripTrailingHardline(newDoc)])),
9027
+ indent$3(concat$4([hardline$3, docUtils$4.stripTrailingHardline(newDoc)])),
9049
9028
  softline$2,
9050
9029
  "`"
9051
9030
  ]);
@@ -9062,7 +9041,7 @@ function replacePlaceholders(quasisDoc, expressionDocs) {
9062
9041
 
9063
9042
  const expressions = expressionDocs.slice();
9064
9043
  let replaceCounter = 0;
9065
- const newDoc = docUtils$3.mapDoc(quasisDoc, doc$$2 => {
9044
+ const newDoc = docUtils$4.mapDoc(quasisDoc, doc$$2 => {
9066
9045
  if (!doc$$2 || !doc$$2.parts || !doc$$2.parts.length) {
9067
9046
  return doc$$2;
9068
9047
  }
@@ -9091,7 +9070,7 @@ function replacePlaceholders(quasisDoc, expressionDocs) {
9091
9070
  const placeholder = parts[atPlaceholderIndex];
9092
9071
  const rest = parts.slice(atPlaceholderIndex + 1);
9093
9072
  const placeholderMatch = placeholder.match(
9094
- /@prettier-placeholder-(.+)-id(.*)/
9073
+ /@prettier-placeholder-(.+)-id([\s\S]*)/
9095
9074
  );
9096
9075
  const placeholderID = placeholderMatch[1];
9097
9076
  // When the expression has a suffix appended, like:
@@ -10552,6 +10531,7 @@ function needsParens(path$$1, options) {
10552
10531
  case "AwaitExpression":
10553
10532
  switch (parent.type) {
10554
10533
  case "TaggedTemplateExpression":
10534
+ case "UnaryExpression":
10555
10535
  case "BinaryExpression":
10556
10536
  case "LogicalExpression":
10557
10537
  case "SpreadElement":
@@ -10824,11 +10804,10 @@ const lineSuffixBoundary = docBuilders.lineSuffixBoundary;
10824
10804
  const addAlignmentToDoc = docBuilders.addAlignmentToDoc;
10825
10805
  const dedent = docBuilders.dedent;
10826
10806
 
10827
- const docUtils = doc.utils;
10828
- const willBreak = docUtils.willBreak;
10829
- const isLineNext = docUtils.isLineNext;
10830
- const isEmpty = docUtils.isEmpty;
10831
- const rawText = docUtils.rawText;
10807
+ const docUtils$3 = doc.utils;
10808
+ const willBreak$1 = docUtils$3.willBreak;
10809
+ const isLineNext$1 = docUtils$3.isLineNext;
10810
+ const isEmpty$1 = docUtils$3.isEmpty;
10832
10811
 
10833
10812
  function shouldPrintComma(options, level) {
10834
10813
  level = level || "es5";
@@ -10855,7 +10834,7 @@ function genericPrint(path$$1, options, printPath, args) {
10855
10834
  let needsParens = false;
10856
10835
  const linesWithoutParens = printPathNoParens(path$$1, options, printPath, args);
10857
10836
 
10858
- if (!node || isEmpty(linesWithoutParens)) {
10837
+ if (!node || isEmpty$1(linesWithoutParens)) {
10859
10838
  return linesWithoutParens;
10860
10839
  }
10861
10840
 
@@ -11076,7 +11055,9 @@ function formatTernaryOperator(path$$1, options, print, operatorOptions) {
11076
11055
  // outer-most ConditionalExpression.
11077
11056
  const maybeGroup = doc$$1 =>
11078
11057
  operatorOpts.breakNested
11079
- ? parent === firstNonConditionalParent ? group(doc$$1) : doc$$1
11058
+ ? parent === firstNonConditionalParent
11059
+ ? group(doc$$1)
11060
+ : doc$$1
11080
11061
  : group(doc$$1); // Always group in normal mode.
11081
11062
 
11082
11063
  // Break the closing paren to keep the chain right after it:
@@ -12731,7 +12712,9 @@ function printPathNoParens(path$$1, options, print, args) {
12731
12712
  concat([
12732
12713
  hasOwnLineComment
12733
12714
  ? hardline
12734
- : hasComment && !isOpeningFragment ? " " : "",
12715
+ : hasComment && !isOpeningFragment
12716
+ ? " "
12717
+ : "",
12735
12718
  comments.printDanglingComments(path$$1, options, true)
12736
12719
  ])
12737
12720
  ),
@@ -13174,7 +13157,7 @@ function printPathNoParens(path$$1, options, print, args) {
13174
13157
  parent.type !== "TSTypeParameterInstantiation" &&
13175
13158
  parent.type !== "GenericTypeAnnotation" &&
13176
13159
  parent.type !== "TSTypeReference" &&
13177
- parent.type !== "FunctionTypeParam" &&
13160
+ !(parent.type === "FunctionTypeParam" && !parent.name) &&
13178
13161
  !(
13179
13162
  (parent.type === "TypeAlias" ||
13180
13163
  parent.type === "VariableDeclarator") &&
@@ -14006,8 +13989,8 @@ function printArgumentsList(path$$1, options, print) {
14006
13989
  if (shouldGroupFirst || shouldGroupLast) {
14007
13990
  const shouldBreak =
14008
13991
  (shouldGroupFirst
14009
- ? printedArguments.slice(1).some(willBreak)
14010
- : printedArguments.slice(0, -1).some(willBreak)) || anyArgEmptyLine;
13992
+ ? printedArguments.slice(1).some(willBreak$1)
13993
+ : printedArguments.slice(0, -1).some(willBreak$1)) || anyArgEmptyLine;
14011
13994
 
14012
13995
  // We want to print the last argument with a special flag
14013
13996
  let printedExpanded;
@@ -14031,7 +14014,7 @@ function printArgumentsList(path$$1, options, print) {
14031
14014
  i++;
14032
14015
  }, "arguments");
14033
14016
 
14034
- const somePrintedArgumentsWillBreak = printedArguments.some(willBreak);
14017
+ const somePrintedArgumentsWillBreak = printedArguments.some(willBreak$1);
14035
14018
 
14036
14019
  const maybeTrailingComma = shouldPrintComma(options, "all") ? "," : "";
14037
14020
 
@@ -14088,7 +14071,7 @@ function printArgumentsList(path$$1, options, print) {
14088
14071
  softline,
14089
14072
  ")"
14090
14073
  ]),
14091
- { shouldBreak: printedArguments.some(willBreak) || anyArgEmptyLine }
14074
+ { shouldBreak: printedArguments.some(willBreak$1) || anyArgEmptyLine }
14092
14075
  );
14093
14076
  }
14094
14077
 
@@ -14182,9 +14165,9 @@ function printFunctionParams(path$$1, print, options, expandArg, printTypeParams
14182
14165
  ) {
14183
14166
  return group(
14184
14167
  concat([
14185
- docUtils.removeLines(typeParams),
14168
+ docUtils$3.removeLines(typeParams),
14186
14169
  "(",
14187
- join(", ", printed.map(docUtils.removeLines)),
14170
+ join(", ", printed.map(docUtils$3.removeLines)),
14188
14171
  ")"
14189
14172
  ])
14190
14173
  );
@@ -15011,7 +14994,7 @@ function printMemberChain(path$$1, options, print) {
15011
14994
  if (
15012
14995
  hasComment ||
15013
14996
  callExpressionCount >= 3 ||
15014
- printedGroups.slice(0, -1).some(willBreak)
14997
+ printedGroups.slice(0, -1).some(willBreak$1)
15015
14998
  ) {
15016
14999
  return group(expanded);
15017
15000
  }
@@ -15020,7 +15003,7 @@ function printMemberChain(path$$1, options, print) {
15020
15003
  // We only need to check `oneLine` because if `expanded` is chosen
15021
15004
  // that means that the parent group has already been broken
15022
15005
  // naturally
15023
- willBreak(oneLine) || shouldHaveEmptyLineBeforeIndent ? breakParent : "",
15006
+ willBreak$1(oneLine) || shouldHaveEmptyLineBeforeIndent ? breakParent : "",
15024
15007
  conditionalGroup([oneLine, expanded])
15025
15008
  ]);
15026
15009
  }
@@ -15347,7 +15330,7 @@ function printJSXElement(path$$1, options, print) {
15347
15330
 
15348
15331
  // Record any breaks. Should never go from true to false, only false to true.
15349
15332
  let forcedBreak =
15350
- willBreak(openingLines) ||
15333
+ willBreak$1(openingLines) ||
15351
15334
  containsTag ||
15352
15335
  containsMultipleAttributes ||
15353
15336
  containsMultipleExpressions;
@@ -15398,8 +15381,8 @@ function printJSXElement(path$$1, options, print) {
15398
15381
  // Trim trailing lines (or empty strings)
15399
15382
  while (
15400
15383
  children.length &&
15401
- (isLineNext(util$1.getLast(children)) ||
15402
- isEmpty(util$1.getLast(children)))
15384
+ (isLineNext$1(util$1.getLast(children)) ||
15385
+ isEmpty$1(util$1.getLast(children)))
15403
15386
  ) {
15404
15387
  children.pop();
15405
15388
  }
@@ -15407,8 +15390,8 @@ function printJSXElement(path$$1, options, print) {
15407
15390
  // Trim leading lines (or empty strings)
15408
15391
  while (
15409
15392
  children.length &&
15410
- (isLineNext(children[0]) || isEmpty(children[0])) &&
15411
- (isLineNext(children[1]) || isEmpty(children[1]))
15393
+ (isLineNext$1(children[0]) || isEmpty$1(children[0])) &&
15394
+ (isLineNext$1(children[1]) || isEmpty$1(children[1]))
15412
15395
  ) {
15413
15396
  children.shift();
15414
15397
  children.shift();
@@ -15443,7 +15426,7 @@ function printJSXElement(path$$1, options, print) {
15443
15426
 
15444
15427
  multilineChildren.push(child);
15445
15428
 
15446
- if (willBreak(child)) {
15429
+ if (willBreak$1(child)) {
15447
15430
  forcedBreak = true;
15448
15431
  }
15449
15432
  });
@@ -16316,6 +16299,10 @@ function printJsDocComment(comment) {
16316
16299
  ]);
16317
16300
  }
16318
16301
 
16302
+ function rawText(node) {
16303
+ return node.extra ? node.extra.raw : node.raw;
16304
+ }
16305
+
16319
16306
  var printerEstree = {
16320
16307
  print: genericPrint,
16321
16308
  embed: embed_1,
@@ -17012,13 +16999,19 @@ function genericPrint$1(path$$1, options, print) {
17012
16999
  : path$$1.call(print, "value"),
17013
17000
  node.raws.important
17014
17001
  ? node.raws.important.replace(/\s*!\s*important/i, " !important")
17015
- : node.important ? " !important" : "",
17002
+ : node.important
17003
+ ? " !important"
17004
+ : "",
17016
17005
  node.raws.scssDefault
17017
17006
  ? node.raws.scssDefault.replace(/\s*!default/i, " !default")
17018
- : node.scssDefault ? " !default" : "",
17007
+ : node.scssDefault
17008
+ ? " !default"
17009
+ : "",
17019
17010
  node.raws.scssGlobal
17020
17011
  ? node.raws.scssGlobal.replace(/\s*!global/i, " !global")
17021
- : node.scssGlobal ? " !global" : "",
17012
+ : node.scssGlobal
17013
+ ? " !global"
17014
+ : "",
17022
17015
  node.nodes
17023
17016
  ? concat$5([
17024
17017
  " {",
@@ -17065,11 +17058,15 @@ function genericPrint$1(path$$1, options, print) {
17065
17058
  " ",
17066
17059
  path$$1.call(print, "value"),
17067
17060
  isControlDirectiveNode(node)
17068
- ? hasParensAround ? " " : line$2
17061
+ ? hasParensAround
17062
+ ? " "
17063
+ : line$2
17069
17064
  : ""
17070
17065
  ])
17071
17066
  )
17072
- : node.name === "else" ? " " : "",
17067
+ : node.name === "else"
17068
+ ? " "
17069
+ : "",
17073
17070
  node.nodes
17074
17071
  ? concat$5([
17075
17072
  isControlDirectiveNode(node) ? "" : " ",
@@ -19020,7 +19017,7 @@ const markAsRoot$1 = docBuilders$9.markAsRoot;
19020
19017
  function embed$2(path$$1, print, textToDoc, options) {
19021
19018
  const node = path$$1.getValue();
19022
19019
 
19023
- if (node.type === "code") {
19020
+ if (node.type === "code" && node.lang !== null) {
19024
19021
  // only look for the first string so as to support [markdown-preview-enhanced](https://shd101wyy.github.io/markdown-preview-enhanced/#/code-chunk)
19025
19022
  const lang = node.lang.split(/\s/, 1)[0];
19026
19023
  const parser = getParserName(lang);
@@ -19063,7 +19060,7 @@ function embed$2(path$$1, print, textToDoc, options) {
19063
19060
  }
19064
19061
 
19065
19062
  function replaceNewlinesWithLiterallines(doc$$2) {
19066
- return util$1.mapDoc(
19063
+ return docUtils.mapDoc(
19067
19064
  doc$$2,
19068
19065
  currentDoc =>
19069
19066
  typeof currentDoc === "string" && currentDoc.includes("\n")
@@ -19174,7 +19171,9 @@ function genericPrint$3(path$$1, options, print) {
19174
19171
  node =>
19175
19172
  node.type === "word"
19176
19173
  ? node.value
19177
- : node.value === "" ? "" : printLine(path$$1, node.value, options)
19174
+ : node.value === ""
19175
+ ? ""
19176
+ : printLine(path$$1, node.value, options)
19178
19177
  )
19179
19178
  );
19180
19179
  }
@@ -19365,9 +19364,13 @@ function genericPrint$3(path$$1, options, print) {
19365
19364
  const rawPrefix = node.ordered
19366
19365
  ? (index === 0
19367
19366
  ? node.start
19368
- : isGitDiffFriendlyOrderedList ? 1 : node.start + index) +
19367
+ : isGitDiffFriendlyOrderedList
19368
+ ? 1
19369
+ : node.start + index) +
19369
19370
  (nthSiblingIndex % 2 === 0 ? ". " : ") ")
19370
- : nthSiblingIndex % 2 === 0 ? "* " : "- ";
19371
+ : nthSiblingIndex % 2 === 0
19372
+ ? "* "
19373
+ : "- ";
19371
19374
 
19372
19375
  // do not print trailing spaces for empty list item since it might be treated as `break` node
19373
19376
  // by [doc-printer](https://github.com/prettier/prettier/blob/1.10.2/src/doc/doc-printer.js#L395-L405),
@@ -19398,7 +19401,9 @@ function genericPrint$3(path$$1, options, print) {
19398
19401
  "]",
19399
19402
  node.referenceType === "full"
19400
19403
  ? concat$8(["[", node.identifier, "]"])
19401
- : node.referenceType === "collapsed" ? "[]" : ""
19404
+ : node.referenceType === "collapsed"
19405
+ ? "[]"
19406
+ : ""
19402
19407
  ]);
19403
19408
  case "imageReference":
19404
19409
  switch (node.referenceType) {
@@ -19558,8 +19563,12 @@ function printLine(path$$1, value, options) {
19558
19563
  options.proseWrap === "always" &&
19559
19564
  !getAncestorNode$1(path$$1, SINGLE_LINE_NODE_TYPES);
19560
19565
  return value !== ""
19561
- ? isBreakable ? line$5 : " "
19562
- : isBreakable ? softline$6 : "";
19566
+ ? isBreakable
19567
+ ? line$5
19568
+ : " "
19569
+ : isBreakable
19570
+ ? softline$6
19571
+ : "";
19563
19572
  }
19564
19573
 
19565
19574
  function printTable(path$$1, options, print) {
@@ -19823,7 +19832,7 @@ function shouldRemainTheSameContent(path$$1) {
19823
19832
  }
19824
19833
 
19825
19834
  function normalizeDoc(doc$$2) {
19826
- return util$1.mapDoc(doc$$2, currentDoc => {
19835
+ return docUtils.mapDoc(doc$$2, currentDoc => {
19827
19836
  if (!currentDoc.parts) {
19828
19837
  return currentDoc;
19829
19838
  }
@@ -19868,7 +19877,11 @@ function printTitle(title, options) {
19868
19877
  const quote =
19869
19878
  singleCount > doubleCount
19870
19879
  ? '"'
19871
- : doubleCount > singleCount ? "'" : options.singleQuote ? "'" : '"';
19880
+ : doubleCount > singleCount
19881
+ ? "'"
19882
+ : options.singleQuote
19883
+ ? "'"
19884
+ : '"';
19872
19885
  title = title.replace(new RegExp(`(${quote})`, "g"), "\\$1");
19873
19886
  return ` ${quote}${title}${quote}`;
19874
19887
  }
@@ -20028,7 +20041,7 @@ var languageMarkdown = {
20028
20041
  printers: printers$4
20029
20042
  };
20030
20043
 
20031
- const docUtils$4 = doc.utils;
20044
+ const docUtils$5 = doc.utils;
20032
20045
  const docBuilders$11 = doc.builders;
20033
20046
  const hardline$10 = docBuilders$11.hardline;
20034
20047
  const concat$11 = docBuilders$11.concat;
@@ -20068,7 +20081,7 @@ function embed$4(path$$1, print, textToDoc, options) {
20068
20081
  // Inline Styles
20069
20082
  if (parent.type === "style") {
20070
20083
  const doc$$2 = textToDoc(getText(options, node), { parser: "css" });
20071
- return concat$11([hardline$10, docUtils$4.stripTrailingHardline(doc$$2)]);
20084
+ return concat$11([hardline$10, docUtils$5.stripTrailingHardline(doc$$2)]);
20072
20085
  }
20073
20086
 
20074
20087
  break;
@@ -20094,7 +20107,7 @@ function embed$4(path$$1, print, textToDoc, options) {
20094
20107
  '="',
20095
20108
  util$1.hasNewlineInRange(node.value, 0, node.value.length)
20096
20109
  ? doc$$2
20097
- : docUtils$4.removeLines(doc$$2),
20110
+ : docUtils$5.removeLines(doc$$2),
20098
20111
  '"'
20099
20112
  ]);
20100
20113
  }
@@ -21321,7 +21334,9 @@ function normalizeOptions$1(options, optionInfos, opts) {
21321
21334
  const logger =
21322
21335
  opts.logger === false
21323
21336
  ? { warn() {} }
21324
- : opts.logger !== undefined ? opts.logger : console;
21337
+ : opts.logger !== undefined
21338
+ ? opts.logger
21339
+ : console;
21325
21340
  const descriptor = opts.descriptor || optionsDescriptor.apiDescriptor;
21326
21341
  const passThrough = opts.passThrough || [];
21327
21342
 
@@ -23894,7 +23909,7 @@ const docBuilders$14 = doc$3.builders;
23894
23909
  const concat$14 = docBuilders$14.concat;
23895
23910
  const hardline$13 = docBuilders$14.hardline;
23896
23911
  const addAlignmentToDoc$2 = docBuilders$14.addAlignmentToDoc;
23897
- const docUtils$5 = doc$3.utils;
23912
+ const docUtils$6 = doc$3.utils;
23898
23913
 
23899
23914
  function printAstToDoc(ast, options, addAlignmentSize) {
23900
23915
  addAlignmentSize = addAlignmentSize || 0;
@@ -23936,12 +23951,12 @@ function printAstToDoc(ast, options, addAlignmentSize) {
23936
23951
  // Add a hardline to make the indents take effect
23937
23952
  // It should be removed in index.js format()
23938
23953
  doc$$2 = addAlignmentToDoc$2(
23939
- docUtils$5.removeLines(concat$14([hardline$13, doc$$2])),
23954
+ docUtils$6.removeLines(concat$14([hardline$13, doc$$2])),
23940
23955
  addAlignmentSize,
23941
23956
  options.tabWidth
23942
23957
  );
23943
23958
  }
23944
- docUtils$5.propagateBreaks(doc$$2);
23959
+ docUtils$6.propagateBreaks(doc$$2);
23945
23960
 
23946
23961
  if (options.parser === "json") {
23947
23962
  doc$$2 = concat$14([doc$$2, hardline$13]);