@putout/printer 11.7.0 → 11.9.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 +14 -0
- package/README.md +2 -0
- package/lib/tokenize/comment/parse-leading-comments.js +1 -1
- package/lib/tokenize/expressions/array-pattern/array-pattern.js +2 -2
- package/lib/tokenize/expressions/logical-expression/chain.js +7 -0
- package/lib/tokenize/expressions/logical-expression/logical-expression.js +1 -1
- package/lib/tokenize/is.js +3 -0
- package/lib/tokenize/overrides/overrides.js +1 -0
- package/lib/tokenize/statements/expression-statement.js +1 -3
- package/lib/tokenize/statements/index.js +1 -1
- package/lib/tokenize/statements/labeled-statement/labeled-statement.js +11 -0
- package/package.json +1 -1
- package/lib/tokenize/statements/labeled-statement/labeled-satement.js +0 -9
package/ChangeLog
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
2024.12.18, v11.9.0
|
|
2
|
+
|
|
3
|
+
fix:
|
|
4
|
+
- d30419e @putout/printer: LabeledStatement
|
|
5
|
+
|
|
6
|
+
feature:
|
|
7
|
+
- 20c554a @putout/printer: TSDeclareMethod: comment: indent
|
|
8
|
+
- 7702bf3 @putout/printer: LogicalExpressions: maxLogicalsInOneLine
|
|
9
|
+
|
|
10
|
+
2024.12.17, v11.8.0
|
|
11
|
+
|
|
12
|
+
feature:
|
|
13
|
+
- 0ed288d @putout/printer: LabeledStatement: nexted
|
|
14
|
+
|
|
1
15
|
2024.12.17, v11.7.0
|
|
2
16
|
|
|
3
17
|
feature:
|
package/README.md
CHANGED
|
@@ -96,6 +96,7 @@ print(ast, {
|
|
|
96
96
|
comments: true,
|
|
97
97
|
maxSpecifiersInOneLine: 2,
|
|
98
98
|
maxElementsInOneLine: 3,
|
|
99
|
+
maxLogicalsInOneLine: 3,
|
|
99
100
|
maxVariablesInOneLine: 4,
|
|
100
101
|
maxTypesInOneLine: 3,
|
|
101
102
|
maxPropertiesInOneLine: 2,
|
|
@@ -177,6 +178,7 @@ if(a>3)console.log('ok');else console.log('not ok');
|
|
|
177
178
|
Options used to configure logic of output, similar to ESLint rules:
|
|
178
179
|
|
|
179
180
|
- ✅ `maxElementsInOneLine` - count of `ArrayExpression` and `ArrayPattern` elements placed in one line.
|
|
181
|
+
- ✅ `maxLogicalsInOneLine` - count of `LogicalExpression` elements placed in one line.
|
|
180
182
|
- ✅ `maxVariablesInOneLine` - count of `VariableDeclarators` in one line.
|
|
181
183
|
- ✅ `maxPropertiesInOneLine` - count of `ObjectProperties` in one line.
|
|
182
184
|
- ✅ `maxPropertiesLengthInOneLine` - maximum length of `Object Property`, when violated splits event if `maxPropertiesInOneLine` satisfies;
|
|
@@ -86,7 +86,7 @@ module.exports.parseLeadingComments = (path, {print, maybe, indent}, semantics)
|
|
|
86
86
|
if (!looksLikeSwitchCase && hasTrailingComment(path.getPrevSibling()))
|
|
87
87
|
return;
|
|
88
88
|
|
|
89
|
-
const insideFn = path.parentPath.isFunction() && !path.isTSTypeParameterDeclaration();
|
|
89
|
+
const insideFn = (path.parentPath.isFunction() || path.parentPath.isTSDeclareMethod()) && !path.isTSTypeParameterDeclaration();
|
|
90
90
|
|
|
91
91
|
const propIs = isProperty(path);
|
|
92
92
|
const isIndent = isFirst(path) || !looksLikeSwitchCase && !path.isClassMethod() && !insideFn && !propIs;
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
const {maybeTypeAnnotation} = require('../../maybe/maybe-type-annotation');
|
|
4
4
|
const isForOf = ({parentPath}) => parentPath.parentPath.parentPath?.isForOfStatement();
|
|
5
5
|
|
|
6
|
-
module.exports.ArrayPattern = maybeTypeAnnotation((path, {indent, maybe, print},
|
|
7
|
-
const {maxElementsInOneLine} =
|
|
6
|
+
module.exports.ArrayPattern = maybeTypeAnnotation((path, {indent, maybe, print}, semantics) => {
|
|
7
|
+
const {maxElementsInOneLine} = semantics;
|
|
8
8
|
|
|
9
9
|
print('[');
|
|
10
10
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const {
|
|
4
|
+
isLogicalExpression,
|
|
4
5
|
isReturnStatement,
|
|
5
6
|
isVariableDeclarator,
|
|
6
7
|
} = require('@putout/babel').types;
|
|
@@ -26,7 +27,13 @@ function down(current) {
|
|
|
26
27
|
|
|
27
28
|
do {
|
|
28
29
|
++count;
|
|
30
|
+
const right = current.get('right');
|
|
31
|
+
|
|
32
|
+
if (isLogicalExpression(right))
|
|
33
|
+
count += down(right)[0];
|
|
34
|
+
|
|
29
35
|
current = current.get('left');
|
|
36
|
+
|
|
30
37
|
const {operator} = current.node;
|
|
31
38
|
|
|
32
39
|
if (operator !== '||' && operator !== '&&')
|
package/lib/tokenize/is.js
CHANGED
|
@@ -12,6 +12,7 @@ const {
|
|
|
12
12
|
isMemberExpression,
|
|
13
13
|
isArrayExpression,
|
|
14
14
|
isObjectExpression,
|
|
15
|
+
isLabeledStatement,
|
|
15
16
|
} = types;
|
|
16
17
|
|
|
17
18
|
const isParentProgram = (path) => path.parentPath?.isProgram();
|
|
@@ -124,6 +125,8 @@ module.exports.isNewlineBetweenSiblings = (path) => {
|
|
|
124
125
|
return startNext - endCurrent > 1;
|
|
125
126
|
};
|
|
126
127
|
|
|
128
|
+
module.exports.isInsideLabel = ({parentPath}) => isLabeledStatement(parentPath);
|
|
129
|
+
|
|
127
130
|
module.exports.satisfy = (conditions) => (path) => {
|
|
128
131
|
for (const condition of conditions)
|
|
129
132
|
if (condition(path))
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const {isLabeledStatement} = require('@putout/babel').types;
|
|
4
3
|
const {
|
|
5
4
|
isNext,
|
|
6
5
|
isLast,
|
|
@@ -11,6 +10,7 @@ const {
|
|
|
11
10
|
noTrailingComment,
|
|
12
11
|
hasTrailingComment,
|
|
13
12
|
isCoupleLines,
|
|
13
|
+
isInsideLabel,
|
|
14
14
|
} = require('../is');
|
|
15
15
|
|
|
16
16
|
const isBeforeElse = (path) => {
|
|
@@ -36,8 +36,6 @@ const shouldBreakline = satisfy([
|
|
|
36
36
|
isStrictMode,
|
|
37
37
|
]);
|
|
38
38
|
|
|
39
|
-
const isInsideLabel = ({parentPath}) => isLabeledStatement(parentPath);
|
|
40
|
-
|
|
41
39
|
module.exports.ExpressionStatement = {
|
|
42
40
|
print(path, {print, maybe, store}) {
|
|
43
41
|
maybe.indent(!isInsideLabel(path));
|
|
@@ -21,7 +21,7 @@ const {BreakStatement} = require('./break-statement');
|
|
|
21
21
|
const {DoWhileStatement} = require('./do-while-statement');
|
|
22
22
|
const {Program} = require('./program/program');
|
|
23
23
|
const {ContinueStatement} = require('./continue-statement');
|
|
24
|
-
const {LabeledStatement} = require('./labeled-statement/labeled-
|
|
24
|
+
const {LabeledStatement} = require('./labeled-statement/labeled-statement');
|
|
25
25
|
|
|
26
26
|
const {
|
|
27
27
|
ExportNamespaceSpecifier,
|
package/package.json
CHANGED