@putout/printer 17.0.6 → 17.0.8
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 +10 -0
- package/README.md +1 -1
- package/lib/json.js +2 -2
- package/lib/tokenize/expressions/function/function-declaration.js +1 -1
- package/lib/tokenize/expressions/function/function-expression.js +1 -1
- package/lib/tokenize/expressions/function/object-method.js +1 -1
- package/lib/tokenize/expressions/function/print-function-params.js +1 -1
- package/lib/tokenize/expressions/index.js +1 -1
- package/lib/tokenize/expressions/object-expression/object-expression.js +13 -0
- package/package.json +1 -1
- /package/lib/tokenize/expressions/{spread-element.js → spread-element/spread-element.js} +0 -0
package/ChangeLog
CHANGED
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ You may also use [Babel 8](https://github.com/putoutjs/babel) with [`estree-to-b
|
|
|
21
21
|
|
|
22
22
|
Supports:
|
|
23
23
|
|
|
24
|
-
- ✅ **
|
|
24
|
+
- ✅ **ES2026**;
|
|
25
25
|
- ✅ **JSX**;
|
|
26
26
|
- ✅ [**TypeScript**](https://www.typescriptlang.org/);
|
|
27
27
|
- ✅ [**JSON**](https://github.com/coderaiser/putout/tree/master/packages/processor-json#readme);
|
package/lib/json.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {types} from '@putout/babel';
|
|
2
|
-
import {
|
|
2
|
+
import {isJSONGroup} from '@putout/operator-json';
|
|
3
3
|
|
|
4
4
|
const {
|
|
5
5
|
isCallExpression,
|
|
@@ -46,5 +46,5 @@ function isASTJSON(ast) {
|
|
|
46
46
|
if (!isIdentifier(callee))
|
|
47
47
|
return false;
|
|
48
48
|
|
|
49
|
-
return
|
|
49
|
+
return isJSONGroup(callee.name);
|
|
50
50
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {types} from '@putout/babel';
|
|
2
2
|
import {isNext, isNextParent} from '#is';
|
|
3
|
+
import {printParams} from '#print-params';
|
|
3
4
|
import {markAfter} from '../../mark.js';
|
|
4
|
-
import {printParams} from './params.js';
|
|
5
5
|
|
|
6
6
|
const not = (fn) => (...a) => !fn(...a);
|
|
7
7
|
const notInsideExportDefaultWithBody = not(isInsideExportDefaultWithBody);
|
|
@@ -12,7 +12,7 @@ export {ArrayExpression} from './array-expression/array-expression.js';
|
|
|
12
12
|
export {ArrayPattern} from './array-pattern/array-pattern.js';
|
|
13
13
|
export {AssignmentPattern} from './assignment-pattern.js';
|
|
14
14
|
export {RestElement} from './rest-element.js';
|
|
15
|
-
export {SpreadElement} from './spread-element.js';
|
|
15
|
+
export {SpreadElement} from './spread-element/spread-element.js';
|
|
16
16
|
export {SequenceExpression} from './sequence-expression/sequence-expression.js';
|
|
17
17
|
export {TaggedTemplateExpression} from './tagged-template-expression.js';
|
|
18
18
|
export {BinaryExpression} from './binary-expression/binary-expression.js';
|
|
@@ -17,6 +17,7 @@ import {isThirdObjectInsideArray} from './is-third-object-inside-array.js';
|
|
|
17
17
|
const {
|
|
18
18
|
isStringLiteral,
|
|
19
19
|
isArrayExpression,
|
|
20
|
+
isSpreadElement,
|
|
20
21
|
} = types;
|
|
21
22
|
|
|
22
23
|
const isBodyOfArrow = (path) => path.parentPath.node.body === path.node;
|
|
@@ -150,12 +151,24 @@ const notLastArgInsideCall = (path) => {
|
|
|
150
151
|
const ONE_LINE = true;
|
|
151
152
|
const MANY_LINES = false;
|
|
152
153
|
|
|
154
|
+
const isFirstSpread = (path) => {
|
|
155
|
+
const [first] = path.get('properties');
|
|
156
|
+
|
|
157
|
+
if (!isSpreadElement(first))
|
|
158
|
+
return false;
|
|
159
|
+
|
|
160
|
+
return !path.parentPath.isForOfStatement();
|
|
161
|
+
};
|
|
162
|
+
|
|
153
163
|
export function isOneLine(path) {
|
|
154
164
|
const {length} = path.get('properties');
|
|
155
165
|
|
|
156
166
|
if (!length)
|
|
157
167
|
return ONE_LINE;
|
|
158
168
|
|
|
169
|
+
if (isFirstSpread(path))
|
|
170
|
+
return MANY_LINES;
|
|
171
|
+
|
|
159
172
|
if (notLastArgInsideCall(path))
|
|
160
173
|
return ONE_LINE;
|
|
161
174
|
|
package/package.json
CHANGED
|
File without changes
|