prettier 3.8.4 → 3.9.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/THIRD-PARTY-NOTICES.md +2233 -279
- package/bin/prettier.cjs +5 -1
- package/doc.js +206 -142
- package/doc.mjs +206 -142
- package/index.cjs +103 -33
- package/index.d.ts +9 -2
- package/index.mjs +8056 -7776
- package/internal/experimental-cli-worker.mjs +22 -107
- package/internal/experimental-cli.mjs +3747 -3965
- package/internal/legacy-cli.mjs +488 -120
- package/package.json +11 -7
- package/plugins/acorn.js +11 -10
- package/plugins/acorn.mjs +11 -10
- package/plugins/angular.js +5 -4
- package/plugins/angular.mjs +5 -4
- package/plugins/babel.js +14 -13
- package/plugins/babel.mjs +14 -13
- package/plugins/estree.js +36 -36
- package/plugins/estree.mjs +36 -36
- package/plugins/flow.js +6 -19
- package/plugins/flow.mjs +6 -19
- package/plugins/glimmer.js +17 -17
- package/plugins/glimmer.mjs +15 -15
- package/plugins/graphql.js +14 -25
- package/plugins/graphql.mjs +14 -25
- package/plugins/html.js +18 -18
- package/plugins/html.mjs +18 -18
- package/plugins/markdown.js +63 -55
- package/plugins/markdown.mjs +63 -55
- package/plugins/meriyah.js +5 -4
- package/plugins/meriyah.mjs +5 -4
- package/plugins/postcss.js +40 -39
- package/plugins/postcss.mjs +40 -39
- package/plugins/typescript.js +16 -15
- package/plugins/typescript.mjs +16 -15
- package/plugins/yaml.js +136 -154
- package/plugins/yaml.mjs +149 -154
- package/standalone.js +28 -28
- package/standalone.mjs +28 -28
package/index.cjs
CHANGED
|
@@ -5,8 +5,13 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __esm = (fn, res) => function __init() {
|
|
9
|
-
|
|
8
|
+
var __esm = (fn, res, err) => function __init() {
|
|
9
|
+
if (err) throw err[0];
|
|
10
|
+
try {
|
|
11
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
12
|
+
} catch (e) {
|
|
13
|
+
throw err = [e], e;
|
|
14
|
+
}
|
|
10
15
|
};
|
|
11
16
|
var __export = (target, all) => {
|
|
12
17
|
for (var name in all)
|
|
@@ -56,7 +61,7 @@ var init_method_replace_all = __esm({
|
|
|
56
61
|
}
|
|
57
62
|
return this.split(pattern).join(replacement);
|
|
58
63
|
};
|
|
59
|
-
replaceAll = createMethodShim("replaceAll", function() {
|
|
64
|
+
replaceAll = /* @__PURE__ */ createMethodShim("replaceAll", function() {
|
|
60
65
|
if (typeof this === "string") {
|
|
61
66
|
return stringReplaceAll;
|
|
62
67
|
}
|
|
@@ -68,10 +73,10 @@ var init_method_replace_all = __esm({
|
|
|
68
73
|
// src/utilities/skip.js
|
|
69
74
|
function skip(characters) {
|
|
70
75
|
return (text, startIndex, options) => {
|
|
71
|
-
const backwards = Boolean(options?.backwards);
|
|
72
76
|
if (startIndex === false) {
|
|
73
77
|
return false;
|
|
74
78
|
}
|
|
79
|
+
const backwards = Boolean(options?.backwards);
|
|
75
80
|
const { length } = text;
|
|
76
81
|
let cursor = startIndex;
|
|
77
82
|
while (cursor >= 0 && cursor < length) {
|
|
@@ -94,10 +99,10 @@ function skip(characters) {
|
|
|
94
99
|
var skipWhitespace, skipSpaces, skipToLineEnd, skipEverythingButNewLine;
|
|
95
100
|
var init_skip = __esm({
|
|
96
101
|
"src/utilities/skip.js"() {
|
|
97
|
-
skipWhitespace = skip(/\s/
|
|
102
|
+
skipWhitespace = skip(/\s/);
|
|
98
103
|
skipSpaces = skip(" ");
|
|
99
104
|
skipToLineEnd = skip(",; ");
|
|
100
|
-
skipEverythingButNewLine = skip(/[^\n\r]/
|
|
105
|
+
skipEverythingButNewLine = skip(/[^\n\r]/);
|
|
101
106
|
}
|
|
102
107
|
});
|
|
103
108
|
|
|
@@ -124,10 +129,10 @@ var init_skip_inline_comment = __esm({
|
|
|
124
129
|
|
|
125
130
|
// src/utilities/skip-newline.js
|
|
126
131
|
function skipNewline(text, startIndex, options) {
|
|
127
|
-
const backwards = Boolean(options?.backwards);
|
|
128
132
|
if (startIndex === false) {
|
|
129
133
|
return false;
|
|
130
134
|
}
|
|
135
|
+
const backwards = Boolean(options?.backwards);
|
|
131
136
|
const character = text.charAt(startIndex);
|
|
132
137
|
if (backwards) {
|
|
133
138
|
if (text.charAt(startIndex - 1) === "\r" && character === "\n") {
|
|
@@ -326,7 +331,7 @@ function getIndentSize(value, tabWidth) {
|
|
|
326
331
|
}
|
|
327
332
|
return get_alignment_size_default(
|
|
328
333
|
// All the leading whitespaces
|
|
329
|
-
value.slice(lastNewlineIndex + 1).match(/^[\t ]*/
|
|
334
|
+
value.slice(lastNewlineIndex + 1).match(/^[\t ]*/)[0],
|
|
330
335
|
tabWidth
|
|
331
336
|
);
|
|
332
337
|
}
|
|
@@ -353,7 +358,7 @@ var init_escape_string_regexp = __esm({
|
|
|
353
358
|
// src/utilities/get-max-continuous-count.js
|
|
354
359
|
function getMaxContinuousCount(text, searchString) {
|
|
355
360
|
let results = text.matchAll(
|
|
356
|
-
new RegExp(`(?:${escapeStringRegexp(searchString)})+`, "
|
|
361
|
+
new RegExp(`(?:${escapeStringRegexp(searchString)})+`, "g")
|
|
357
362
|
);
|
|
358
363
|
if (!results.reduce) {
|
|
359
364
|
results = [...results];
|
|
@@ -400,7 +405,7 @@ function getPreferredQuote(text, preferredQuoteOrPreferSingleQuote) {
|
|
|
400
405
|
}
|
|
401
406
|
return (preferredQuoteCount > alternateQuoteCount ? alternate : preferred).character;
|
|
402
407
|
}
|
|
403
|
-
var SINGLE_QUOTE, DOUBLE_QUOTE, SINGLE_QUOTE_DATA, DOUBLE_QUOTE_DATA, SINGLE_QUOTE_SETTINGS, DOUBLE_QUOTE_SETTINGS
|
|
408
|
+
var SINGLE_QUOTE, DOUBLE_QUOTE, SINGLE_QUOTE_DATA, DOUBLE_QUOTE_DATA, SINGLE_QUOTE_SETTINGS, DOUBLE_QUOTE_SETTINGS;
|
|
404
409
|
var init_get_preferred_quote = __esm({
|
|
405
410
|
"src/utilities/get-preferred-quote.js"() {
|
|
406
411
|
SINGLE_QUOTE = "'";
|
|
@@ -421,7 +426,6 @@ var init_get_preferred_quote = __esm({
|
|
|
421
426
|
preferred: DOUBLE_QUOTE_DATA,
|
|
422
427
|
alternate: SINGLE_QUOTE_DATA
|
|
423
428
|
});
|
|
424
|
-
get_preferred_quote_default = getPreferredQuote;
|
|
425
429
|
}
|
|
426
430
|
});
|
|
427
431
|
|
|
@@ -435,15 +439,81 @@ var init_emoji_regex = __esm({
|
|
|
435
439
|
}
|
|
436
440
|
});
|
|
437
441
|
|
|
442
|
+
// node_modules/get-east-asian-width/lookup-data.js
|
|
443
|
+
var fullwidthMinimalCodePoint, fullwidthMaximumCodePoint, fullwidthRanges, wideMinimalCodePoint, wideMaximumCodePoint, wideRanges;
|
|
444
|
+
var init_lookup_data = __esm({
|
|
445
|
+
"node_modules/get-east-asian-width/lookup-data.js"() {
|
|
446
|
+
fullwidthMinimalCodePoint = 12288;
|
|
447
|
+
fullwidthMaximumCodePoint = 65510;
|
|
448
|
+
fullwidthRanges = [12288, 12288, 65281, 65376, 65504, 65510];
|
|
449
|
+
wideMinimalCodePoint = 4352;
|
|
450
|
+
wideMaximumCodePoint = 262141;
|
|
451
|
+
wideRanges = [4352, 4447, 8986, 8987, 9001, 9002, 9193, 9196, 9200, 9200, 9203, 9203, 9725, 9726, 9748, 9749, 9776, 9783, 9800, 9811, 9855, 9855, 9866, 9871, 9875, 9875, 9889, 9889, 9898, 9899, 9917, 9918, 9924, 9925, 9934, 9934, 9940, 9940, 9962, 9962, 9970, 9971, 9973, 9973, 9978, 9978, 9981, 9981, 9989, 9989, 9994, 9995, 10024, 10024, 10060, 10060, 10062, 10062, 10067, 10069, 10071, 10071, 10133, 10135, 10160, 10160, 10175, 10175, 11035, 11036, 11088, 11088, 11093, 11093, 11904, 11929, 11931, 12019, 12032, 12245, 12272, 12287, 12289, 12350, 12353, 12438, 12441, 12543, 12549, 12591, 12593, 12686, 12688, 12773, 12783, 12830, 12832, 12871, 12880, 42124, 42128, 42182, 43360, 43388, 44032, 55203, 63744, 64255, 65040, 65049, 65072, 65106, 65108, 65126, 65128, 65131, 94176, 94180, 94192, 94198, 94208, 101589, 101631, 101662, 101760, 101874, 110576, 110579, 110581, 110587, 110589, 110590, 110592, 110882, 110898, 110898, 110928, 110930, 110933, 110933, 110948, 110951, 110960, 111355, 119552, 119638, 119648, 119670, 126980, 126980, 127183, 127183, 127374, 127374, 127377, 127386, 127488, 127490, 127504, 127547, 127552, 127560, 127568, 127569, 127584, 127589, 127744, 127776, 127789, 127797, 127799, 127868, 127870, 127891, 127904, 127946, 127951, 127955, 127968, 127984, 127988, 127988, 127992, 128062, 128064, 128064, 128066, 128252, 128255, 128317, 128331, 128334, 128336, 128359, 128378, 128378, 128405, 128406, 128420, 128420, 128507, 128591, 128640, 128709, 128716, 128716, 128720, 128722, 128725, 128728, 128732, 128735, 128747, 128748, 128756, 128764, 128992, 129003, 129008, 129008, 129292, 129338, 129340, 129349, 129351, 129535, 129648, 129660, 129664, 129674, 129678, 129734, 129736, 129736, 129741, 129756, 129759, 129770, 129775, 129784, 131072, 196605, 196608, 262141];
|
|
452
|
+
}
|
|
453
|
+
});
|
|
454
|
+
|
|
455
|
+
// node_modules/get-east-asian-width/utilities.js
|
|
456
|
+
var isInRange;
|
|
457
|
+
var init_utilities2 = __esm({
|
|
458
|
+
"node_modules/get-east-asian-width/utilities.js"() {
|
|
459
|
+
isInRange = (ranges, codePoint) => {
|
|
460
|
+
let low = 0;
|
|
461
|
+
let high = Math.floor(ranges.length / 2) - 1;
|
|
462
|
+
while (low <= high) {
|
|
463
|
+
const mid = Math.floor((low + high) / 2);
|
|
464
|
+
const i = mid * 2;
|
|
465
|
+
if (codePoint < ranges[i]) {
|
|
466
|
+
high = mid - 1;
|
|
467
|
+
} else if (codePoint > ranges[i + 1]) {
|
|
468
|
+
low = mid + 1;
|
|
469
|
+
} else {
|
|
470
|
+
return true;
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
return false;
|
|
474
|
+
};
|
|
475
|
+
}
|
|
476
|
+
});
|
|
477
|
+
|
|
438
478
|
// node_modules/get-east-asian-width/lookup.js
|
|
439
|
-
function
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
479
|
+
function findWideFastPathRange(ranges) {
|
|
480
|
+
let fastPathStart = ranges[0];
|
|
481
|
+
let fastPathEnd = ranges[1];
|
|
482
|
+
for (let index = 0; index < ranges.length; index += 2) {
|
|
483
|
+
const start = ranges[index];
|
|
484
|
+
const end = ranges[index + 1];
|
|
485
|
+
if (commonCjkCodePoint >= start && commonCjkCodePoint <= end) {
|
|
486
|
+
return [start, end];
|
|
487
|
+
}
|
|
488
|
+
if (end - start > fastPathEnd - fastPathStart) {
|
|
489
|
+
fastPathStart = start;
|
|
490
|
+
fastPathEnd = end;
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
return [fastPathStart, fastPathEnd];
|
|
444
494
|
}
|
|
495
|
+
var commonCjkCodePoint, wideFastPathStart, wideFastPathEnd, isFullWidth, isWide;
|
|
445
496
|
var init_lookup = __esm({
|
|
446
497
|
"node_modules/get-east-asian-width/lookup.js"() {
|
|
498
|
+
init_lookup_data();
|
|
499
|
+
init_utilities2();
|
|
500
|
+
commonCjkCodePoint = 19968;
|
|
501
|
+
[wideFastPathStart, wideFastPathEnd] = /* @__PURE__ */ findWideFastPathRange(wideRanges);
|
|
502
|
+
isFullWidth = (codePoint) => {
|
|
503
|
+
if (codePoint < fullwidthMinimalCodePoint || codePoint > fullwidthMaximumCodePoint) {
|
|
504
|
+
return false;
|
|
505
|
+
}
|
|
506
|
+
return isInRange(fullwidthRanges, codePoint);
|
|
507
|
+
};
|
|
508
|
+
isWide = (codePoint) => {
|
|
509
|
+
if (codePoint >= wideFastPathStart && codePoint <= wideFastPathEnd) {
|
|
510
|
+
return true;
|
|
511
|
+
}
|
|
512
|
+
if (codePoint < wideMinimalCodePoint || codePoint > wideMaximumCodePoint) {
|
|
513
|
+
return false;
|
|
514
|
+
}
|
|
515
|
+
return isInRange(wideRanges, codePoint);
|
|
516
|
+
};
|
|
447
517
|
}
|
|
448
518
|
});
|
|
449
519
|
|
|
@@ -454,11 +524,12 @@ var init_get_east_asian_width = __esm({
|
|
|
454
524
|
}
|
|
455
525
|
});
|
|
456
526
|
|
|
457
|
-
//
|
|
458
|
-
var
|
|
459
|
-
var
|
|
460
|
-
"
|
|
461
|
-
|
|
527
|
+
// node_modules/narrow-emojis/index.js
|
|
528
|
+
var narrowEmojiRegexp, isNarrowEmojiCharacter;
|
|
529
|
+
var init_narrow_emojis = __esm({
|
|
530
|
+
"node_modules/narrow-emojis/index.js"() {
|
|
531
|
+
narrowEmojiRegexp = /^(?:[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u2764\u27A1\u2934\u2935\u2B05-\u2B07]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF3\uDFF5\uDFF7]|\uD83D[\uDC3F\uDC41\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])$/;
|
|
532
|
+
isNarrowEmojiCharacter = (character) => narrowEmojiRegexp.test(character);
|
|
462
533
|
}
|
|
463
534
|
});
|
|
464
535
|
|
|
@@ -470,11 +541,11 @@ function getStringWidth(text) {
|
|
|
470
541
|
if (!notAsciiRegex.test(text)) {
|
|
471
542
|
return text.length;
|
|
472
543
|
}
|
|
473
|
-
text = text.replace(
|
|
474
|
-
emoji_regex_default(),
|
|
475
|
-
(match) => narrowEmojisSet.has(match) ? " " : " "
|
|
476
|
-
);
|
|
477
544
|
let width = 0;
|
|
545
|
+
text = text.replace(emoji_regex_default(), (character) => {
|
|
546
|
+
width += isNarrowEmojiCharacter(character) ? 1 : 2;
|
|
547
|
+
return "";
|
|
548
|
+
});
|
|
478
549
|
for (const character of text) {
|
|
479
550
|
const codePoint = character.codePointAt(0);
|
|
480
551
|
if (codePoint <= 31 || codePoint >= 127 && codePoint <= 159) {
|
|
@@ -490,14 +561,13 @@ function getStringWidth(text) {
|
|
|
490
561
|
}
|
|
491
562
|
return width;
|
|
492
563
|
}
|
|
493
|
-
var notAsciiRegex,
|
|
564
|
+
var notAsciiRegex, get_string_width_default;
|
|
494
565
|
var init_get_string_width = __esm({
|
|
495
566
|
"src/utilities/get-string-width.js"() {
|
|
496
567
|
init_emoji_regex();
|
|
497
568
|
init_get_east_asian_width();
|
|
498
|
-
|
|
499
|
-
notAsciiRegex = /[^\x20-\x7F]
|
|
500
|
-
narrowEmojisSet = new Set(narrow_emojis_evaluate_default);
|
|
569
|
+
init_narrow_emojis();
|
|
570
|
+
notAsciiRegex = /[^\x20-\x7F]/;
|
|
501
571
|
get_string_width_default = getStringWidth;
|
|
502
572
|
}
|
|
503
573
|
});
|
|
@@ -546,7 +616,7 @@ __export(public_exports, {
|
|
|
546
616
|
getMaxContinuousCount: () => get_max_continuous_count_default,
|
|
547
617
|
getNextNonSpaceNonCommentCharacter: () => get_next_non_space_non_comment_character_default,
|
|
548
618
|
getNextNonSpaceNonCommentCharacterIndex: () => getNextNonSpaceNonCommentCharacterIndex2,
|
|
549
|
-
getPreferredQuote: () =>
|
|
619
|
+
getPreferredQuote: () => getPreferredQuote,
|
|
550
620
|
getStringWidth: () => get_string_width_default,
|
|
551
621
|
hasNewline: () => has_newline_default,
|
|
552
622
|
hasNewlineInRange: () => has_newline_in_range_default,
|
|
@@ -589,7 +659,7 @@ function legacyIsNextLineEmpty(text, node, locEnd) {
|
|
|
589
659
|
}
|
|
590
660
|
function makeString(rawText, enclosingQuote, unescapeUnnecessaryEscapes) {
|
|
591
661
|
const otherQuote = enclosingQuote === '"' ? "'" : '"';
|
|
592
|
-
const regex = /\\(.)|(["'])/
|
|
662
|
+
const regex = /\\(.)|(["'])/gs;
|
|
593
663
|
const raw = method_replace_all_default(
|
|
594
664
|
/* OPTIONAL_OBJECT: false */
|
|
595
665
|
0,
|
|
@@ -605,7 +675,7 @@ function makeString(rawText, enclosingQuote, unescapeUnnecessaryEscapes) {
|
|
|
605
675
|
if (quote) {
|
|
606
676
|
return quote;
|
|
607
677
|
}
|
|
608
|
-
return unescapeUnnecessaryEscapes && /^[^\n\r"'0-7\\bfnrt-vx\u2028\u2029]
|
|
678
|
+
return unescapeUnnecessaryEscapes && /^[^\n\r"'0-7\\bfnrt-vx\u2028\u2029]$/.test(escaped) ? escaped : "\\" + escaped;
|
|
609
679
|
}
|
|
610
680
|
);
|
|
611
681
|
return enclosingQuote + raw + enclosingQuote;
|
|
@@ -648,7 +718,7 @@ __export(version_evaluate_exports, {
|
|
|
648
718
|
var version_evaluate_default;
|
|
649
719
|
var init_version_evaluate = __esm({
|
|
650
720
|
"src/main/version.evaluate.js"() {
|
|
651
|
-
version_evaluate_default = "3.
|
|
721
|
+
version_evaluate_default = "3.9.0";
|
|
652
722
|
}
|
|
653
723
|
});
|
|
654
724
|
|
package/index.d.ts
CHANGED
|
@@ -488,13 +488,19 @@ export interface Printer<T = any> {
|
|
|
488
488
|
print(
|
|
489
489
|
path: AstPath<T>,
|
|
490
490
|
options: ParserOptions<T>,
|
|
491
|
-
print: (
|
|
491
|
+
print: (
|
|
492
|
+
selector?: string | number | Array<string | number> | AstPath<T>,
|
|
493
|
+
args?: unknown,
|
|
494
|
+
) => Doc,
|
|
492
495
|
args?: unknown,
|
|
493
496
|
): Doc;
|
|
494
497
|
printPrettierIgnored?(
|
|
495
498
|
path: AstPath<T>,
|
|
496
499
|
options: ParserOptions<T>,
|
|
497
|
-
print: (
|
|
500
|
+
print: (
|
|
501
|
+
selector?: string | number | Array<string | number> | AstPath<T>,
|
|
502
|
+
args?: unknown,
|
|
503
|
+
) => Doc,
|
|
498
504
|
args?: unknown,
|
|
499
505
|
): Doc;
|
|
500
506
|
embed?:
|
|
@@ -506,6 +512,7 @@ export interface Printer<T = any> {
|
|
|
506
512
|
textToDoc: (text: string, options: Options) => Promise<Doc>,
|
|
507
513
|
print: (
|
|
508
514
|
selector?: string | number | Array<string | number> | AstPath,
|
|
515
|
+
args?: unknown,
|
|
509
516
|
) => Doc,
|
|
510
517
|
path: AstPath,
|
|
511
518
|
options: Options,
|