prettier 1.11.0-rc.1 → 1.11.0

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
@@ -190,7 +190,7 @@ function printKeyValues(key, valueOrArray) {
190
190
  unwrapExports(build);
191
191
 
192
192
  var name = "prettier";
193
- var version$1 = "1.11.0-rc.1";
193
+ var version$1 = "1.11.0";
194
194
  var description = "Prettier is an opinionated code formatter";
195
195
  var bin = {"prettier":"./bin/prettier.js"};
196
196
  var repository = "prettier/prettier";
@@ -14118,6 +14118,7 @@ function printMemberChain(path$$1, options, print) {
14118
14118
  let i = 1;
14119
14119
  for (; i < printedNodes.length; ++i) {
14120
14120
  if (
14121
+ printedNodes[i].node.type === "TSNonNullExpression" ||
14121
14122
  printedNodes[i].node.type === "CallExpression" ||
14122
14123
  (printedNodes[i].node.type === "MemberExpression" &&
14123
14124
  printedNodes[i].node.computed &&
@@ -16371,15 +16372,22 @@ function genericPrint$1(path$$1, options, print) {
16371
16372
  return adjustStrings(node.value, options);
16372
16373
  }
16373
16374
  case "selector-tag": {
16375
+ const parentNode = path$$1.getParentNode();
16376
+ const index = parentNode && parentNode.nodes.indexOf(node);
16377
+ const prevNode = index && parentNode.nodes[index - 1];
16378
+
16374
16379
  return concat$5([
16375
16380
  node.namespace
16376
16381
  ? concat$5([node.namespace === true ? "" : node.namespace.trim(), "|"])
16377
16382
  : "",
16378
- adjustNumbers(
16379
- isHTMLTag(node.value) || isKeyframeAtRuleKeywords(path$$1, node.value)
16380
- ? node.value.toLowerCase()
16381
- : node.value
16382
- )
16383
+ prevNode.type === "selector-nesting"
16384
+ ? node.value
16385
+ : adjustNumbers(
16386
+ isHTMLTag(node.value) ||
16387
+ isKeyframeAtRuleKeywords(path$$1, node.value)
16388
+ ? node.value.toLowerCase()
16389
+ : node.value
16390
+ )
16383
16391
  ]);
16384
16392
  }
16385
16393
  case "selector-id": {
@@ -16473,14 +16481,6 @@ function genericPrint$1(path$$1, options, print) {
16473
16481
 
16474
16482
  const printed = path$$1.map(print, "groups");
16475
16483
  const parts = [];
16476
- const hasProgidPrefix =
16477
- declAncestorNode &&
16478
- declAncestorNode.value.group &&
16479
- declAncestorNode.value.group.group &&
16480
- declAncestorNode.value.group.group.groups &&
16481
- declAncestorNode.value.group.group.groups[0] &&
16482
- declAncestorNode.value.group.group.groups[0].type === "value-word" &&
16483
- declAncestorNode.value.group.group.groups[0].value === "progid";
16484
16484
  const functionAncestorNode = getAncestorNode(path$$1, "value-func");
16485
16485
  const insideInFunction =
16486
16486
  functionAncestorNode && functionAncestorNode.value;
@@ -16511,15 +16511,6 @@ function genericPrint$1(path$$1, options, print) {
16511
16511
  continue;
16512
16512
  }
16513
16513
 
16514
- // Ignore `filter: progid:DXImageTransform.Microsoft.Gradient(params);`
16515
- if (
16516
- hasProgidPrefix &&
16517
- iNode.type === "value-word" &&
16518
- iNode.value.endsWith("=")
16519
- ) {
16520
- continue;
16521
- }
16522
-
16523
16514
  // Ignore `@` in Less (i.e. `@@var;`)
16524
16515
  if (iNode.type === "value-atword" && iNode.value === "") {
16525
16516
  continue;
@@ -16684,7 +16675,7 @@ function genericPrint$1(path$$1, options, print) {
16684
16675
  return group$2(indent$4(concat$5(parts)));
16685
16676
  }
16686
16677
 
16687
- return group$2(hasProgidPrefix ? fill$3(parts) : indent$4(fill$3(parts)));
16678
+ return group$2(indent$4(fill$3(parts)));
16688
16679
  }
16689
16680
  case "value-paren_group": {
16690
16681
  const parentNode = path$$1.getParentNode();
@@ -16767,15 +16758,7 @@ function genericPrint$1(path$$1, options, print) {
16767
16758
  return node.value;
16768
16759
  }
16769
16760
  case "value-colon": {
16770
- const parent = path$$1.getParentNode();
16771
- const index = getNodeIndex(path$$1, node);
16772
- const hasProgidPrefix =
16773
- parent.groups[index - 1] && parent.groups[index - 1].value === "progid";
16774
-
16775
- return concat$5([
16776
- node.value,
16777
- hasProgidPrefix || insideURLFunctionNode(path$$1) ? "" : line$2
16778
- ]);
16761
+ return concat$5([node.value, insideURLFunctionNode(path$$1) ? "" : line$2]);
16779
16762
  }
16780
16763
  case "value-comma": {
16781
16764
  return concat$5([node.value, " "]);
@@ -16839,16 +16822,6 @@ function insideURLFunctionNode(path$$1) {
16839
16822
  );
16840
16823
  }
16841
16824
 
16842
- function getNodeIndex(path$$1, node) {
16843
- const parent = path$$1.getParentNode();
16844
- return (
16845
- parent &&
16846
- parent.groups &&
16847
- parent.groups.length > 0 &&
16848
- parent.groups.indexOf(node)
16849
- );
16850
- }
16851
-
16852
16825
  function isParenGroupNode(node) {
16853
16826
  return node.type && node.type === "value-paren_group";
16854
16827
  }
@@ -17451,7 +17424,8 @@ const languages$2 = [
17451
17424
  extensions: [".handlebars", ".hbs"],
17452
17425
  tm_scope: "text.html.handlebars",
17453
17426
  ace_mode: "handlebars",
17454
- language_id: 155
17427
+ language_id: 155,
17428
+ since: null // unreleased
17455
17429
  }
17456
17430
  ];
17457
17431
 
@@ -18455,12 +18429,7 @@ function genericPrint$3(path$$1, options, print) {
18455
18429
 
18456
18430
  return printChildren(path$$1, options, print, {
18457
18431
  processor: (childPath, index) => {
18458
- const prefix = node.ordered
18459
- ? (index === 0
18460
- ? node.start
18461
- : isGitDiffFriendlyOrderedList ? 1 : node.start + index) +
18462
- (nthSiblingIndex % 2 === 0 ? ". " : ") ")
18463
- : nthSiblingIndex % 2 === 0 ? "* " : "- ";
18432
+ const prefix = getPrefix();
18464
18433
  return concat$8([
18465
18434
  prefix,
18466
18435
  align$2(
@@ -18468,6 +18437,23 @@ function genericPrint$3(path$$1, options, print) {
18468
18437
  printListItem(childPath, options, print, prefix)
18469
18438
  )
18470
18439
  ]);
18440
+
18441
+ function getPrefix() {
18442
+ const rawPrefix = node.ordered
18443
+ ? (index === 0
18444
+ ? node.start
18445
+ : isGitDiffFriendlyOrderedList ? 1 : node.start + index) +
18446
+ (nthSiblingIndex % 2 === 0 ? ". " : ") ")
18447
+ : nthSiblingIndex % 2 === 0 ? "* " : "- ";
18448
+
18449
+ // do not print trailing spaces for empty list item since it might be treated as `break` node
18450
+ // by [doc-printer](https://github.com/prettier/prettier/blob/1.10.2/src/doc/doc-printer.js#L395-L405),
18451
+ // we don't want to preserve unnecessary trailing spaces.
18452
+ const listItem = childPath.getValue();
18453
+ return listItem.children.length
18454
+ ? alignListPrefix(rawPrefix, options)
18455
+ : rawPrefix;
18456
+ }
18471
18457
  }
18472
18458
  });
18473
18459
  }
@@ -18567,7 +18553,7 @@ function printListItem(path$$1, options, print, listPrefix) {
18567
18553
  }
18568
18554
 
18569
18555
  const alignment = " ".repeat(
18570
- clamp(options.tabWidth - listPrefix.length, 0, 3) // 4 will cause indented codeblock
18556
+ clamp(options.tabWidth - listPrefix.length, 0, 3) // 4+ will cause indented code block
18571
18557
  );
18572
18558
  return concat$8([alignment, align$2(alignment, childPath.call(print))]);
18573
18559
  }
@@ -18575,6 +18561,21 @@ function printListItem(path$$1, options, print, listPrefix) {
18575
18561
  ]);
18576
18562
  }
18577
18563
 
18564
+ function alignListPrefix(prefix, options) {
18565
+ const additionalSpaces = getAdditionalSpaces();
18566
+ return (
18567
+ prefix +
18568
+ " ".repeat(
18569
+ additionalSpaces >= 4 ? 0 : additionalSpaces // 4+ will cause indented code block
18570
+ )
18571
+ );
18572
+
18573
+ function getAdditionalSpaces() {
18574
+ const restSpaces = prefix.length % options.tabWidth;
18575
+ return restSpaces === 0 ? 0 : options.tabWidth - restSpaces;
18576
+ }
18577
+ }
18578
+
18578
18579
  function getNthListSiblingIndex(node, parentNode) {
18579
18580
  return getNthSiblingIndex(
18580
18581
  node,
@@ -19235,7 +19236,7 @@ var printerHtmlparser2 = {
19235
19236
  const languages$5 = [
19236
19237
  {
19237
19238
  name: "HTML",
19238
- since: undefined, // unreleased
19239
+ since: null, // unreleased
19239
19240
  parsers: ["parse5"],
19240
19241
  group: "HTML",
19241
19242
  tmScope: "text.html.basic",
@@ -19915,7 +19916,12 @@ function getSupportInfo$1(version, opts) {
19915
19916
 
19916
19917
  const languages = plugins
19917
19918
  .reduce((all, plugin) => all.concat(plugin.languages), [])
19918
- .filter(language => language.since && semver.gte(version, language.since))
19919
+ .filter(
19920
+ language =>
19921
+ language.since
19922
+ ? semver.gte(version, language.since)
19923
+ : language.since !== null
19924
+ )
19919
19925
  .map(language => {
19920
19926
  // Prevent breaking changes
19921
19927
  if (language.name === "Markdown") {
@@ -23278,7 +23284,7 @@ function inferParser(filepath, plugins) {
23278
23284
  pluginsLoaded: true
23279
23285
  }).languages.find(
23280
23286
  language =>
23281
- typeof language.since === "string" &&
23287
+ language.since !== null &&
23282
23288
  (language.extensions.indexOf(extension) > -1 ||
23283
23289
  (language.filenames &&
23284
23290
  language.filenames.find(name => name.toLowerCase() === filename)))
@@ -32220,7 +32226,7 @@ var resolveConfigEditorconfig = createCommonjsModule(function (module) {
32220
32226
 
32221
32227
  const maybeParse = (filePath, config, parse) => {
32222
32228
  const root = findProjectRoot(path.dirname(path.resolve(filePath)));
32223
- return filePath && !config && parse(filePath, { root });
32229
+ return filePath && parse(filePath, { root });
32224
32230
  };
32225
32231
 
32226
32232
  const editorconfigAsyncNoCache = (filePath, config) => {
package/index.js CHANGED
@@ -187,7 +187,7 @@ function printKeyValues(key, valueOrArray) {
187
187
  unwrapExports(build);
188
188
 
189
189
  var name = "prettier";
190
- var version$1 = "1.11.0-rc.1";
190
+ var version$1 = "1.11.0";
191
191
  var description = "Prettier is an opinionated code formatter";
192
192
  var bin = {"prettier":"./bin/prettier.js"};
193
193
  var repository = "prettier/prettier";
@@ -14066,6 +14066,7 @@ function printMemberChain(path$$1, options, print) {
14066
14066
  let i = 1;
14067
14067
  for (; i < printedNodes.length; ++i) {
14068
14068
  if (
14069
+ printedNodes[i].node.type === "TSNonNullExpression" ||
14069
14070
  printedNodes[i].node.type === "CallExpression" ||
14070
14071
  (printedNodes[i].node.type === "MemberExpression" &&
14071
14072
  printedNodes[i].node.computed &&
@@ -16319,15 +16320,22 @@ function genericPrint$1(path$$1, options, print) {
16319
16320
  return adjustStrings(node.value, options);
16320
16321
  }
16321
16322
  case "selector-tag": {
16323
+ const parentNode = path$$1.getParentNode();
16324
+ const index = parentNode && parentNode.nodes.indexOf(node);
16325
+ const prevNode = index && parentNode.nodes[index - 1];
16326
+
16322
16327
  return concat$5([
16323
16328
  node.namespace
16324
16329
  ? concat$5([node.namespace === true ? "" : node.namespace.trim(), "|"])
16325
16330
  : "",
16326
- adjustNumbers(
16327
- isHTMLTag(node.value) || isKeyframeAtRuleKeywords(path$$1, node.value)
16328
- ? node.value.toLowerCase()
16329
- : node.value
16330
- )
16331
+ prevNode.type === "selector-nesting"
16332
+ ? node.value
16333
+ : adjustNumbers(
16334
+ isHTMLTag(node.value) ||
16335
+ isKeyframeAtRuleKeywords(path$$1, node.value)
16336
+ ? node.value.toLowerCase()
16337
+ : node.value
16338
+ )
16331
16339
  ]);
16332
16340
  }
16333
16341
  case "selector-id": {
@@ -16421,14 +16429,6 @@ function genericPrint$1(path$$1, options, print) {
16421
16429
 
16422
16430
  const printed = path$$1.map(print, "groups");
16423
16431
  const parts = [];
16424
- const hasProgidPrefix =
16425
- declAncestorNode &&
16426
- declAncestorNode.value.group &&
16427
- declAncestorNode.value.group.group &&
16428
- declAncestorNode.value.group.group.groups &&
16429
- declAncestorNode.value.group.group.groups[0] &&
16430
- declAncestorNode.value.group.group.groups[0].type === "value-word" &&
16431
- declAncestorNode.value.group.group.groups[0].value === "progid";
16432
16432
  const functionAncestorNode = getAncestorNode(path$$1, "value-func");
16433
16433
  const insideInFunction =
16434
16434
  functionAncestorNode && functionAncestorNode.value;
@@ -16459,15 +16459,6 @@ function genericPrint$1(path$$1, options, print) {
16459
16459
  continue;
16460
16460
  }
16461
16461
 
16462
- // Ignore `filter: progid:DXImageTransform.Microsoft.Gradient(params);`
16463
- if (
16464
- hasProgidPrefix &&
16465
- iNode.type === "value-word" &&
16466
- iNode.value.endsWith("=")
16467
- ) {
16468
- continue;
16469
- }
16470
-
16471
16462
  // Ignore `@` in Less (i.e. `@@var;`)
16472
16463
  if (iNode.type === "value-atword" && iNode.value === "") {
16473
16464
  continue;
@@ -16632,7 +16623,7 @@ function genericPrint$1(path$$1, options, print) {
16632
16623
  return group$2(indent$4(concat$5(parts)));
16633
16624
  }
16634
16625
 
16635
- return group$2(hasProgidPrefix ? fill$3(parts) : indent$4(fill$3(parts)));
16626
+ return group$2(indent$4(fill$3(parts)));
16636
16627
  }
16637
16628
  case "value-paren_group": {
16638
16629
  const parentNode = path$$1.getParentNode();
@@ -16715,15 +16706,7 @@ function genericPrint$1(path$$1, options, print) {
16715
16706
  return node.value;
16716
16707
  }
16717
16708
  case "value-colon": {
16718
- const parent = path$$1.getParentNode();
16719
- const index = getNodeIndex(path$$1, node);
16720
- const hasProgidPrefix =
16721
- parent.groups[index - 1] && parent.groups[index - 1].value === "progid";
16722
-
16723
- return concat$5([
16724
- node.value,
16725
- hasProgidPrefix || insideURLFunctionNode(path$$1) ? "" : line$2
16726
- ]);
16709
+ return concat$5([node.value, insideURLFunctionNode(path$$1) ? "" : line$2]);
16727
16710
  }
16728
16711
  case "value-comma": {
16729
16712
  return concat$5([node.value, " "]);
@@ -16787,16 +16770,6 @@ function insideURLFunctionNode(path$$1) {
16787
16770
  );
16788
16771
  }
16789
16772
 
16790
- function getNodeIndex(path$$1, node) {
16791
- const parent = path$$1.getParentNode();
16792
- return (
16793
- parent &&
16794
- parent.groups &&
16795
- parent.groups.length > 0 &&
16796
- parent.groups.indexOf(node)
16797
- );
16798
- }
16799
-
16800
16773
  function isParenGroupNode(node) {
16801
16774
  return node.type && node.type === "value-paren_group";
16802
16775
  }
@@ -17399,7 +17372,8 @@ const languages$2 = [
17399
17372
  extensions: [".handlebars", ".hbs"],
17400
17373
  tm_scope: "text.html.handlebars",
17401
17374
  ace_mode: "handlebars",
17402
- language_id: 155
17375
+ language_id: 155,
17376
+ since: null // unreleased
17403
17377
  }
17404
17378
  ];
17405
17379
 
@@ -18403,12 +18377,7 @@ function genericPrint$3(path$$1, options, print) {
18403
18377
 
18404
18378
  return printChildren(path$$1, options, print, {
18405
18379
  processor: (childPath, index) => {
18406
- const prefix = node.ordered
18407
- ? (index === 0
18408
- ? node.start
18409
- : isGitDiffFriendlyOrderedList ? 1 : node.start + index) +
18410
- (nthSiblingIndex % 2 === 0 ? ". " : ") ")
18411
- : nthSiblingIndex % 2 === 0 ? "* " : "- ";
18380
+ const prefix = getPrefix();
18412
18381
  return concat$8([
18413
18382
  prefix,
18414
18383
  align$2(
@@ -18416,6 +18385,23 @@ function genericPrint$3(path$$1, options, print) {
18416
18385
  printListItem(childPath, options, print, prefix)
18417
18386
  )
18418
18387
  ]);
18388
+
18389
+ function getPrefix() {
18390
+ const rawPrefix = node.ordered
18391
+ ? (index === 0
18392
+ ? node.start
18393
+ : isGitDiffFriendlyOrderedList ? 1 : node.start + index) +
18394
+ (nthSiblingIndex % 2 === 0 ? ". " : ") ")
18395
+ : nthSiblingIndex % 2 === 0 ? "* " : "- ";
18396
+
18397
+ // do not print trailing spaces for empty list item since it might be treated as `break` node
18398
+ // by [doc-printer](https://github.com/prettier/prettier/blob/1.10.2/src/doc/doc-printer.js#L395-L405),
18399
+ // we don't want to preserve unnecessary trailing spaces.
18400
+ const listItem = childPath.getValue();
18401
+ return listItem.children.length
18402
+ ? alignListPrefix(rawPrefix, options)
18403
+ : rawPrefix;
18404
+ }
18419
18405
  }
18420
18406
  });
18421
18407
  }
@@ -18515,7 +18501,7 @@ function printListItem(path$$1, options, print, listPrefix) {
18515
18501
  }
18516
18502
 
18517
18503
  const alignment = " ".repeat(
18518
- clamp(options.tabWidth - listPrefix.length, 0, 3) // 4 will cause indented codeblock
18504
+ clamp(options.tabWidth - listPrefix.length, 0, 3) // 4+ will cause indented code block
18519
18505
  );
18520
18506
  return concat$8([alignment, align$2(alignment, childPath.call(print))]);
18521
18507
  }
@@ -18523,6 +18509,21 @@ function printListItem(path$$1, options, print, listPrefix) {
18523
18509
  ]);
18524
18510
  }
18525
18511
 
18512
+ function alignListPrefix(prefix, options) {
18513
+ const additionalSpaces = getAdditionalSpaces();
18514
+ return (
18515
+ prefix +
18516
+ " ".repeat(
18517
+ additionalSpaces >= 4 ? 0 : additionalSpaces // 4+ will cause indented code block
18518
+ )
18519
+ );
18520
+
18521
+ function getAdditionalSpaces() {
18522
+ const restSpaces = prefix.length % options.tabWidth;
18523
+ return restSpaces === 0 ? 0 : options.tabWidth - restSpaces;
18524
+ }
18525
+ }
18526
+
18526
18527
  function getNthListSiblingIndex(node, parentNode) {
18527
18528
  return getNthSiblingIndex(
18528
18529
  node,
@@ -19183,7 +19184,7 @@ var printerHtmlparser2 = {
19183
19184
  const languages$5 = [
19184
19185
  {
19185
19186
  name: "HTML",
19186
- since: undefined, // unreleased
19187
+ since: null, // unreleased
19187
19188
  parsers: ["parse5"],
19188
19189
  group: "HTML",
19189
19190
  tmScope: "text.html.basic",
@@ -19863,7 +19864,12 @@ function getSupportInfo$1(version, opts) {
19863
19864
 
19864
19865
  const languages = plugins
19865
19866
  .reduce((all, plugin) => all.concat(plugin.languages), [])
19866
- .filter(language => language.since && semver.gte(version, language.since))
19867
+ .filter(
19868
+ language =>
19869
+ language.since
19870
+ ? semver.gte(version, language.since)
19871
+ : language.since !== null
19872
+ )
19867
19873
  .map(language => {
19868
19874
  // Prevent breaking changes
19869
19875
  if (language.name === "Markdown") {
@@ -23226,7 +23232,7 @@ function inferParser(filepath, plugins) {
23226
23232
  pluginsLoaded: true
23227
23233
  }).languages.find(
23228
23234
  language =>
23229
- typeof language.since === "string" &&
23235
+ language.since !== null &&
23230
23236
  (language.extensions.indexOf(extension) > -1 ||
23231
23237
  (language.filenames &&
23232
23238
  language.filenames.find(name => name.toLowerCase() === filename)))
@@ -32168,7 +32174,7 @@ var resolveConfigEditorconfig = createCommonjsModule(function (module) {
32168
32174
 
32169
32175
  const maybeParse = (filePath, config, parse) => {
32170
32176
  const root = findProjectRoot(path.dirname(path.resolve(filePath)));
32171
- return filePath && !config && parse(filePath, { root });
32177
+ return filePath && parse(filePath, { root });
32172
32178
  };
32173
32179
 
32174
32180
  const editorconfigAsyncNoCache = (filePath, config) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prettier",
3
- "version": "1.11.0-rc.1",
3
+ "version": "1.11.0",
4
4
  "description": "Prettier is an opinionated code formatter",
5
5
  "bin": "./bin-prettier.js",
6
6
  "repository": "prettier/prettier",
package/parser-postcss.js CHANGED
@@ -40186,6 +40186,10 @@ function parseNestedCSS(node) {
40186
40186
  }
40187
40187
  }
40188
40188
 
40189
+ if (value.startsWith("progid:")) {
40190
+ return node;
40191
+ }
40192
+
40189
40193
  node.value = parseValue(value);
40190
40194
  } catch (e) {
40191
40195
  throw createError(