esrap 2.2.1 → 2.2.3
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 +1 -1
- package/src/context.js +1 -2
- package/src/languages/ts/index.js +29 -2
- package/types/index.d.ts.map +1 -1
package/package.json
CHANGED
package/src/context.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/** @import { TSESTree } from '@typescript-eslint/types' */
|
|
2
1
|
/** @import { BaseNode, Command, Visitors } from './types' */
|
|
3
2
|
|
|
4
3
|
export const margin = 0;
|
|
@@ -51,7 +50,7 @@ export class Context {
|
|
|
51
50
|
append(context) {
|
|
52
51
|
this.#commands.push(context.#commands);
|
|
53
52
|
|
|
54
|
-
if (this.#has_newline) {
|
|
53
|
+
if (this.#has_newline || context.multiline) {
|
|
55
54
|
this.multiline = true;
|
|
56
55
|
}
|
|
57
56
|
}
|
|
@@ -232,6 +232,16 @@ export default (options = {}) => {
|
|
|
232
232
|
}
|
|
233
233
|
}
|
|
234
234
|
|
|
235
|
+
/**
|
|
236
|
+
* @param {TSESTree.Node} node
|
|
237
|
+
* @returns {boolean}
|
|
238
|
+
*/
|
|
239
|
+
function has_object_or_array_value(node) {
|
|
240
|
+
if (!node || node.type !== 'Property') return false;
|
|
241
|
+
const value = node.value?.type === 'AssignmentPattern' ? node.value.left : node.value;
|
|
242
|
+
return value?.type === 'ObjectExpression' || value?.type === 'ArrayExpression';
|
|
243
|
+
}
|
|
244
|
+
|
|
235
245
|
/**
|
|
236
246
|
* @param {Context} context
|
|
237
247
|
* @param {TSESTree.Node[]} nodes
|
|
@@ -280,8 +290,10 @@ export default (options = {}) => {
|
|
|
280
290
|
const child = children[i];
|
|
281
291
|
|
|
282
292
|
if (prev !== null) {
|
|
283
|
-
if (multiline_nodes[i - 1]
|
|
284
|
-
|
|
293
|
+
if (multiline_nodes[i - 1] && multiline_nodes[i]) {
|
|
294
|
+
if (!has_object_or_array_value(nodes[i - 1]) || !has_object_or_array_value(nodes[i])) {
|
|
295
|
+
context.margin();
|
|
296
|
+
}
|
|
285
297
|
}
|
|
286
298
|
|
|
287
299
|
if (nodes[i]) {
|
|
@@ -554,6 +566,13 @@ export default (options = {}) => {
|
|
|
554
566
|
if (node.superClass) {
|
|
555
567
|
context.write('extends ');
|
|
556
568
|
context.visit(node.superClass);
|
|
569
|
+
|
|
570
|
+
// @ts-expect-error `acorn-typescript` and `@typescript-eslint/types` have slightly different type definitions
|
|
571
|
+
var type_arguments = node.superTypeParameters ?? node.superTypeArguments;
|
|
572
|
+
if (type_arguments) {
|
|
573
|
+
context.visit(type_arguments);
|
|
574
|
+
}
|
|
575
|
+
|
|
557
576
|
context.write(' ');
|
|
558
577
|
}
|
|
559
578
|
|
|
@@ -626,6 +645,14 @@ export default (options = {}) => {
|
|
|
626
645
|
context.write('abstract ');
|
|
627
646
|
}
|
|
628
647
|
|
|
648
|
+
if (node.accessibility) {
|
|
649
|
+
context.write(node.accessibility + ' ');
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
if (node.override) {
|
|
653
|
+
context.write('override ');
|
|
654
|
+
}
|
|
655
|
+
|
|
629
656
|
if (node.static) {
|
|
630
657
|
context.write('static ');
|
|
631
658
|
}
|
package/types/index.d.ts.map
CHANGED
|
@@ -35,6 +35,6 @@
|
|
|
35
35
|
null,
|
|
36
36
|
null
|
|
37
37
|
],
|
|
38
|
-
"mappings": ";MAGYA,QAAQA;;;;;;;;MAQfC,MAAMA;;MAENC,mBAAmBA;;;;MAIZC,OAAOA;;aAEPC,QAAQA;;;;WAwBHC,QAAQA;;;;;;MAWbC,OAAOA;;kBAEFC,YAAYA;;;;;;;;;iBCHbC,KAAKA;;;;
|
|
38
|
+
"mappings": ";MAGYA,QAAQA;;;;;;;;MAQfC,MAAMA;;MAENC,mBAAmBA;;;;MAIZC,OAAOA;;aAEPC,QAAQA;;;;WAwBHC,QAAQA;;;;;;MAWbC,OAAOA;;kBAEFC,YAAYA;;;;;;;;;iBCHbC,KAAKA;;;;cC7CRC,OAAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cCAPC,sBAAsBA;;aAHZC,IAAIA;MCFfC,SAASA;;;;;;;WAOXC,QAAQA;;;;;;;kBAODC,WAAWA;;;;;;;kBAOXC,OAAOA;;;;;;MJrBZf,QAAQA;;;;;;;;MAQfC,MAAMA;;MAENC,mBAAmBA;;;;MAIZC,OAAOA;;MAEPC,QAAQA;;;;;;;;;;;aKdGO,IAAIA;MDFfC,SAASA;;;;;;;WAOXC,QAAQA;;;;;;;kBAODC,WAAWA;;;;;;;kBAOXC,OAAOA;;;;;;MJrBZf,QAAQA;;;;;;;;MAQfC,MAAMA;;MAENC,mBAAmBA;;;;MAIZC,OAAOA;;MAEPC,QAAQA",
|
|
39
39
|
"ignoreList": []
|
|
40
40
|
}
|