prettier 4.0.0-alpha.8 → 4.0.0-alpha.9
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/LICENSE +63 -541
- package/bin/prettier.cjs +4 -8
- package/doc.js +30 -39
- package/doc.mjs +30 -39
- package/index.cjs +2 -2
- package/index.d.ts +32 -13
- package/index.mjs +3097 -4468
- package/internal/cli.mjs +468 -3739
- package/package.json +2 -2
- package/plugins/acorn.js +14 -12
- package/plugins/acorn.mjs +14 -12
- package/plugins/angular.js +1 -1
- package/plugins/angular.mjs +1 -1
- package/plugins/babel.d.ts +1 -0
- package/plugins/babel.js +10 -11
- package/plugins/babel.mjs +10 -11
- package/plugins/estree.js +28 -28
- package/plugins/estree.mjs +28 -28
- package/plugins/flow.js +15 -17
- package/plugins/flow.mjs +15 -17
- package/plugins/glimmer.js +23 -23
- package/plugins/glimmer.mjs +23 -23
- package/plugins/graphql.js +9 -9
- package/plugins/graphql.mjs +9 -9
- package/plugins/html.js +18 -15
- package/plugins/html.mjs +18 -15
- package/plugins/markdown.js +45 -42
- package/plugins/markdown.mjs +45 -42
- package/plugins/meriyah.js +4 -5
- package/plugins/meriyah.mjs +4 -5
- package/plugins/postcss.js +29 -26
- package/plugins/postcss.mjs +29 -26
- package/plugins/typescript.js +15 -20
- package/plugins/typescript.mjs +15 -20
- package/plugins/yaml.js +32 -32
- package/plugins/yaml.mjs +32 -32
- package/standalone.js +27 -27
- package/standalone.mjs +27 -27
package/bin/prettier.cjs
CHANGED
|
@@ -16,14 +16,10 @@ var require_semver_compare = __commonJS({
|
|
|
16
16
|
for (var i = 0; i < 3; i++) {
|
|
17
17
|
var na = Number(pa[i]);
|
|
18
18
|
var nb = Number(pb[i]);
|
|
19
|
-
if (na > nb)
|
|
20
|
-
|
|
21
|
-
if (nb
|
|
22
|
-
|
|
23
|
-
if (!isNaN(na) && isNaN(nb))
|
|
24
|
-
return 1;
|
|
25
|
-
if (isNaN(na) && !isNaN(nb))
|
|
26
|
-
return -1;
|
|
19
|
+
if (na > nb) return 1;
|
|
20
|
+
if (nb > na) return -1;
|
|
21
|
+
if (!isNaN(na) && isNaN(nb)) return 1;
|
|
22
|
+
if (isNaN(na) && !isNaN(nb)) return -1;
|
|
27
23
|
}
|
|
28
24
|
return 0;
|
|
29
25
|
};
|
package/doc.js
CHANGED
|
@@ -403,15 +403,6 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`;
|
|
|
403
403
|
var get_string_width_default = getStringWidth;
|
|
404
404
|
|
|
405
405
|
// src/document/utils.js
|
|
406
|
-
var getDocParts = (doc) => {
|
|
407
|
-
if (Array.isArray(doc)) {
|
|
408
|
-
return doc;
|
|
409
|
-
}
|
|
410
|
-
if (doc.type !== DOC_TYPE_FILL) {
|
|
411
|
-
throw new Error(`Expect doc to be 'array' or '${DOC_TYPE_FILL}'.`);
|
|
412
|
-
}
|
|
413
|
-
return doc.parts;
|
|
414
|
-
};
|
|
415
406
|
function mapDoc(doc, cb) {
|
|
416
407
|
if (typeof doc === "string") {
|
|
417
408
|
return cb(doc);
|
|
@@ -512,7 +503,7 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`;
|
|
|
512
503
|
function breakParentGroup(groupStack) {
|
|
513
504
|
if (groupStack.length > 0) {
|
|
514
505
|
const parentGroup = at_default(
|
|
515
|
-
/* isOptionalObject*/
|
|
506
|
+
/* isOptionalObject */
|
|
516
507
|
false,
|
|
517
508
|
groupStack,
|
|
518
509
|
-1
|
|
@@ -569,12 +560,12 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`;
|
|
|
569
560
|
function stripTrailingHardlineFromParts(parts) {
|
|
570
561
|
parts = [...parts];
|
|
571
562
|
while (parts.length >= 2 && at_default(
|
|
572
|
-
/* isOptionalObject*/
|
|
563
|
+
/* isOptionalObject */
|
|
573
564
|
false,
|
|
574
565
|
parts,
|
|
575
566
|
-2
|
|
576
567
|
).type === DOC_TYPE_LINE && at_default(
|
|
577
|
-
/* isOptionalObject*/
|
|
568
|
+
/* isOptionalObject */
|
|
578
569
|
false,
|
|
579
570
|
parts,
|
|
580
571
|
-1
|
|
@@ -583,7 +574,7 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`;
|
|
|
583
574
|
}
|
|
584
575
|
if (parts.length > 0) {
|
|
585
576
|
const lastPart = stripTrailingHardlineFromDoc(at_default(
|
|
586
|
-
/* isOptionalObject*/
|
|
577
|
+
/* isOptionalObject */
|
|
587
578
|
false,
|
|
588
579
|
parts,
|
|
589
580
|
-1
|
|
@@ -594,7 +585,6 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`;
|
|
|
594
585
|
}
|
|
595
586
|
function stripTrailingHardlineFromDoc(doc) {
|
|
596
587
|
switch (get_doc_type_default(doc)) {
|
|
597
|
-
case DOC_TYPE_ALIGN:
|
|
598
588
|
case DOC_TYPE_INDENT:
|
|
599
589
|
case DOC_TYPE_INDENT_IF_BREAK:
|
|
600
590
|
case DOC_TYPE_GROUP:
|
|
@@ -621,6 +611,7 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`;
|
|
|
621
611
|
return stripTrailingHardlineFromParts(doc);
|
|
622
612
|
case DOC_TYPE_STRING:
|
|
623
613
|
return doc.replace(/[\n\r]*$/, "");
|
|
614
|
+
case DOC_TYPE_ALIGN:
|
|
624
615
|
case DOC_TYPE_CURSOR:
|
|
625
616
|
case DOC_TYPE_TRIM:
|
|
626
617
|
case DOC_TYPE_LINE_SUFFIX_BOUNDARY:
|
|
@@ -671,7 +662,7 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`;
|
|
|
671
662
|
}
|
|
672
663
|
const [currentPart, ...restParts] = Array.isArray(part) ? part : [part];
|
|
673
664
|
if (typeof currentPart === "string" && typeof at_default(
|
|
674
|
-
/* isOptionalObject*/
|
|
665
|
+
/* isOptionalObject */
|
|
675
666
|
false,
|
|
676
667
|
parts,
|
|
677
668
|
-1
|
|
@@ -830,26 +821,25 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`;
|
|
|
830
821
|
let trimCount = 0;
|
|
831
822
|
let cursorCount = 0;
|
|
832
823
|
let outIndex = out.length;
|
|
833
|
-
outer:
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
break outer;
|
|
850
|
-
}
|
|
824
|
+
outer: while (outIndex--) {
|
|
825
|
+
const last = out[outIndex];
|
|
826
|
+
if (last === CURSOR_PLACEHOLDER) {
|
|
827
|
+
cursorCount++;
|
|
828
|
+
continue;
|
|
829
|
+
}
|
|
830
|
+
if (false) {
|
|
831
|
+
throw new Error(`Unexpected value in trim: '${typeof last}'`);
|
|
832
|
+
}
|
|
833
|
+
for (let charIndex = last.length - 1; charIndex >= 0; charIndex--) {
|
|
834
|
+
const char = last[charIndex];
|
|
835
|
+
if (char === " " || char === " ") {
|
|
836
|
+
trimCount++;
|
|
837
|
+
} else {
|
|
838
|
+
out[outIndex] = last.slice(0, charIndex + 1);
|
|
839
|
+
break outer;
|
|
851
840
|
}
|
|
852
841
|
}
|
|
842
|
+
}
|
|
853
843
|
if (trimCount > 0 || cursorCount > 0) {
|
|
854
844
|
out.length = outIndex + 1;
|
|
855
845
|
while (cursorCount-- > 0) {
|
|
@@ -877,14 +867,15 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`;
|
|
|
877
867
|
mode,
|
|
878
868
|
doc
|
|
879
869
|
} = cmds.pop();
|
|
880
|
-
|
|
870
|
+
const docType = get_doc_type_default(doc);
|
|
871
|
+
switch (docType) {
|
|
881
872
|
case DOC_TYPE_STRING:
|
|
882
873
|
out.push(doc);
|
|
883
874
|
width -= get_string_width_default(doc);
|
|
884
875
|
break;
|
|
885
876
|
case DOC_TYPE_ARRAY:
|
|
886
877
|
case DOC_TYPE_FILL: {
|
|
887
|
-
const parts =
|
|
878
|
+
const parts = docType === DOC_TYPE_ARRAY ? doc : doc.parts;
|
|
888
879
|
for (let i = parts.length - 1; i >= 0; i--) {
|
|
889
880
|
cmds.push({
|
|
890
881
|
mode,
|
|
@@ -911,7 +902,7 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`;
|
|
|
911
902
|
}
|
|
912
903
|
const groupMode = doc.break ? MODE_BREAK : mode;
|
|
913
904
|
const contents = doc.expandedStates && groupMode === MODE_BREAK ? at_default(
|
|
914
|
-
/* isOptionalObject*/
|
|
905
|
+
/* isOptionalObject */
|
|
915
906
|
false,
|
|
916
907
|
doc.expandedStates,
|
|
917
908
|
-1
|
|
@@ -978,7 +969,7 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`;
|
|
|
978
969
|
switch (get_doc_type_default(doc2)) {
|
|
979
970
|
case DOC_TYPE_STRING: {
|
|
980
971
|
const formatted = newLine !== "\n" ? string_replace_all_default(
|
|
981
|
-
/* isOptionalObject*/
|
|
972
|
+
/* isOptionalObject */
|
|
982
973
|
false,
|
|
983
974
|
doc2,
|
|
984
975
|
"\n",
|
|
@@ -1048,7 +1039,7 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`;
|
|
|
1048
1039
|
} else {
|
|
1049
1040
|
if (doc2.expandedStates) {
|
|
1050
1041
|
const mostExpanded = at_default(
|
|
1051
|
-
/* isOptionalObject*/
|
|
1042
|
+
/* isOptionalObject */
|
|
1052
1043
|
false,
|
|
1053
1044
|
doc2.expandedStates,
|
|
1054
1045
|
-1
|
|
@@ -1096,7 +1087,7 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`;
|
|
|
1096
1087
|
}
|
|
1097
1088
|
if (doc2.id) {
|
|
1098
1089
|
groupModeMap[doc2.id] = at_default(
|
|
1099
|
-
/* isOptionalObject*/
|
|
1090
|
+
/* isOptionalObject */
|
|
1100
1091
|
false,
|
|
1101
1092
|
cmds,
|
|
1102
1093
|
-1
|
package/doc.mjs
CHANGED
|
@@ -368,15 +368,6 @@ function getStringWidth(text) {
|
|
|
368
368
|
var get_string_width_default = getStringWidth;
|
|
369
369
|
|
|
370
370
|
// src/document/utils.js
|
|
371
|
-
var getDocParts = (doc) => {
|
|
372
|
-
if (Array.isArray(doc)) {
|
|
373
|
-
return doc;
|
|
374
|
-
}
|
|
375
|
-
if (doc.type !== DOC_TYPE_FILL) {
|
|
376
|
-
throw new Error(`Expect doc to be 'array' or '${DOC_TYPE_FILL}'.`);
|
|
377
|
-
}
|
|
378
|
-
return doc.parts;
|
|
379
|
-
};
|
|
380
371
|
function mapDoc(doc, cb) {
|
|
381
372
|
if (typeof doc === "string") {
|
|
382
373
|
return cb(doc);
|
|
@@ -477,7 +468,7 @@ function willBreak(doc) {
|
|
|
477
468
|
function breakParentGroup(groupStack) {
|
|
478
469
|
if (groupStack.length > 0) {
|
|
479
470
|
const parentGroup = at_default(
|
|
480
|
-
/* isOptionalObject*/
|
|
471
|
+
/* isOptionalObject */
|
|
481
472
|
false,
|
|
482
473
|
groupStack,
|
|
483
474
|
-1
|
|
@@ -534,12 +525,12 @@ function removeLines(doc) {
|
|
|
534
525
|
function stripTrailingHardlineFromParts(parts) {
|
|
535
526
|
parts = [...parts];
|
|
536
527
|
while (parts.length >= 2 && at_default(
|
|
537
|
-
/* isOptionalObject*/
|
|
528
|
+
/* isOptionalObject */
|
|
538
529
|
false,
|
|
539
530
|
parts,
|
|
540
531
|
-2
|
|
541
532
|
).type === DOC_TYPE_LINE && at_default(
|
|
542
|
-
/* isOptionalObject*/
|
|
533
|
+
/* isOptionalObject */
|
|
543
534
|
false,
|
|
544
535
|
parts,
|
|
545
536
|
-1
|
|
@@ -548,7 +539,7 @@ function stripTrailingHardlineFromParts(parts) {
|
|
|
548
539
|
}
|
|
549
540
|
if (parts.length > 0) {
|
|
550
541
|
const lastPart = stripTrailingHardlineFromDoc(at_default(
|
|
551
|
-
/* isOptionalObject*/
|
|
542
|
+
/* isOptionalObject */
|
|
552
543
|
false,
|
|
553
544
|
parts,
|
|
554
545
|
-1
|
|
@@ -559,7 +550,6 @@ function stripTrailingHardlineFromParts(parts) {
|
|
|
559
550
|
}
|
|
560
551
|
function stripTrailingHardlineFromDoc(doc) {
|
|
561
552
|
switch (get_doc_type_default(doc)) {
|
|
562
|
-
case DOC_TYPE_ALIGN:
|
|
563
553
|
case DOC_TYPE_INDENT:
|
|
564
554
|
case DOC_TYPE_INDENT_IF_BREAK:
|
|
565
555
|
case DOC_TYPE_GROUP:
|
|
@@ -586,6 +576,7 @@ function stripTrailingHardlineFromDoc(doc) {
|
|
|
586
576
|
return stripTrailingHardlineFromParts(doc);
|
|
587
577
|
case DOC_TYPE_STRING:
|
|
588
578
|
return doc.replace(/[\n\r]*$/, "");
|
|
579
|
+
case DOC_TYPE_ALIGN:
|
|
589
580
|
case DOC_TYPE_CURSOR:
|
|
590
581
|
case DOC_TYPE_TRIM:
|
|
591
582
|
case DOC_TYPE_LINE_SUFFIX_BOUNDARY:
|
|
@@ -636,7 +627,7 @@ function cleanDocFn(doc) {
|
|
|
636
627
|
}
|
|
637
628
|
const [currentPart, ...restParts] = Array.isArray(part) ? part : [part];
|
|
638
629
|
if (typeof currentPart === "string" && typeof at_default(
|
|
639
|
-
/* isOptionalObject*/
|
|
630
|
+
/* isOptionalObject */
|
|
640
631
|
false,
|
|
641
632
|
parts,
|
|
642
633
|
-1
|
|
@@ -795,26 +786,25 @@ function trim2(out) {
|
|
|
795
786
|
let trimCount = 0;
|
|
796
787
|
let cursorCount = 0;
|
|
797
788
|
let outIndex = out.length;
|
|
798
|
-
outer:
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
break outer;
|
|
815
|
-
}
|
|
789
|
+
outer: while (outIndex--) {
|
|
790
|
+
const last = out[outIndex];
|
|
791
|
+
if (last === CURSOR_PLACEHOLDER) {
|
|
792
|
+
cursorCount++;
|
|
793
|
+
continue;
|
|
794
|
+
}
|
|
795
|
+
if (false) {
|
|
796
|
+
throw new Error(`Unexpected value in trim: '${typeof last}'`);
|
|
797
|
+
}
|
|
798
|
+
for (let charIndex = last.length - 1; charIndex >= 0; charIndex--) {
|
|
799
|
+
const char = last[charIndex];
|
|
800
|
+
if (char === " " || char === " ") {
|
|
801
|
+
trimCount++;
|
|
802
|
+
} else {
|
|
803
|
+
out[outIndex] = last.slice(0, charIndex + 1);
|
|
804
|
+
break outer;
|
|
816
805
|
}
|
|
817
806
|
}
|
|
807
|
+
}
|
|
818
808
|
if (trimCount > 0 || cursorCount > 0) {
|
|
819
809
|
out.length = outIndex + 1;
|
|
820
810
|
while (cursorCount-- > 0) {
|
|
@@ -842,14 +832,15 @@ function fits(next, restCommands, width, hasLineSuffix, groupModeMap, mustBeFlat
|
|
|
842
832
|
mode,
|
|
843
833
|
doc
|
|
844
834
|
} = cmds.pop();
|
|
845
|
-
|
|
835
|
+
const docType = get_doc_type_default(doc);
|
|
836
|
+
switch (docType) {
|
|
846
837
|
case DOC_TYPE_STRING:
|
|
847
838
|
out.push(doc);
|
|
848
839
|
width -= get_string_width_default(doc);
|
|
849
840
|
break;
|
|
850
841
|
case DOC_TYPE_ARRAY:
|
|
851
842
|
case DOC_TYPE_FILL: {
|
|
852
|
-
const parts =
|
|
843
|
+
const parts = docType === DOC_TYPE_ARRAY ? doc : doc.parts;
|
|
853
844
|
for (let i = parts.length - 1; i >= 0; i--) {
|
|
854
845
|
cmds.push({
|
|
855
846
|
mode,
|
|
@@ -876,7 +867,7 @@ function fits(next, restCommands, width, hasLineSuffix, groupModeMap, mustBeFlat
|
|
|
876
867
|
}
|
|
877
868
|
const groupMode = doc.break ? MODE_BREAK : mode;
|
|
878
869
|
const contents = doc.expandedStates && groupMode === MODE_BREAK ? at_default(
|
|
879
|
-
/* isOptionalObject*/
|
|
870
|
+
/* isOptionalObject */
|
|
880
871
|
false,
|
|
881
872
|
doc.expandedStates,
|
|
882
873
|
-1
|
|
@@ -943,7 +934,7 @@ function printDocToString(doc, options) {
|
|
|
943
934
|
switch (get_doc_type_default(doc2)) {
|
|
944
935
|
case DOC_TYPE_STRING: {
|
|
945
936
|
const formatted = newLine !== "\n" ? string_replace_all_default(
|
|
946
|
-
/* isOptionalObject*/
|
|
937
|
+
/* isOptionalObject */
|
|
947
938
|
false,
|
|
948
939
|
doc2,
|
|
949
940
|
"\n",
|
|
@@ -1013,7 +1004,7 @@ function printDocToString(doc, options) {
|
|
|
1013
1004
|
} else {
|
|
1014
1005
|
if (doc2.expandedStates) {
|
|
1015
1006
|
const mostExpanded = at_default(
|
|
1016
|
-
/* isOptionalObject*/
|
|
1007
|
+
/* isOptionalObject */
|
|
1017
1008
|
false,
|
|
1018
1009
|
doc2.expandedStates,
|
|
1019
1010
|
-1
|
|
@@ -1061,7 +1052,7 @@ function printDocToString(doc, options) {
|
|
|
1061
1052
|
}
|
|
1062
1053
|
if (doc2.id) {
|
|
1063
1054
|
groupModeMap[doc2.id] = at_default(
|
|
1064
|
-
/* isOptionalObject*/
|
|
1055
|
+
/* isOptionalObject */
|
|
1065
1056
|
false,
|
|
1066
1057
|
cmds,
|
|
1067
1058
|
-1
|
package/index.cjs
CHANGED
|
@@ -472,7 +472,7 @@ function makeString(rawText, enclosingQuote, unescapeUnnecessaryEscapes) {
|
|
|
472
472
|
const otherQuote = enclosingQuote === '"' ? "'" : '"';
|
|
473
473
|
const regex = /\\(.)|(["'])/gs;
|
|
474
474
|
const raw = string_replace_all_default(
|
|
475
|
-
/* isOptionalObject*/
|
|
475
|
+
/* isOptionalObject */
|
|
476
476
|
false,
|
|
477
477
|
rawText,
|
|
478
478
|
regex,
|
|
@@ -585,7 +585,7 @@ var init_public = __esm({
|
|
|
585
585
|
// src/main/version.evaluate.cjs
|
|
586
586
|
var require_version_evaluate = __commonJS({
|
|
587
587
|
"src/main/version.evaluate.cjs"(exports2, module2) {
|
|
588
|
-
module2.exports = "4.0.0-alpha.
|
|
588
|
+
module2.exports = "4.0.0-alpha.9";
|
|
589
589
|
}
|
|
590
590
|
});
|
|
591
591
|
|
package/index.d.ts
CHANGED
|
@@ -39,9 +39,8 @@ type ArrayProperties<T> = {
|
|
|
39
39
|
// A union of the properties of the given array T that can be used to index it.
|
|
40
40
|
// If the array is a tuple, then that's going to be the explicit indices of the
|
|
41
41
|
// array, otherwise it's going to just be number.
|
|
42
|
-
type IndexProperties<T extends { length: number }> =
|
|
43
|
-
? Exclude<Partial<T>["length"], T["length"]>
|
|
44
|
-
: number;
|
|
42
|
+
type IndexProperties<T extends { length: number }> =
|
|
43
|
+
IsTuple<T> extends true ? Exclude<Partial<T>["length"], T["length"]> : number;
|
|
45
44
|
|
|
46
45
|
// Effectively performing T[P], except that it's telling TypeScript that it's
|
|
47
46
|
// safe to do this for tuples, arrays, or objects.
|
|
@@ -291,6 +290,7 @@ export type BuiltInParserName =
|
|
|
291
290
|
| "json-stringify"
|
|
292
291
|
| "json"
|
|
293
292
|
| "json5"
|
|
293
|
+
| "jsonc"
|
|
294
294
|
| "less"
|
|
295
295
|
| "lwc"
|
|
296
296
|
| "markdown"
|
|
@@ -347,12 +347,6 @@ export interface RequiredOptions extends doc.printer.Options {
|
|
|
347
347
|
* @default false
|
|
348
348
|
*/
|
|
349
349
|
bracketSameLine: boolean;
|
|
350
|
-
/**
|
|
351
|
-
* Put the `>` of a multi-line JSX element at the end of the last line instead of being alone on the next line.
|
|
352
|
-
* @default false
|
|
353
|
-
* @deprecated use bracketSameLine instead
|
|
354
|
-
*/
|
|
355
|
-
jsxBracketSameLine: boolean;
|
|
356
350
|
/**
|
|
357
351
|
* Format only a segment of a file.
|
|
358
352
|
* @default 0
|
|
@@ -430,6 +424,22 @@ export interface RequiredOptions extends doc.printer.Options {
|
|
|
430
424
|
* @default false
|
|
431
425
|
*/
|
|
432
426
|
singleAttributePerLine: boolean;
|
|
427
|
+
/**
|
|
428
|
+
* Use curious ternaries, with the question mark after the condition, instead
|
|
429
|
+
* of on the same line as the consequent.
|
|
430
|
+
* @default false
|
|
431
|
+
*/
|
|
432
|
+
experimentalTernaries: boolean;
|
|
433
|
+
/**
|
|
434
|
+
* Put the `>` of a multi-line JSX element at the end of the last line instead of being alone on the next line.
|
|
435
|
+
* @default false
|
|
436
|
+
* @deprecated use bracketSameLine instead
|
|
437
|
+
*/
|
|
438
|
+
jsxBracketSameLine?: boolean;
|
|
439
|
+
/**
|
|
440
|
+
* Arbitrary additional values on an options object are always allowed.
|
|
441
|
+
*/
|
|
442
|
+
[_: string]: unknown;
|
|
433
443
|
}
|
|
434
444
|
|
|
435
445
|
export interface ParserOptions<T = any> extends RequiredOptions {
|
|
@@ -486,10 +496,12 @@ export interface Printer<T = any> {
|
|
|
486
496
|
insertPragma?: (text: string) => string;
|
|
487
497
|
/**
|
|
488
498
|
* @returns `null` if you want to remove this node
|
|
489
|
-
* @returns `void` if you want to use modified
|
|
499
|
+
* @returns `void` if you want to use modified `cloned`
|
|
490
500
|
* @returns anything if you want to replace the node with it
|
|
491
501
|
*/
|
|
492
|
-
massageAstNode?:
|
|
502
|
+
massageAstNode?:
|
|
503
|
+
| ((original: any, cloned: any, parent: any) => any)
|
|
504
|
+
| undefined;
|
|
493
505
|
hasPrettierIgnore?: ((path: AstPath<T>) => boolean) | undefined;
|
|
494
506
|
canAttachComment?: ((node: T) => boolean) | undefined;
|
|
495
507
|
isBlockComment?: ((node: T) => boolean) | undefined;
|
|
@@ -780,7 +792,7 @@ export interface SupportInfo {
|
|
|
780
792
|
export interface FileInfoOptions {
|
|
781
793
|
ignorePath?: string | URL | (string | URL)[] | undefined;
|
|
782
794
|
withNodeModules?: boolean | undefined;
|
|
783
|
-
plugins?: string
|
|
795
|
+
plugins?: Array<string | Plugin> | undefined;
|
|
784
796
|
resolveConfig?: boolean | undefined;
|
|
785
797
|
}
|
|
786
798
|
|
|
@@ -794,10 +806,17 @@ export function getFileInfo(
|
|
|
794
806
|
options?: FileInfoOptions,
|
|
795
807
|
): Promise<FileInfoResult>;
|
|
796
808
|
|
|
809
|
+
export interface SupportInfoOptions {
|
|
810
|
+
plugins?: Array<string | Plugin> | undefined;
|
|
811
|
+
showDeprecated?: boolean | undefined;
|
|
812
|
+
}
|
|
813
|
+
|
|
797
814
|
/**
|
|
798
815
|
* Returns an object representing the parsers, languages and file types Prettier supports for the current version.
|
|
799
816
|
*/
|
|
800
|
-
export function getSupportInfo(
|
|
817
|
+
export function getSupportInfo(
|
|
818
|
+
options?: SupportInfoOptions,
|
|
819
|
+
): Promise<SupportInfo>;
|
|
801
820
|
|
|
802
821
|
/**
|
|
803
822
|
* `version` field in `package.json`
|