@putout/printer 11.10.0 → 11.10.2

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/ChangeLog CHANGED
@@ -1,3 +1,14 @@
1
+ 2024.12.20, v11.10.2
2
+
3
+ feature:
4
+ - c9ced91 group imports
5
+ - be513ff @putout/printer: nodejs/declare-after-require: apply
6
+
7
+ 2024.12.19, v11.10.1
8
+
9
+ feature:
10
+ - 6589deb @putout/printer: @putout/plugin-printer v4.0.0
11
+
1
12
  2024.12.18, v11.10.0
2
13
 
3
14
  feature:
package/lib/json.js CHANGED
@@ -1,11 +1,12 @@
1
1
  'use strict';
2
2
 
3
+ const {types} = require('@putout/babel');
4
+ const {isJSON} = require('@putout/operator-json');
5
+
3
6
  const {
4
7
  isCallExpression,
5
8
  isIdentifier,
6
- } = require('@putout/babel').types;
7
-
8
- const {isJSON} = require('@putout/operator-json');
9
+ } = types;
9
10
 
10
11
  module.exports.maybeJSON = (ast, overrides) => {
11
12
  if (isASTJSON(ast))
@@ -1,9 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const {
4
- isDecorator,
5
- isMemberExpression,
6
- } = require('@putout/babel').types;
3
+ const {types} = require('@putout/babel');
7
4
 
8
5
  const {
9
6
  isLast,
@@ -11,6 +8,11 @@ const {
11
8
  isNext,
12
9
  } = require('../is');
13
10
 
11
+ const {
12
+ isDecorator,
13
+ isMemberExpression,
14
+ } = types;
15
+
14
16
  const hasBody = (path) => {
15
17
  if (path.isTSModuleDeclaration())
16
18
  return true;
@@ -1,11 +1,11 @@
1
1
  'use strict';
2
2
 
3
- const {stringify} = JSON;
4
- const {TYPES} = require('../types');
3
+ const process = require('node:process');
5
4
  const toSnakeCase = require('just-snake-case');
6
-
7
5
  const {codeFrameColumns} = require('@putout/babel');
6
+ const {TYPES} = require('../types');
8
7
 
8
+ const {stringify} = JSON;
9
9
  const {
10
10
  LOG,
11
11
  LOG_ALL,
@@ -1,6 +1,17 @@
1
1
  'use strict';
2
2
 
3
3
  const {isSimple} = require('@putout/operate');
4
+ const {types} = require('@putout/babel');
5
+
6
+ const {
7
+ isStringAndMember,
8
+ isStringAndIdentifier,
9
+ isIdentifierAndString,
10
+ isCoupleLines,
11
+ isStringAndArray,
12
+ isIdentifierAndIdentifier,
13
+ isSimpleAndNotEmptyObject,
14
+ } = require('../../is');
4
15
 
5
16
  const {
6
17
  isObjectExpression,
@@ -12,17 +23,7 @@ const {
12
23
  isNullLiteral,
13
24
  isStringLiteral,
14
25
  isSpreadElement,
15
- } = require('@putout/babel').types;
16
-
17
- const {
18
- isStringAndMember,
19
- isStringAndIdentifier,
20
- isIdentifierAndString,
21
- isCoupleLines,
22
- isStringAndArray,
23
- isIdentifierAndIdentifier,
24
- isSimpleAndNotEmptyObject,
25
- } = require('../../is');
26
+ } = types;
26
27
 
27
28
  const {round} = Math;
28
29
 
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
 
3
+ const {types} = require('@putout/babel');
3
4
  const {
4
5
  maybePrintLeftBrace,
5
6
  maybePrintRightBrace,
@@ -8,7 +9,7 @@ const {
8
9
  const {
9
10
  isExpressionStatement,
10
11
  isAssignmentExpression,
11
- } = require('@putout/babel').types;
12
+ } = types;
12
13
 
13
14
  module.exports.AssignmentExpression = (path, printer, semantics) => {
14
15
  const {print} = printer;
@@ -1,10 +1,11 @@
1
1
  'use strict';
2
2
 
3
+ const {types} = require('@putout/babel');
3
4
  const {
4
5
  isStringLiteral,
5
6
  isTemplateLiteral,
6
7
  isBinaryExpression,
7
- } = require('@putout/babel').types;
8
+ } = types;
8
9
 
9
10
  const isStringLike = (a) => {
10
11
  if (isStringLiteral(a))
@@ -1,13 +1,14 @@
1
1
  'use strict';
2
2
 
3
- const {isFunction} = require('@putout/babel').types;
3
+ const {types} = require('@putout/babel');
4
+
4
5
  const {isNext} = require('../../is');
5
6
  const {markAfter} = require('../../mark');
6
7
 
7
8
  const {maybeDeclare} = require('../../maybe/maybe-declare');
8
9
  const {parseComments} = require('../../comment/comment');
9
10
  const {maybeDecorators} = require('../../maybe/maybe-decorators');
10
-
11
+ const {isFunction} = types;
11
12
  const isInsideExport = ({parentPath}) => parentPath.isExportDeclaration();
12
13
  const isFunctionLike = (path) => isFunction(path.parentPath.parentPath);
13
14
  const hasBody = ({node}) => node.body.body.length;
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
- const {isMemberExpression} = require('@putout/babel').types;
3
+ const {types} = require('@putout/babel');
4
+ const {isMemberExpression} = types;
4
5
 
5
6
  module.exports.Decorator = (path, {print, maybe}) => {
6
7
  const {expression} = path.node;
@@ -1,15 +1,17 @@
1
1
  'use strict';
2
2
 
3
- const {
4
- isTSModuleBlock,
5
- isBlockStatement,
6
- isExportNamedDeclaration,
7
- } = require('@putout/babel').types;
3
+ const {types} = require('@putout/babel');
8
4
 
9
5
  const {markAfter} = require('../../mark');
10
6
  const {isNext, isNextParent} = require('../../is');
11
7
  const {printParams} = require('./params');
12
8
 
9
+ const {
10
+ isTSModuleBlock,
11
+ isBlockStatement,
12
+ isExportNamedDeclaration,
13
+ } = types;
14
+
13
15
  const isInsideNamedExport = ({parentPath}) => isExportNamedDeclaration(parentPath);
14
16
 
15
17
  module.exports.FunctionDeclaration = {
@@ -1,10 +1,11 @@
1
1
  'use strict';
2
2
 
3
+ const {types} = require('@putout/babel');
3
4
  const {
4
5
  isLogicalExpression,
5
6
  isReturnStatement,
6
7
  isVariableDeclarator,
7
- } = require('@putout/babel').types;
8
+ } = types;
8
9
 
9
10
  module.exports.isRootOk = (path) => {
10
11
  return isReturnStatement(path) || isVariableDeclarator(path);
@@ -1,10 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const {
4
- isUnaryExpression,
5
- isArrowFunctionExpression,
6
- isIfStatement,
7
- } = require('@putout/babel').types;
3
+ const {types} = require('@putout/babel');
8
4
 
9
5
  const {chain} = require('./chain');
10
6
  const {satisfy} = require('../../is');
@@ -12,6 +8,12 @@ const {satisfy} = require('../../is');
12
8
  const {maybePrintComputed} = require('../object-expression/maybe-print-computed');
13
9
  const {maybeParens} = require('../../maybe/maybe-parens');
14
10
 
11
+ const {
12
+ isUnaryExpression,
13
+ isArrowFunctionExpression,
14
+ isIfStatement,
15
+ } = types;
16
+
15
17
  const isArgOfCall = (path) => path.parentPath.isCallExpression() && path.parentPath.get('arguments.0') === path;
16
18
 
17
19
  module.exports.MemberExpression = (path, printer) => {
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
 
3
+ const {types} = require('@putout/babel');
3
4
  const {
4
5
  isCoupleLines,
5
6
  isForOf,
@@ -13,7 +14,7 @@ const {
13
14
 
14
15
  const {parseComments} = require('../../comment/comment');
15
16
  const {likeChain} = require('../member-expression/member-expressions');
16
- const {types} = require('@putout/babel');
17
+
17
18
  const {isStringLiteral} = types;
18
19
 
19
20
  const isBodyOfArrow = (path) => path.parentPath.node.body === path.node;
@@ -1,11 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const {
4
- isIdentifier,
5
- isObjectPattern,
6
- isAssignmentPattern,
7
- isVariableDeclarator,
8
- } = require('@putout/babel').types;
3
+ const {types} = require('@putout/babel');
9
4
 
10
5
  const {wrongShorthand} = require('./wrong-shortand');
11
6
 
@@ -16,11 +11,18 @@ const {
16
11
  } = require('../../is');
17
12
 
18
13
  const {moreThenMaxPropertiesInOneLine} = require('./more-then-max-properties-in-one-line');
19
- const isInsideFn = (path) => path.parentPath.isFunction();
20
14
 
21
15
  const {maybeTypeAnnotation} = require('../../maybe/maybe-type-annotation');
22
16
  const {moreThenMaxPropertiesLengthInOneLine} = require('./more-then-max-properties-length-in-one-line');
23
17
  const {printKey} = require('../object-expression/print-key');
18
+ const isInsideFn = (path) => path.parentPath.isFunction();
19
+
20
+ const {
21
+ isIdentifier,
22
+ isObjectPattern,
23
+ isAssignmentPattern,
24
+ isVariableDeclarator,
25
+ } = types;
24
26
 
25
27
  function isIndent(path) {
26
28
  return !path.parentPath.isArrayPattern();
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- const {isJSXElement} = require('@putout/babel').types;
4
-
3
+ const {types} = require('@putout/babel');
4
+ const {isJSXElement} = types;
5
5
  const isInsideArrow = ({parentPath}) => parentPath.isArrowFunctionExpression();
6
6
 
7
7
  module.exports.JSXElement = {
@@ -1,6 +1,8 @@
1
1
  'use strict';
2
2
 
3
3
  const rendy = require('rendy');
4
+
5
+ const {types} = require('@putout/babel');
4
6
  const maybeSatisfy = require('./satisfy');
5
7
 
6
8
  const {
@@ -10,7 +12,7 @@ const {
10
12
  ExpressionStatement,
11
13
  Program,
12
14
  isStatement,
13
- } = require('@putout/babel').types;
15
+ } = types;
14
16
 
15
17
  const isFn = (a) => typeof a === 'function';
16
18
 
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
 
3
+ const {types} = require('@putout/babel');
3
4
  const {
4
5
  isNext,
5
6
  isParentProgram,
@@ -8,6 +9,11 @@ const {
8
9
  satisfy,
9
10
  } = require('../../is');
10
11
 
12
+ const {markAfter} = require('../../mark');
13
+ const {parseComments} = require('../../comment/comment');
14
+ const {insideIfWithNoBody} = require('./inside-if-with-no-body');
15
+ const {getDirectives} = require('./get-directives');
16
+
11
17
  const {
12
18
  isArrowFunctionExpression,
13
19
  isObjectMethod,
@@ -15,12 +21,7 @@ const {
15
21
  isExportDeclaration,
16
22
  isDoWhileStatement,
17
23
  isBlockStatement,
18
- } = require('@putout/babel').types;
19
-
20
- const {markAfter} = require('../../mark');
21
- const {parseComments} = require('../../comment/comment');
22
- const {insideIfWithNoBody} = require('./inside-if-with-no-body');
23
- const {getDirectives} = require('./get-directives');
24
+ } = types;
24
25
 
25
26
  const isFirstStatement = (path) => path.node.body[0];
26
27
  const isFirstDirective = (path) => path.node.directives?.[0];
@@ -1,7 +1,9 @@
1
1
  'use strict';
2
2
 
3
- const {isExportNamespaceSpecifier} = require('@putout/babel').types;
3
+ const {types} = require('@putout/babel');
4
+
4
5
  const {markAfter, isMarkedAfter} = require('../../mark');
6
+
5
7
  const {
6
8
  isNewlineBetweenSiblings,
7
9
  exists,
@@ -9,6 +11,7 @@ const {
9
11
  isLast,
10
12
  } = require('../../is');
11
13
 
14
+ const {isExportNamespaceSpecifier} = types;
12
15
  const isDeclarationNewline = (path) => isMarkedAfter(path.get('declaration'));
13
16
  const isInsideNamespace = (path) => path.parentPath.isTSModuleBlock();
14
17
 
@@ -119,4 +122,3 @@ module.exports.ExportNamedDeclaration = {
119
122
  markAfter(path);
120
123
  },
121
124
  };
122
-
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const {isJSXElement} = require('@putout/babel').types;
3
+ const {types} = require('@putout/babel');
4
4
 
5
5
  const {
6
6
  isPrevBody,
@@ -10,7 +10,7 @@ const {
10
10
 
11
11
  const {hasPrevNewline} = require('../../mark');
12
12
  const {maybeSpaceAfterKeyword} = require('./maybe-space-after-keyword');
13
-
13
+ const {isJSXElement} = types;
14
14
  const isBodyLength = ({parentPath}) => parentPath.node?.body?.length > 2;
15
15
 
16
16
  const isInsideIfWithElse = ({parentPath}) => parentPath.isIfStatement() && parentPath.node.alternate;
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
 
3
+ const {types} = require('@putout/babel');
3
4
  const {
4
5
  isNext,
5
6
  isCoupleLines,
@@ -9,13 +10,13 @@ const {
9
10
  } = require('../../is');
10
11
 
11
12
  const {hasPrevNewline} = require('../../mark');
12
- const {isExportDeclaration} = require('@putout/babel').types;
13
+
13
14
  const {maybeSpaceAfterKeyword} = require('./maybe-space-after-keyword');
14
15
 
15
16
  const {isConcatenation} = require('../../expressions/binary-expression/concatenate');
16
17
  const {parseLeadingComments} = require('../../comment/comment');
17
18
  const {maybeDeclare} = require('../../maybe/maybe-declare');
18
-
19
+ const {isExportDeclaration} = types;
19
20
  const isParentTSModuleBlock = (path) => path.parentPath.isTSModuleBlock();
20
21
  const isParentBlock = (path) => /Program|BlockStatement|Export|LabeledStatement/.test(path.parentPath.type);
21
22
  const isInsideBlock = (path) => /^(Program|BlockStatement|TSModuleBlock|SwitchCase)$/.test(path.parentPath.type);
@@ -1,8 +1,7 @@
1
1
  'use strict';
2
2
 
3
- const {round} = Math;
4
3
  const fullstore = require('fullstore');
5
- const isObject = (a) => a && typeof a === 'object';
4
+
6
5
  const babelTraverse = require('@putout/babel').traverse;
7
6
  const {TYPES} = require('../types');
8
7
  const baseVisitors = require('./visitors');
@@ -22,7 +21,8 @@ const {
22
21
  } = require('./comment/comment');
23
22
 
24
23
  const {parseOverrides} = require('./overrides/overrides');
25
-
24
+ const isObject = (a) => a && typeof a === 'object';
25
+ const {round} = Math;
26
26
  const isString = (a) => typeof a === 'string';
27
27
  const {assign, freeze} = Object;
28
28
 
@@ -1,15 +1,17 @@
1
1
  'use strict';
2
2
 
3
3
  const {types} = require('@putout/babel');
4
+
5
+ const {isNext, isNextParent} = require('../../is');
6
+ const {maybeDeclare} = require('../../maybe/maybe-declare');
7
+ const {markAfter} = require('../../mark');
8
+
4
9
  const {
5
10
  isTSTypeAliasDeclaration,
6
11
  isExportNamedDeclaration,
7
12
  isTSModuleBlock,
8
13
  } = types;
9
14
 
10
- const {isNext, isNextParent} = require('../../is');
11
- const {maybeDeclare} = require('../../maybe/maybe-declare');
12
- const {markAfter} = require('../../mark');
13
15
  const isInsideNamespace = (path) => isTSModuleBlock(path.parentPath.parentPath);
14
16
 
15
17
  module.exports.TSInterfaceDeclaration = {
@@ -1,10 +1,12 @@
1
1
  'use strict';
2
2
 
3
+ const {types} = require('@putout/babel');
3
4
  const {maybeParens} = require('../../maybe/maybe-parens');
5
+
4
6
  const {
5
7
  isVariableDeclarator,
6
8
  isObjectExpression,
7
- } = require('@putout/babel').types;
9
+ } = types;
8
10
 
9
11
  module.exports.TSAsExpression = maybeParens((path, {print, maybe}) => {
10
12
  const is = isParens(path);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "11.10.0",
3
+ "version": "11.10.2",
4
4
  "type": "commonjs",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "Simplest possible opinionated Babel AST printer for 🐊Putout",
@@ -53,7 +53,7 @@
53
53
  "devDependencies": {
54
54
  "@putout/eslint": "^3.5.0",
55
55
  "@putout/plugin-minify": "^9.0.0",
56
- "@putout/plugin-printer": "^3.0.0",
56
+ "@putout/plugin-printer": "^4.0.0",
57
57
  "@putout/plugin-promises": "^16.0.0",
58
58
  "@putout/plugin-react-hook-form": "^4.0.0",
59
59
  "@putout/plugin-react-hooks": "^6.0.0",