@putout/printer 9.11.0 → 9.13.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.
package/ChangeLog CHANGED
@@ -1,3 +1,14 @@
1
+ 2024.09.01, v9.13.0
2
+
3
+ feature:
4
+ - 627dda0 @putout/printer: add AST validation
5
+ - 88ab70b @putout/printer: eslint-plugin-putout v23.0.0
6
+
7
+ 2024.08.24, v9.12.0
8
+
9
+ feature:
10
+ - f58710e @putout/printer: ContinueStatement, BreakSteatement: add support of label
11
+
1
12
  2024.08.01, v9.11.0
2
13
 
3
14
  feature:
package/lib/printer.js CHANGED
@@ -8,6 +8,8 @@ const {maybeVisitor} = require('./tokenize/maybe/index');
8
8
  const visitors = require('./tokenize/visitors');
9
9
 
10
10
  module.exports.print = (ast, overrides = {}) => {
11
+ check(ast);
12
+
11
13
  const options = maybeJSON(ast, overrides);
12
14
  const tokens = tokenize(ast, options);
13
15
 
@@ -16,3 +18,8 @@ module.exports.print = (ast, overrides = {}) => {
16
18
 
17
19
  module.exports.visitors = visitors;
18
20
  module.exports.maybeVisitor = maybeVisitor;
21
+
22
+ function check(ast) {
23
+ if (typeof ast !== 'object')
24
+ throw Error('☝️Looks like ast not an object');
25
+ }
@@ -121,4 +121,3 @@ module.exports.parseTrailingComments = (path, {write, maybe}, semantics) => {
121
121
  }
122
122
  }
123
123
  };
124
-
@@ -4,6 +4,7 @@ const {
4
4
  isNext,
5
5
  hasTrailingComment,
6
6
  } = require('../../is');
7
+
7
8
  const {printParams} = require('./params');
8
9
  const {maybeDecorators} = require('../../maybe/maybe-decorators');
9
10
  const {printKey} = require('../object-expression/print-key');
@@ -8,9 +8,13 @@ module.exports.BreakStatement = {
8
8
  split(path, {print}) {
9
9
  print.newline();
10
10
  },
11
- print(path, {print, indent}) {
11
+ print(path, {print, indent, maybe}) {
12
+ const {label} = path.node;
12
13
  indent();
13
- print('break;');
14
+ print('break');
15
+ maybe.print.space(label);
16
+ print('__label');
17
+ print(';');
14
18
  },
15
19
  afterSatisfy: () => [
16
20
  isParentBlock,
@@ -0,0 +1,14 @@
1
+ 'use strict';
2
+
3
+ module.exports.ContinueStatement = (path, {indent, print, maybe, write}) => {
4
+ const {label} = path.node;
5
+
6
+ indent();
7
+ print('continue');
8
+
9
+ maybe.print.space(label);
10
+ print('__label');
11
+
12
+ write(';');
13
+ print.newline();
14
+ };
@@ -20,6 +20,7 @@ const {ExportDefaultDeclaration} = require('./export-declaration/export-default-
20
20
  const {BreakStatement} = require('./break-statement');
21
21
  const {DoWhileStatement} = require('./do-while-statement');
22
22
  const {Program} = require('./program/program');
23
+ const {ContinueStatement} = require('./continue-statement');
23
24
 
24
25
  const {
25
26
  ExportNamespaceSpecifier,
@@ -61,10 +62,6 @@ module.exports = {
61
62
  SwitchStatement,
62
63
  ...TryStatements,
63
64
  BreakStatement,
64
- ContinueStatement(path, {indent, print}) {
65
- indent();
66
- print('continue;');
67
- print.newline();
68
- },
65
+ ContinueStatement,
69
66
  WhileStatement,
70
67
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/printer",
3
- "version": "9.11.0",
3
+ "version": "9.13.0",
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",
@@ -56,7 +56,7 @@
56
56
  "check-dts": "^0.8.0",
57
57
  "escover": "^4.0.1",
58
58
  "eslint": "^9.0.0",
59
- "eslint-plugin-putout": "^22.0.0",
59
+ "eslint-plugin-putout": "^23.0.0",
60
60
  "estree-to-babel": "^9.0.0",
61
61
  "goldstein": "^5.14.0",
62
62
  "just-kebab-case": "^4.2.0",