@tsrx/prettier-plugin 0.3.123 → 0.3.126
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/package.json +6 -6
- package/src/index.js +102 -102
- package/src/index.test.js +33 -33
package/package.json
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsrx/prettier-plugin",
|
|
3
|
-
"version": "0.3.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.3.126",
|
|
4
|
+
"description": "TSRX plugin for Prettier",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "src/index.js",
|
|
7
7
|
"main": "src/index.js",
|
|
8
8
|
"keywords": [
|
|
9
9
|
"prettier",
|
|
10
10
|
"plugin",
|
|
11
|
-
"
|
|
11
|
+
"tsrx",
|
|
12
12
|
"formatter"
|
|
13
13
|
],
|
|
14
|
-
"homepage": "https://
|
|
14
|
+
"homepage": "https://tsrx.dev/",
|
|
15
15
|
"author": "Dominic Gannaway",
|
|
16
16
|
"license": "MIT",
|
|
17
17
|
"repository": {
|
|
18
18
|
"type": "git",
|
|
19
|
-
"url": "git+https://github.com/
|
|
19
|
+
"url": "git+https://github.com/tsrx-org/tsrx.git",
|
|
20
20
|
"directory": "packages/prettier-plugin"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"prettier": "^3.9.6"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@tsrx/core": "0.1.
|
|
30
|
+
"@tsrx/core": "0.1.61"
|
|
31
31
|
},
|
|
32
32
|
"files": [
|
|
33
33
|
"src/"
|
package/src/index.js
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* @typedef {((path: AstPath) => Doc) & ((path: AstPath, args: PrintArgs) => Doc)} PrintFn
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
/** @typedef {Partial<Pick<ParserOptions, 'singleQuote' | 'jsxSingleQuote' | 'semi' | 'trailingComma' | 'useTabs' | 'tabWidth' | 'singleAttributePerLine' | 'bracketSameLine' | 'bracketSpacing' | 'arrowParens' | 'originalText' | 'printWidth'>> & { locStart: (node: AST.NodeWithLocation) => number, locEnd: (node: AST.NodeWithLocation) => number }}
|
|
17
|
+
/** @typedef {Partial<Pick<ParserOptions, 'singleQuote' | 'jsxSingleQuote' | 'semi' | 'trailingComma' | 'useTabs' | 'tabWidth' | 'singleAttributePerLine' | 'bracketSameLine' | 'bracketSpacing' | 'arrowParens' | 'originalText' | 'printWidth'>> & { locStart: (node: AST.NodeWithLocation) => number, locEnd: (node: AST.NodeWithLocation) => number }} TsrxFormatOptions */
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* Any node the parser may hang decorators off. The individual node types do not
|
|
@@ -52,7 +52,7 @@ export const languages = [
|
|
|
52
52
|
name: 'tsrx',
|
|
53
53
|
parsers: ['tsrx'],
|
|
54
54
|
extensions: ['.tsrx'],
|
|
55
|
-
vscodeLanguageIds: ['tsrx'
|
|
55
|
+
vscodeLanguageIds: ['tsrx'],
|
|
56
56
|
},
|
|
57
57
|
];
|
|
58
58
|
|
|
@@ -62,7 +62,7 @@ export const parsers = {
|
|
|
62
62
|
// consumers of prettier/standalone do not need to register PostCSS separately.
|
|
63
63
|
...postcssPlugin.parsers,
|
|
64
64
|
tsrx: {
|
|
65
|
-
astFormat: '
|
|
65
|
+
astFormat: 'tsrx-ast',
|
|
66
66
|
/**
|
|
67
67
|
* @param {string} text
|
|
68
68
|
* @param {ParserOptions<AST.Node | AST.CSS.StyleSheet>} options
|
|
@@ -93,18 +93,18 @@ export const parsers = {
|
|
|
93
93
|
/** @type {import('prettier').Plugin['printers']} */
|
|
94
94
|
export const printers = {
|
|
95
95
|
...postcssPlugin.printers,
|
|
96
|
-
'
|
|
96
|
+
'tsrx-ast': {
|
|
97
97
|
/**
|
|
98
98
|
* @param {AstPath<AST.Node | AST.CSS.StyleSheet>} path
|
|
99
|
-
* @param {
|
|
99
|
+
* @param {TsrxFormatOptions} options
|
|
100
100
|
* @param {PrintFn} print
|
|
101
101
|
* @param {PrintArgs} [args]
|
|
102
102
|
* @returns {Doc}
|
|
103
103
|
*/
|
|
104
104
|
print(path, options, print, args) {
|
|
105
105
|
const node = path.node;
|
|
106
|
-
const parts =
|
|
107
|
-
// If
|
|
106
|
+
const parts = printTsrxNode(node, path, options, print, args);
|
|
107
|
+
// If printTsrxNode returns doc parts, return them directly
|
|
108
108
|
// If it returns a string, wrap it for consistency
|
|
109
109
|
// If it returns an array, concatenate it
|
|
110
110
|
if (Array.isArray(parts)) {
|
|
@@ -199,7 +199,7 @@ export const printers = {
|
|
|
199
199
|
/**
|
|
200
200
|
* Raw-text `<script>` element: the parser stores the verbatim JS/TS body on
|
|
201
201
|
* `content` and mirrors it as a single JSXText child. Checking the tag name
|
|
202
|
-
* alongside `content` matches the other raw-aware consumers (the
|
|
202
|
+
* alongside `content` matches the other raw-aware consumers (the target
|
|
203
203
|
* transforms, the compiler's script regions).
|
|
204
204
|
* @param {AST.TSRXJSXElement | AST.JSXStyleElement | null | undefined} node
|
|
205
205
|
* @returns {boolean}
|
|
@@ -216,7 +216,7 @@ function isRawScriptElement(node) {
|
|
|
216
216
|
/**
|
|
217
217
|
* Format a string literal according to Prettier options
|
|
218
218
|
* @param {string | number | bigint | boolean | RegExp | null | undefined} value - value to format
|
|
219
|
-
* @param {
|
|
219
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
220
220
|
* @returns {string} - The formatted string literal with quotes
|
|
221
221
|
*/
|
|
222
222
|
function formatStringLiteral(value, options) {
|
|
@@ -268,7 +268,7 @@ function formatNumericLiteral(raw) {
|
|
|
268
268
|
|
|
269
269
|
/**
|
|
270
270
|
* Add semicolon based on options.semi setting
|
|
271
|
-
* @param {
|
|
271
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
272
272
|
* @returns {string} - Semicolon or empty string
|
|
273
273
|
*/
|
|
274
274
|
function semi(options) {
|
|
@@ -349,7 +349,7 @@ function getFunctionParameters(node) {
|
|
|
349
349
|
|
|
350
350
|
/**
|
|
351
351
|
* Iterate over function parameters with path callbacks.
|
|
352
|
-
* TypeScript/
|
|
352
|
+
* TypeScript/TSRX functions can have additional `this` and `rest` parameters.
|
|
353
353
|
* @param {AstPath<AST.FunctionExpression | AST.ArrowFunctionExpression | AST.TSDeclareFunction | AST.FunctionDeclaration>} path - The function path
|
|
354
354
|
* @param {(paramPath: AstPath<AST.FunctionExpression | AST.ArrowFunctionExpression | AST.TSDeclareFunction | AST.FunctionDeclaration>, index: number) => void} iteratee - Callback for each parameter
|
|
355
355
|
* @returns {void}
|
|
@@ -668,7 +668,7 @@ function isRegExpLiteral(node) {
|
|
|
668
668
|
/**
|
|
669
669
|
* Check if a comment is followed by a paren on the same line
|
|
670
670
|
* @param {AST.Comment} comment - The comment node
|
|
671
|
-
* @param {
|
|
671
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
672
672
|
* @returns {boolean}
|
|
673
673
|
*/
|
|
674
674
|
function isCommentFollowedBySameLineParen(comment, options) {
|
|
@@ -708,7 +708,7 @@ function hasNewline(text, startIndex, options) {
|
|
|
708
708
|
/**
|
|
709
709
|
* Check if the next line after a node is empty
|
|
710
710
|
* @param {AST.Node | AST.Comment} node - The AST node
|
|
711
|
-
* @param {
|
|
711
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
712
712
|
* @returns {boolean}
|
|
713
713
|
*/
|
|
714
714
|
function isNextLineEmpty(node, options) {
|
|
@@ -748,7 +748,7 @@ function hasRestParameter(node) {
|
|
|
748
748
|
|
|
749
749
|
/**
|
|
750
750
|
* Determine if a trailing comma should be printed based on options
|
|
751
|
-
* @param {
|
|
751
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
752
752
|
* @param {'es5' | 'all'} [level='all'] - Comma level to check
|
|
753
753
|
* @returns {boolean}
|
|
754
754
|
*/
|
|
@@ -830,7 +830,7 @@ function buildInlineArrayCommentDoc(comments) {
|
|
|
830
830
|
* Print an object, method, or class field key
|
|
831
831
|
* @param {AST.Property | AST.MethodDefinition | AST.PropertyDefinition} node - The property or method node
|
|
832
832
|
* @param {AstPath<AST.Property | AST.MethodDefinition | AST.PropertyDefinition>} path - The AST path
|
|
833
|
-
* @param {
|
|
833
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
834
834
|
* @param {PrintFn} print - Print callback
|
|
835
835
|
* @returns {Doc[]}
|
|
836
836
|
*/
|
|
@@ -886,7 +886,7 @@ function getDecorators(node) {
|
|
|
886
886
|
* both change what they decorate and strand the parens.
|
|
887
887
|
* @param {AST.Node} node - The AST node
|
|
888
888
|
* @param {AstPath} path - The AST path
|
|
889
|
-
* @param {
|
|
889
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
890
890
|
* @returns {boolean}
|
|
891
891
|
*/
|
|
892
892
|
function decoratorsPrintedByParent(node, path, options) {
|
|
@@ -925,7 +925,7 @@ function isClassMember(node) {
|
|
|
925
925
|
* Whether a class member's decorators must each go on their own line, which is
|
|
926
926
|
* how they were written when any of them is followed by a newline.
|
|
927
927
|
* @param {AST.Node} node - The decorated node
|
|
928
|
-
* @param {
|
|
928
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
929
929
|
* @returns {boolean}
|
|
930
930
|
*/
|
|
931
931
|
function shouldBreakDecorators(node, options) {
|
|
@@ -951,7 +951,7 @@ function shouldBreakDecorators(node, options) {
|
|
|
951
951
|
* notably — decorators stay inline.
|
|
952
952
|
* @param {AST.Node} node - The decorated node
|
|
953
953
|
* @param {AstPath} path - The AST path, positioned at the decorated node
|
|
954
|
-
* @param {
|
|
954
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
955
955
|
* @param {PrintFn} print - Print callback
|
|
956
956
|
* @returns {Doc[]} The prefix parts, or an empty array when there are none
|
|
957
957
|
*/
|
|
@@ -981,7 +981,7 @@ function printDecorators(node, path, options, print) {
|
|
|
981
981
|
* here — see {@link decoratorsPrintedByParent}.
|
|
982
982
|
* @param {AST.ExportNamedDeclaration | AST.ExportDefaultDeclaration} node - The export node
|
|
983
983
|
* @param {AstPath} path - The AST path
|
|
984
|
-
* @param {
|
|
984
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
985
985
|
* @param {PrintFn} print - Print callback
|
|
986
986
|
* @returns {Doc[]} The prefix parts, or an empty array when there are none
|
|
987
987
|
*/
|
|
@@ -1010,13 +1010,13 @@ function printDeclarationDecorators(node, path, options, print) {
|
|
|
1010
1010
|
|
|
1011
1011
|
/**
|
|
1012
1012
|
* Combine already-printed leading comment parts, a node's printed body, and its
|
|
1013
|
-
* trailing comments into the final Doc returned by {@link
|
|
1013
|
+
* trailing comments into the final Doc returned by {@link printTsrxNode}.
|
|
1014
1014
|
* @param {AST.Node} node - The AST node
|
|
1015
1015
|
* @param {Doc[]} parts - Leading-comment parts already collected for the node
|
|
1016
1016
|
* @param {Doc[] | Doc} nodeContent - The printed body of the node
|
|
1017
1017
|
* @returns {Doc[] | Doc}
|
|
1018
1018
|
*/
|
|
1019
|
-
function
|
|
1019
|
+
function finishTsrxNode(node, parts, nodeContent) {
|
|
1020
1020
|
// Handle trailing comments
|
|
1021
1021
|
if (node.trailingComments) {
|
|
1022
1022
|
const trailingParts = [];
|
|
@@ -1073,15 +1073,15 @@ function finishRippleNode(node, parts, nodeContent) {
|
|
|
1073
1073
|
}
|
|
1074
1074
|
|
|
1075
1075
|
/**
|
|
1076
|
-
* Main print function for
|
|
1076
|
+
* Main print function for TSRX AST nodes
|
|
1077
1077
|
* @param {AST.Node | AST.CSS.StyleSheet} node - The AST node to print
|
|
1078
1078
|
* @param {AstPath} path - The AST path
|
|
1079
|
-
* @param {
|
|
1079
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
1080
1080
|
* @param {PrintFn} print - Print callback
|
|
1081
1081
|
* @param {PrintArgs} [args] - Additional context arguments
|
|
1082
1082
|
* @returns {Doc[] | Doc}
|
|
1083
1083
|
*/
|
|
1084
|
-
function
|
|
1084
|
+
function printTsrxNode(node, path, options, print, args) {
|
|
1085
1085
|
if (!node || typeof node !== 'object') {
|
|
1086
1086
|
return String(node || '');
|
|
1087
1087
|
}
|
|
@@ -1172,7 +1172,7 @@ function printRippleNode(node, path, options, print, args) {
|
|
|
1172
1172
|
typeof ignoreStart === 'number' &&
|
|
1173
1173
|
typeof ignoreEnd === 'number'
|
|
1174
1174
|
) {
|
|
1175
|
-
return
|
|
1175
|
+
return finishTsrxNode(
|
|
1176
1176
|
commentNode,
|
|
1177
1177
|
parts,
|
|
1178
1178
|
replaceEndOfLine(options.originalText.slice(ignoreStart, ignoreEnd)),
|
|
@@ -2844,14 +2844,14 @@ function printRippleNode(node, path, options, print, args) {
|
|
|
2844
2844
|
nodeContent = [...printDecorators(decorated, path, options, print), nodeContent];
|
|
2845
2845
|
}
|
|
2846
2846
|
|
|
2847
|
-
return
|
|
2847
|
+
return finishTsrxNode(/** @type {AST.Node} */ (node), parts, nodeContent);
|
|
2848
2848
|
}
|
|
2849
2849
|
|
|
2850
2850
|
/**
|
|
2851
2851
|
* Print an import declaration
|
|
2852
2852
|
* @param {AST.TSRXImportDeclaration} node - The import declaration node
|
|
2853
2853
|
* @param {AstPath<AST.TSRXImportDeclaration>} path - The AST path
|
|
2854
|
-
* @param {
|
|
2854
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
2855
2855
|
* @param {PrintFn} _print - Print callback (unused)
|
|
2856
2856
|
* @returns {Doc[]}
|
|
2857
2857
|
*/
|
|
@@ -2876,7 +2876,7 @@ function printImportDeclaration(node, path, options, _print) {
|
|
|
2876
2876
|
if (spec.type === 'ImportDefaultSpecifier') {
|
|
2877
2877
|
defaultImports.push(/** @type {string} */ (spec.local.name));
|
|
2878
2878
|
} else if (spec.type === 'ImportSpecifier') {
|
|
2879
|
-
// Handle inline type imports: import { type Component } from '
|
|
2879
|
+
// Handle inline type imports: import { type Component } from '@example/runtime'
|
|
2880
2880
|
const typePrefix = spec.importKind === 'type' ? 'type ' : '';
|
|
2881
2881
|
const importedName = /** @type {AST.Identifier} */ (spec.imported).name;
|
|
2882
2882
|
const localName = spec.local.name;
|
|
@@ -2955,7 +2955,7 @@ function printImportDeclaration(node, path, options, _print) {
|
|
|
2955
2955
|
* Print an export named declaration
|
|
2956
2956
|
* @param {AST.ExportNamedDeclaration} node - The export declaration node
|
|
2957
2957
|
* @param {AstPath<AST.ExportNamedDeclaration>} path - The AST path
|
|
2958
|
-
* @param {
|
|
2958
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
2959
2959
|
* @param {PrintFn} print - Print callback
|
|
2960
2960
|
* @returns {Doc[] | Doc}
|
|
2961
2961
|
*/
|
|
@@ -3009,7 +3009,7 @@ function printExportNamedDeclaration(node, path, options, print) {
|
|
|
3009
3009
|
* Print a variable declaration
|
|
3010
3010
|
* @param {AST.VariableDeclaration} node - The variable declaration node
|
|
3011
3011
|
* @param {AstPath<AST.VariableDeclaration>} path - The AST path
|
|
3012
|
-
* @param {
|
|
3012
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
3013
3013
|
* @param {PrintFn} print - Print callback
|
|
3014
3014
|
* @returns {Doc}
|
|
3015
3015
|
*/
|
|
@@ -3047,7 +3047,7 @@ function printVariableDeclaration(node, path, options, print) {
|
|
|
3047
3047
|
* Print a function expression
|
|
3048
3048
|
* @param {AST.FunctionExpression} node - The function expression node
|
|
3049
3049
|
* @param {AstPath<AST.FunctionExpression>} path - The AST path
|
|
3050
|
-
* @param {
|
|
3050
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
3051
3051
|
* @param {PrintFn} print - Print callback
|
|
3052
3052
|
* @returns {Doc[]}
|
|
3053
3053
|
*/
|
|
@@ -3103,7 +3103,7 @@ function printFunctionExpression(node, path, options, print) {
|
|
|
3103
3103
|
* Print an arrow function expression
|
|
3104
3104
|
* @param {AST.ArrowFunctionExpression} node - The arrow function node
|
|
3105
3105
|
* @param {AstPath<AST.ArrowFunctionExpression>} path - The AST path
|
|
3106
|
-
* @param {
|
|
3106
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
3107
3107
|
* @param {PrintFn} print - Print callback
|
|
3108
3108
|
* @param {PrintArgs} [args] - Additional context arguments
|
|
3109
3109
|
* @returns {Doc}
|
|
@@ -3238,7 +3238,7 @@ function stripComments(text) {
|
|
|
3238
3238
|
* between the keyword and the declaration has to be consulted.
|
|
3239
3239
|
*
|
|
3240
3240
|
* @param {AST.TSRXExportDefaultDeclaration} node - The export default node
|
|
3241
|
-
* @param {
|
|
3241
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
3242
3242
|
* @returns {boolean}
|
|
3243
3243
|
*/
|
|
3244
3244
|
function isParenthesizedDefaultExport(node, options) {
|
|
@@ -3290,7 +3290,7 @@ function isParenthesizedDefaultExport(node, options) {
|
|
|
3290
3290
|
* {@link isParenthesizedDefaultExport}, which reads the source.
|
|
3291
3291
|
*
|
|
3292
3292
|
* @param {AST.TSRXExportDefaultDeclaration} node - The export default node
|
|
3293
|
-
* @param {
|
|
3293
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
3294
3294
|
* @returns {boolean}
|
|
3295
3295
|
*/
|
|
3296
3296
|
function defaultExportNeedsSemicolon(node, options) {
|
|
@@ -3318,7 +3318,7 @@ function defaultExportNeedsSemicolon(node, options) {
|
|
|
3318
3318
|
* Print an export default declaration
|
|
3319
3319
|
* @param {AST.ExportDefaultDeclaration} node - The export default node
|
|
3320
3320
|
* @param {AstPath<AST.ExportDefaultDeclaration>} path - The AST path
|
|
3321
|
-
* @param {
|
|
3321
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
3322
3322
|
* @param {PrintFn} print - Print callback
|
|
3323
3323
|
* @returns {Doc[]}
|
|
3324
3324
|
*/
|
|
@@ -3418,7 +3418,7 @@ function isHuggableParameterType(node) {
|
|
|
3418
3418
|
/**
|
|
3419
3419
|
* Print function parameters with proper formatting
|
|
3420
3420
|
* @param {AstPath<AST.FunctionExpression | AST.ArrowFunctionExpression | AST.TSDeclareFunction | AST.FunctionDeclaration>} path - The function path
|
|
3421
|
-
* @param {
|
|
3421
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
3422
3422
|
* @param {PrintFn} print - Print callback
|
|
3423
3423
|
* @returns {Doc[]}
|
|
3424
3424
|
*/
|
|
@@ -3503,7 +3503,7 @@ function shouldGroupFunctionParameters(functionNode, returnTypeDoc) {
|
|
|
3503
3503
|
* return type, matching vanilla prettier's signature layout.
|
|
3504
3504
|
* @param {AST.FunctionExpression | AST.ArrowFunctionExpression | AST.TSDeclareFunction | AST.FunctionDeclaration} node - The function node
|
|
3505
3505
|
* @param {AstPath<AST.FunctionExpression | AST.ArrowFunctionExpression | AST.TSDeclareFunction | AST.FunctionDeclaration>} path - The function path
|
|
3506
|
-
* @param {
|
|
3506
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
3507
3507
|
* @param {PrintFn} print - Print callback
|
|
3508
3508
|
* @returns {Doc}
|
|
3509
3509
|
*/
|
|
@@ -3620,7 +3620,7 @@ function shouldHugArrowFunctions(args) {
|
|
|
3620
3620
|
/**
|
|
3621
3621
|
* Print call expression arguments
|
|
3622
3622
|
* @param {AstPath<AST.CallExpression>} path - The call path
|
|
3623
|
-
* @param {
|
|
3623
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
3624
3624
|
* @param {PrintFn} print - Print callback
|
|
3625
3625
|
* @returns {Doc}
|
|
3626
3626
|
*/
|
|
@@ -3825,7 +3825,7 @@ function printCallArguments(path, options, print) {
|
|
|
3825
3825
|
* These are function signatures without bodies, ending with semicolon
|
|
3826
3826
|
* @param {AST.TSDeclareFunction} node - The TS function declaration node
|
|
3827
3827
|
* @param {AstPath<AST.TSDeclareFunction>} path - The AST path
|
|
3828
|
-
* @param {
|
|
3828
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
3829
3829
|
* @param {PrintFn} print - Print callback
|
|
3830
3830
|
* @returns {Doc[]}
|
|
3831
3831
|
*/
|
|
@@ -3879,7 +3879,7 @@ function printTSDeclareFunction(node, path, options, print) {
|
|
|
3879
3879
|
* Print a function declaration
|
|
3880
3880
|
* @param {AST.FunctionDeclaration} node - The function declaration node
|
|
3881
3881
|
* @param {AstPath<AST.FunctionDeclaration>} path - The AST path
|
|
3882
|
-
* @param {
|
|
3882
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
3883
3883
|
* @param {PrintFn} print - Print callback
|
|
3884
3884
|
* @returns {Doc[]}
|
|
3885
3885
|
*/
|
|
@@ -3975,7 +3975,7 @@ function extractAndPrintLeadingComments(node) {
|
|
|
3975
3975
|
* Print an if statement
|
|
3976
3976
|
* @param {AST.IfStatement} node - The if statement node
|
|
3977
3977
|
* @param {AstPath<AST.IfStatement>} path - The AST path
|
|
3978
|
-
* @param {
|
|
3978
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
3979
3979
|
* @param {PrintFn} print - Print callback
|
|
3980
3980
|
* @param {boolean} [directive]
|
|
3981
3981
|
* @returns {Doc[]}
|
|
@@ -4051,7 +4051,7 @@ function printIfStatement(node, path, options, print, directive = false) {
|
|
|
4051
4051
|
* Print a for-in statement
|
|
4052
4052
|
* @param {AST.ForInStatement} node - The for-in statement node
|
|
4053
4053
|
* @param {AstPath<AST.ForInStatement>} path - The AST path
|
|
4054
|
-
* @param {
|
|
4054
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
4055
4055
|
* @param {PrintFn} print - Print callback
|
|
4056
4056
|
* @returns {Doc[]}
|
|
4057
4057
|
*/
|
|
@@ -4070,10 +4070,10 @@ function printForInStatement(node, path, options, print) {
|
|
|
4070
4070
|
}
|
|
4071
4071
|
|
|
4072
4072
|
/**
|
|
4073
|
-
* Print a for-of statement (with
|
|
4073
|
+
* Print a for-of statement (with TSRX index/key extensions)
|
|
4074
4074
|
* @param {AST.ForOfStatement} node - The for-of statement node
|
|
4075
4075
|
* @param {AstPath<AST.ForOfStatement>} path - The AST path
|
|
4076
|
-
* @param {
|
|
4076
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
4077
4077
|
* @param {PrintFn} print - Print callback
|
|
4078
4078
|
* @param {boolean} [directive]
|
|
4079
4079
|
* @returns {Doc[]}
|
|
@@ -4086,7 +4086,7 @@ function printForOfStatement(node, path, options, print, directive = false) {
|
|
|
4086
4086
|
parts.push(' of ');
|
|
4087
4087
|
parts.push(path.call(print, 'right'));
|
|
4088
4088
|
|
|
4089
|
-
// Handle
|
|
4089
|
+
// Handle TSRX-specific index syntax
|
|
4090
4090
|
if (node.index) {
|
|
4091
4091
|
parts.push('; index ');
|
|
4092
4092
|
parts.push(path.call(print, 'index'));
|
|
@@ -4111,7 +4111,7 @@ function printForOfStatement(node, path, options, print, directive = false) {
|
|
|
4111
4111
|
* Print a for statement
|
|
4112
4112
|
* @param {AST.ForStatement} node - The for statement node
|
|
4113
4113
|
* @param {AstPath<AST.ForStatement>} path - The AST path
|
|
4114
|
-
* @param {
|
|
4114
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
4115
4115
|
* @param {PrintFn} print - Print callback
|
|
4116
4116
|
* @returns {Doc[]}
|
|
4117
4117
|
*/
|
|
@@ -4149,7 +4149,7 @@ function printForStatement(node, path, options, print) {
|
|
|
4149
4149
|
* Print a while statement
|
|
4150
4150
|
* @param {AST.WhileStatement} node - The while statement node
|
|
4151
4151
|
* @param {AstPath<AST.WhileStatement>} path - The AST path
|
|
4152
|
-
* @param {
|
|
4152
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
4153
4153
|
* @param {PrintFn} print - Print callback
|
|
4154
4154
|
* @returns {Doc[]}
|
|
4155
4155
|
*/
|
|
@@ -4178,7 +4178,7 @@ function printWhileStatement(node, path, options, print) {
|
|
|
4178
4178
|
* Print a do-while statement
|
|
4179
4179
|
* @param {AST.DoWhileStatement} node - The do-while statement node
|
|
4180
4180
|
* @param {AstPath<AST.DoWhileStatement>} path - The AST path
|
|
4181
|
-
* @param {
|
|
4181
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
4182
4182
|
* @param {PrintFn} print - Print callback
|
|
4183
4183
|
* @returns {Doc[]}
|
|
4184
4184
|
*/
|
|
@@ -4215,7 +4215,7 @@ function printDoWhileStatement(node, path, options, print) {
|
|
|
4215
4215
|
* Print an object expression
|
|
4216
4216
|
* @param {AST.ObjectExpression} node - The object expression node
|
|
4217
4217
|
* @param {AstPath<AST.ObjectExpression>} path - The AST path
|
|
4218
|
-
* @param {
|
|
4218
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
4219
4219
|
* @param {PrintFn} print - Print callback
|
|
4220
4220
|
* @param {PrintArgs} [args] - Additional context arguments
|
|
4221
4221
|
* @returns {Doc}
|
|
@@ -4377,7 +4377,7 @@ function printObjectExpression(node, path, options, print, args) {
|
|
|
4377
4377
|
* Print a class declaration
|
|
4378
4378
|
* @param {AST.ClassDeclaration | AST.ClassExpression} node - The class node
|
|
4379
4379
|
* @param {AstPath<AST.ClassDeclaration | AST.ClassExpression>} path - The AST path
|
|
4380
|
-
* @param {
|
|
4380
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
4381
4381
|
* @param {PrintFn} print - Print callback
|
|
4382
4382
|
* @returns {Doc[]}
|
|
4383
4383
|
*/
|
|
@@ -4424,10 +4424,10 @@ function printClassDeclaration(node, path, options, print) {
|
|
|
4424
4424
|
}
|
|
4425
4425
|
|
|
4426
4426
|
/**
|
|
4427
|
-
* Print a try statement (with
|
|
4427
|
+
* Print a try statement (with TSRX pending block extension)
|
|
4428
4428
|
* @param {AST.TryStatement} node - The try statement node
|
|
4429
4429
|
* @param {AstPath<AST.TryStatement>} path - The AST path
|
|
4430
|
-
* @param {
|
|
4430
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
4431
4431
|
* @param {PrintFn} print - Print callback
|
|
4432
4432
|
* @param {boolean} [directive=false] - Whether this is a JSX @try expression.
|
|
4433
4433
|
* @returns {Doc[]}
|
|
@@ -4483,7 +4483,7 @@ function printTryStatement(node, path, options, print, directive = false) {
|
|
|
4483
4483
|
* Print a class body
|
|
4484
4484
|
* @param {AST.ClassBody} node - The class body node
|
|
4485
4485
|
* @param {AstPath<AST.ClassBody>} path - The AST path
|
|
4486
|
-
* @param {
|
|
4486
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
4487
4487
|
* @param {PrintFn} print - Print callback
|
|
4488
4488
|
* @returns {Doc}
|
|
4489
4489
|
*/
|
|
@@ -4516,7 +4516,7 @@ function printClassBody(node, path, options, print) {
|
|
|
4516
4516
|
* Print a class property definition
|
|
4517
4517
|
* @param {AST.PropertyDefinition} node - The property definition node
|
|
4518
4518
|
* @param {AstPath<AST.PropertyDefinition>} path - The AST path
|
|
4519
|
-
* @param {
|
|
4519
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
4520
4520
|
* @param {PrintFn} print - Print callback
|
|
4521
4521
|
* @returns {Doc}
|
|
4522
4522
|
*/
|
|
@@ -4589,7 +4589,7 @@ function printPropertyDefinition(node, path, options, print) {
|
|
|
4589
4589
|
* Print a method definition
|
|
4590
4590
|
* @param {AST.MethodDefinition} node - The method definition node
|
|
4591
4591
|
* @param {AstPath<AST.MethodDefinition>} path - The AST path
|
|
4592
|
-
* @param {
|
|
4592
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
4593
4593
|
* @param {PrintFn} print - Print callback
|
|
4594
4594
|
* @returns {Doc}
|
|
4595
4595
|
*/
|
|
@@ -4681,7 +4681,7 @@ function printMethodDefinition(node, path, options, print) {
|
|
|
4681
4681
|
* Print a member expression (object.property or object[property])
|
|
4682
4682
|
* @param {AST.MemberExpression} node - The member expression node
|
|
4683
4683
|
* @param {AstPath<AST.MemberExpression>} path - The AST path
|
|
4684
|
-
* @param {
|
|
4684
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
4685
4685
|
* @param {PrintFn} print - Print callback
|
|
4686
4686
|
* @param {PrintArgs} [args] - Additional context arguments
|
|
4687
4687
|
* @returns {Doc}
|
|
@@ -4721,7 +4721,7 @@ function printMemberExpression(node, path, options, print, args) {
|
|
|
4721
4721
|
* Print a unary expression
|
|
4722
4722
|
* @param {AST.UnaryExpression} node - The unary expression node
|
|
4723
4723
|
* @param {AstPath<AST.UnaryExpression>} path - The AST path
|
|
4724
|
-
* @param {
|
|
4724
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
4725
4725
|
* @param {PrintFn} print - Print callback
|
|
4726
4726
|
* @returns {Doc[]}
|
|
4727
4727
|
*/
|
|
@@ -4761,7 +4761,7 @@ function printUnaryExpression(node, path, options, print) {
|
|
|
4761
4761
|
* Print a yield expression
|
|
4762
4762
|
* @param {AST.YieldExpression} node - The yield expression node
|
|
4763
4763
|
* @param {AstPath<AST.YieldExpression>} path - The AST path
|
|
4764
|
-
* @param {
|
|
4764
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
4765
4765
|
* @param {PrintFn} print - Print callback
|
|
4766
4766
|
* @returns {Doc[]}
|
|
4767
4767
|
*/
|
|
@@ -4786,7 +4786,7 @@ function printYieldExpression(node, path, options, print) {
|
|
|
4786
4786
|
* Print a new expression
|
|
4787
4787
|
* @param {AST.NewExpression} node - The new expression node
|
|
4788
4788
|
* @param {AstPath<AST.NewExpression>} path - The AST path
|
|
4789
|
-
* @param {
|
|
4789
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
4790
4790
|
* @param {PrintFn} print - Print callback
|
|
4791
4791
|
* @returns {Doc[]}
|
|
4792
4792
|
*/
|
|
@@ -4819,7 +4819,7 @@ function printNewExpression(node, path, options, print) {
|
|
|
4819
4819
|
* Print a template literal
|
|
4820
4820
|
* @param {AST.TemplateLiteral} node - The template literal node
|
|
4821
4821
|
* @param {AstPath<AST.TemplateLiteral>} path - The AST path
|
|
4822
|
-
* @param {
|
|
4822
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
4823
4823
|
* @param {PrintFn} print - Print callback
|
|
4824
4824
|
* @returns {Doc[]}
|
|
4825
4825
|
*/
|
|
@@ -4865,7 +4865,7 @@ function printTemplateLiteral(node, path, options, print) {
|
|
|
4865
4865
|
* Print a tagged template expression
|
|
4866
4866
|
* @param {AST.TaggedTemplateExpression} node - The tagged template node
|
|
4867
4867
|
* @param {AstPath<AST.TaggedTemplateExpression>} path - The AST path
|
|
4868
|
-
* @param {
|
|
4868
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
4869
4869
|
* @param {PrintFn} print - Print callback
|
|
4870
4870
|
* @returns {Doc[]}
|
|
4871
4871
|
*/
|
|
@@ -4881,7 +4881,7 @@ function printTaggedTemplateExpression(node, path, options, print) {
|
|
|
4881
4881
|
* Print a throw statement
|
|
4882
4882
|
* @param {AST.ThrowStatement} node - The throw statement node
|
|
4883
4883
|
* @param {AstPath<AST.ThrowStatement>} path - The AST path
|
|
4884
|
-
* @param {
|
|
4884
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
4885
4885
|
* @param {PrintFn} print - Print callback
|
|
4886
4886
|
* @returns {Doc[]}
|
|
4887
4887
|
*/
|
|
@@ -4936,7 +4936,7 @@ function argumentHasOwnLineLeadingComment(argument) {
|
|
|
4936
4936
|
* Print a TypeScript interface declaration
|
|
4937
4937
|
* @param {AST.TSInterfaceDeclaration} node - The interface declaration node
|
|
4938
4938
|
* @param {AstPath<AST.TSInterfaceDeclaration>} path - The AST path
|
|
4939
|
-
* @param {
|
|
4939
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
4940
4940
|
* @param {PrintFn} print - Print callback
|
|
4941
4941
|
* @returns {Doc[]}
|
|
4942
4942
|
*/
|
|
@@ -4967,7 +4967,7 @@ function printTSInterfaceDeclaration(node, path, options, print) {
|
|
|
4967
4967
|
* Print a TypeScript interface body
|
|
4968
4968
|
* @param {AST.TSInterfaceBody} node - The interface body node
|
|
4969
4969
|
* @param {AstPath<AST.TSInterfaceBody>} path - The AST path
|
|
4970
|
-
* @param {
|
|
4970
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
4971
4971
|
* @param {PrintFn} print - Print callback
|
|
4972
4972
|
* @returns {Doc}
|
|
4973
4973
|
*/
|
|
@@ -4988,7 +4988,7 @@ function printTSInterfaceBody(node, path, options, print) {
|
|
|
4988
4988
|
* Print a TypeScript type alias declaration
|
|
4989
4989
|
* @param {AST.TSTypeAliasDeclaration} node - The type alias node
|
|
4990
4990
|
* @param {AstPath<AST.TSTypeAliasDeclaration>} path - The AST path
|
|
4991
|
-
* @param {
|
|
4991
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
4992
4992
|
* @param {PrintFn} print - Print callback
|
|
4993
4993
|
* @returns {Doc}
|
|
4994
4994
|
*/
|
|
@@ -5040,7 +5040,7 @@ function printTSUnionType(node, path, print, args) {
|
|
|
5040
5040
|
* Print a TypeScript enum declaration
|
|
5041
5041
|
* @param {AST.TSEnumDeclaration} node - The enum declaration node
|
|
5042
5042
|
* @param {AstPath<AST.TSEnumDeclaration>} path - The AST path
|
|
5043
|
-
* @param {
|
|
5043
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
5044
5044
|
* @param {PrintFn} print - Print callback
|
|
5045
5045
|
* @returns {Doc[]}
|
|
5046
5046
|
*/
|
|
@@ -5094,7 +5094,7 @@ function printTSEnumDeclaration(node, path, options, print) {
|
|
|
5094
5094
|
* Print a TypeScript enum member
|
|
5095
5095
|
* @param {AST.TSEnumMember} node - The enum member node
|
|
5096
5096
|
* @param {AstPath<AST.TSEnumMember>} path - The AST path
|
|
5097
|
-
* @param {
|
|
5097
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
5098
5098
|
* @param {PrintFn} print - Print callback
|
|
5099
5099
|
* @returns {Doc[]}
|
|
5100
5100
|
*/
|
|
@@ -5123,7 +5123,7 @@ function printTSEnumMember(node, path, options, print) {
|
|
|
5123
5123
|
* Print TypeScript type parameter declaration (<T, U extends V>)
|
|
5124
5124
|
* @param {AST.TSTypeParameterDeclaration} node - The type parameter declaration node
|
|
5125
5125
|
* @param {AstPath<AST.TSTypeParameterDeclaration>} path - The AST path
|
|
5126
|
-
* @param {
|
|
5126
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
5127
5127
|
* @param {PrintFn} print - Print callback
|
|
5128
5128
|
* @returns {Doc[] | Doc}
|
|
5129
5129
|
*/
|
|
@@ -5159,7 +5159,7 @@ function printTSTypeParameterDeclaration(node, path, options, print) {
|
|
|
5159
5159
|
* Print a single TypeScript type parameter
|
|
5160
5160
|
* @param {AST.TSTypeParameter} node - The type parameter node
|
|
5161
5161
|
* @param {AstPath<AST.TSTypeParameter>} path - The AST path
|
|
5162
|
-
* @param {
|
|
5162
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
5163
5163
|
* @param {PrintFn} print - Print callback
|
|
5164
5164
|
* @returns {Doc[]}
|
|
5165
5165
|
*/
|
|
@@ -5185,7 +5185,7 @@ function printTSTypeParameter(node, path, options, print) {
|
|
|
5185
5185
|
* Print TypeScript type parameter instantiation (<string, number>)
|
|
5186
5186
|
* @param {AST.TSTypeParameterInstantiation} node - The type parameter instantiation node
|
|
5187
5187
|
* @param {AstPath<AST.TSTypeParameterInstantiation>} path - The AST path
|
|
5188
|
-
* @param {
|
|
5188
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
5189
5189
|
* @param {PrintFn} print - Print callback
|
|
5190
5190
|
* @returns {Doc}
|
|
5191
5191
|
*/
|
|
@@ -5234,7 +5234,7 @@ function printTSTypeParameterInstantiation(node, path, options, print) {
|
|
|
5234
5234
|
* Print a switch statement
|
|
5235
5235
|
* @param {AST.SwitchStatement} node - The switch statement node
|
|
5236
5236
|
* @param {AstPath<AST.SwitchStatement>} path - The AST path
|
|
5237
|
-
* @param {
|
|
5237
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
5238
5238
|
* @param {PrintFn} print - Print callback
|
|
5239
5239
|
* @returns {Doc[]}
|
|
5240
5240
|
*/
|
|
@@ -5280,7 +5280,7 @@ function printSwitchStatement(node, path, options, print) {
|
|
|
5280
5280
|
* `case value: { ... }`, unlike ordinary JavaScript switch cases.
|
|
5281
5281
|
* @param {AST.SwitchStatement} node - The switch expression node
|
|
5282
5282
|
* @param {AstPath<AST.SwitchStatement>} path - The AST path
|
|
5283
|
-
* @param {
|
|
5283
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
5284
5284
|
* @param {PrintFn} print - Print callback
|
|
5285
5285
|
* @returns {Doc[]}
|
|
5286
5286
|
*/
|
|
@@ -5317,7 +5317,7 @@ function printJSXSwitchExpression(node, path, options, print) {
|
|
|
5317
5317
|
/**
|
|
5318
5318
|
* @param {AST.SwitchCase} node
|
|
5319
5319
|
* @param {AstPath<AST.SwitchStatement>} path
|
|
5320
|
-
* @param {
|
|
5320
|
+
* @param {TsrxFormatOptions} options
|
|
5321
5321
|
* @param {PrintFn} print
|
|
5322
5322
|
* @param {number} index
|
|
5323
5323
|
* @returns {Doc[]}
|
|
@@ -5351,7 +5351,7 @@ function printJSXSwitchCase(node, path, options, print, index) {
|
|
|
5351
5351
|
* Print a switch case
|
|
5352
5352
|
* @param {AST.SwitchCase} node - The switch case node
|
|
5353
5353
|
* @param {AstPath<AST.SwitchCase>} path - The AST path
|
|
5354
|
-
* @param {
|
|
5354
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
5355
5355
|
* @param {PrintFn} print - Print callback
|
|
5356
5356
|
* @returns {Doc}
|
|
5357
5357
|
*/
|
|
@@ -5425,7 +5425,7 @@ function printSwitchCase(node, path, options, print) {
|
|
|
5425
5425
|
* Print a break statement
|
|
5426
5426
|
* @param {AST.BreakStatement} node - The break statement node
|
|
5427
5427
|
* @param {AstPath<AST.BreakStatement>} path - The AST path
|
|
5428
|
-
* @param {
|
|
5428
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
5429
5429
|
* @param {PrintFn} print - Print callback
|
|
5430
5430
|
* @returns {Doc[]}
|
|
5431
5431
|
*/
|
|
@@ -5445,7 +5445,7 @@ function printBreakStatement(node, path, options, print) {
|
|
|
5445
5445
|
* Print a continue statement
|
|
5446
5446
|
* @param {AST.ContinueStatement} node - The continue statement node
|
|
5447
5447
|
* @param {AstPath<AST.ContinueStatement>} path - The AST path
|
|
5448
|
-
* @param {
|
|
5448
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
5449
5449
|
* @param {PrintFn} print - Print callback
|
|
5450
5450
|
* @returns {Doc[]}
|
|
5451
5451
|
*/
|
|
@@ -5465,7 +5465,7 @@ function printContinueStatement(node, path, options, print) {
|
|
|
5465
5465
|
* Print a debugger statement
|
|
5466
5466
|
* @param {AST.DebuggerStatement} node - The debugger statement node
|
|
5467
5467
|
* @param {AstPath<AST.DebuggerStatement>} path - The AST path
|
|
5468
|
-
* @param {
|
|
5468
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
5469
5469
|
* @returns {string}
|
|
5470
5470
|
*/
|
|
5471
5471
|
function printDebuggerStatement(node, path, options) {
|
|
@@ -5476,7 +5476,7 @@ function printDebuggerStatement(node, path, options) {
|
|
|
5476
5476
|
* Print a sequence expression
|
|
5477
5477
|
* @param {AST.SequenceExpression} node - The sequence expression node
|
|
5478
5478
|
* @param {AstPath<AST.SequenceExpression>} path - The AST path
|
|
5479
|
-
* @param {
|
|
5479
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
5480
5480
|
* @param {PrintFn} print - Print callback
|
|
5481
5481
|
* @returns {Doc[]}
|
|
5482
5482
|
*/
|
|
@@ -5595,7 +5595,7 @@ function shouldAddBlankLine(currentNode, nextNode) {
|
|
|
5595
5595
|
* Print an object pattern (destructuring)
|
|
5596
5596
|
* @param {AST.ObjectPattern} node - The object pattern node
|
|
5597
5597
|
* @param {AstPath<AST.ObjectPattern>} path - The AST path
|
|
5598
|
-
* @param {
|
|
5598
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
5599
5599
|
* @param {PrintFn} print - Print callback
|
|
5600
5600
|
* @returns {Doc}
|
|
5601
5601
|
*/
|
|
@@ -5674,7 +5674,7 @@ function printObjectPattern(node, path, options, print) {
|
|
|
5674
5674
|
* Print an array pattern (destructuring)
|
|
5675
5675
|
* @param {AST.ArrayPattern} node - The array pattern node
|
|
5676
5676
|
* @param {AstPath<AST.ArrayPattern>} path - The AST path
|
|
5677
|
-
* @param {
|
|
5677
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
5678
5678
|
* @param {PrintFn} print - Print callback
|
|
5679
5679
|
* @returns {Doc[]}
|
|
5680
5680
|
*/
|
|
@@ -5701,7 +5701,7 @@ function printArrayPattern(node, path, options, print) {
|
|
|
5701
5701
|
* Print a property (object property or method)
|
|
5702
5702
|
* @param {AST.Property} node - The property node
|
|
5703
5703
|
* @param {AstPath<AST.Property>} path - The AST path
|
|
5704
|
-
* @param {
|
|
5704
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
5705
5705
|
* @param {PrintFn} print - Print callback
|
|
5706
5706
|
* @returns {Doc[] | Doc}
|
|
5707
5707
|
*/
|
|
@@ -5801,7 +5801,7 @@ function printProperty(node, path, options, print) {
|
|
|
5801
5801
|
* Print a variable declarator
|
|
5802
5802
|
* @param {AST.VariableDeclarator} node - The variable declarator node
|
|
5803
5803
|
* @param {AstPath<AST.VariableDeclarator>} path - The AST path
|
|
5804
|
-
* @param {
|
|
5804
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
5805
5805
|
* @param {PrintFn} print - Print callback
|
|
5806
5806
|
* @returns {Doc}
|
|
5807
5807
|
*/
|
|
@@ -5934,7 +5934,7 @@ function printVariableDeclarator(node, path, options, print) {
|
|
|
5934
5934
|
* Print an assignment pattern (default parameter)
|
|
5935
5935
|
* @param {AST.AssignmentPattern} node - The assignment pattern node
|
|
5936
5936
|
* @param {AstPath<AST.AssignmentPattern>} path - The AST path
|
|
5937
|
-
* @param {
|
|
5937
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
5938
5938
|
* @param {PrintFn} print - Print callback
|
|
5939
5939
|
* @returns {Doc}
|
|
5940
5940
|
*/
|
|
@@ -5947,7 +5947,7 @@ function printAssignmentPattern(node, path, options, print) {
|
|
|
5947
5947
|
* Print a TypeScript type literal
|
|
5948
5948
|
* @param {AST.TSTypeLiteral} node - The type literal node
|
|
5949
5949
|
* @param {AstPath<AST.TSTypeLiteral>} path - The AST path
|
|
5950
|
-
* @param {
|
|
5950
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
5951
5951
|
* @param {PrintFn} print - Print callback
|
|
5952
5952
|
* @returns {Doc}
|
|
5953
5953
|
*/
|
|
@@ -5987,7 +5987,7 @@ function printTSTypeLiteral(node, path, options, print) {
|
|
|
5987
5987
|
* Print a TypeScript property signature in an interface
|
|
5988
5988
|
* @param {AST.TSPropertySignature} node - The property signature node
|
|
5989
5989
|
* @param {AstPath<AST.TSPropertySignature>} path - The AST path
|
|
5990
|
-
* @param {
|
|
5990
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
5991
5991
|
* @param {PrintFn} print - Print callback
|
|
5992
5992
|
* @returns {Doc[]}
|
|
5993
5993
|
*/
|
|
@@ -6024,7 +6024,7 @@ function printTSPropertySignature(node, path, options, print) {
|
|
|
6024
6024
|
* Print a TypeScript method signature in an interface
|
|
6025
6025
|
* @param {AST.TSMethodSignature} node - The method signature node
|
|
6026
6026
|
* @param {AstPath<AST.TSMethodSignature>} path - The AST path
|
|
6027
|
-
* @param {
|
|
6027
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
6028
6028
|
* @param {PrintFn} print - Print callback
|
|
6029
6029
|
* @returns {Doc[]}
|
|
6030
6030
|
*/
|
|
@@ -6086,7 +6086,7 @@ function printTSMethodSignature(node, path, options, print) {
|
|
|
6086
6086
|
* Print a TypeScript call signature in an interface
|
|
6087
6087
|
* @param {AST.TSCallSignatureDeclaration} node - The call signature node
|
|
6088
6088
|
* @param {AstPath<AST.TSCallSignatureDeclaration>} path - The AST path
|
|
6089
|
-
* @param {
|
|
6089
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
6090
6090
|
* @param {PrintFn} print - Print callback
|
|
6091
6091
|
* @returns {Doc[]}
|
|
6092
6092
|
*/
|
|
@@ -6126,7 +6126,7 @@ function printTSCallSignatureDeclaration(node, path, options, print) {
|
|
|
6126
6126
|
* Print a TypeScript construct signature in an interface or type literal
|
|
6127
6127
|
* @param {AST.TSConstructSignatureDeclaration} node - The construct signature node
|
|
6128
6128
|
* @param {AstPath<AST.TSConstructSignatureDeclaration>} path - The AST path
|
|
6129
|
-
* @param {
|
|
6129
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
6130
6130
|
* @param {PrintFn} print - Print callback
|
|
6131
6131
|
* @returns {Doc[]}
|
|
6132
6132
|
*/
|
|
@@ -6165,7 +6165,7 @@ function printTSConstructSignatureDeclaration(node, path, options, print) {
|
|
|
6165
6165
|
* Print a TypeScript type reference (e.g., Array<string>)
|
|
6166
6166
|
* @param {AST.TSTypeReference} node - The type reference node
|
|
6167
6167
|
* @param {AstPath<AST.TSTypeReference>} path - The AST path
|
|
6168
|
-
* @param {
|
|
6168
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
6169
6169
|
* @param {PrintFn} print - Print callback
|
|
6170
6170
|
* @returns {Doc[]}
|
|
6171
6171
|
*/
|
|
@@ -6192,7 +6192,7 @@ function printTSTypeReference(node, path, options, print) {
|
|
|
6192
6192
|
* Print a TypeScript tuple type
|
|
6193
6193
|
* @param {AST.TSTupleType} node - The tuple type node
|
|
6194
6194
|
* @param {AstPath<AST.TSTupleType>} path - The AST path
|
|
6195
|
-
* @param {
|
|
6195
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
6196
6196
|
* @param {PrintFn} print - Print callback
|
|
6197
6197
|
* @returns {Doc[]}
|
|
6198
6198
|
*/
|
|
@@ -6212,7 +6212,7 @@ function printTSTupleType(node, path, options, print) {
|
|
|
6212
6212
|
* Print a TypeScript named tuple member
|
|
6213
6213
|
* @param {AST.TSNamedTupleMember} node - The named tuple member node
|
|
6214
6214
|
* @param {AstPath<AST.TSNamedTupleMember>} path - The AST path
|
|
6215
|
-
* @param {
|
|
6215
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
6216
6216
|
* @param {PrintFn} print - Print callback
|
|
6217
6217
|
* @returns {Doc[]}
|
|
6218
6218
|
*/
|
|
@@ -6229,7 +6229,7 @@ function printTSNamedTupleMember(node, path, options, print) {
|
|
|
6229
6229
|
* Print a TypeScript index signature
|
|
6230
6230
|
* @param {AST.TSIndexSignature} node - The index signature node
|
|
6231
6231
|
* @param {AstPath<AST.TSIndexSignature>} path - The AST path
|
|
6232
|
-
* @param {
|
|
6232
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
6233
6233
|
* @param {PrintFn} print - Print callback
|
|
6234
6234
|
* @returns {Doc[]}
|
|
6235
6235
|
*/
|
|
@@ -6260,7 +6260,7 @@ function printTSIndexSignature(node, path, options, print) {
|
|
|
6260
6260
|
* Print a TypeScript constructor type
|
|
6261
6261
|
* @param {AST.TSConstructorType} node - The constructor type node
|
|
6262
6262
|
* @param {AstPath<AST.TSConstructorType>} path - The AST path
|
|
6263
|
-
* @param {
|
|
6263
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
6264
6264
|
* @param {PrintFn} print - Print callback
|
|
6265
6265
|
* @returns {Doc[]}
|
|
6266
6266
|
*/
|
|
@@ -6293,7 +6293,7 @@ function printTSConstructorType(node, path, options, print) {
|
|
|
6293
6293
|
* Print a TypeScript conditional type
|
|
6294
6294
|
* @param {AST.TSConditionalType} node - The conditional type node
|
|
6295
6295
|
* @param {AstPath<AST.TSConditionalType>} path - The AST path
|
|
6296
|
-
* @param {
|
|
6296
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
6297
6297
|
* @param {PrintFn} print - Print callback
|
|
6298
6298
|
* @returns {Doc}
|
|
6299
6299
|
*/
|
|
@@ -6317,7 +6317,7 @@ function printTSConditionalType(node, path, options, print) {
|
|
|
6317
6317
|
* Print a TypeScript mapped type
|
|
6318
6318
|
* @param {AST.TSMappedType} node - The mapped type node
|
|
6319
6319
|
* @param {AstPath<AST.TSMappedType>} path - The AST path
|
|
6320
|
-
* @param {
|
|
6320
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
6321
6321
|
* @param {PrintFn} print - Print callback
|
|
6322
6322
|
* @returns {Doc[] | Doc}
|
|
6323
6323
|
*/
|
|
@@ -6367,7 +6367,7 @@ function printTSMappedType(node, path, options, print) {
|
|
|
6367
6367
|
/**
|
|
6368
6368
|
* @param {AST.TSQualifiedName} node
|
|
6369
6369
|
* @param {AstPath<AST.TSQualifiedName>} path
|
|
6370
|
-
* @param {
|
|
6370
|
+
* @param {TsrxFormatOptions} options
|
|
6371
6371
|
* @param {PrintFn} print
|
|
6372
6372
|
* @returns {Doc}
|
|
6373
6373
|
*/
|
|
@@ -6378,7 +6378,7 @@ function printTSQualifiedName(node, path, options, print) {
|
|
|
6378
6378
|
/**
|
|
6379
6379
|
* @param {AST.TSImportType} node
|
|
6380
6380
|
* @param {AstPath<AST.TSImportType>} path
|
|
6381
|
-
* @param {
|
|
6381
|
+
* @param {TsrxFormatOptions} options
|
|
6382
6382
|
* @param {PrintFn} print
|
|
6383
6383
|
* @returns {Doc}
|
|
6384
6384
|
*/
|
|
@@ -6400,7 +6400,7 @@ function printTSImportType(node, path, options, print) {
|
|
|
6400
6400
|
/**
|
|
6401
6401
|
* @param {AST.TSIndexedAccessType} node
|
|
6402
6402
|
* @param {AstPath<AST.TSIndexedAccessType>} path
|
|
6403
|
-
* @param {
|
|
6403
|
+
* @param {TsrxFormatOptions} options
|
|
6404
6404
|
* @param {PrintFn} print
|
|
6405
6405
|
* @returns {Doc}
|
|
6406
6406
|
*/
|
|
@@ -6550,7 +6550,7 @@ function isSimpleJSXExpressionChild(child) {
|
|
|
6550
6550
|
* Print a JSX element
|
|
6551
6551
|
* @param {AST.TSRXJSXElement | AST.JSXStyleElement} node - The JSX element node
|
|
6552
6552
|
* @param {AstPath<AST.TSRXJSXElement>} path - The AST path
|
|
6553
|
-
* @param {
|
|
6553
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
6554
6554
|
* @param {PrintFn} print - Print callback
|
|
6555
6555
|
* @returns {Doc | Doc[]}
|
|
6556
6556
|
*/
|
|
@@ -6899,7 +6899,7 @@ function printJSXElement(node, path, options, print) {
|
|
|
6899
6899
|
* Print a JSX fragment (<>...</>)
|
|
6900
6900
|
* @param {AST.TSRXJSXFragment} node - The JSX fragment node
|
|
6901
6901
|
* @param {AstPath<AST.TSRXJSXFragment>} path - The AST path
|
|
6902
|
-
* @param {
|
|
6902
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
6903
6903
|
* @param {PrintFn} print - Print callback
|
|
6904
6904
|
* @returns {Doc}
|
|
6905
6905
|
*/
|
|
@@ -7199,7 +7199,7 @@ function printElementBodyComments(commentList, previousNode = null) {
|
|
|
7199
7199
|
* on its own as an arrow body it stands alone.
|
|
7200
7200
|
* @param {AST.JSXCodeBlock} node
|
|
7201
7201
|
* @param {AstPath<AST.JSXCodeBlock>} path
|
|
7202
|
-
* @param {
|
|
7202
|
+
* @param {TsrxFormatOptions} options
|
|
7203
7203
|
* @param {PrintFn} print
|
|
7204
7204
|
* @returns {Doc}
|
|
7205
7205
|
*/
|
|
@@ -7247,7 +7247,7 @@ function printJSXCodeBlock(node, path, options, print) {
|
|
|
7247
7247
|
* Print a JSX attribute
|
|
7248
7248
|
* @param {ESTreeJSX.JSXAttribute} attr - The JSX attribute node
|
|
7249
7249
|
* @param {AstPath<ESTreeJSX.JSXAttribute>} path - The AST path
|
|
7250
|
-
* @param {
|
|
7250
|
+
* @param {TsrxFormatOptions} options - Prettier options
|
|
7251
7251
|
* @param {PrintFn} print - Print callback
|
|
7252
7252
|
* @returns {Doc | Doc[]}
|
|
7253
7253
|
*/
|
package/src/index.test.js
CHANGED
|
@@ -136,7 +136,7 @@ const items=[1,2,3];
|
|
|
136
136
|
it('formats setup statements and wrapped render output in a fragment code block', async () => {
|
|
137
137
|
const input = `function SetTest() {
|
|
138
138
|
return <>@{
|
|
139
|
-
let items = new
|
|
139
|
+
let items = new ReactiveSet([1, 2, 3]);
|
|
140
140
|
let &[hasValue] = track(() => items.has(2));
|
|
141
141
|
<>
|
|
142
142
|
<button onClick={() => items.delete(2)}>{'delete'}</button>
|
|
@@ -146,7 +146,7 @@ const items=[1,2,3];
|
|
|
146
146
|
}`;
|
|
147
147
|
const expected = `function SetTest() {
|
|
148
148
|
return <>@{
|
|
149
|
-
let items = new
|
|
149
|
+
let items = new ReactiveSet([1, 2, 3]);
|
|
150
150
|
let &[hasValue] = track(() => items.has(2));
|
|
151
151
|
<>
|
|
152
152
|
<button onClick={() => items.delete(2)}>{"delete"}</button>
|
|
@@ -1718,10 +1718,10 @@ async function load() {
|
|
|
1718
1718
|
});
|
|
1719
1719
|
|
|
1720
1720
|
it('should handle import type statements', async () => {
|
|
1721
|
-
const input = `import { type Component } from '
|
|
1722
|
-
import { Something, type Props, track } from '
|
|
1723
|
-
const expected = `import { type Component } from '
|
|
1724
|
-
import { Something, type Props, track } from '
|
|
1721
|
+
const input = `import { type Component } from '@example/runtime';
|
|
1722
|
+
import { Something, type Props, track } from '@example/runtime';`;
|
|
1723
|
+
const expected = `import { type Component } from '@example/runtime';
|
|
1724
|
+
import { Something, type Props, track } from '@example/runtime';`;
|
|
1725
1725
|
const result = await format(input, { singleQuote: true });
|
|
1726
1726
|
expect(result).toBeWithNewline(expected);
|
|
1727
1727
|
});
|
|
@@ -1784,7 +1784,7 @@ function assertTruthy(x: unknown): asserts x {}`;
|
|
|
1784
1784
|
});
|
|
1785
1785
|
|
|
1786
1786
|
it('should format long import statements correctly', async () => {
|
|
1787
|
-
const input = `import { flushSync, track, effect, bindValue, bindChecked, bindGroup, bindClientWidth, bindClientHeight, bindOffsetWidth, bindOffsetHeight, bindContentRect, bindContentBoxSize, bindBorderBoxSize, bindDevicePixelContentBoxSize, bindInnerHTML, bindInnerText, bindTextContent, bindNode } from '
|
|
1787
|
+
const input = `import { flushSync, track, effect, bindValue, bindChecked, bindGroup, bindClientWidth, bindClientHeight, bindOffsetWidth, bindOffsetHeight, bindContentRect, bindContentBoxSize, bindBorderBoxSize, bindDevicePixelContentBoxSize, bindInnerHTML, bindInnerText, bindTextContent, bindNode } from '@example/runtime';`;
|
|
1788
1788
|
const expected = `import {
|
|
1789
1789
|
flushSync,
|
|
1790
1790
|
track,
|
|
@@ -1804,7 +1804,7 @@ function assertTruthy(x: unknown): asserts x {}`;
|
|
|
1804
1804
|
bindInnerText,
|
|
1805
1805
|
bindTextContent,
|
|
1806
1806
|
bindNode,
|
|
1807
|
-
} from '
|
|
1807
|
+
} from '@example/runtime';`;
|
|
1808
1808
|
|
|
1809
1809
|
const result = await format(input, { singleQuote: true, printWidth: 80 });
|
|
1810
1810
|
expect(result).toBeWithNewline(expected);
|
|
@@ -1921,7 +1921,7 @@ export function Test({ a, b }: Props) {}`;
|
|
|
1921
1921
|
const expected = `// comment
|
|
1922
1922
|
|
|
1923
1923
|
import { useCount, incrementCount } from './useCount';
|
|
1924
|
-
import { effect, track } from '
|
|
1924
|
+
import { effect, track } from '@example/runtime';`;
|
|
1925
1925
|
|
|
1926
1926
|
const result = await format(expected, { singleQuote: true, printWidth: 100 });
|
|
1927
1927
|
expect(result).toBeWithNewline(expected);
|
|
@@ -2194,9 +2194,9 @@ const [obj1, obj2] = arrayOfObjects;`;
|
|
|
2194
2194
|
expect(result).toBeWithNewline(expected);
|
|
2195
2195
|
});
|
|
2196
2196
|
|
|
2197
|
-
it('should keep
|
|
2198
|
-
const expected = `const map = new
|
|
2199
|
-
const set = new
|
|
2197
|
+
it('should keep ReactiveMap short syntax intact', async () => {
|
|
2198
|
+
const expected = `const map = new ReactiveMap([['key1', 'value1'], ['key2', 'value2']]);
|
|
2199
|
+
const set = new ReactiveSet([1, 2, 3]);`;
|
|
2200
2200
|
|
|
2201
2201
|
const result = await format(expected, { singleQuote: true, printWidth: 100 });
|
|
2202
2202
|
expect(result).toBeWithNewline(expected);
|
|
@@ -2251,7 +2251,7 @@ enum Status {
|
|
|
2251
2251
|
getRootNode?: GetRootNode | undefined;
|
|
2252
2252
|
}
|
|
2253
2253
|
|
|
2254
|
-
import { Portal as
|
|
2254
|
+
import { Portal as RuntimePortal } from '@example/runtime';`;
|
|
2255
2255
|
|
|
2256
2256
|
const result = await format(expected, { singleQuote: true, printWidth: 100 });
|
|
2257
2257
|
expect(result).toBeWithNewline(expected);
|
|
@@ -2260,7 +2260,7 @@ import { Portal as RipplePortal } from 'ripple';`;
|
|
|
2260
2260
|
it('should preserve blank lines between export statements and import statements or comments', async () => {
|
|
2261
2261
|
const expected = `export { handler } from './test.tsrx';
|
|
2262
2262
|
|
|
2263
|
-
import { Portal as
|
|
2263
|
+
import { Portal as RuntimePortal } from '@example/runtime';
|
|
2264
2264
|
|
|
2265
2265
|
// export { something } from './test.tsrx;
|
|
2266
2266
|
|
|
@@ -2271,7 +2271,7 @@ import { GetRootNode } from './somewhere';`;
|
|
|
2271
2271
|
});
|
|
2272
2272
|
|
|
2273
2273
|
it('should preserve export interface with extends as provided', async () => {
|
|
2274
|
-
const expected = `export interface
|
|
2274
|
+
const expected = `export interface ReactiveArray<T> extends Array<T> {}`;
|
|
2275
2275
|
|
|
2276
2276
|
const result = await format(expected, { singleQuote: true, printWidth: 100 });
|
|
2277
2277
|
expect(result).toBeWithNewline(expected);
|
|
@@ -2283,7 +2283,7 @@ import { GetRootNode } from './somewhere';`;
|
|
|
2283
2283
|
* @param {'contentRect' | 'contentBoxSize' | 'borderBoxSize' | 'devicePixelContentBoxSize'} type
|
|
2284
2284
|
*/
|
|
2285
2285
|
function bind_element_rect(maybe_tracked, type) {
|
|
2286
|
-
if (!
|
|
2286
|
+
if (!is_tsrx_object(maybe_tracked)) {
|
|
2287
2287
|
throw not_tracked_type_error(\`bind\${type.charAt(0).toUpperCase() + type.slice(1)}()\`);
|
|
2288
2288
|
}
|
|
2289
2289
|
|
|
@@ -3062,7 +3062,7 @@ function Qux() {
|
|
|
3062
3062
|
|
|
3063
3063
|
it('keeps dynamic import TSImportType intact', async () => {
|
|
3064
3064
|
const expected = `let streamed_error: Error | null = null;
|
|
3065
|
-
const sink: import('
|
|
3065
|
+
const sink: import('@example/runtime/server').SSRStreamSink = {
|
|
3066
3066
|
push(_chunk: string) {},
|
|
3067
3067
|
close() {},
|
|
3068
3068
|
error(reason: unknown) {
|
|
@@ -3126,7 +3126,7 @@ let message: string[] = [];
|
|
|
3126
3126
|
|
|
3127
3127
|
// comments should be preserved
|
|
3128
3128
|
|
|
3129
|
-
message.push(greet(\`
|
|
3129
|
+
message.push(greet(\`TSRX\`));
|
|
3130
3130
|
message.push(\`User: \${JSON.stringify({ name: 'Alice', age: 30 } as User)}\`);`;
|
|
3131
3131
|
|
|
3132
3132
|
const expected = `type User = { name: string; age: number };
|
|
@@ -3134,7 +3134,7 @@ let message: string[] = [];
|
|
|
3134
3134
|
|
|
3135
3135
|
// comments should be preserved
|
|
3136
3136
|
|
|
3137
|
-
message.push(greet(\`
|
|
3137
|
+
message.push(greet(\`TSRX\`));
|
|
3138
3138
|
message.push(\`User: \${JSON.stringify({ name: "Alice", age: 30 } as User)}\`);`;
|
|
3139
3139
|
|
|
3140
3140
|
const result = await format(input);
|
|
@@ -3144,12 +3144,12 @@ message.push(\`User: \${JSON.stringify({ name: "Alice", age: 30 } as User)}\`);`
|
|
|
3144
3144
|
it('should correctly handle inline jsx like comments', async () => {
|
|
3145
3145
|
const input = `let message: string[] = []; // comments should be preserved
|
|
3146
3146
|
|
|
3147
|
-
message.push(/* Some test comment */ greet(\`
|
|
3147
|
+
message.push(/* Some test comment */ greet(\`TSRX\`));
|
|
3148
3148
|
`;
|
|
3149
3149
|
|
|
3150
3150
|
const expected = `let message: string[] = []; // comments should be preserved
|
|
3151
3151
|
|
|
3152
|
-
message.push(/* Some test comment */ greet(\`
|
|
3152
|
+
message.push(/* Some test comment */ greet(\`TSRX\`));`;
|
|
3153
3153
|
|
|
3154
3154
|
const result = await format(input);
|
|
3155
3155
|
expect(result).toBeWithNewline(expected);
|
|
@@ -3158,12 +3158,12 @@ message.push(/* Some test comment */ greet(\`Ripple\`));`;
|
|
|
3158
3158
|
it('should correctly handle inline document like comments', async () => {
|
|
3159
3159
|
const input = `let message: string[] = []; // comments should be preserved
|
|
3160
3160
|
|
|
3161
|
-
message.push(/* Some test comment */ greet( /* Some text */ \`
|
|
3161
|
+
message.push(/* Some test comment */ greet( /* Some text */ \`TSRX\`));
|
|
3162
3162
|
`;
|
|
3163
3163
|
|
|
3164
3164
|
const expected = `let message: string[] = []; // comments should be preserved
|
|
3165
3165
|
|
|
3166
|
-
message.push(/* Some test comment */ greet(/* Some text */ \`
|
|
3166
|
+
message.push(/* Some test comment */ greet(/* Some text */ \`TSRX\`));`;
|
|
3167
3167
|
|
|
3168
3168
|
const result = await format(input);
|
|
3169
3169
|
expect(result).toBeWithNewline(expected);
|
|
@@ -5538,7 +5538,7 @@ function Polygon() {
|
|
|
5538
5538
|
expect(result).toBeWithNewline(expected);
|
|
5539
5539
|
});
|
|
5540
5540
|
|
|
5541
|
-
it('should format template arrow returns in
|
|
5541
|
+
it('should format template arrow returns in TSX attributes like TSRX attributes', async () => {
|
|
5542
5542
|
const input = `function Test(props) {
|
|
5543
5543
|
const view = <>
|
|
5544
5544
|
<List
|
|
@@ -5905,9 +5905,9 @@ if (status === 'a') status = 'b'; else if (status === 'b') status = 'c'; else st
|
|
|
5905
5905
|
expect(result).toBeWithNewline(expected);
|
|
5906
5906
|
});
|
|
5907
5907
|
|
|
5908
|
-
it('should keep
|
|
5908
|
+
it('should keep ReactiveSet parents with short syntax and no args intact', async () => {
|
|
5909
5909
|
const expected = `function SetTest() @{
|
|
5910
|
-
let items = new
|
|
5910
|
+
let items = new ReactiveSet();
|
|
5911
5911
|
|
|
5912
5912
|
<>
|
|
5913
5913
|
<button onClick={() => items.add(1)}>{'add'}</button>
|
|
@@ -5919,9 +5919,9 @@ if (status === 'a') status = 'b'; else if (status === 'b') status = 'c'; else st
|
|
|
5919
5919
|
expect(result).toBeWithNewline(expected);
|
|
5920
5920
|
});
|
|
5921
5921
|
|
|
5922
|
-
it('should keep
|
|
5922
|
+
it('should keep ReactiveMap parents with short syntax and no args intact', async () => {
|
|
5923
5923
|
const expected = `function MapTest() @{
|
|
5924
|
-
let items = new
|
|
5924
|
+
let items = new ReactiveMap();
|
|
5925
5925
|
|
|
5926
5926
|
<>
|
|
5927
5927
|
<button onClick={() => items.set('key', 1)}>{'add'}</button>
|
|
@@ -6185,7 +6185,7 @@ if(n<2){go("now")}</script>`;
|
|
|
6185
6185
|
expect(result).toBeWithNewline(expected);
|
|
6186
6186
|
});
|
|
6187
6187
|
|
|
6188
|
-
it(
|
|
6188
|
+
it('should correctly handle comments in TSRX syntax', async () => {
|
|
6189
6189
|
const input = `// input
|
|
6190
6190
|
<>
|
|
6191
6191
|
<section>
|
|
@@ -6299,7 +6299,7 @@ if(n<2){go("now")}</script>`;
|
|
|
6299
6299
|
|
|
6300
6300
|
it('should preserve the order of try / pending / catch blocks', async () => {
|
|
6301
6301
|
const expected = `function Test() {
|
|
6302
|
-
let items:
|
|
6302
|
+
let items: ReactiveArray<string> | null = null;
|
|
6303
6303
|
let error: string | null = null;
|
|
6304
6304
|
|
|
6305
6305
|
async function* throwingIterable() {
|
|
@@ -6307,7 +6307,7 @@ if(n<2){go("now")}</script>`;
|
|
|
6307
6307
|
}
|
|
6308
6308
|
|
|
6309
6309
|
return @try {
|
|
6310
|
-
items =
|
|
6310
|
+
items = ReactiveArray.fromAsync(throwingIterable());
|
|
6311
6311
|
@for (const item of items) {
|
|
6312
6312
|
<li>{item}</li>
|
|
6313
6313
|
}
|
|
@@ -6470,7 +6470,7 @@ if(n<2){go("now")}</script>`;
|
|
|
6470
6470
|
it('should preserve comments above attributes on dom elements', async () => {
|
|
6471
6471
|
const expected = `function App() {
|
|
6472
6472
|
return <div
|
|
6473
|
-
// @
|
|
6473
|
+
// @tsrx-ignore
|
|
6474
6474
|
something="test"
|
|
6475
6475
|
>
|
|
6476
6476
|
test
|
|
@@ -6484,7 +6484,7 @@ if(n<2){go("now")}</script>`;
|
|
|
6484
6484
|
it('should preserve comments above attributes on components', async () => {
|
|
6485
6485
|
const expected = `function App() {
|
|
6486
6486
|
return <Child
|
|
6487
|
-
// @
|
|
6487
|
+
// @tsrx-ignore
|
|
6488
6488
|
something="test"
|
|
6489
6489
|
>
|
|
6490
6490
|
test
|