@putout/printer 9.15.1 → 9.16.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/tokenize/comment/parse-trailing-comments.js +3 -0
- package/lib/tokenize/expressions/call-expression.js +1 -1
- package/lib/tokenize/expressions/function/function-declaration.js +7 -1
- package/lib/tokenize/literals/index.js +2 -31
- package/lib/tokenize/literals/string-literal.js +33 -0
- package/lib/tokenize/statements/block-statement/block-statement.js +2 -0
- package/lib/tokenize/statements/for-in-statement.js +2 -1
- package/package.json +2 -2
package/ChangeLog
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
2024.09.27, v9.16.0
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- 3cf8ea6 @putout/printer: strict mode: newline
|
|
5
|
+
- 41c63a8 @putout/printer: FunctionExpression: IIFE: improve support
|
|
6
|
+
|
|
7
|
+
2024.09.11, v9.15.2
|
|
8
|
+
|
|
9
|
+
fix:
|
|
10
|
+
- 568ab44 @putout/printer: comment: parse-trailing-comments: no loc
|
|
11
|
+
|
|
1
12
|
2024.09.11, v9.15.1
|
|
2
13
|
|
|
3
14
|
feature:
|
|
@@ -73,6 +73,9 @@ function isCommentOnNextLine(path) {
|
|
|
73
73
|
if (next.node && line < next.node.loc?.start.line)
|
|
74
74
|
return false;
|
|
75
75
|
|
|
76
|
+
if (!loc)
|
|
77
|
+
return true;
|
|
78
|
+
|
|
76
79
|
const isNextLine = line === loc.start.line + 1;
|
|
77
80
|
const isNextLineAfterNewline = line === loc.start.line + 2;
|
|
78
81
|
|
|
@@ -6,13 +6,19 @@ const {printParams} = require('./params');
|
|
|
6
6
|
|
|
7
7
|
module.exports.FunctionDeclaration = {
|
|
8
8
|
print(path, printer, semantics) {
|
|
9
|
-
const {
|
|
9
|
+
const {
|
|
10
|
+
print,
|
|
11
|
+
maybe,
|
|
12
|
+
indent,
|
|
13
|
+
} = printer;
|
|
14
|
+
|
|
10
15
|
const {
|
|
11
16
|
async,
|
|
12
17
|
generator,
|
|
13
18
|
returnType,
|
|
14
19
|
} = path.node;
|
|
15
20
|
|
|
21
|
+
indent();
|
|
16
22
|
maybe.print(async, 'async ');
|
|
17
23
|
|
|
18
24
|
print('function');
|
|
@@ -4,16 +4,7 @@ const {TemplateLiteral} = require('./template-literal');
|
|
|
4
4
|
const {Identifier} = require('./identifier');
|
|
5
5
|
|
|
6
6
|
const {Decorator} = require('../expressions/decorator');
|
|
7
|
-
|
|
8
|
-
const maybeEncode = (value, {encodeDoubleQuote, encodeSingleQuote}) => {
|
|
9
|
-
if (encodeSingleQuote && !value.includes('\\'))
|
|
10
|
-
return value.replaceAll(`'`, `\\'`);
|
|
11
|
-
|
|
12
|
-
if (encodeDoubleQuote && !value.includes('\\"'))
|
|
13
|
-
return value.replaceAll(`"`, '\\"');
|
|
14
|
-
|
|
15
|
-
return value;
|
|
16
|
-
};
|
|
7
|
+
const {StringLiteral} = require('./string-literal');
|
|
17
8
|
|
|
18
9
|
module.exports = {
|
|
19
10
|
Identifier,
|
|
@@ -44,27 +35,7 @@ module.exports = {
|
|
|
44
35
|
BooleanLiteral(path, {write}) {
|
|
45
36
|
write(path.node.value);
|
|
46
37
|
},
|
|
47
|
-
StringLiteral
|
|
48
|
-
const {raw, value} = path.node;
|
|
49
|
-
|
|
50
|
-
if (raw && path.parentPath.isJSXAttribute()) {
|
|
51
|
-
write(raw);
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (raw) {
|
|
56
|
-
const value = raw.slice(1, -1);
|
|
57
|
-
write.quote();
|
|
58
|
-
write(maybeEncode(value, semantics));
|
|
59
|
-
write.quote();
|
|
60
|
-
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
write.quote();
|
|
65
|
-
write(value);
|
|
66
|
-
write.quote();
|
|
67
|
-
},
|
|
38
|
+
StringLiteral,
|
|
68
39
|
RegExpLiteral(path, {print}) {
|
|
69
40
|
const {raw, pattern} = path.node;
|
|
70
41
|
print(raw || `/${pattern}/`);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const maybeEncode = (value, {encodeDoubleQuote, encodeSingleQuote}) => {
|
|
4
|
+
if (encodeSingleQuote && !value.includes('\\'))
|
|
5
|
+
return value.replaceAll(`'`, `\\'`);
|
|
6
|
+
|
|
7
|
+
if (encodeDoubleQuote && !value.includes('\\"'))
|
|
8
|
+
return value.replaceAll(`"`, '\\"');
|
|
9
|
+
|
|
10
|
+
return value;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
module.exports.StringLiteral = (path, {write}, semantics) => {
|
|
14
|
+
const {raw, value} = path.node;
|
|
15
|
+
|
|
16
|
+
if (raw && path.parentPath.isJSXAttribute()) {
|
|
17
|
+
write(raw);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (raw) {
|
|
22
|
+
const value = raw.slice(1, -1);
|
|
23
|
+
write.quote();
|
|
24
|
+
write(maybeEncode(value, semantics));
|
|
25
|
+
write.quote();
|
|
26
|
+
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
write.quote();
|
|
31
|
+
write(value);
|
|
32
|
+
write.quote();
|
|
33
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/printer",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.16.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",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
},
|
|
13
13
|
"repository": {
|
|
14
14
|
"type": "git",
|
|
15
|
-
"url": "git://github.com/putoutjs/printer.git"
|
|
15
|
+
"url": "git+https://github.com/putoutjs/printer.git"
|
|
16
16
|
},
|
|
17
17
|
"scripts": {
|
|
18
18
|
"wisdom": "madrun wisdom",
|