prettier 4.0.0-alpha.7 → 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 -629
- package/bin/prettier.cjs +4 -8
- package/doc.js +30 -39
- package/doc.mjs +30 -39
- package/index.cjs +159 -159
- package/index.d.ts +32 -13
- package/index.mjs +15694 -17412
- package/internal/cli.mjs +1983 -5254
- 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 +13 -13
- package/plugins/graphql.mjs +13 -13
- package/plugins/html.js +19 -16
- package/plugins/html.mjs +19 -16
- package/plugins/markdown.js +47 -44
- package/plugins/markdown.mjs +47 -44
- package/plugins/meriyah.js +4 -5
- package/plugins/meriyah.mjs +4 -5
- package/plugins/postcss.js +32 -29
- package/plugins/postcss.mjs +32 -29
- package/plugins/typescript.js +15 -20
- package/plugins/typescript.mjs +15 -20
- package/plugins/yaml.js +48 -48
- package/plugins/yaml.mjs +48 -48
- package/standalone.js +28 -28
- package/standalone.mjs +28 -28
package/index.cjs
CHANGED
|
@@ -33,6 +33,42 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
33
33
|
));
|
|
34
34
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
35
35
|
|
|
36
|
+
// src/utils/skip.js
|
|
37
|
+
function skip(characters) {
|
|
38
|
+
return (text, startIndex, options) => {
|
|
39
|
+
const backwards = Boolean(options == null ? void 0 : options.backwards);
|
|
40
|
+
if (startIndex === false) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
const { length } = text;
|
|
44
|
+
let cursor = startIndex;
|
|
45
|
+
while (cursor >= 0 && cursor < length) {
|
|
46
|
+
const character = text.charAt(cursor);
|
|
47
|
+
if (characters instanceof RegExp) {
|
|
48
|
+
if (!characters.test(character)) {
|
|
49
|
+
return cursor;
|
|
50
|
+
}
|
|
51
|
+
} else if (!characters.includes(character)) {
|
|
52
|
+
return cursor;
|
|
53
|
+
}
|
|
54
|
+
backwards ? cursor-- : cursor++;
|
|
55
|
+
}
|
|
56
|
+
if (cursor === -1 || cursor === length) {
|
|
57
|
+
return cursor;
|
|
58
|
+
}
|
|
59
|
+
return false;
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
var skipWhitespace, skipSpaces, skipToLineEnd, skipEverythingButNewLine;
|
|
63
|
+
var init_skip = __esm({
|
|
64
|
+
"src/utils/skip.js"() {
|
|
65
|
+
skipWhitespace = skip(/\s/);
|
|
66
|
+
skipSpaces = skip(" ");
|
|
67
|
+
skipToLineEnd = skip(",; ");
|
|
68
|
+
skipEverythingButNewLine = skip(/[^\n\r]/);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
|
|
36
72
|
// src/utils/skip-inline-comment.js
|
|
37
73
|
function skipInlineComment(text, startIndex) {
|
|
38
74
|
if (startIndex === false) {
|
|
@@ -85,42 +121,6 @@ var init_skip_newline = __esm({
|
|
|
85
121
|
}
|
|
86
122
|
});
|
|
87
123
|
|
|
88
|
-
// src/utils/skip.js
|
|
89
|
-
function skip(characters) {
|
|
90
|
-
return (text, startIndex, options) => {
|
|
91
|
-
const backwards = Boolean(options == null ? void 0 : options.backwards);
|
|
92
|
-
if (startIndex === false) {
|
|
93
|
-
return false;
|
|
94
|
-
}
|
|
95
|
-
const { length } = text;
|
|
96
|
-
let cursor = startIndex;
|
|
97
|
-
while (cursor >= 0 && cursor < length) {
|
|
98
|
-
const character = text.charAt(cursor);
|
|
99
|
-
if (characters instanceof RegExp) {
|
|
100
|
-
if (!characters.test(character)) {
|
|
101
|
-
return cursor;
|
|
102
|
-
}
|
|
103
|
-
} else if (!characters.includes(character)) {
|
|
104
|
-
return cursor;
|
|
105
|
-
}
|
|
106
|
-
backwards ? cursor-- : cursor++;
|
|
107
|
-
}
|
|
108
|
-
if (cursor === -1 || cursor === length) {
|
|
109
|
-
return cursor;
|
|
110
|
-
}
|
|
111
|
-
return false;
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
var skipWhitespace, skipSpaces, skipToLineEnd, skipEverythingButNewLine;
|
|
115
|
-
var init_skip = __esm({
|
|
116
|
-
"src/utils/skip.js"() {
|
|
117
|
-
skipWhitespace = skip(/\s/);
|
|
118
|
-
skipSpaces = skip(" ");
|
|
119
|
-
skipToLineEnd = skip(",; ");
|
|
120
|
-
skipEverythingButNewLine = skip(/[^\n\r]/);
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
|
|
124
124
|
// src/utils/skip-trailing-comment.js
|
|
125
125
|
function skipTrailingComment(text, startIndex) {
|
|
126
126
|
if (startIndex === false) {
|
|
@@ -155,32 +155,14 @@ function getNextNonSpaceNonCommentCharacterIndex(text, startIndex) {
|
|
|
155
155
|
var get_next_non_space_non_comment_character_index_default;
|
|
156
156
|
var init_get_next_non_space_non_comment_character_index = __esm({
|
|
157
157
|
"src/utils/get-next-non-space-non-comment-character-index.js"() {
|
|
158
|
+
init_skip();
|
|
158
159
|
init_skip_inline_comment();
|
|
159
160
|
init_skip_newline();
|
|
160
161
|
init_skip_trailing_comment();
|
|
161
|
-
init_skip();
|
|
162
162
|
get_next_non_space_non_comment_character_index_default = getNextNonSpaceNonCommentCharacterIndex;
|
|
163
163
|
}
|
|
164
164
|
});
|
|
165
165
|
|
|
166
|
-
// src/utils/is-previous-line-empty.js
|
|
167
|
-
function isPreviousLineEmpty(text, startIndex) {
|
|
168
|
-
let idx = startIndex - 1;
|
|
169
|
-
idx = skipSpaces(text, idx, { backwards: true });
|
|
170
|
-
idx = skip_newline_default(text, idx, { backwards: true });
|
|
171
|
-
idx = skipSpaces(text, idx, { backwards: true });
|
|
172
|
-
const idx2 = skip_newline_default(text, idx, { backwards: true });
|
|
173
|
-
return idx !== idx2;
|
|
174
|
-
}
|
|
175
|
-
var is_previous_line_empty_default;
|
|
176
|
-
var init_is_previous_line_empty = __esm({
|
|
177
|
-
"src/utils/is-previous-line-empty.js"() {
|
|
178
|
-
init_skip_newline();
|
|
179
|
-
init_skip();
|
|
180
|
-
is_previous_line_empty_default = isPreviousLineEmpty;
|
|
181
|
-
}
|
|
182
|
-
});
|
|
183
|
-
|
|
184
166
|
// src/utils/has-newline.js
|
|
185
167
|
function hasNewline(text, startIndex, options = {}) {
|
|
186
168
|
const idx = skipSpaces(
|
|
@@ -217,15 +199,112 @@ function isNextLineEmpty(text, startIndex) {
|
|
|
217
199
|
var is_next_line_empty_default;
|
|
218
200
|
var init_is_next_line_empty = __esm({
|
|
219
201
|
"src/utils/is-next-line-empty.js"() {
|
|
220
|
-
|
|
202
|
+
init_has_newline();
|
|
221
203
|
init_skip();
|
|
222
204
|
init_skip_inline_comment();
|
|
205
|
+
init_skip_newline();
|
|
223
206
|
init_skip_trailing_comment();
|
|
224
|
-
init_has_newline();
|
|
225
207
|
is_next_line_empty_default = isNextLineEmpty;
|
|
226
208
|
}
|
|
227
209
|
});
|
|
228
210
|
|
|
211
|
+
// src/utils/is-previous-line-empty.js
|
|
212
|
+
function isPreviousLineEmpty(text, startIndex) {
|
|
213
|
+
let idx = startIndex - 1;
|
|
214
|
+
idx = skipSpaces(text, idx, { backwards: true });
|
|
215
|
+
idx = skip_newline_default(text, idx, { backwards: true });
|
|
216
|
+
idx = skipSpaces(text, idx, { backwards: true });
|
|
217
|
+
const idx2 = skip_newline_default(text, idx, { backwards: true });
|
|
218
|
+
return idx !== idx2;
|
|
219
|
+
}
|
|
220
|
+
var is_previous_line_empty_default;
|
|
221
|
+
var init_is_previous_line_empty = __esm({
|
|
222
|
+
"src/utils/is-previous-line-empty.js"() {
|
|
223
|
+
init_skip();
|
|
224
|
+
init_skip_newline();
|
|
225
|
+
is_previous_line_empty_default = isPreviousLineEmpty;
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
// src/main/comments/utils.js
|
|
230
|
+
function describeNodeForDebugging(node) {
|
|
231
|
+
const nodeType = node.type || node.kind || "(unknown type)";
|
|
232
|
+
let nodeName = String(
|
|
233
|
+
node.name || node.id && (typeof node.id === "object" ? node.id.name : node.id) || node.key && (typeof node.key === "object" ? node.key.name : node.key) || node.value && (typeof node.value === "object" ? "" : String(node.value)) || node.operator || ""
|
|
234
|
+
);
|
|
235
|
+
if (nodeName.length > 20) {
|
|
236
|
+
nodeName = nodeName.slice(0, 19) + "\u2026";
|
|
237
|
+
}
|
|
238
|
+
return nodeType + (nodeName ? " " + nodeName : "");
|
|
239
|
+
}
|
|
240
|
+
function addCommentHelper(node, comment) {
|
|
241
|
+
const comments = node.comments ?? (node.comments = []);
|
|
242
|
+
comments.push(comment);
|
|
243
|
+
comment.printed = false;
|
|
244
|
+
comment.nodeDescription = describeNodeForDebugging(node);
|
|
245
|
+
}
|
|
246
|
+
function addLeadingComment(node, comment) {
|
|
247
|
+
comment.leading = true;
|
|
248
|
+
comment.trailing = false;
|
|
249
|
+
addCommentHelper(node, comment);
|
|
250
|
+
}
|
|
251
|
+
function addDanglingComment(node, comment, marker) {
|
|
252
|
+
comment.leading = false;
|
|
253
|
+
comment.trailing = false;
|
|
254
|
+
if (marker) {
|
|
255
|
+
comment.marker = marker;
|
|
256
|
+
}
|
|
257
|
+
addCommentHelper(node, comment);
|
|
258
|
+
}
|
|
259
|
+
function addTrailingComment(node, comment) {
|
|
260
|
+
comment.leading = false;
|
|
261
|
+
comment.trailing = true;
|
|
262
|
+
addCommentHelper(node, comment);
|
|
263
|
+
}
|
|
264
|
+
var init_utils = __esm({
|
|
265
|
+
"src/main/comments/utils.js"() {
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
// src/utils/get-alignment-size.js
|
|
270
|
+
function getAlignmentSize(text, tabWidth, startIndex = 0) {
|
|
271
|
+
let size = 0;
|
|
272
|
+
for (let i = startIndex; i < text.length; ++i) {
|
|
273
|
+
if (text[i] === " ") {
|
|
274
|
+
size = size + tabWidth - size % tabWidth;
|
|
275
|
+
} else {
|
|
276
|
+
size++;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
return size;
|
|
280
|
+
}
|
|
281
|
+
var get_alignment_size_default;
|
|
282
|
+
var init_get_alignment_size = __esm({
|
|
283
|
+
"src/utils/get-alignment-size.js"() {
|
|
284
|
+
get_alignment_size_default = getAlignmentSize;
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
// src/utils/get-indent-size.js
|
|
289
|
+
function getIndentSize(value, tabWidth) {
|
|
290
|
+
const lastNewlineIndex = value.lastIndexOf("\n");
|
|
291
|
+
if (lastNewlineIndex === -1) {
|
|
292
|
+
return 0;
|
|
293
|
+
}
|
|
294
|
+
return get_alignment_size_default(
|
|
295
|
+
// All the leading whitespaces
|
|
296
|
+
value.slice(lastNewlineIndex + 1).match(/^[\t ]*/)[0],
|
|
297
|
+
tabWidth
|
|
298
|
+
);
|
|
299
|
+
}
|
|
300
|
+
var get_indent_size_default;
|
|
301
|
+
var init_get_indent_size = __esm({
|
|
302
|
+
"src/utils/get-indent-size.js"() {
|
|
303
|
+
init_get_alignment_size();
|
|
304
|
+
get_indent_size_default = getIndentSize;
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
|
|
229
308
|
// node_modules/escape-string-regexp/index.js
|
|
230
309
|
function escapeStringRegexp(string) {
|
|
231
310
|
if (typeof string !== "string") {
|
|
@@ -259,6 +338,19 @@ var init_get_max_continuous_count = __esm({
|
|
|
259
338
|
}
|
|
260
339
|
});
|
|
261
340
|
|
|
341
|
+
// src/utils/get-next-non-space-non-comment-character.js
|
|
342
|
+
function getNextNonSpaceNonCommentCharacter(text, startIndex) {
|
|
343
|
+
const index = get_next_non_space_non_comment_character_index_default(text, startIndex);
|
|
344
|
+
return index === false ? "" : text.charAt(index);
|
|
345
|
+
}
|
|
346
|
+
var get_next_non_space_non_comment_character_default;
|
|
347
|
+
var init_get_next_non_space_non_comment_character = __esm({
|
|
348
|
+
"src/utils/get-next-non-space-non-comment-character.js"() {
|
|
349
|
+
init_get_next_non_space_non_comment_character_index();
|
|
350
|
+
get_next_non_space_non_comment_character_default = getNextNonSpaceNonCommentCharacter;
|
|
351
|
+
}
|
|
352
|
+
});
|
|
353
|
+
|
|
262
354
|
// node_modules/emoji-regex/index.mjs
|
|
263
355
|
var emoji_regex_default;
|
|
264
356
|
var init_emoji_regex = __esm({
|
|
@@ -322,45 +414,6 @@ var init_get_string_width = __esm({
|
|
|
322
414
|
}
|
|
323
415
|
});
|
|
324
416
|
|
|
325
|
-
// src/utils/get-alignment-size.js
|
|
326
|
-
function getAlignmentSize(text, tabWidth, startIndex = 0) {
|
|
327
|
-
let size = 0;
|
|
328
|
-
for (let i = startIndex; i < text.length; ++i) {
|
|
329
|
-
if (text[i] === " ") {
|
|
330
|
-
size = size + tabWidth - size % tabWidth;
|
|
331
|
-
} else {
|
|
332
|
-
size++;
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
return size;
|
|
336
|
-
}
|
|
337
|
-
var get_alignment_size_default;
|
|
338
|
-
var init_get_alignment_size = __esm({
|
|
339
|
-
"src/utils/get-alignment-size.js"() {
|
|
340
|
-
get_alignment_size_default = getAlignmentSize;
|
|
341
|
-
}
|
|
342
|
-
});
|
|
343
|
-
|
|
344
|
-
// src/utils/get-indent-size.js
|
|
345
|
-
function getIndentSize(value, tabWidth) {
|
|
346
|
-
const lastNewlineIndex = value.lastIndexOf("\n");
|
|
347
|
-
if (lastNewlineIndex === -1) {
|
|
348
|
-
return 0;
|
|
349
|
-
}
|
|
350
|
-
return get_alignment_size_default(
|
|
351
|
-
// All the leading whitespaces
|
|
352
|
-
value.slice(lastNewlineIndex + 1).match(/^[\t ]*/)[0],
|
|
353
|
-
tabWidth
|
|
354
|
-
);
|
|
355
|
-
}
|
|
356
|
-
var get_indent_size_default;
|
|
357
|
-
var init_get_indent_size = __esm({
|
|
358
|
-
"src/utils/get-indent-size.js"() {
|
|
359
|
-
init_get_alignment_size();
|
|
360
|
-
get_indent_size_default = getIndentSize;
|
|
361
|
-
}
|
|
362
|
-
});
|
|
363
|
-
|
|
364
417
|
// src/utils/has-newline-in-range.js
|
|
365
418
|
function hasNewlineInRange(text, startIndex, endIndex) {
|
|
366
419
|
for (let i = startIndex; i < endIndex; ++i) {
|
|
@@ -394,19 +447,6 @@ var init_has_spaces = __esm({
|
|
|
394
447
|
}
|
|
395
448
|
});
|
|
396
449
|
|
|
397
|
-
// src/utils/get-next-non-space-non-comment-character.js
|
|
398
|
-
function getNextNonSpaceNonCommentCharacter(text, startIndex) {
|
|
399
|
-
const index = get_next_non_space_non_comment_character_index_default(text, startIndex);
|
|
400
|
-
return index === false ? "" : text.charAt(index);
|
|
401
|
-
}
|
|
402
|
-
var get_next_non_space_non_comment_character_default;
|
|
403
|
-
var init_get_next_non_space_non_comment_character = __esm({
|
|
404
|
-
"src/utils/get-next-non-space-non-comment-character.js"() {
|
|
405
|
-
init_get_next_non_space_non_comment_character_index();
|
|
406
|
-
get_next_non_space_non_comment_character_default = getNextNonSpaceNonCommentCharacter;
|
|
407
|
-
}
|
|
408
|
-
});
|
|
409
|
-
|
|
410
450
|
// scripts/build/shims/string-replace-all.js
|
|
411
451
|
var stringReplaceAll, string_replace_all_default;
|
|
412
452
|
var init_string_replace_all = __esm({
|
|
@@ -432,7 +472,7 @@ function makeString(rawText, enclosingQuote, unescapeUnnecessaryEscapes) {
|
|
|
432
472
|
const otherQuote = enclosingQuote === '"' ? "'" : '"';
|
|
433
473
|
const regex = /\\(.)|(["'])/gs;
|
|
434
474
|
const raw = string_replace_all_default(
|
|
435
|
-
/* isOptionalObject*/
|
|
475
|
+
/* isOptionalObject */
|
|
436
476
|
false,
|
|
437
477
|
rawText,
|
|
438
478
|
regex,
|
|
@@ -459,46 +499,6 @@ var init_make_string = __esm({
|
|
|
459
499
|
}
|
|
460
500
|
});
|
|
461
501
|
|
|
462
|
-
// src/main/comments/utils.js
|
|
463
|
-
function describeNodeForDebugging(node) {
|
|
464
|
-
const nodeType = node.type || node.kind || "(unknown type)";
|
|
465
|
-
let nodeName = String(
|
|
466
|
-
node.name || node.id && (typeof node.id === "object" ? node.id.name : node.id) || node.key && (typeof node.key === "object" ? node.key.name : node.key) || node.value && (typeof node.value === "object" ? "" : String(node.value)) || node.operator || ""
|
|
467
|
-
);
|
|
468
|
-
if (nodeName.length > 20) {
|
|
469
|
-
nodeName = nodeName.slice(0, 19) + "\u2026";
|
|
470
|
-
}
|
|
471
|
-
return nodeType + (nodeName ? " " + nodeName : "");
|
|
472
|
-
}
|
|
473
|
-
function addCommentHelper(node, comment) {
|
|
474
|
-
const comments = node.comments ?? (node.comments = []);
|
|
475
|
-
comments.push(comment);
|
|
476
|
-
comment.printed = false;
|
|
477
|
-
comment.nodeDescription = describeNodeForDebugging(node);
|
|
478
|
-
}
|
|
479
|
-
function addLeadingComment(node, comment) {
|
|
480
|
-
comment.leading = true;
|
|
481
|
-
comment.trailing = false;
|
|
482
|
-
addCommentHelper(node, comment);
|
|
483
|
-
}
|
|
484
|
-
function addDanglingComment(node, comment, marker) {
|
|
485
|
-
comment.leading = false;
|
|
486
|
-
comment.trailing = false;
|
|
487
|
-
if (marker) {
|
|
488
|
-
comment.marker = marker;
|
|
489
|
-
}
|
|
490
|
-
addCommentHelper(node, comment);
|
|
491
|
-
}
|
|
492
|
-
function addTrailingComment(node, comment) {
|
|
493
|
-
comment.leading = false;
|
|
494
|
-
comment.trailing = true;
|
|
495
|
-
addCommentHelper(node, comment);
|
|
496
|
-
}
|
|
497
|
-
var init_utils = __esm({
|
|
498
|
-
"src/main/comments/utils.js"() {
|
|
499
|
-
}
|
|
500
|
-
});
|
|
501
|
-
|
|
502
502
|
// src/utils/public.js
|
|
503
503
|
var public_exports = {};
|
|
504
504
|
__export(public_exports, {
|
|
@@ -563,29 +563,29 @@ function isNextLineEmpty2(text, startIndex) {
|
|
|
563
563
|
var init_public = __esm({
|
|
564
564
|
"src/utils/public.js"() {
|
|
565
565
|
init_get_next_non_space_non_comment_character_index();
|
|
566
|
-
init_is_previous_line_empty();
|
|
567
566
|
init_is_next_line_empty();
|
|
568
|
-
|
|
569
|
-
|
|
567
|
+
init_is_previous_line_empty();
|
|
568
|
+
init_utils();
|
|
570
569
|
init_get_alignment_size();
|
|
571
570
|
init_get_indent_size();
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
571
|
+
init_get_max_continuous_count();
|
|
572
|
+
init_get_next_non_space_non_comment_character();
|
|
573
|
+
init_get_string_width();
|
|
575
574
|
init_has_newline();
|
|
576
575
|
init_has_newline_in_range();
|
|
577
576
|
init_has_spaces();
|
|
578
|
-
init_get_next_non_space_non_comment_character();
|
|
579
577
|
init_make_string();
|
|
580
578
|
init_skip();
|
|
581
|
-
|
|
579
|
+
init_skip_inline_comment();
|
|
580
|
+
init_skip_newline();
|
|
581
|
+
init_skip_trailing_comment();
|
|
582
582
|
}
|
|
583
583
|
});
|
|
584
584
|
|
|
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`
|