@typespec/prettier-plugin-typespec 0.44.0-dev.1 → 0.45.0-dev.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/dist/index.js +30 -23
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1020,6 +1020,21 @@ const diagnostics = {
|
|
|
1020
1020
|
default: paramMessage `${"message"}`,
|
|
1021
1021
|
},
|
|
1022
1022
|
},
|
|
1023
|
+
/**
|
|
1024
|
+
* Init templates
|
|
1025
|
+
*/
|
|
1026
|
+
"init-template-invalid-json": {
|
|
1027
|
+
severity: "error",
|
|
1028
|
+
messages: {
|
|
1029
|
+
default: paramMessage `Unable to parse ${"url"}: ${"message"}. Check that the template URL is correct.`,
|
|
1030
|
+
},
|
|
1031
|
+
},
|
|
1032
|
+
"init-template-download-failed": {
|
|
1033
|
+
severity: "error",
|
|
1034
|
+
messages: {
|
|
1035
|
+
default: paramMessage `Failed to download template from ${"url"}: ${"message"}. Check that the template URL is correct.`,
|
|
1036
|
+
},
|
|
1037
|
+
},
|
|
1023
1038
|
/**
|
|
1024
1039
|
* Parser errors.
|
|
1025
1040
|
*/
|
|
@@ -1043,12 +1058,6 @@ const diagnostics = {
|
|
|
1043
1058
|
topLevel: "Imports must be top-level and come prior to namespaces or other declarations.",
|
|
1044
1059
|
},
|
|
1045
1060
|
},
|
|
1046
|
-
"default-optional": {
|
|
1047
|
-
severity: "error",
|
|
1048
|
-
messages: {
|
|
1049
|
-
default: "Cannot use default with non optional properties",
|
|
1050
|
-
},
|
|
1051
|
-
},
|
|
1052
1061
|
"token-expected": {
|
|
1053
1062
|
severity: "error",
|
|
1054
1063
|
messages: {
|
|
@@ -1517,12 +1526,6 @@ const diagnostics = {
|
|
|
1517
1526
|
default: paramMessage `Requested emitter package ${"emitterPackage"} does not provide an "onEmit" function.`,
|
|
1518
1527
|
},
|
|
1519
1528
|
},
|
|
1520
|
-
"emitter-not-found": {
|
|
1521
|
-
severity: "warning",
|
|
1522
|
-
messages: {
|
|
1523
|
-
default: paramMessage `Emitter with name ${"emitterName"} is not found.`,
|
|
1524
|
-
},
|
|
1525
|
-
},
|
|
1526
1529
|
"missing-import": {
|
|
1527
1530
|
severity: "error",
|
|
1528
1531
|
messages: {
|
|
@@ -1606,6 +1609,14 @@ const diagnostics = {
|
|
|
1606
1609
|
duplicate: paramMessage `Discriminator value "${"discriminator"}" is already used in another variant.`,
|
|
1607
1610
|
},
|
|
1608
1611
|
},
|
|
1612
|
+
"invalid-encode": {
|
|
1613
|
+
severity: "error",
|
|
1614
|
+
messages: {
|
|
1615
|
+
default: "Invalid encoding",
|
|
1616
|
+
wrongType: paramMessage `Encoding '${"encoding"}' cannot be used on type '${"type"}'. Expected: ${"expected"}.`,
|
|
1617
|
+
wrongEncodingType: paramMessage `Encoding '${"encoding"}' on type '${"type"}' is expected to be serialized as '${"expected"}' but got '${"actual"}'.`,
|
|
1618
|
+
},
|
|
1619
|
+
},
|
|
1609
1620
|
/**
|
|
1610
1621
|
* Service
|
|
1611
1622
|
*/
|
|
@@ -2946,6 +2957,7 @@ function addStatementDecoratorComment(comment) {
|
|
|
2946
2957
|
(enclosingNode.kind === SyntaxKind.NamespaceStatement ||
|
|
2947
2958
|
enclosingNode.kind === SyntaxKind.ModelStatement ||
|
|
2948
2959
|
enclosingNode.kind === SyntaxKind.EnumStatement ||
|
|
2960
|
+
enclosingNode.kind === SyntaxKind.OperationStatement ||
|
|
2949
2961
|
enclosingNode.kind === SyntaxKind.ModelProperty ||
|
|
2950
2962
|
enclosingNode.kind === SyntaxKind.EnumMember ||
|
|
2951
2963
|
enclosingNode.kind === SyntaxKind.UnionStatement)) {
|
|
@@ -3229,7 +3241,7 @@ function printComment(commentPath, options) {
|
|
|
3229
3241
|
case SyntaxKind.BlockComment:
|
|
3230
3242
|
return printBlockComment(commentPath, options);
|
|
3231
3243
|
case SyntaxKind.LineComment:
|
|
3232
|
-
return `${options.originalText.slice(comment.pos, comment.end).
|
|
3244
|
+
return `${options.originalText.slice(comment.pos, comment.end).trimEnd()}`;
|
|
3233
3245
|
default:
|
|
3234
3246
|
throw new Error(`Not a comment: ${JSON.stringify(comment)}`);
|
|
3235
3247
|
}
|
|
@@ -4620,9 +4632,6 @@ function createParser(code, options = {}) {
|
|
|
4620
4632
|
parseExpected(Token.Colon);
|
|
4621
4633
|
const value = parseExpression();
|
|
4622
4634
|
const hasDefault = parseOptional(Token.Equals);
|
|
4623
|
-
if (hasDefault && !optional) {
|
|
4624
|
-
error({ code: "default-optional" });
|
|
4625
|
-
}
|
|
4626
4635
|
const defaultValue = hasDefault ? parseExpression() : undefined;
|
|
4627
4636
|
return {
|
|
4628
4637
|
kind: SyntaxKind.ModelProperty,
|
|
@@ -5058,12 +5067,13 @@ function createParser(code, options = {}) {
|
|
|
5058
5067
|
}
|
|
5059
5068
|
function parseNumericLiteral() {
|
|
5060
5069
|
const pos = tokenPos();
|
|
5061
|
-
const
|
|
5062
|
-
const value = Number(
|
|
5070
|
+
const valueAsString = tokenValue();
|
|
5071
|
+
const value = Number(valueAsString);
|
|
5063
5072
|
parseExpected(Token.NumericLiteral);
|
|
5064
5073
|
return {
|
|
5065
5074
|
kind: SyntaxKind.NumericLiteral,
|
|
5066
5075
|
value,
|
|
5076
|
+
valueAsString,
|
|
5067
5077
|
...finishNode(pos),
|
|
5068
5078
|
};
|
|
5069
5079
|
}
|
|
@@ -5664,9 +5674,6 @@ function createParser(code, options = {}) {
|
|
|
5664
5674
|
parseExpected(Token.Colon);
|
|
5665
5675
|
const value = parseProjectionExpression();
|
|
5666
5676
|
const hasDefault = parseOptional(Token.Equals);
|
|
5667
|
-
if (hasDefault && !optional) {
|
|
5668
|
-
error({ code: "default-optional" });
|
|
5669
|
-
}
|
|
5670
5677
|
const defaultValue = hasDefault ? parseProjectionExpression() : undefined;
|
|
5671
5678
|
return {
|
|
5672
5679
|
kind: SyntaxKind.ProjectionModelProperty,
|
|
@@ -5801,7 +5808,7 @@ function createParser(code, options = {}) {
|
|
|
5801
5808
|
};
|
|
5802
5809
|
}
|
|
5803
5810
|
function parseDocList() {
|
|
5804
|
-
if (docRanges.length === 0 ||
|
|
5811
|
+
if (docRanges.length === 0 || options.docs === false) {
|
|
5805
5812
|
return [tokenPos(), []];
|
|
5806
5813
|
}
|
|
5807
5814
|
const docs = [];
|
|
@@ -6321,7 +6328,7 @@ function isBlocklessNamespace(node) {
|
|
|
6321
6328
|
}
|
|
6322
6329
|
|
|
6323
6330
|
function parse(text, parsers, opts) {
|
|
6324
|
-
const result = parse$1(text, { comments: true });
|
|
6331
|
+
const result = parse$1(text, { comments: true, docs: false });
|
|
6325
6332
|
const errors = result.parseDiagnostics.filter((x) => x.severity === "error");
|
|
6326
6333
|
if (errors.length > 0 && !result.printable) {
|
|
6327
6334
|
throw new PrettierParserError(errors[0]);
|