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/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.12.0";
15
+ var version$1 = "1.12.1";
16
16
  var description = "Prettier is an opinionated code formatter";
17
17
  var bin = {"prettier":"./bin/prettier.js"};
18
18
  var repository = "prettier/prettier";
@@ -22,7 +22,7 @@ var license = "MIT";
22
22
  var main = "./index.js";
23
23
  var engines = {"node":">=4"};
24
24
  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"};
25
- 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"};
25
+ 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"};
26
26
  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"};
27
27
  var _package = {
28
28
  name: name,
@@ -809,7 +809,9 @@ function printString(raw, options, isDirectiveLiteral) {
809
809
  const enclosingQuote =
810
810
  options.parser === "json"
811
811
  ? double.quote
812
- : shouldUseAlternateQuote ? alternate.quote : preferred.quote;
812
+ : shouldUseAlternateQuote
813
+ ? alternate.quote
814
+ : preferred.quote;
813
815
 
814
816
  // Directives are exact code unit sequences, which means that you can't
815
817
  // change the escape sequences they use.
@@ -907,20 +909,6 @@ function getMaxContinuousCount(str, target) {
907
909
  );
908
910
  }
909
911
 
910
- function mapDoc(doc, callback) {
911
- if (doc.parts) {
912
- const parts = doc.parts.map(part => mapDoc(part, callback));
913
- return callback(Object.assign({}, doc, { parts }));
914
- }
915
-
916
- if (doc.contents) {
917
- const contents = mapDoc(doc.contents, callback);
918
- return callback(Object.assign({}, doc, { contents }));
919
- }
920
-
921
- return callback(doc);
922
- }
923
-
924
912
  /**
925
913
  * split text into whitespaces and words
926
914
  * @param {string} text
@@ -1102,7 +1090,6 @@ var util$1 = {
1102
1090
  punctuationCharRange,
1103
1091
  getStringWidth,
1104
1092
  splitText,
1105
- mapDoc,
1106
1093
  getMaxContinuousCount,
1107
1094
  getPrecedence,
1108
1095
  shouldFlatten,
@@ -1141,6 +1128,196 @@ var util$1 = {
1141
1128
  addTrailingComment
1142
1129
  };
1143
1130
 
1131
+ function traverseDoc(doc, onEnter, onExit, shouldTraverseConditionalGroups) {
1132
+ function traverseDocRec(doc) {
1133
+ let shouldRecurse = true;
1134
+ if (onEnter) {
1135
+ if (onEnter(doc) === false) {
1136
+ shouldRecurse = false;
1137
+ }
1138
+ }
1139
+
1140
+ if (shouldRecurse) {
1141
+ if (doc.type === "concat" || doc.type === "fill") {
1142
+ for (let i = 0; i < doc.parts.length; i++) {
1143
+ traverseDocRec(doc.parts[i]);
1144
+ }
1145
+ } else if (doc.type === "if-break") {
1146
+ if (doc.breakContents) {
1147
+ traverseDocRec(doc.breakContents);
1148
+ }
1149
+ if (doc.flatContents) {
1150
+ traverseDocRec(doc.flatContents);
1151
+ }
1152
+ } else if (doc.type === "group" && doc.expandedStates) {
1153
+ if (shouldTraverseConditionalGroups) {
1154
+ doc.expandedStates.forEach(traverseDocRec);
1155
+ } else {
1156
+ traverseDocRec(doc.contents);
1157
+ }
1158
+ } else if (doc.contents) {
1159
+ traverseDocRec(doc.contents);
1160
+ }
1161
+ }
1162
+
1163
+ if (onExit) {
1164
+ onExit(doc);
1165
+ }
1166
+ }
1167
+
1168
+ traverseDocRec(doc);
1169
+ }
1170
+
1171
+ function mapDoc(doc, cb) {
1172
+ if (doc.type === "concat" || doc.type === "fill") {
1173
+ const parts = doc.parts.map(part => mapDoc(part, cb));
1174
+ return cb(Object.assign({}, doc, { parts }));
1175
+ } else if (doc.type === "if-break") {
1176
+ const breakContents = doc.breakContents && mapDoc(doc.breakContents, cb);
1177
+ const flatContents = doc.flatContents && mapDoc(doc.flatContents, cb);
1178
+ return cb(Object.assign({}, doc, { breakContents, flatContents }));
1179
+ } else if (doc.contents) {
1180
+ const contents = mapDoc(doc.contents, cb);
1181
+ return cb(Object.assign({}, doc, { contents }));
1182
+ }
1183
+ return cb(doc);
1184
+ }
1185
+
1186
+ function findInDoc(doc, fn, defaultValue) {
1187
+ let result = defaultValue;
1188
+ let hasStopped = false;
1189
+ traverseDoc(doc, doc => {
1190
+ const maybeResult = fn(doc);
1191
+ if (maybeResult !== undefined) {
1192
+ hasStopped = true;
1193
+ result = maybeResult;
1194
+ }
1195
+ if (hasStopped) {
1196
+ return false;
1197
+ }
1198
+ });
1199
+ return result;
1200
+ }
1201
+
1202
+ function isEmpty(n) {
1203
+ return typeof n === "string" && n.length === 0;
1204
+ }
1205
+
1206
+ function isLineNext(doc) {
1207
+ return findInDoc(
1208
+ doc,
1209
+ doc => {
1210
+ if (typeof doc === "string") {
1211
+ return false;
1212
+ }
1213
+ if (doc.type === "line") {
1214
+ return true;
1215
+ }
1216
+ },
1217
+ false
1218
+ );
1219
+ }
1220
+
1221
+ function willBreak(doc) {
1222
+ return findInDoc(
1223
+ doc,
1224
+ doc => {
1225
+ if (doc.type === "group" && doc.break) {
1226
+ return true;
1227
+ }
1228
+ if (doc.type === "line" && doc.hard) {
1229
+ return true;
1230
+ }
1231
+ if (doc.type === "break-parent") {
1232
+ return true;
1233
+ }
1234
+ },
1235
+ false
1236
+ );
1237
+ }
1238
+
1239
+ function breakParentGroup(groupStack) {
1240
+ if (groupStack.length > 0) {
1241
+ const parentGroup = groupStack[groupStack.length - 1];
1242
+ // Breaks are not propagated through conditional groups because
1243
+ // the user is expected to manually handle what breaks.
1244
+ if (!parentGroup.expandedStates) {
1245
+ parentGroup.break = true;
1246
+ }
1247
+ }
1248
+ return null;
1249
+ }
1250
+
1251
+ function propagateBreaks(doc) {
1252
+ const alreadyVisited = new Map();
1253
+ const groupStack = [];
1254
+ traverseDoc(
1255
+ doc,
1256
+ doc => {
1257
+ if (doc.type === "break-parent") {
1258
+ breakParentGroup(groupStack);
1259
+ }
1260
+ if (doc.type === "group") {
1261
+ groupStack.push(doc);
1262
+ if (alreadyVisited.has(doc)) {
1263
+ return false;
1264
+ }
1265
+ alreadyVisited.set(doc, true);
1266
+ }
1267
+ },
1268
+ doc => {
1269
+ if (doc.type === "group") {
1270
+ const group = groupStack.pop();
1271
+ if (group.break) {
1272
+ breakParentGroup(groupStack);
1273
+ }
1274
+ }
1275
+ },
1276
+ /* shouldTraverseConditionalGroups */ true
1277
+ );
1278
+ }
1279
+
1280
+ function removeLines(doc) {
1281
+ // Force this doc into flat mode by statically converting all
1282
+ // lines into spaces (or soft lines into nothing). Hard lines
1283
+ // should still output because there's too great of a chance
1284
+ // of breaking existing assumptions otherwise.
1285
+ return mapDoc(doc, d => {
1286
+ if (d.type === "line" && !d.hard) {
1287
+ return d.soft ? "" : " ";
1288
+ } else if (d.type === "if-break") {
1289
+ return d.flatContents || "";
1290
+ }
1291
+ return d;
1292
+ });
1293
+ }
1294
+
1295
+ function stripTrailingHardline(doc) {
1296
+ // HACK remove ending hardline, original PR: #1984
1297
+ if (
1298
+ doc.type === "concat" &&
1299
+ doc.parts.length === 2 &&
1300
+ doc.parts[1].type === "concat" &&
1301
+ doc.parts[1].parts.length === 2 &&
1302
+ doc.parts[1].parts[0].hard &&
1303
+ doc.parts[1].parts[1].type === "break-parent"
1304
+ ) {
1305
+ return doc.parts[0];
1306
+ }
1307
+ return doc;
1308
+ }
1309
+
1310
+ var docUtils = {
1311
+ isEmpty,
1312
+ willBreak,
1313
+ isLineNext,
1314
+ traverseDoc,
1315
+ mapDoc,
1316
+ propagateBreaks,
1317
+ removeLines,
1318
+ stripTrailingHardline
1319
+ };
1320
+
1144
1321
  function isNextLineEmpty$1(text, node, options) {
1145
1322
  return util$1.isNextLineEmpty(text, node, options.locEnd);
1146
1323
  }
@@ -1157,7 +1334,7 @@ var utilShared = {
1157
1334
  isNextLineEmpty: isNextLineEmpty$1,
1158
1335
  isNextLineEmptyAfterIndex: util$1.isNextLineEmptyAfterIndex,
1159
1336
  getNextNonSpaceNonCommentCharacterIndex: getNextNonSpaceNonCommentCharacterIndex$1,
1160
- mapDoc: util$1.mapDoc,
1337
+ mapDoc: docUtils.mapDoc, // TODO: remove in 2.0, we already exposed it in docUtils
1161
1338
  makeString: util$1.makeString,
1162
1339
  addLeadingComment: util$1.addLeadingComment,
1163
1340
  addDanglingComment: util$1.addDanglingComment,
@@ -7409,204 +7586,6 @@ function printDocToString$1(doc, options) {
7409
7586
 
7410
7587
  var docPrinter = { printDocToString: printDocToString$1 };
7411
7588
 
7412
- function traverseDoc(doc, onEnter, onExit, shouldTraverseConditionalGroups) {
7413
- function traverseDocRec(doc) {
7414
- let shouldRecurse = true;
7415
- if (onEnter) {
7416
- if (onEnter(doc) === false) {
7417
- shouldRecurse = false;
7418
- }
7419
- }
7420
-
7421
- if (shouldRecurse) {
7422
- if (doc.type === "concat" || doc.type === "fill") {
7423
- for (let i = 0; i < doc.parts.length; i++) {
7424
- traverseDocRec(doc.parts[i]);
7425
- }
7426
- } else if (doc.type === "if-break") {
7427
- if (doc.breakContents) {
7428
- traverseDocRec(doc.breakContents);
7429
- }
7430
- if (doc.flatContents) {
7431
- traverseDocRec(doc.flatContents);
7432
- }
7433
- } else if (doc.type === "group" && doc.expandedStates) {
7434
- if (shouldTraverseConditionalGroups) {
7435
- doc.expandedStates.forEach(traverseDocRec);
7436
- } else {
7437
- traverseDocRec(doc.contents);
7438
- }
7439
- } else if (doc.contents) {
7440
- traverseDocRec(doc.contents);
7441
- }
7442
- }
7443
-
7444
- if (onExit) {
7445
- onExit(doc);
7446
- }
7447
- }
7448
-
7449
- traverseDocRec(doc);
7450
- }
7451
-
7452
- function mapDoc$1(doc, func) {
7453
- doc = func(doc);
7454
-
7455
- if (doc.type === "concat" || doc.type === "fill") {
7456
- return Object.assign({}, doc, {
7457
- parts: doc.parts.map(d => mapDoc$1(d, func))
7458
- });
7459
- } else if (doc.type === "if-break") {
7460
- return Object.assign({}, doc, {
7461
- breakContents: doc.breakContents && mapDoc$1(doc.breakContents, func),
7462
- flatContents: doc.flatContents && mapDoc$1(doc.flatContents, func)
7463
- });
7464
- } else if (doc.contents) {
7465
- return Object.assign({}, doc, { contents: mapDoc$1(doc.contents, func) });
7466
- }
7467
- return doc;
7468
- }
7469
-
7470
- function findInDoc(doc, fn, defaultValue) {
7471
- let result = defaultValue;
7472
- let hasStopped = false;
7473
- traverseDoc(doc, doc => {
7474
- const maybeResult = fn(doc);
7475
- if (maybeResult !== undefined) {
7476
- hasStopped = true;
7477
- result = maybeResult;
7478
- }
7479
- if (hasStopped) {
7480
- return false;
7481
- }
7482
- });
7483
- return result;
7484
- }
7485
-
7486
- function isEmpty$1(n) {
7487
- return typeof n === "string" && n.length === 0;
7488
- }
7489
-
7490
- function isLineNext$1(doc) {
7491
- return findInDoc(
7492
- doc,
7493
- doc => {
7494
- if (typeof doc === "string") {
7495
- return false;
7496
- }
7497
- if (doc.type === "line") {
7498
- return true;
7499
- }
7500
- },
7501
- false
7502
- );
7503
- }
7504
-
7505
- function willBreak$1(doc) {
7506
- return findInDoc(
7507
- doc,
7508
- doc => {
7509
- if (doc.type === "group" && doc.break) {
7510
- return true;
7511
- }
7512
- if (doc.type === "line" && doc.hard) {
7513
- return true;
7514
- }
7515
- if (doc.type === "break-parent") {
7516
- return true;
7517
- }
7518
- },
7519
- false
7520
- );
7521
- }
7522
-
7523
- function breakParentGroup(groupStack) {
7524
- if (groupStack.length > 0) {
7525
- const parentGroup = groupStack[groupStack.length - 1];
7526
- // Breaks are not propagated through conditional groups because
7527
- // the user is expected to manually handle what breaks.
7528
- if (!parentGroup.expandedStates) {
7529
- parentGroup.break = true;
7530
- }
7531
- }
7532
- return null;
7533
- }
7534
-
7535
- function propagateBreaks(doc) {
7536
- const alreadyVisited = new Map();
7537
- const groupStack = [];
7538
- traverseDoc(
7539
- doc,
7540
- doc => {
7541
- if (doc.type === "break-parent") {
7542
- breakParentGroup(groupStack);
7543
- }
7544
- if (doc.type === "group") {
7545
- groupStack.push(doc);
7546
- if (alreadyVisited.has(doc)) {
7547
- return false;
7548
- }
7549
- alreadyVisited.set(doc, true);
7550
- }
7551
- },
7552
- doc => {
7553
- if (doc.type === "group") {
7554
- const group = groupStack.pop();
7555
- if (group.break) {
7556
- breakParentGroup(groupStack);
7557
- }
7558
- }
7559
- },
7560
- /* shouldTraverseConditionalGroups */ true
7561
- );
7562
- }
7563
-
7564
- function removeLines(doc) {
7565
- // Force this doc into flat mode by statically converting all
7566
- // lines into spaces (or soft lines into nothing). Hard lines
7567
- // should still output because there's too great of a chance
7568
- // of breaking existing assumptions otherwise.
7569
- return mapDoc$1(doc, d => {
7570
- if (d.type === "line" && !d.hard) {
7571
- return d.soft ? "" : " ";
7572
- } else if (d.type === "if-break") {
7573
- return d.flatContents || "";
7574
- }
7575
- return d;
7576
- });
7577
- }
7578
-
7579
- function stripTrailingHardline(doc) {
7580
- // HACK remove ending hardline, original PR: #1984
7581
- if (
7582
- doc.type === "concat" &&
7583
- doc.parts.length === 2 &&
7584
- doc.parts[1].type === "concat" &&
7585
- doc.parts[1].parts.length === 2 &&
7586
- doc.parts[1].parts[0].hard &&
7587
- doc.parts[1].parts[1].type === "break-parent"
7588
- ) {
7589
- return doc.parts[0];
7590
- }
7591
- return doc;
7592
- }
7593
-
7594
- function rawText$1(node) {
7595
- return node.extra ? node.extra.raw : node.raw;
7596
- }
7597
-
7598
- var docUtils$1 = {
7599
- isEmpty: isEmpty$1,
7600
- willBreak: willBreak$1,
7601
- isLineNext: isLineNext$1,
7602
- traverseDoc,
7603
- mapDoc: mapDoc$1,
7604
- propagateBreaks,
7605
- removeLines,
7606
- stripTrailingHardline,
7607
- rawText: rawText$1
7608
- };
7609
-
7610
7589
  function flattenDoc(doc) {
7611
7590
  if (doc.type === "concat") {
7612
7591
  const res = [];
@@ -7739,7 +7718,7 @@ var docDebug = {
7739
7718
  var doc = {
7740
7719
  builders: docBuilders$2,
7741
7720
  printer: docPrinter,
7742
- utils: docUtils$1,
7721
+ utils: docUtils,
7743
7722
  debug: docDebug
7744
7723
  };
7745
7724
 
@@ -8758,7 +8737,7 @@ var utils$2 = createCommonjsModule(function (module, exports) {
8758
8737
  });
8759
8738
 
8760
8739
  const doc$2 = doc;
8761
- const docUtils$3 = doc$2.utils;
8740
+ const docUtils$4 = doc$2.utils;
8762
8741
  const docBuilders$5 = doc$2.builders;
8763
8742
  const indent$3 = docBuilders$5.indent;
8764
8743
  const join$3 = docBuilders$5.join;
@@ -8867,7 +8846,7 @@ function embed(path$$1, print, textToDoc /*, options */) {
8867
8846
  doc$$2 = printGraphqlComments(lines);
8868
8847
  } else {
8869
8848
  try {
8870
- doc$$2 = docUtils$3.stripTrailingHardline(
8849
+ doc$$2 = docUtils$4.stripTrailingHardline(
8871
8850
  textToDoc(text, { parser: "graphql" })
8872
8851
  );
8873
8852
  } catch (error) {
@@ -8945,7 +8924,7 @@ function embed(path$$1, print, textToDoc /*, options */) {
8945
8924
 
8946
8925
  function printMarkdown(text) {
8947
8926
  const doc$$2 = textToDoc(text, { parser: "markdown", __inJsTemplate: true });
8948
- return docUtils$3.stripTrailingHardline(escapeBackticks(doc$$2));
8927
+ return docUtils$4.stripTrailingHardline(escapeBackticks(doc$$2));
8949
8928
  }
8950
8929
  }
8951
8930
 
@@ -8955,7 +8934,7 @@ function getIndentation(str) {
8955
8934
  }
8956
8935
 
8957
8936
  function escapeBackticks(doc$$2) {
8958
- return util$1.mapDoc(doc$$2, currentDoc => {
8937
+ return docUtils$4.mapDoc(doc$$2, currentDoc => {
8959
8938
  if (!currentDoc.parts) {
8960
8939
  return currentDoc;
8961
8940
  }
@@ -8993,7 +8972,7 @@ function transformCssDoc(quasisDoc, path$$1, print) {
8993
8972
  }
8994
8973
  return concat$4([
8995
8974
  "`",
8996
- indent$3(concat$4([hardline$3, docUtils$3.stripTrailingHardline(newDoc)])),
8975
+ indent$3(concat$4([hardline$3, docUtils$4.stripTrailingHardline(newDoc)])),
8997
8976
  softline$2,
8998
8977
  "`"
8999
8978
  ]);
@@ -9010,7 +8989,7 @@ function replacePlaceholders(quasisDoc, expressionDocs) {
9010
8989
 
9011
8990
  const expressions = expressionDocs.slice();
9012
8991
  let replaceCounter = 0;
9013
- const newDoc = docUtils$3.mapDoc(quasisDoc, doc$$2 => {
8992
+ const newDoc = docUtils$4.mapDoc(quasisDoc, doc$$2 => {
9014
8993
  if (!doc$$2 || !doc$$2.parts || !doc$$2.parts.length) {
9015
8994
  return doc$$2;
9016
8995
  }
@@ -9039,7 +9018,7 @@ function replacePlaceholders(quasisDoc, expressionDocs) {
9039
9018
  const placeholder = parts[atPlaceholderIndex];
9040
9019
  const rest = parts.slice(atPlaceholderIndex + 1);
9041
9020
  const placeholderMatch = placeholder.match(
9042
- /@prettier-placeholder-(.+)-id(.*)/
9021
+ /@prettier-placeholder-(.+)-id([\s\S]*)/
9043
9022
  );
9044
9023
  const placeholderID = placeholderMatch[1];
9045
9024
  // When the expression has a suffix appended, like:
@@ -10500,6 +10479,7 @@ function needsParens(path$$1, options) {
10500
10479
  case "AwaitExpression":
10501
10480
  switch (parent.type) {
10502
10481
  case "TaggedTemplateExpression":
10482
+ case "UnaryExpression":
10503
10483
  case "BinaryExpression":
10504
10484
  case "LogicalExpression":
10505
10485
  case "SpreadElement":
@@ -10772,11 +10752,10 @@ const lineSuffixBoundary = docBuilders.lineSuffixBoundary;
10772
10752
  const addAlignmentToDoc = docBuilders.addAlignmentToDoc;
10773
10753
  const dedent = docBuilders.dedent;
10774
10754
 
10775
- const docUtils = doc.utils;
10776
- const willBreak = docUtils.willBreak;
10777
- const isLineNext = docUtils.isLineNext;
10778
- const isEmpty = docUtils.isEmpty;
10779
- const rawText = docUtils.rawText;
10755
+ const docUtils$3 = doc.utils;
10756
+ const willBreak$1 = docUtils$3.willBreak;
10757
+ const isLineNext$1 = docUtils$3.isLineNext;
10758
+ const isEmpty$1 = docUtils$3.isEmpty;
10780
10759
 
10781
10760
  function shouldPrintComma(options, level) {
10782
10761
  level = level || "es5";
@@ -10803,7 +10782,7 @@ function genericPrint(path$$1, options, printPath, args) {
10803
10782
  let needsParens = false;
10804
10783
  const linesWithoutParens = printPathNoParens(path$$1, options, printPath, args);
10805
10784
 
10806
- if (!node || isEmpty(linesWithoutParens)) {
10785
+ if (!node || isEmpty$1(linesWithoutParens)) {
10807
10786
  return linesWithoutParens;
10808
10787
  }
10809
10788
 
@@ -11024,7 +11003,9 @@ function formatTernaryOperator(path$$1, options, print, operatorOptions) {
11024
11003
  // outer-most ConditionalExpression.
11025
11004
  const maybeGroup = doc$$1 =>
11026
11005
  operatorOpts.breakNested
11027
- ? parent === firstNonConditionalParent ? group(doc$$1) : doc$$1
11006
+ ? parent === firstNonConditionalParent
11007
+ ? group(doc$$1)
11008
+ : doc$$1
11028
11009
  : group(doc$$1); // Always group in normal mode.
11029
11010
 
11030
11011
  // Break the closing paren to keep the chain right after it:
@@ -12679,7 +12660,9 @@ function printPathNoParens(path$$1, options, print, args) {
12679
12660
  concat([
12680
12661
  hasOwnLineComment
12681
12662
  ? hardline
12682
- : hasComment && !isOpeningFragment ? " " : "",
12663
+ : hasComment && !isOpeningFragment
12664
+ ? " "
12665
+ : "",
12683
12666
  comments.printDanglingComments(path$$1, options, true)
12684
12667
  ])
12685
12668
  ),
@@ -13122,7 +13105,7 @@ function printPathNoParens(path$$1, options, print, args) {
13122
13105
  parent.type !== "TSTypeParameterInstantiation" &&
13123
13106
  parent.type !== "GenericTypeAnnotation" &&
13124
13107
  parent.type !== "TSTypeReference" &&
13125
- parent.type !== "FunctionTypeParam" &&
13108
+ !(parent.type === "FunctionTypeParam" && !parent.name) &&
13126
13109
  !(
13127
13110
  (parent.type === "TypeAlias" ||
13128
13111
  parent.type === "VariableDeclarator") &&
@@ -13954,8 +13937,8 @@ function printArgumentsList(path$$1, options, print) {
13954
13937
  if (shouldGroupFirst || shouldGroupLast) {
13955
13938
  const shouldBreak =
13956
13939
  (shouldGroupFirst
13957
- ? printedArguments.slice(1).some(willBreak)
13958
- : printedArguments.slice(0, -1).some(willBreak)) || anyArgEmptyLine;
13940
+ ? printedArguments.slice(1).some(willBreak$1)
13941
+ : printedArguments.slice(0, -1).some(willBreak$1)) || anyArgEmptyLine;
13959
13942
 
13960
13943
  // We want to print the last argument with a special flag
13961
13944
  let printedExpanded;
@@ -13979,7 +13962,7 @@ function printArgumentsList(path$$1, options, print) {
13979
13962
  i++;
13980
13963
  }, "arguments");
13981
13964
 
13982
- const somePrintedArgumentsWillBreak = printedArguments.some(willBreak);
13965
+ const somePrintedArgumentsWillBreak = printedArguments.some(willBreak$1);
13983
13966
 
13984
13967
  const maybeTrailingComma = shouldPrintComma(options, "all") ? "," : "";
13985
13968
 
@@ -14036,7 +14019,7 @@ function printArgumentsList(path$$1, options, print) {
14036
14019
  softline,
14037
14020
  ")"
14038
14021
  ]),
14039
- { shouldBreak: printedArguments.some(willBreak) || anyArgEmptyLine }
14022
+ { shouldBreak: printedArguments.some(willBreak$1) || anyArgEmptyLine }
14040
14023
  );
14041
14024
  }
14042
14025
 
@@ -14130,9 +14113,9 @@ function printFunctionParams(path$$1, print, options, expandArg, printTypeParams
14130
14113
  ) {
14131
14114
  return group(
14132
14115
  concat([
14133
- docUtils.removeLines(typeParams),
14116
+ docUtils$3.removeLines(typeParams),
14134
14117
  "(",
14135
- join(", ", printed.map(docUtils.removeLines)),
14118
+ join(", ", printed.map(docUtils$3.removeLines)),
14136
14119
  ")"
14137
14120
  ])
14138
14121
  );
@@ -14959,7 +14942,7 @@ function printMemberChain(path$$1, options, print) {
14959
14942
  if (
14960
14943
  hasComment ||
14961
14944
  callExpressionCount >= 3 ||
14962
- printedGroups.slice(0, -1).some(willBreak)
14945
+ printedGroups.slice(0, -1).some(willBreak$1)
14963
14946
  ) {
14964
14947
  return group(expanded);
14965
14948
  }
@@ -14968,7 +14951,7 @@ function printMemberChain(path$$1, options, print) {
14968
14951
  // We only need to check `oneLine` because if `expanded` is chosen
14969
14952
  // that means that the parent group has already been broken
14970
14953
  // naturally
14971
- willBreak(oneLine) || shouldHaveEmptyLineBeforeIndent ? breakParent : "",
14954
+ willBreak$1(oneLine) || shouldHaveEmptyLineBeforeIndent ? breakParent : "",
14972
14955
  conditionalGroup([oneLine, expanded])
14973
14956
  ]);
14974
14957
  }
@@ -15295,7 +15278,7 @@ function printJSXElement(path$$1, options, print) {
15295
15278
 
15296
15279
  // Record any breaks. Should never go from true to false, only false to true.
15297
15280
  let forcedBreak =
15298
- willBreak(openingLines) ||
15281
+ willBreak$1(openingLines) ||
15299
15282
  containsTag ||
15300
15283
  containsMultipleAttributes ||
15301
15284
  containsMultipleExpressions;
@@ -15346,8 +15329,8 @@ function printJSXElement(path$$1, options, print) {
15346
15329
  // Trim trailing lines (or empty strings)
15347
15330
  while (
15348
15331
  children.length &&
15349
- (isLineNext(util$1.getLast(children)) ||
15350
- isEmpty(util$1.getLast(children)))
15332
+ (isLineNext$1(util$1.getLast(children)) ||
15333
+ isEmpty$1(util$1.getLast(children)))
15351
15334
  ) {
15352
15335
  children.pop();
15353
15336
  }
@@ -15355,8 +15338,8 @@ function printJSXElement(path$$1, options, print) {
15355
15338
  // Trim leading lines (or empty strings)
15356
15339
  while (
15357
15340
  children.length &&
15358
- (isLineNext(children[0]) || isEmpty(children[0])) &&
15359
- (isLineNext(children[1]) || isEmpty(children[1]))
15341
+ (isLineNext$1(children[0]) || isEmpty$1(children[0])) &&
15342
+ (isLineNext$1(children[1]) || isEmpty$1(children[1]))
15360
15343
  ) {
15361
15344
  children.shift();
15362
15345
  children.shift();
@@ -15391,7 +15374,7 @@ function printJSXElement(path$$1, options, print) {
15391
15374
 
15392
15375
  multilineChildren.push(child);
15393
15376
 
15394
- if (willBreak(child)) {
15377
+ if (willBreak$1(child)) {
15395
15378
  forcedBreak = true;
15396
15379
  }
15397
15380
  });
@@ -16264,6 +16247,10 @@ function printJsDocComment(comment) {
16264
16247
  ]);
16265
16248
  }
16266
16249
 
16250
+ function rawText(node) {
16251
+ return node.extra ? node.extra.raw : node.raw;
16252
+ }
16253
+
16267
16254
  var printerEstree = {
16268
16255
  print: genericPrint,
16269
16256
  embed: embed_1,
@@ -16960,13 +16947,19 @@ function genericPrint$1(path$$1, options, print) {
16960
16947
  : path$$1.call(print, "value"),
16961
16948
  node.raws.important
16962
16949
  ? node.raws.important.replace(/\s*!\s*important/i, " !important")
16963
- : node.important ? " !important" : "",
16950
+ : node.important
16951
+ ? " !important"
16952
+ : "",
16964
16953
  node.raws.scssDefault
16965
16954
  ? node.raws.scssDefault.replace(/\s*!default/i, " !default")
16966
- : node.scssDefault ? " !default" : "",
16955
+ : node.scssDefault
16956
+ ? " !default"
16957
+ : "",
16967
16958
  node.raws.scssGlobal
16968
16959
  ? node.raws.scssGlobal.replace(/\s*!global/i, " !global")
16969
- : node.scssGlobal ? " !global" : "",
16960
+ : node.scssGlobal
16961
+ ? " !global"
16962
+ : "",
16970
16963
  node.nodes
16971
16964
  ? concat$5([
16972
16965
  " {",
@@ -17013,11 +17006,15 @@ function genericPrint$1(path$$1, options, print) {
17013
17006
  " ",
17014
17007
  path$$1.call(print, "value"),
17015
17008
  isControlDirectiveNode(node)
17016
- ? hasParensAround ? " " : line$2
17009
+ ? hasParensAround
17010
+ ? " "
17011
+ : line$2
17017
17012
  : ""
17018
17013
  ])
17019
17014
  )
17020
- : node.name === "else" ? " " : "",
17015
+ : node.name === "else"
17016
+ ? " "
17017
+ : "",
17021
17018
  node.nodes
17022
17019
  ? concat$5([
17023
17020
  isControlDirectiveNode(node) ? "" : " ",
@@ -18968,7 +18965,7 @@ const markAsRoot$1 = docBuilders$9.markAsRoot;
18968
18965
  function embed$2(path$$1, print, textToDoc, options) {
18969
18966
  const node = path$$1.getValue();
18970
18967
 
18971
- if (node.type === "code") {
18968
+ if (node.type === "code" && node.lang !== null) {
18972
18969
  // only look for the first string so as to support [markdown-preview-enhanced](https://shd101wyy.github.io/markdown-preview-enhanced/#/code-chunk)
18973
18970
  const lang = node.lang.split(/\s/, 1)[0];
18974
18971
  const parser = getParserName(lang);
@@ -19011,7 +19008,7 @@ function embed$2(path$$1, print, textToDoc, options) {
19011
19008
  }
19012
19009
 
19013
19010
  function replaceNewlinesWithLiterallines(doc$$2) {
19014
- return util$1.mapDoc(
19011
+ return docUtils.mapDoc(
19015
19012
  doc$$2,
19016
19013
  currentDoc =>
19017
19014
  typeof currentDoc === "string" && currentDoc.includes("\n")
@@ -19122,7 +19119,9 @@ function genericPrint$3(path$$1, options, print) {
19122
19119
  node =>
19123
19120
  node.type === "word"
19124
19121
  ? node.value
19125
- : node.value === "" ? "" : printLine(path$$1, node.value, options)
19122
+ : node.value === ""
19123
+ ? ""
19124
+ : printLine(path$$1, node.value, options)
19126
19125
  )
19127
19126
  );
19128
19127
  }
@@ -19313,9 +19312,13 @@ function genericPrint$3(path$$1, options, print) {
19313
19312
  const rawPrefix = node.ordered
19314
19313
  ? (index === 0
19315
19314
  ? node.start
19316
- : isGitDiffFriendlyOrderedList ? 1 : node.start + index) +
19315
+ : isGitDiffFriendlyOrderedList
19316
+ ? 1
19317
+ : node.start + index) +
19317
19318
  (nthSiblingIndex % 2 === 0 ? ". " : ") ")
19318
- : nthSiblingIndex % 2 === 0 ? "* " : "- ";
19319
+ : nthSiblingIndex % 2 === 0
19320
+ ? "* "
19321
+ : "- ";
19319
19322
 
19320
19323
  // do not print trailing spaces for empty list item since it might be treated as `break` node
19321
19324
  // by [doc-printer](https://github.com/prettier/prettier/blob/1.10.2/src/doc/doc-printer.js#L395-L405),
@@ -19346,7 +19349,9 @@ function genericPrint$3(path$$1, options, print) {
19346
19349
  "]",
19347
19350
  node.referenceType === "full"
19348
19351
  ? concat$8(["[", node.identifier, "]"])
19349
- : node.referenceType === "collapsed" ? "[]" : ""
19352
+ : node.referenceType === "collapsed"
19353
+ ? "[]"
19354
+ : ""
19350
19355
  ]);
19351
19356
  case "imageReference":
19352
19357
  switch (node.referenceType) {
@@ -19506,8 +19511,12 @@ function printLine(path$$1, value, options) {
19506
19511
  options.proseWrap === "always" &&
19507
19512
  !getAncestorNode$1(path$$1, SINGLE_LINE_NODE_TYPES);
19508
19513
  return value !== ""
19509
- ? isBreakable ? line$5 : " "
19510
- : isBreakable ? softline$6 : "";
19514
+ ? isBreakable
19515
+ ? line$5
19516
+ : " "
19517
+ : isBreakable
19518
+ ? softline$6
19519
+ : "";
19511
19520
  }
19512
19521
 
19513
19522
  function printTable(path$$1, options, print) {
@@ -19771,7 +19780,7 @@ function shouldRemainTheSameContent(path$$1) {
19771
19780
  }
19772
19781
 
19773
19782
  function normalizeDoc(doc$$2) {
19774
- return util$1.mapDoc(doc$$2, currentDoc => {
19783
+ return docUtils.mapDoc(doc$$2, currentDoc => {
19775
19784
  if (!currentDoc.parts) {
19776
19785
  return currentDoc;
19777
19786
  }
@@ -19816,7 +19825,11 @@ function printTitle(title, options) {
19816
19825
  const quote =
19817
19826
  singleCount > doubleCount
19818
19827
  ? '"'
19819
- : doubleCount > singleCount ? "'" : options.singleQuote ? "'" : '"';
19828
+ : doubleCount > singleCount
19829
+ ? "'"
19830
+ : options.singleQuote
19831
+ ? "'"
19832
+ : '"';
19820
19833
  title = title.replace(new RegExp(`(${quote})`, "g"), "\\$1");
19821
19834
  return ` ${quote}${title}${quote}`;
19822
19835
  }
@@ -19976,7 +19989,7 @@ var languageMarkdown = {
19976
19989
  printers: printers$4
19977
19990
  };
19978
19991
 
19979
- const docUtils$4 = doc.utils;
19992
+ const docUtils$5 = doc.utils;
19980
19993
  const docBuilders$11 = doc.builders;
19981
19994
  const hardline$10 = docBuilders$11.hardline;
19982
19995
  const concat$11 = docBuilders$11.concat;
@@ -20016,7 +20029,7 @@ function embed$4(path$$1, print, textToDoc, options) {
20016
20029
  // Inline Styles
20017
20030
  if (parent.type === "style") {
20018
20031
  const doc$$2 = textToDoc(getText(options, node), { parser: "css" });
20019
- return concat$11([hardline$10, docUtils$4.stripTrailingHardline(doc$$2)]);
20032
+ return concat$11([hardline$10, docUtils$5.stripTrailingHardline(doc$$2)]);
20020
20033
  }
20021
20034
 
20022
20035
  break;
@@ -20042,7 +20055,7 @@ function embed$4(path$$1, print, textToDoc, options) {
20042
20055
  '="',
20043
20056
  util$1.hasNewlineInRange(node.value, 0, node.value.length)
20044
20057
  ? doc$$2
20045
- : docUtils$4.removeLines(doc$$2),
20058
+ : docUtils$5.removeLines(doc$$2),
20046
20059
  '"'
20047
20060
  ]);
20048
20061
  }
@@ -21269,7 +21282,9 @@ function normalizeOptions$1(options, optionInfos, opts) {
21269
21282
  const logger =
21270
21283
  opts.logger === false
21271
21284
  ? { warn() {} }
21272
- : opts.logger !== undefined ? opts.logger : console;
21285
+ : opts.logger !== undefined
21286
+ ? opts.logger
21287
+ : console;
21273
21288
  const descriptor = opts.descriptor || optionsDescriptor.apiDescriptor;
21274
21289
  const passThrough = opts.passThrough || [];
21275
21290
 
@@ -23842,7 +23857,7 @@ const docBuilders$14 = doc$3.builders;
23842
23857
  const concat$14 = docBuilders$14.concat;
23843
23858
  const hardline$13 = docBuilders$14.hardline;
23844
23859
  const addAlignmentToDoc$2 = docBuilders$14.addAlignmentToDoc;
23845
- const docUtils$5 = doc$3.utils;
23860
+ const docUtils$6 = doc$3.utils;
23846
23861
 
23847
23862
  function printAstToDoc(ast, options, addAlignmentSize) {
23848
23863
  addAlignmentSize = addAlignmentSize || 0;
@@ -23884,12 +23899,12 @@ function printAstToDoc(ast, options, addAlignmentSize) {
23884
23899
  // Add a hardline to make the indents take effect
23885
23900
  // It should be removed in index.js format()
23886
23901
  doc$$2 = addAlignmentToDoc$2(
23887
- docUtils$5.removeLines(concat$14([hardline$13, doc$$2])),
23902
+ docUtils$6.removeLines(concat$14([hardline$13, doc$$2])),
23888
23903
  addAlignmentSize,
23889
23904
  options.tabWidth
23890
23905
  );
23891
23906
  }
23892
- docUtils$5.propagateBreaks(doc$$2);
23907
+ docUtils$6.propagateBreaks(doc$$2);
23893
23908
 
23894
23909
  if (options.parser === "json") {
23895
23910
  doc$$2 = concat$14([doc$$2, hardline$13]);