@putout/printer 16.5.0 → 17.0.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.
Files changed (167) hide show
  1. package/ChangeLog +16 -0
  2. package/README.md +5 -5
  3. package/lib/json.js +3 -5
  4. package/lib/print-tokens/cook.js +1 -3
  5. package/lib/print-tokens/index.js +2 -4
  6. package/lib/printer.js +6 -11
  7. package/lib/tokenize/comment/comment.js +3 -9
  8. package/lib/tokenize/comment/comments-printer/comments-printer.js +4 -6
  9. package/lib/tokenize/comment/maybe-inside-fn.js +1 -3
  10. package/lib/tokenize/comment/parse-comments.js +2 -4
  11. package/lib/tokenize/comment/parse-leading-comments.js +8 -12
  12. package/lib/tokenize/comment/parse-trailing-comments.js +8 -15
  13. package/lib/tokenize/debug.js +6 -8
  14. package/lib/tokenize/expressions/array-expression/array-expression.js +10 -15
  15. package/lib/tokenize/expressions/array-expression/indent.js +5 -11
  16. package/lib/tokenize/expressions/array-expression/is-object-after-simple.js +3 -5
  17. package/lib/tokenize/expressions/array-expression/newline.js +7 -11
  18. package/lib/tokenize/expressions/array-pattern/array-pattern.js +2 -3
  19. package/lib/tokenize/expressions/assignment-expression/assignment-expression-comments.js +6 -7
  20. package/lib/tokenize/expressions/assignment-expression/assignment-expression.js +8 -12
  21. package/lib/tokenize/expressions/assignment-expression/maybe-parens-condition.js +3 -6
  22. package/lib/tokenize/expressions/assignment-expression/print-separator.js +2 -3
  23. package/lib/tokenize/expressions/assignment-pattern.js +1 -3
  24. package/lib/tokenize/expressions/binary-expression/binary-expression.js +5 -8
  25. package/lib/tokenize/expressions/binary-expression/concatenate.js +3 -4
  26. package/lib/tokenize/expressions/binary-expression/maybe-space.js +1 -3
  27. package/lib/tokenize/expressions/call-expression/call-expression.js +4 -6
  28. package/lib/tokenize/expressions/class/class-property.js +9 -11
  29. package/lib/tokenize/expressions/class/class.js +8 -12
  30. package/lib/tokenize/expressions/class/static-block.js +1 -3
  31. package/lib/tokenize/expressions/conditional-expression.js +2 -4
  32. package/lib/tokenize/expressions/function/arrow-function-expression.js +4 -6
  33. package/lib/tokenize/expressions/function/class-method.js +8 -12
  34. package/lib/tokenize/expressions/function/function-declaration.js +5 -7
  35. package/lib/tokenize/expressions/function/function-expression.js +4 -6
  36. package/lib/tokenize/expressions/function/functions.js +5 -19
  37. package/lib/tokenize/expressions/function/kind.js +1 -3
  38. package/lib/tokenize/expressions/function/object-method.js +5 -7
  39. package/lib/tokenize/expressions/function/params.js +2 -4
  40. package/lib/tokenize/expressions/function/print-function-params.js +4 -8
  41. package/lib/tokenize/expressions/import-expression.js +2 -5
  42. package/lib/tokenize/expressions/index.js +29 -68
  43. package/lib/tokenize/expressions/logical-expression/chain.js +3 -4
  44. package/lib/tokenize/expressions/logical-expression/logical-expression.js +3 -5
  45. package/lib/tokenize/expressions/member-expression/chain.js +2 -3
  46. package/lib/tokenize/expressions/member-expression/is-looks-like-chain.js +4 -6
  47. package/lib/tokenize/expressions/member-expression/member-expressions.js +6 -8
  48. package/lib/tokenize/expressions/new-expression/new-expression.js +4 -6
  49. package/lib/tokenize/expressions/object-expression/is-inside-tuple.js +2 -3
  50. package/lib/tokenize/expressions/object-expression/is-third-object-inside-array.js +2 -3
  51. package/lib/tokenize/expressions/object-expression/maybe-print-computed.js +1 -3
  52. package/lib/tokenize/expressions/object-expression/object-expression.js +9 -13
  53. package/lib/tokenize/expressions/object-expression/object-property.js +4 -6
  54. package/lib/tokenize/expressions/object-expression/print-key.js +2 -4
  55. package/lib/tokenize/expressions/object-pattern/calculate-long-assign-pattern.js +3 -6
  56. package/lib/tokenize/expressions/object-pattern/comments.js +1 -3
  57. package/lib/tokenize/expressions/object-pattern/more-then-max-properties-in-one-line.js +1 -3
  58. package/lib/tokenize/expressions/object-pattern/more-then-max-properties-length-in-one-line.js +2 -3
  59. package/lib/tokenize/expressions/object-pattern/object-pattern.js +12 -20
  60. package/lib/tokenize/expressions/object-pattern/wrong-shorthand.js +1 -3
  61. package/lib/tokenize/expressions/parenthesized-expression/parenthesized-expression.js +2 -3
  62. package/lib/tokenize/expressions/rest-element.js +2 -4
  63. package/lib/tokenize/expressions/sequence-expression/maybe-write-brace.js +1 -3
  64. package/lib/tokenize/expressions/sequence-expression/sequence-expression-comments.js +4 -5
  65. package/lib/tokenize/expressions/sequence-expression/sequence-expression.js +8 -11
  66. package/lib/tokenize/expressions/spread-element.js +2 -4
  67. package/lib/tokenize/expressions/tagged-template-expression.js +1 -3
  68. package/lib/tokenize/expressions/unary-expression/unary-expressions.js +7 -9
  69. package/lib/tokenize/is.js +35 -43
  70. package/lib/tokenize/jsx/index.js +38 -45
  71. package/lib/tokenize/jsx/jsx-attribute.js +2 -4
  72. package/lib/tokenize/jsx/jsx-element.js +2 -3
  73. package/lib/tokenize/jsx/jsx-fragment.js +3 -5
  74. package/lib/tokenize/jsx/jsx-opening-element.js +2 -4
  75. package/lib/tokenize/jsx/jsx-text/jsx-text.js +2 -4
  76. package/lib/tokenize/{expressions → literals}/decorator/decorator.js +3 -4
  77. package/lib/tokenize/literals/directive-literal.js +1 -3
  78. package/lib/tokenize/literals/identifier.js +4 -6
  79. package/lib/tokenize/literals/index.js +45 -49
  80. package/lib/tokenize/literals/string-literal.js +1 -3
  81. package/lib/tokenize/literals/template-literal.js +2 -4
  82. package/lib/tokenize/literals/void-pattern/void-pattern.js +1 -3
  83. package/lib/tokenize/literals/write-template-literal.js +1 -3
  84. package/lib/tokenize/mark.js +5 -11
  85. package/lib/tokenize/maybe/index.js +6 -9
  86. package/lib/tokenize/maybe/maybe-declare.js +1 -3
  87. package/lib/tokenize/maybe/maybe-decorators.js +1 -3
  88. package/lib/tokenize/maybe/maybe-parens.js +3 -5
  89. package/lib/tokenize/maybe/maybe-type-annotation.js +3 -6
  90. package/lib/tokenize/maybe/satisfy.js +2 -4
  91. package/lib/tokenize/maybe-get.js +1 -3
  92. package/lib/tokenize/overrides/overrides.js +3 -5
  93. package/lib/tokenize/overrides/parse-quotes.js +1 -3
  94. package/lib/tokenize/overrides/parse-round-braces.js +4 -10
  95. package/lib/tokenize/statements/block-statement/block-statement.js +9 -12
  96. package/lib/tokenize/statements/block-statement/get-directives.js +1 -3
  97. package/lib/tokenize/statements/block-statement/inside-if-with-no-body.js +2 -4
  98. package/lib/tokenize/statements/block-statement/is-call-inside-chain.js +3 -4
  99. package/lib/tokenize/statements/break-statement/break-statement.js +3 -5
  100. package/lib/tokenize/statements/continue-statement/continue-statement.js +2 -4
  101. package/lib/tokenize/statements/debugger-statement.js +2 -3
  102. package/lib/tokenize/statements/do-while-statement/do-while-statement.js +2 -3
  103. package/lib/tokenize/statements/empty-statement/empty-statement.js +2 -4
  104. package/lib/tokenize/statements/export-declaration/export-all-declaration.js +1 -3
  105. package/lib/tokenize/statements/export-declaration/export-declaration.js +33 -17
  106. package/lib/tokenize/statements/export-declaration/export-default-declaration.js +3 -5
  107. package/lib/tokenize/statements/expression-statement/expression-statement-comments.js +4 -6
  108. package/lib/tokenize/statements/expression-statement/expression-statement.js +9 -25
  109. package/lib/tokenize/statements/expression-statement/is-inside-assign-next-assign-function.js +2 -3
  110. package/lib/tokenize/statements/for-in-statement.js +1 -3
  111. package/lib/tokenize/statements/for-of-statement/for-of-statement.js +5 -8
  112. package/lib/tokenize/statements/for-statement.js +4 -7
  113. package/lib/tokenize/statements/if-statement/if-statement.js +5 -8
  114. package/lib/tokenize/statements/import-declaration/import-attribute.js +2 -4
  115. package/lib/tokenize/statements/import-declaration/import-declaration-comments.js +3 -4
  116. package/lib/tokenize/statements/import-declaration/import-declaration.js +10 -17
  117. package/lib/tokenize/statements/index.js +28 -61
  118. package/lib/tokenize/statements/labeled-statement/labeled-statement.js +2 -4
  119. package/lib/tokenize/statements/program/program.js +4 -6
  120. package/lib/tokenize/statements/return-statement/maybe-space-after-keyword.js +1 -3
  121. package/lib/tokenize/statements/return-statement/return-statement.js +8 -11
  122. package/lib/tokenize/statements/switch-statement/switch-statement.js +5 -9
  123. package/lib/tokenize/statements/try-statement/try-statements.js +3 -5
  124. package/lib/tokenize/statements/variable-declaration/maybe-space-after-keyword.js +1 -3
  125. package/lib/tokenize/statements/variable-declaration/variable-declaration.js +9 -13
  126. package/lib/tokenize/statements/while-statement/while-statement.js +3 -5
  127. package/lib/tokenize/statements/with-statement/with-statement.js +3 -5
  128. package/lib/tokenize/tokenize.js +12 -18
  129. package/lib/tokenize/typescript/enum/ts-enum-declaration.js +4 -7
  130. package/lib/tokenize/typescript/enum/ts-enum-member.js +1 -3
  131. package/lib/tokenize/typescript/function/print-return-type.js +2 -4
  132. package/lib/tokenize/typescript/function/ts-call-signature-declaration.js +3 -5
  133. package/lib/tokenize/typescript/function/ts-construct-signature-declaration.js +4 -7
  134. package/lib/tokenize/typescript/function/ts-constructor-type.js +3 -5
  135. package/lib/tokenize/typescript/function/ts-declare-function.js +4 -6
  136. package/lib/tokenize/typescript/function/ts-declare-method.js +2 -4
  137. package/lib/tokenize/typescript/function/ts-function-type.js +4 -7
  138. package/lib/tokenize/typescript/function/ts-method-signature.js +6 -9
  139. package/lib/tokenize/typescript/index.js +172 -207
  140. package/lib/tokenize/typescript/interface/ts-interface-body.js +2 -4
  141. package/lib/tokenize/typescript/interface/ts-interface-declaration.js +5 -8
  142. package/lib/tokenize/typescript/mapped-type/ts-mapped-type.js +2 -3
  143. package/lib/tokenize/typescript/namespace/ts-module-declaration.js +4 -6
  144. package/lib/tokenize/typescript/ts-as-expression/ts-as-expression.js +3 -5
  145. package/lib/tokenize/typescript/ts-conditional-type.js +1 -3
  146. package/lib/tokenize/typescript/ts-export-assignment/ts-export-assignment.js +2 -4
  147. package/lib/tokenize/typescript/ts-import-type/ts-import-type.js +2 -4
  148. package/lib/tokenize/typescript/ts-infer-type/ts-infer-type.js +2 -4
  149. package/lib/tokenize/typescript/ts-intersection-type.js +1 -3
  150. package/lib/tokenize/typescript/ts-optional-type/ts-optional-type.js +1 -3
  151. package/lib/tokenize/typescript/ts-parameter-property/ts-parameter-property.js +3 -5
  152. package/lib/tokenize/typescript/ts-parenthesized-type/ts-parenthesized-type.js +1 -3
  153. package/lib/tokenize/typescript/ts-property-signature/comments.js +4 -7
  154. package/lib/tokenize/typescript/ts-property-signature/ts-property-signature.js +10 -15
  155. package/lib/tokenize/typescript/ts-template-literal-type/ts-template-literal-type.js +2 -4
  156. package/lib/tokenize/typescript/ts-type-parameter-declaration/ts-type-parameter-declaration.js +4 -5
  157. package/lib/tokenize/typescript/ts-type-query/ts-type-query.js +2 -4
  158. package/lib/tokenize/typescript/ts-type-reference/ts-type-reference.js +1 -3
  159. package/lib/tokenize/typescript/ts-union-type/ts-union-type.js +2 -3
  160. package/lib/tokenize/typescript/tuple/ts-named-tuple-member.js +1 -3
  161. package/lib/tokenize/typescript/tuple/ts-tuple-type.js +1 -3
  162. package/lib/tokenize/typescript/type/ts-type-alias-declaration.js +5 -8
  163. package/lib/tokenize/typescript/type/ts-type-literal.js +1 -3
  164. package/lib/tokenize/typescript/type/ts-type-parameter.js +2 -4
  165. package/lib/tokenize/visitors.js +5 -14
  166. package/lib/types.js +1 -3
  167. package/package.json +9 -9
@@ -1,9 +1,8 @@
1
- 'use strict';
1
+ import {types} from '@putout/babel';
2
2
 
3
- const {types} = require('@putout/babel');
4
3
  const {isTSConditionalType} = types;
5
4
 
6
- module.exports.TSMappedType = (path, {print, indent, maybe}) => {
5
+ export const TSMappedType = (path, {print, indent, maybe}) => {
7
6
  const {
8
7
  readonly,
9
8
  optional,
@@ -1,9 +1,7 @@
1
- 'use strict';
1
+ import {isNext} from '../../is.js';
2
+ import {maybeDeclare} from '../../maybe/maybe-declare.js';
2
3
 
3
- const {isNext} = require('../../is');
4
- const {maybeDeclare} = require('../../maybe/maybe-declare');
5
-
6
- module.exports.TSModuleDeclaration = {
4
+ export const TSModuleDeclaration = {
7
5
  print: maybeDeclare((path, {print}) => {
8
6
  const {kind} = path.node;
9
7
  const id = path.get('id');
@@ -24,7 +22,7 @@ module.exports.TSModuleDeclaration = {
24
22
  },
25
23
  };
26
24
 
27
- module.exports.TSModuleBlock = (path, {print, traverse, indent}) => {
25
+ export const TSModuleBlock = (path, {print, traverse, indent}) => {
28
26
  print('{');
29
27
  print.breakline();
30
28
  indent.inc();
@@ -1,14 +1,12 @@
1
- 'use strict';
2
-
3
- const {types} = require('@putout/babel');
4
- const {maybeParens} = require('../../maybe/maybe-parens');
1
+ import {types} from '@putout/babel';
2
+ import {maybeParens} from '../../maybe/maybe-parens.js';
5
3
 
6
4
  const {
7
5
  isVariableDeclarator,
8
6
  isObjectExpression,
9
7
  } = types;
10
8
 
11
- module.exports.TSAsExpression = maybeParens((path, {print, maybe}) => {
9
+ export const TSAsExpression = maybeParens((path, {print, maybe}) => {
12
10
  const is = isParens(path);
13
11
 
14
12
  maybe.print(is, '(');
@@ -1,6 +1,4 @@
1
- 'use strict';
2
-
3
- module.exports.TSConditionalType = (path, {print, indent}) => {
1
+ export const TSConditionalType = (path, {print, indent}) => {
4
2
  indent.inc();
5
3
  print.breakline();
6
4
  print('__checkType');
@@ -1,8 +1,6 @@
1
- 'use strict';
1
+ import {isNext} from '../../is.js';
2
2
 
3
- const {isNext} = require('../../is');
4
-
5
- module.exports.TSExportAssignment = {
3
+ export const TSExportAssignment = {
6
4
  print: (path, {print}) => {
7
5
  print('export = ');
8
6
  print('__expression');
@@ -1,7 +1,5 @@
1
- 'use strict';
1
+ import {createImportExpression} from '../../expressions/import-expression.js';
2
2
 
3
- const {createImportExpression} = require('../../expressions/import-expression');
4
-
5
- module.exports.TSImportType = (path, printer) => {
3
+ export const TSImportType = (path, printer) => {
6
4
  createImportExpression(path, printer);
7
5
  };
@@ -1,8 +1,6 @@
1
- 'use strict';
1
+ import {maybeParens} from '../../maybe/maybe-parens.js';
2
2
 
3
- const {maybeParens} = require('../../maybe/maybe-parens');
4
-
5
- module.exports.TSInferType = maybeParens((path, {print}) => {
3
+ export const TSInferType = maybeParens((path, {print}) => {
6
4
  print('infer ');
7
5
  print('__typeParameter');
8
6
  });
@@ -1,6 +1,4 @@
1
- 'use strict';
2
-
3
- module.exports.TSIntersectionType = (path, {traverse, write}) => {
1
+ export const TSIntersectionType = (path, {traverse, write}) => {
4
2
  const types = path.get('types');
5
3
  const n = types.length - 1;
6
4
 
@@ -1,6 +1,4 @@
1
- 'use strict';
2
-
3
- module.exports.TSOptionalType = (path, {print}) => {
1
+ export const TSOptionalType = (path, {print}) => {
4
2
  print('__typeAnnotation');
5
3
  print('?');
6
4
  };
@@ -1,8 +1,6 @@
1
- 'use strict';
1
+ import {hasLeadingComment} from '../../is.js';
2
2
 
3
- const {hasLeadingComment} = require('../../is');
4
-
5
- module.exports.TSParameterProperty = (path, {print, maybe, indent}) => {
3
+ export const TSParameterProperty = (path, {print, maybe, indent}) => {
6
4
  const {
7
5
  decorators,
8
6
  readonly,
@@ -43,7 +41,7 @@ module.exports.TSParameterProperty = (path, {print, maybe, indent}) => {
43
41
  print.breakline();
44
42
  };
45
43
 
46
- module.exports.TSParameterProperty.printLeadingCommentLine = (path, printer, semantics, {printComment}) => {
44
+ TSParameterProperty.printLeadingCommentLine = (path, printer, semantics, {printComment}) => {
47
45
  const {indent, print} = printer;
48
46
 
49
47
  if (path.node.decorators) {
@@ -1,6 +1,4 @@
1
- 'use strict';
2
-
3
- module.exports.TSParenthesizedType = (path, {print}) => {
1
+ export const TSParenthesizedType = (path, {print}) => {
4
2
  print('(');
5
3
  print('__typeAnnotation');
6
4
  print(')');
@@ -1,16 +1,13 @@
1
- 'use strict';
1
+ import {isPrev} from '#is';
2
2
 
3
- const {isPrev} = require('#is');
4
- const noop = () => {};
5
-
6
- module.exports.printLeadingCommentLine = (path, printer, semantics, {printComment}) => {
3
+ export const printLeadingCommentLine = (path, printer, semantics, {printComment}) => {
7
4
  const {print} = printer;
8
5
  print.breakline();
9
6
  printComment();
10
7
  print.breakline();
11
8
  };
12
9
 
13
- module.exports.printLeadingCommentBlock = (path, printer, semantics, {printComment}) => {
10
+ export const printLeadingCommentBlock = (path, printer, semantics, {printComment}) => {
14
11
  const {print, maybe} = printer;
15
12
 
16
13
  maybe.print.breakline(!isPrev(path));
@@ -18,4 +15,4 @@ module.exports.printLeadingCommentBlock = (path, printer, semantics, {printComme
18
15
  print.indent();
19
16
  };
20
17
 
21
- module.exports.printTrailingCommentBlock = noop;
18
+ export const printTrailingCommentBlock = () => {};
@@ -1,21 +1,16 @@
1
- 'use strict';
2
-
3
- const {maybePrintTypeAnnotation} = require('../../maybe/maybe-type-annotation');
4
-
5
- const {
1
+ import {maybePrintTypeAnnotation} from '../../maybe/maybe-type-annotation.js';
2
+ import {
6
3
  hasTrailingComment,
7
4
  isNext,
8
- } = require('../../is');
9
-
10
- const {printKey} = require('../../expressions/object-expression/print-key');
11
-
12
- const {
5
+ } from '../../is.js';
6
+ import {printKey} from '../../expressions/object-expression/print-key.js';
7
+ import {
13
8
  printLeadingCommentLine,
14
9
  printLeadingCommentBlock,
15
10
  printTrailingCommentBlock,
16
- } = require('./comments');
11
+ } from './comments.js';
17
12
 
18
- module.exports.TSPropertySignature = (path, printer) => {
13
+ export const TSPropertySignature = (path, printer) => {
19
14
  const {maybe, write} = printer;
20
15
  const {optional, readonly} = path.node;
21
16
 
@@ -33,9 +28,9 @@ module.exports.TSPropertySignature = (path, printer) => {
33
28
  if (isNext(path) && hasTrailingComment(path))
34
29
  write.newline();
35
30
  };
36
- module.exports.TSPropertySignature.printLeadingCommentLine = printLeadingCommentLine;
37
- module.exports.TSPropertySignature.printLeadingCommentBlock = printLeadingCommentBlock;
38
- module.exports.TSPropertySignature.printTrailingCommentBlock = printTrailingCommentBlock;
31
+ TSPropertySignature.printLeadingCommentLine = printLeadingCommentLine;
32
+ TSPropertySignature.printLeadingCommentBlock = printLeadingCommentBlock;
33
+ TSPropertySignature.printTrailingCommentBlock = printTrailingCommentBlock;
39
34
 
40
35
  function isTSTypeLiteralWithOneMember({parentPath}) {
41
36
  if (!parentPath.parentPath.isTSTypeParameterInstantiation())
@@ -1,8 +1,6 @@
1
- 'use strict';
1
+ import {writeTemplateLiteral} from '../../literals/write-template-literal.js';
2
2
 
3
- const {writeTemplateLiteral} = require('../../literals/write-template-literal');
4
-
5
- module.exports.TSTemplateLiteralType = (path, printer) => {
3
+ export const TSTemplateLiteralType = (path, printer) => {
6
4
  const quasis = path.get('quasis');
7
5
  const types = path.get('types');
8
6
 
@@ -1,12 +1,11 @@
1
- 'use strict';
1
+ import {types} from '@putout/babel';
2
+ import {createPrintSpace} from '../../expressions/function/print-function-params.js';
3
+ import {printParams} from '../../expressions/function/params.js';
2
4
 
3
- const {types} = require('@putout/babel');
4
- const {createPrintSpace} = require('../../expressions/function/print-function-params');
5
- const {printParams} = require('../../expressions/function/params');
6
5
  const {isTSUnionType} = types;
7
6
  const noop = () => {};
8
7
 
9
- module.exports.TSTypeParameterDeclaration = (path, printer, semantics) => {
8
+ export const TSTypeParameterDeclaration = (path, printer, semantics) => {
10
9
  const {print, indent} = printer;
11
10
  const isNewline = hasComplexParameters(path);
12
11
  const printSpace = createPrintSpace({
@@ -1,8 +1,6 @@
1
- 'use strict';
1
+ import {maybeParens} from '../../maybe/maybe-parens.js';
2
2
 
3
- const {maybeParens} = require('../../maybe/maybe-parens');
4
-
5
- module.exports.TSTypeQuery = maybeParens((path, {print}) => {
3
+ export const TSTypeQuery = maybeParens((path, {print}) => {
6
4
  print('typeof ');
7
5
  print('__exprName');
8
6
  });
@@ -1,6 +1,4 @@
1
- 'use strict';
2
-
3
- module.exports.TSTypeReference = (path, {print}) => {
1
+ export const TSTypeReference = (path, {print}) => {
4
2
  print('__typeName');
5
3
  print('__typeArguments');
6
4
  };
@@ -1,9 +1,8 @@
1
- 'use strict';
1
+ import {maybeParens} from '../../maybe/maybe-parens.js';
2
2
 
3
- const {maybeParens} = require('../../maybe/maybe-parens');
4
3
  const insideTypeDeclaration = ({parentPath}) => parentPath.isTSTypeAliasDeclaration();
5
4
 
6
- module.exports.TSUnionType = maybeParens({
5
+ export const TSUnionType = maybeParens({
7
6
  condition: (path) => {
8
7
  return path.parentPath.isTSArrayType();
9
8
  },
@@ -1,6 +1,4 @@
1
- 'use strict';
2
-
3
- module.exports.TSNamedTupleMember = (path, {print}) => {
1
+ export const TSNamedTupleMember = (path, {print}) => {
4
2
  print('__label');
5
3
  print(':');
6
4
  print.space();
@@ -1,6 +1,4 @@
1
- 'use strict';
2
-
3
- module.exports.TSTupleType = (path, {write, traverse, indent, maybe}) => {
1
+ export const TSTupleType = (path, {write, traverse, indent, maybe}) => {
4
2
  const elementTypes = path.get('elementTypes');
5
3
 
6
4
  write('[');
@@ -1,13 +1,10 @@
1
- 'use strict';
2
-
3
- const {
1
+ import {
4
2
  isLast,
5
3
  isNext,
6
4
  isNextParent,
7
- } = require('../../is');
8
-
9
- const {markAfter} = require('../../mark');
10
- const {maybeDeclare} = require('../../maybe/maybe-declare');
5
+ } from '../../is.js';
6
+ import {markAfter} from '../../mark.js';
7
+ import {maybeDeclare} from '../../maybe/maybe-declare.js';
11
8
 
12
9
  const isNextType = (a) => a
13
10
  .getNextSibling()
@@ -17,7 +14,7 @@ const isNextExport = (a) => a
17
14
  .getNextSibling()
18
15
  .isExportDeclaration();
19
16
 
20
- module.exports.TSTypeAliasDeclaration = {
17
+ export const TSTypeAliasDeclaration = {
21
18
  beforeIf: (path) => !path.parentPath.isExportDeclaration(),
22
19
  before: (path, {indent}) => {
23
20
  indent();
@@ -1,6 +1,4 @@
1
- 'use strict';
2
-
3
- module.exports.TSTypeLiteral = (path, {indent, traverse, write}) => {
1
+ export const TSTypeLiteral = (path, {indent, traverse, write}) => {
4
2
  const members = path.get('members');
5
3
  write('{');
6
4
 
@@ -1,8 +1,6 @@
1
- 'use strict';
1
+ import {exists} from '../../is.js';
2
2
 
3
- const {exists} = require('../../is');
4
-
5
- module.exports.TSTypeParameter = (path, {write, traverse}) => {
3
+ export const TSTypeParameter = (path, {write, traverse}) => {
6
4
  const constraint = path.get('constraint');
7
5
 
8
6
  if (path.node.in)
@@ -1,15 +1,6 @@
1
- 'use strict';
1
+ export * from './expressions/index.js';
2
+ export * from './statements/index.js';
3
+ export * from './literals/index.js';
4
+ export * from './typescript/index.js';
5
+ export * from './jsx/index.js';
2
6
 
3
- const expressions = require('./expressions');
4
- const statements = require('./statements');
5
- const literals = require('./literals');
6
- const typescript = require('./typescript');
7
- const jsx = require('./jsx');
8
-
9
- module.exports = {
10
- ...expressions,
11
- ...statements,
12
- ...literals,
13
- ...typescript,
14
- ...jsx,
15
- };
package/lib/types.js CHANGED
@@ -1,6 +1,4 @@
1
- 'use strict';
2
-
3
- module.exports.TYPES = {
1
+ export const TYPES = {
4
2
  TOKEN: 'Token',
5
3
  NEWLINE: 'Newline',
6
4
  LINEBREAK: 'Linebreak',
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "16.5.0",
4
- "type": "commonjs",
3
+ "version": "17.0.0",
4
+ "type": "module",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "Simplest possible opinionated Babel AST printer for 🐊Putout",
7
7
  "homepage": "https://github.com/putoutjs/printer#readme",
@@ -70,9 +70,9 @@
70
70
  },
71
71
  "devDependencies": {
72
72
  "@babel/parser": "8.0.0-beta.2",
73
- "@putout/eslint": "^4.1.0",
73
+ "@putout/eslint": "^5.0.2",
74
74
  "@putout/plugin-minify": "^11.2.1",
75
- "@putout/plugin-printer": "^6.0.0",
75
+ "@putout/plugin-printer": "^7.0.0",
76
76
  "@putout/plugin-promises": "^18.0.0",
77
77
  "@putout/plugin-react-hook-form": "^6.0.0",
78
78
  "@putout/plugin-react-hooks": "^9.0.0",
@@ -83,16 +83,16 @@
83
83
  "eslint": "^9.0.0",
84
84
  "eslint-plugin-putout": "^29.0.0",
85
85
  "estree-to-babel": "^11.0.2",
86
- "goldstein": "^6.0.1",
86
+ "goldstein": "^7.0.0",
87
87
  "just-kebab-case": "^4.2.0",
88
- "madrun": "^11.0.0",
88
+ "madrun": "^12.0.0",
89
89
  "montag": "^1.0.0",
90
90
  "nodemon": "^3.0.1",
91
91
  "putout": "^41.0.0",
92
- "redlint": "^4.0.0",
93
- "samadhi": "^3.0.3",
92
+ "redlint": "^5.0.2",
93
+ "samadhi": "^4.0.2",
94
94
  "supertape": "^11.1.0",
95
- "try-catch": "^3.0.0",
95
+ "try-catch": "^4.0.6",
96
96
  "typescript": "^5.3.3"
97
97
  },
98
98
  "license": "MIT",