@putout/printer 8.5.0 → 8.6.1
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/lib/printer.js +5 -1
- package/lib/tokenize/expressions/array-expression/array-expression.js +1 -2
- package/lib/tokenize/expressions/array-expression/tuple-expression.js +2 -2
- package/lib/tokenize/maybe/index.js +1 -1
- package/lib/tokenize/tokenize.js +2 -2
- package/package.json +1 -1
package/ChangeLog
CHANGED
package/lib/printer.js
CHANGED
|
@@ -4,6 +4,9 @@ const {tokenize} = require('./tokenize/tokenize');
|
|
|
4
4
|
const {printTokens} = require('./print-tokens');
|
|
5
5
|
const {maybeJSON} = require('./json');
|
|
6
6
|
|
|
7
|
+
const {maybeVisitor} = require('./tokenize/maybe/index');
|
|
8
|
+
const visitors = require('./tokenize/visitors');
|
|
9
|
+
|
|
7
10
|
module.exports.print = (ast, overrides = {}) => {
|
|
8
11
|
const options = maybeJSON(ast, overrides);
|
|
9
12
|
const tokens = tokenize(ast, options);
|
|
@@ -11,4 +14,5 @@ module.exports.print = (ast, overrides = {}) => {
|
|
|
11
14
|
return printTokens(tokens);
|
|
12
15
|
};
|
|
13
16
|
|
|
14
|
-
module.exports.visitors =
|
|
17
|
+
module.exports.visitors = visitors;
|
|
18
|
+
module.exports.maybeVisitor = maybeVisitor;
|
|
@@ -54,7 +54,7 @@ module.exports.ArrayExpression = {
|
|
|
54
54
|
before(path, {print}) {
|
|
55
55
|
print.breakline();
|
|
56
56
|
},
|
|
57
|
-
print(path, {print, maybe
|
|
57
|
+
print(path, {print, maybe}, semantics) {
|
|
58
58
|
const {
|
|
59
59
|
maxElementsInOneLine,
|
|
60
60
|
trailingComma,
|
|
@@ -135,4 +135,3 @@ module.exports.ArrayExpression = {
|
|
|
135
135
|
indent.inc();
|
|
136
136
|
},
|
|
137
137
|
};
|
|
138
|
-
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const {ArrayExpression} = require('./array-expression');
|
|
4
|
-
const {
|
|
4
|
+
const {maybeVisitor} = require('../../maybe');
|
|
5
5
|
|
|
6
6
|
module.exports.TupleExpression = (path, operations, semantics) => {
|
|
7
7
|
const {write} = operations;
|
|
8
8
|
write('#');
|
|
9
|
-
|
|
9
|
+
maybeVisitor(ArrayExpression, path, operations, semantics);
|
|
10
10
|
};
|
|
@@ -32,7 +32,7 @@ const maybeProgram = (ast) => isProgram(ast) ? ast : Program([
|
|
|
32
32
|
|
|
33
33
|
module.exports.maybeFile = (ast) => isFile(ast) ? ast : File(maybeProgram(ast));
|
|
34
34
|
|
|
35
|
-
module.exports.
|
|
35
|
+
module.exports.maybeVisitor = (plugin, path, printer, options) => {
|
|
36
36
|
if (isFn(plugin))
|
|
37
37
|
return plugin(path, printer, options);
|
|
38
38
|
|
package/lib/tokenize/tokenize.js
CHANGED
|
@@ -9,7 +9,7 @@ const baseVisitors = require('./visitors');
|
|
|
9
9
|
|
|
10
10
|
const {
|
|
11
11
|
maybeFile,
|
|
12
|
-
|
|
12
|
+
maybeVisitor,
|
|
13
13
|
maybeThrow,
|
|
14
14
|
} = require('./maybe');
|
|
15
15
|
|
|
@@ -221,7 +221,7 @@ module.exports.tokenize = (ast, overrides) => {
|
|
|
221
221
|
const currentIndent = i;
|
|
222
222
|
parseLeadingComments(path, printer, semantics);
|
|
223
223
|
// this is main thing
|
|
224
|
-
|
|
224
|
+
maybeVisitor(currentTraverse, path, printer, semantics);
|
|
225
225
|
parseTrailingComments(path, printer, semantics);
|
|
226
226
|
maybeThrow(i !== currentIndent, path, `☝️Looks like indent level changed after token visitor: '{{ type }}', for code: '{{ path }}'`);
|
|
227
227
|
|
package/package.json
CHANGED