@putout/printer 9.12.0 → 9.14.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 +11 -0
- package/lib/printer.js +7 -0
- package/lib/tokenize/comment/parse-trailing-comments.js +0 -1
- package/lib/tokenize/expressions/function/class-method.js +1 -0
- package/lib/tokenize/expressions/object-expression/object-expression.js +2 -1
- package/lib/tokenize/typescript/ts-as-expression/ts-as-expression.js +14 -3
- package/package.json +2 -2
package/ChangeLog
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
2024.09.02, v9.14.0
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- c75c1c5 @putout/printer: TSAsExpression: parens
|
|
5
|
+
|
|
6
|
+
2024.09.01, v9.13.0
|
|
7
|
+
|
|
8
|
+
feature:
|
|
9
|
+
- 627dda0 @putout/printer: add AST validation
|
|
10
|
+
- 88ab70b @putout/printer: eslint-plugin-putout v23.0.0
|
|
11
|
+
|
|
1
12
|
2024.08.24, v9.12.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
|
+
}
|
|
@@ -13,7 +13,8 @@ const {
|
|
|
13
13
|
|
|
14
14
|
const {parseComments} = require('../../comment/comment');
|
|
15
15
|
const {likeChain} = require('../member-expression/member-expressions');
|
|
16
|
-
const {
|
|
16
|
+
const {types} = require('@putout/babel');
|
|
17
|
+
const {isStringLiteral} = types;
|
|
17
18
|
|
|
18
19
|
const isBodyOfArrow = (path) => path.parentPath.node.body === path.node;
|
|
19
20
|
const isLogical = (path) => path.get('argument').isLogicalExpression();
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const {maybeParens} = require('../../expressions/function/parens');
|
|
4
|
-
const {
|
|
4
|
+
const {
|
|
5
|
+
isVariableDeclarator,
|
|
6
|
+
isObjectExpression,
|
|
7
|
+
} = require('@putout/babel').types;
|
|
5
8
|
|
|
6
9
|
module.exports.TSAsExpression = maybeParens((path, {print, maybe}) => {
|
|
7
|
-
const
|
|
8
|
-
const is = isObjectExpression(expression);
|
|
10
|
+
const is = isParens(path);
|
|
9
11
|
|
|
10
12
|
maybe.print(is, '(');
|
|
11
13
|
print('__expression');
|
|
@@ -14,3 +16,12 @@ module.exports.TSAsExpression = maybeParens((path, {print, maybe}) => {
|
|
|
14
16
|
print(' as ');
|
|
15
17
|
print('__typeAnnotation');
|
|
16
18
|
});
|
|
19
|
+
|
|
20
|
+
function isParens(path) {
|
|
21
|
+
const {expression} = path.node;
|
|
22
|
+
|
|
23
|
+
if (isVariableDeclarator(path.parentPath))
|
|
24
|
+
return false;
|
|
25
|
+
|
|
26
|
+
return isObjectExpression(expression);
|
|
27
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/printer",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.14.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": "^
|
|
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",
|