@putout/printer 1.81.5 → 1.82.1

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,13 @@
1
+ 2023.05.07, v1.82.1
2
+
3
+ fix:
4
+ - 039781e @putout/printer: ExportDeclaration newline
5
+
6
+ 2023.05.07, v1.82.0
7
+
8
+ feature:
9
+ - 55727fa @putout/printer: add support of ExportAllDeclaration
10
+
1
11
  2023.05.05, v1.81.5
2
12
 
3
13
  feature:
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const {markAfter} = require('../../mark');
4
+
4
5
  const {
5
6
  isNext,
6
7
  isNextParent,
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+
3
+ module.exports.ExportAllDeclaration = (path, {print}) => {
4
+ print('export * from ');
5
+ print('__source');
6
+ print(';');
7
+ print.newline();
8
+ };
@@ -1,11 +1,11 @@
1
1
  'use strict';
2
2
 
3
- const {isNewlineBetweenSiblings} = require('../is');
3
+ const {isNewlineBetweenSiblings} = require('../../is');
4
4
 
5
5
  const {
6
6
  markAfter,
7
7
  isMarkedAfter,
8
- } = require('../mark');
8
+ } = require('../../mark');
9
9
 
10
10
  const isDeclarationNewline = (path) => isMarkedAfter(path.get('declaration'));
11
11
 
@@ -59,6 +59,7 @@ module.exports.ExportNamedDeclaration = {
59
59
 
60
60
  indent.dec();
61
61
  write('}');
62
+ write(';');
62
63
  }
63
64
 
64
65
  print('__declaration');
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const {isNext} = require('../is');
3
+ const {isNext} = require('../../is');
4
4
 
5
5
  const notClass = (path) => {
6
6
  if (!isNext(path))
@@ -9,12 +9,22 @@ const notClass = (path) => {
9
9
  return !path.get('declaration').isClass();
10
10
  };
11
11
 
12
+ function shouldAddSemi(path) {
13
+ if (path.isClassDeclaration())
14
+ return false;
15
+
16
+ if (path.isFunctionDeclaration())
17
+ return false;
18
+
19
+ return true;
20
+ }
21
+
12
22
  module.exports.ExportDefaultDeclaration = {
13
23
  print(path, {print, traverse, maybe}) {
14
24
  const declaration = path.get('declaration');
15
25
  print('export default ');
16
26
  traverse(declaration);
17
- maybe.print(!declaration.isClassDeclaration(), ';');
27
+ maybe.print(shouldAddSemi(declaration), ';');
18
28
  },
19
29
  afterSatisfy: () => [
20
30
  notClass,
@@ -10,11 +10,13 @@ const TryStatements = require('./try-statements');
10
10
  const {DebuggerStatement} = require('./debugger-statement');
11
11
  const {ForStatement} = require('./for-statement');
12
12
  const importDeclarations = require('./import-declaration/import-declaration');
13
- const exportDeclarations = require('./export-declarations');
13
+ const exportDeclarations = require('./export-declaration/export-declaration');
14
+ const {ExportAllDeclaration} = require('./export-declaration/export-all-declaration');
15
+
14
16
  const {WhileStatement} = require('./while-statement');
15
17
  const {SwitchStatement} = require('./switch-statement');
16
18
  const {ForInStatement} = require('./for-in-statement');
17
- const {ExportDefaultDeclaration} = require('./export-default-declaration');
19
+ const {ExportDefaultDeclaration} = require('./export-declaration/export-default-declaration');
18
20
  const {BreakStatement} = require('./break-statement');
19
21
 
20
22
  const {
@@ -30,6 +32,7 @@ module.exports = {
30
32
  ExportSpecifier,
31
33
  ExportNamespaceSpecifier,
32
34
  ExportDefaultDeclaration,
35
+ ExportAllDeclaration,
33
36
  VariableDeclaration,
34
37
  IfStatement,
35
38
  ForStatement,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "1.81.5",
3
+ "version": "1.82.1",
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 fro 🐊Putout",