prettier 2.8.3 → 2.8.5
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 +13 -43
- package/cli.js +1 -1
- package/esm/parser-babel.mjs +20 -20
- package/esm/parser-espree.mjs +20 -20
- package/esm/parser-flow.mjs +26 -26
- package/esm/parser-html.mjs +1 -1
- package/esm/parser-markdown.mjs +1 -1
- package/esm/parser-meriyah.mjs +14 -14
- package/esm/parser-typescript.mjs +40 -248
- package/esm/standalone.mjs +56 -56
- package/index.js +54 -39
- package/package.json +1 -1
- package/parser-babel.js +21 -21
- package/parser-espree.js +19 -19
- package/parser-flow.js +26 -26
- package/parser-html.js +1 -1
- package/parser-markdown.js +1 -1
- package/parser-meriyah.js +14 -14
- package/parser-typescript.js +40 -248
- package/standalone.js +63 -63
package/index.js
CHANGED
|
@@ -18317,8 +18317,12 @@ var require_editorconfig_to_prettier = __commonJS2({
|
|
|
18317
18317
|
} else if (editorConfig.tab_width !== void 0) {
|
|
18318
18318
|
result.tabWidth = editorConfig.tab_width;
|
|
18319
18319
|
}
|
|
18320
|
-
if (editorConfig.max_line_length
|
|
18321
|
-
|
|
18320
|
+
if (editorConfig.max_line_length) {
|
|
18321
|
+
if (editorConfig.max_line_length === "off") {
|
|
18322
|
+
result.printWidth = Number.POSITIVE_INFINITY;
|
|
18323
|
+
} else {
|
|
18324
|
+
result.printWidth = editorConfig.max_line_length;
|
|
18325
|
+
}
|
|
18322
18326
|
}
|
|
18323
18327
|
if (editorConfig.quote_type === "single") {
|
|
18324
18328
|
result.singleQuote = true;
|
|
@@ -23392,6 +23396,16 @@ var require_pragma = __commonJS2({
|
|
|
23392
23396
|
};
|
|
23393
23397
|
}
|
|
23394
23398
|
});
|
|
23399
|
+
var require_is_type_cast_comment = __commonJS2({
|
|
23400
|
+
"src/language-js/utils/is-type-cast-comment.js"(exports2, module2) {
|
|
23401
|
+
"use strict";
|
|
23402
|
+
var isBlockComment = require_is_block_comment();
|
|
23403
|
+
function isTypeCastComment(comment) {
|
|
23404
|
+
return isBlockComment(comment) && comment.value[0] === "*" && /@(?:type|satisfies)\b/.test(comment.value);
|
|
23405
|
+
}
|
|
23406
|
+
module2.exports = isTypeCastComment;
|
|
23407
|
+
}
|
|
23408
|
+
});
|
|
23395
23409
|
var require_comments2 = __commonJS2({
|
|
23396
23410
|
"src/language-js/comments.js"(exports2, module2) {
|
|
23397
23411
|
"use strict";
|
|
@@ -23429,6 +23443,7 @@ var require_comments2 = __commonJS2({
|
|
|
23429
23443
|
locEnd
|
|
23430
23444
|
} = require_loc();
|
|
23431
23445
|
var isBlockComment = require_is_block_comment();
|
|
23446
|
+
var isTypeCastComment = require_is_type_cast_comment();
|
|
23432
23447
|
function handleOwnLineComment(context) {
|
|
23433
23448
|
return [handleIgnoreComments, handleLastFunctionArgComments, handleMemberExpressionComments, handleIfStatementComments, handleWhileComments, handleTryStatementComments, handleClassComments, handleForComments, handleUnionTypeComments, handleOnlyComments, handleModuleSpecifiersComments, handleAssignmentPatternComments, handleMethodNameComments, handleLabeledStatementComments, handleBreakAndContinueStatementComments].some((fn) => fn(context));
|
|
23434
23449
|
}
|
|
@@ -23937,9 +23952,6 @@ var require_comments2 = __commonJS2({
|
|
|
23937
23952
|
return [...node.decorators || [], node.key, node.value.body];
|
|
23938
23953
|
}
|
|
23939
23954
|
}
|
|
23940
|
-
function isTypeCastComment(comment) {
|
|
23941
|
-
return isBlockComment(comment) && comment.value[0] === "*" && /@type\b/.test(comment.value);
|
|
23942
|
-
}
|
|
23943
23955
|
function willPrintOwnComments(path) {
|
|
23944
23956
|
const node = path.getValue();
|
|
23945
23957
|
const parent = path.getParentNode();
|
|
@@ -23950,7 +23962,6 @@ var require_comments2 = __commonJS2({
|
|
|
23950
23962
|
handleOwnLineComment,
|
|
23951
23963
|
handleEndOfLineComment,
|
|
23952
23964
|
handleRemainingComment,
|
|
23953
|
-
isTypeCastComment,
|
|
23954
23965
|
getCommentChildNodes,
|
|
23955
23966
|
willPrintOwnComments
|
|
23956
23967
|
};
|
|
@@ -24037,6 +24048,9 @@ var require_needs_parens = __commonJS2({
|
|
|
24037
24048
|
}
|
|
24038
24049
|
case "Decorator": {
|
|
24039
24050
|
if (name === "expression") {
|
|
24051
|
+
if (isMemberExpression(node) && node.computed) {
|
|
24052
|
+
return true;
|
|
24053
|
+
}
|
|
24040
24054
|
let hasCallExpression = false;
|
|
24041
24055
|
let hasMemberExpression = false;
|
|
24042
24056
|
let current = node;
|
|
@@ -24230,14 +24244,19 @@ var require_needs_parens = __commonJS2({
|
|
|
24230
24244
|
return false;
|
|
24231
24245
|
}
|
|
24232
24246
|
case "TSConditionalType":
|
|
24233
|
-
if (name === "extendsType" && parent.type === "TSConditionalType") {
|
|
24234
|
-
return true;
|
|
24235
|
-
}
|
|
24236
24247
|
case "TSFunctionType":
|
|
24237
24248
|
case "TSConstructorType":
|
|
24238
24249
|
if (name === "extendsType" && parent.type === "TSConditionalType") {
|
|
24239
|
-
|
|
24240
|
-
|
|
24250
|
+
if (node.type === "TSConditionalType") {
|
|
24251
|
+
return true;
|
|
24252
|
+
}
|
|
24253
|
+
let {
|
|
24254
|
+
typeAnnotation
|
|
24255
|
+
} = node.returnType || node.typeAnnotation;
|
|
24256
|
+
if (typeAnnotation.type === "TSTypePredicate" && typeAnnotation.typeAnnotation) {
|
|
24257
|
+
typeAnnotation = typeAnnotation.typeAnnotation.typeAnnotation;
|
|
24258
|
+
}
|
|
24259
|
+
if (typeAnnotation.type === "TSInferType" && typeAnnotation.typeParameter.constraint) {
|
|
24241
24260
|
return true;
|
|
24242
24261
|
}
|
|
24243
24262
|
}
|
|
@@ -24257,6 +24276,8 @@ var require_needs_parens = __commonJS2({
|
|
|
24257
24276
|
return parent.type === "TSArrayType" || parent.type === "TSOptionalType" || parent.type === "TSRestType" || name === "objectType" && parent.type === "TSIndexedAccessType" || parent.type === "TSTypeOperator" || parent.type === "TSTypeAnnotation" && path.getParentNode(1).type.startsWith("TSJSDoc");
|
|
24258
24277
|
case "TSTypeQuery":
|
|
24259
24278
|
return name === "objectType" && parent.type === "TSIndexedAccessType" || name === "elementType" && parent.type === "TSArrayType";
|
|
24279
|
+
case "TypeofTypeAnnotation":
|
|
24280
|
+
return name === "objectType" && (parent.type === "IndexedAccessType" || parent.type === "OptionalIndexedAccessType") || name === "elementType" && parent.type === "ArrayTypeAnnotation";
|
|
24260
24281
|
case "ArrayTypeAnnotation":
|
|
24261
24282
|
return parent.type === "NullableTypeAnnotation";
|
|
24262
24283
|
case "IntersectionTypeAnnotation":
|
|
@@ -24270,8 +24291,6 @@ var require_needs_parens = __commonJS2({
|
|
|
24270
24291
|
}
|
|
24271
24292
|
case "OptionalIndexedAccessType":
|
|
24272
24293
|
return name === "objectType" && parent.type === "IndexedAccessType";
|
|
24273
|
-
case "TypeofTypeAnnotation":
|
|
24274
|
-
return name === "objectType" && (parent.type === "IndexedAccessType" || parent.type === "OptionalIndexedAccessType");
|
|
24275
24294
|
case "StringLiteral":
|
|
24276
24295
|
case "NumericLiteral":
|
|
24277
24296
|
case "Literal":
|
|
@@ -27113,7 +27132,8 @@ var require_type_parameters = __commonJS2({
|
|
|
27113
27132
|
isTSXFile,
|
|
27114
27133
|
shouldPrintComma,
|
|
27115
27134
|
getFunctionParameters,
|
|
27116
|
-
isObjectType
|
|
27135
|
+
isObjectType,
|
|
27136
|
+
getTypeScriptMappedTypeModifier
|
|
27117
27137
|
} = require_utils7();
|
|
27118
27138
|
var {
|
|
27119
27139
|
createGroupIdMapper
|
|
@@ -27159,9 +27179,12 @@ var require_type_parameters = __commonJS2({
|
|
|
27159
27179
|
}
|
|
27160
27180
|
function printTypeParameter(path, options, print) {
|
|
27161
27181
|
const node = path.getValue();
|
|
27162
|
-
const parts = [];
|
|
27182
|
+
const parts = [node.type === "TSTypeParameter" && node.const ? "const " : ""];
|
|
27163
27183
|
const parent = path.getParentNode();
|
|
27164
27184
|
if (parent.type === "TSMappedType") {
|
|
27185
|
+
if (parent.readonly) {
|
|
27186
|
+
parts.push(getTypeScriptMappedTypeModifier(parent.readonly, "readonly"), " ");
|
|
27187
|
+
}
|
|
27165
27188
|
parts.push("[", print("name"));
|
|
27166
27189
|
if (node.constraint) {
|
|
27167
27190
|
parts.push(" in ", print("constraint"));
|
|
@@ -29203,7 +29226,7 @@ var require_typescript = __commonJS2({
|
|
|
29203
29226
|
return [node.operator, " ", print("typeAnnotation")];
|
|
29204
29227
|
case "TSMappedType": {
|
|
29205
29228
|
const shouldBreak = hasNewlineInRange(options.originalText, locStart(node), locEnd(node));
|
|
29206
|
-
return group(["{", indent([options.bracketSpacing ? line : softline,
|
|
29229
|
+
return group(["{", indent([options.bracketSpacing ? line : softline, print("typeParameter"), node.optional ? getTypeScriptMappedTypeModifier(node.optional, "?") : "", node.typeAnnotation ? ": " : "", print("typeAnnotation"), ifBreak(semi)]), printDanglingComments(path, options, true), options.bracketSpacing ? line : softline, "}"], {
|
|
29207
29230
|
shouldBreak
|
|
29208
29231
|
});
|
|
29209
29232
|
}
|
|
@@ -32057,20 +32080,16 @@ var require_clean3 = __commonJS2({
|
|
|
32057
32080
|
module2.exports = clean;
|
|
32058
32081
|
}
|
|
32059
32082
|
});
|
|
32060
|
-
var
|
|
32061
|
-
"
|
|
32062
|
-
module2.exports =
|
|
32063
|
-
htmlVoidElements: ["area", "base", "basefont", "bgsound", "br", "col", "command", "embed", "frame", "hr", "image", "img", "input", "isindex", "keygen", "link", "menuitem", "meta", "nextid", "param", "source", "track", "wbr"]
|
|
32064
|
-
};
|
|
32083
|
+
var require_html_void_elements_evaluate = __commonJS2({
|
|
32084
|
+
"src/language-handlebars/html-void-elements.evaluate.js"(exports2, module2) {
|
|
32085
|
+
module2.exports = ["area", "base", "br", "col", "command", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"];
|
|
32065
32086
|
}
|
|
32066
32087
|
});
|
|
32067
32088
|
var require_utils9 = __commonJS2({
|
|
32068
32089
|
"src/language-handlebars/utils.js"(exports2, module2) {
|
|
32069
32090
|
"use strict";
|
|
32070
|
-
var {
|
|
32071
|
-
htmlVoidElements
|
|
32072
|
-
} = require_html_void_elements();
|
|
32073
32091
|
var getLast = require_get_last();
|
|
32092
|
+
var htmlVoidElements = require_html_void_elements_evaluate();
|
|
32074
32093
|
function isLastNodeOfSiblings(path) {
|
|
32075
32094
|
const node = path.getValue();
|
|
32076
32095
|
const parentNode = path.getParentNode(0);
|
|
@@ -32089,8 +32108,11 @@ var require_utils9 = __commonJS2({
|
|
|
32089
32108
|
return isNodeOfSomeType(node, ["ElementNode"]) && typeof node.tag === "string" && !node.tag.startsWith(":") && (isUppercase(node.tag[0]) || node.tag.includes("."));
|
|
32090
32109
|
}
|
|
32091
32110
|
var voidTags = new Set(htmlVoidElements);
|
|
32111
|
+
function isVoidTag(tag) {
|
|
32112
|
+
return voidTags.has(tag.toLowerCase()) && !isUppercase(tag[0]);
|
|
32113
|
+
}
|
|
32092
32114
|
function isVoid(node) {
|
|
32093
|
-
return
|
|
32115
|
+
return node.selfClosing === true || isVoidTag(node.tag) || isGlimmerComponent(node) && node.children.every((node2) => isWhitespaceNode(node2));
|
|
32094
32116
|
}
|
|
32095
32117
|
function isWhitespaceNode(node) {
|
|
32096
32118
|
return isNodeOfSomeType(node, ["TextNode"]) && !/\S/.test(node.chars);
|
|
@@ -32477,30 +32499,23 @@ var require_printer_glimmer = __commonJS2({
|
|
|
32477
32499
|
}
|
|
32478
32500
|
function printOpenBlock(path, print2) {
|
|
32479
32501
|
const node = path.getValue();
|
|
32480
|
-
const
|
|
32481
|
-
const
|
|
32482
|
-
|
|
32483
|
-
|
|
32484
|
-
if (params) {
|
|
32485
|
-
attributes.push(line, params);
|
|
32502
|
+
const parts = [];
|
|
32503
|
+
const paramsDoc = printParams(path, print2);
|
|
32504
|
+
if (paramsDoc) {
|
|
32505
|
+
parts.push(group(paramsDoc));
|
|
32486
32506
|
}
|
|
32487
32507
|
if (isNonEmptyArray(node.program.blockParams)) {
|
|
32488
|
-
|
|
32489
|
-
attributes.push(line, block);
|
|
32508
|
+
parts.push(printBlockParams(node.program));
|
|
32490
32509
|
}
|
|
32491
|
-
return group([
|
|
32510
|
+
return group([printOpeningBlockOpeningMustache(node), printPath(path, print2), parts.length > 0 ? indent([line, join(line, parts)]) : "", softline, printOpeningBlockClosingMustache(node)]);
|
|
32492
32511
|
}
|
|
32493
32512
|
function printElseBlock(node, options) {
|
|
32494
32513
|
return [options.htmlWhitespaceSensitivity === "ignore" ? hardline : "", printInverseBlockOpeningMustache(node), "else", printInverseBlockClosingMustache(node)];
|
|
32495
32514
|
}
|
|
32496
32515
|
function printElseIfLikeBlock(path, print2, ifLikeKeyword) {
|
|
32497
32516
|
const node = path.getValue();
|
|
32498
|
-
let blockParams = [];
|
|
32499
|
-
if (isNonEmptyArray(node.program.blockParams)) {
|
|
32500
|
-
blockParams = [line, printBlockParams(node.program)];
|
|
32501
|
-
}
|
|
32502
32517
|
const parentNode = path.getParentNode(1);
|
|
32503
|
-
return group([printInverseBlockOpeningMustache(parentNode),
|
|
32518
|
+
return group([printInverseBlockOpeningMustache(parentNode), ["else", " ", ifLikeKeyword], indent([line, group(printParams(path, print2)), ...isNonEmptyArray(node.program.blockParams) ? [line, printBlockParams(node.program)] : []]), softline, printInverseBlockClosingMustache(parentNode)]);
|
|
32504
32519
|
}
|
|
32505
32520
|
function printCloseBlock(path, print2, options) {
|
|
32506
32521
|
const node = path.getValue();
|