prettier 1.17.0 → 1.18.2

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/doc.js CHANGED
@@ -731,7 +731,7 @@ function printString(raw, options, isDirectiveLiteral) {
731
731
  // sure that we consistently output the minimum amount of escaped quotes.
732
732
 
733
733
 
734
- return makeString(rawContent, enclosingQuote, !(options.parser === "css" || options.parser === "less" || options.parser === "scss" || options.parentParser === "html" || options.parentParser === "vue" || options.parentParser === "angular" || options.parentParser === "lwc"));
734
+ return makeString(rawContent, enclosingQuote, !(options.parser === "css" || options.parser === "less" || options.parser === "scss" || options.embeddedInHtml));
735
735
  }
736
736
 
737
737
  function makeString(rawContent, enclosingQuote, unescapeUnnecessaryEscapes) {
@@ -787,6 +787,53 @@ function getMaxContinuousCount(str, target) {
787
787
  }, 0);
788
788
  }
789
789
 
790
+ function getMinNotPresentContinuousCount(str, target) {
791
+ var matches = str.match(new RegExp("(".concat(escapeStringRegexp(target), ")+"), "g"));
792
+
793
+ if (matches === null) {
794
+ return 0;
795
+ }
796
+
797
+ var countPresent = new Map();
798
+ var max = 0;
799
+ var _iteratorNormalCompletion = true;
800
+ var _didIteratorError = false;
801
+ var _iteratorError = undefined;
802
+
803
+ try {
804
+ for (var _iterator = matches[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
805
+ var match = _step.value;
806
+ var count = match.length / target.length;
807
+ countPresent.set(count, true);
808
+
809
+ if (count > max) {
810
+ max = count;
811
+ }
812
+ }
813
+ } catch (err) {
814
+ _didIteratorError = true;
815
+ _iteratorError = err;
816
+ } finally {
817
+ try {
818
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
819
+ _iterator.return();
820
+ }
821
+ } finally {
822
+ if (_didIteratorError) {
823
+ throw _iteratorError;
824
+ }
825
+ }
826
+ }
827
+
828
+ for (var i = 1; i < max; i++) {
829
+ if (!countPresent.get(i)) {
830
+ return i;
831
+ }
832
+ }
833
+
834
+ return max + 1;
835
+ }
836
+
790
837
  function getStringWidth$1(text) {
791
838
  if (!text) {
792
839
  return 0;
@@ -877,13 +924,13 @@ function isWithinParentArrayProperty(path, propertyName) {
877
924
 
878
925
  function replaceEndOfLineWith(text, replacement) {
879
926
  var parts = [];
880
- var _iteratorNormalCompletion = true;
881
- var _didIteratorError = false;
882
- var _iteratorError = undefined;
927
+ var _iteratorNormalCompletion2 = true;
928
+ var _didIteratorError2 = false;
929
+ var _iteratorError2 = undefined;
883
930
 
884
931
  try {
885
- for (var _iterator = text.split("\n")[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
886
- var part = _step.value;
932
+ for (var _iterator2 = text.split("\n")[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
933
+ var part = _step2.value;
887
934
 
888
935
  if (parts.length !== 0) {
889
936
  parts.push(replacement);
@@ -892,16 +939,16 @@ function replaceEndOfLineWith(text, replacement) {
892
939
  parts.push(part);
893
940
  }
894
941
  } catch (err) {
895
- _didIteratorError = true;
896
- _iteratorError = err;
942
+ _didIteratorError2 = true;
943
+ _iteratorError2 = err;
897
944
  } finally {
898
945
  try {
899
- if (!_iteratorNormalCompletion && _iterator.return != null) {
900
- _iterator.return();
946
+ if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
947
+ _iterator2.return();
901
948
  }
902
949
  } finally {
903
- if (_didIteratorError) {
904
- throw _iteratorError;
950
+ if (_didIteratorError2) {
951
+ throw _iteratorError2;
905
952
  }
906
953
  }
907
954
  }
@@ -913,6 +960,7 @@ var util = {
913
960
  replaceEndOfLineWith: replaceEndOfLineWith,
914
961
  getStringWidth: getStringWidth$1,
915
962
  getMaxContinuousCount: getMaxContinuousCount,
963
+ getMinNotPresentContinuousCount: getMinNotPresentContinuousCount,
916
964
  getPrecedence: getPrecedence,
917
965
  shouldFlatten: shouldFlatten,
918
966
  isBitwiseOperator: isBitwiseOperator,
@@ -1803,6 +1851,7 @@ var docUtils = {
1803
1851
  willBreak: willBreak,
1804
1852
  isLineNext: isLineNext,
1805
1853
  traverseDoc: traverseDoc,
1854
+ findInDoc: findInDoc,
1806
1855
  mapDoc: mapDoc,
1807
1856
  propagateBreaks: propagateBreaks,
1808
1857
  removeLines: removeLines,