@putout/printer 5.44.0 → 6.0.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 +11 -0
- package/README.md +2 -0
- package/lib/tokenize/overrides.js +1 -0
- package/lib/tokenize/statements/program/program.js +5 -5
- package/lib/tokenize/tokenize.js +8 -0
- package/lib/types.js +1 -0
- package/package.json +2 -2
package/ChangeLog
CHANGED
package/README.md
CHANGED
|
@@ -89,6 +89,7 @@ print(ast, {
|
|
|
89
89
|
roundBraceOpen: '(',
|
|
90
90
|
roundBraceClose: ')',
|
|
91
91
|
quote: `'`,
|
|
92
|
+
endOfFile: '\n',
|
|
92
93
|
},
|
|
93
94
|
semantics: {
|
|
94
95
|
comments: true,
|
|
@@ -124,6 +125,7 @@ const overrides = {
|
|
|
124
125
|
splitter: '\n',
|
|
125
126
|
roundBraceOpen: '(',
|
|
126
127
|
roundBraceClose: ')',
|
|
128
|
+
endOfFile: '\n',
|
|
127
129
|
},
|
|
128
130
|
};
|
|
129
131
|
```
|
|
@@ -6,27 +6,27 @@ const {getDirectives} = require('../block-statement/get-directives');
|
|
|
6
6
|
module.exports.Program = (path, printer, semantics) => {
|
|
7
7
|
const {body} = path.node;
|
|
8
8
|
const {
|
|
9
|
-
print,
|
|
10
9
|
traverse,
|
|
11
10
|
maybe,
|
|
11
|
+
write,
|
|
12
12
|
} = printer;
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
traverse(path.get('interpreter'));
|
|
15
15
|
parseComments(path, printer, semantics);
|
|
16
16
|
|
|
17
17
|
const directives = getDirectives(path);
|
|
18
18
|
|
|
19
19
|
for (const directive of directives) {
|
|
20
20
|
traverse(directive);
|
|
21
|
-
maybe.
|
|
21
|
+
maybe.write.newline(body.length);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
path
|
|
25
25
|
.get('body')
|
|
26
|
-
.forEach(
|
|
26
|
+
.forEach(traverse);
|
|
27
27
|
|
|
28
28
|
if (directives.length && !body.length)
|
|
29
29
|
return;
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
write.endOfFile();
|
|
32
32
|
};
|
package/lib/tokenize/tokenize.js
CHANGED
|
@@ -129,6 +129,13 @@ module.exports.tokenize = (ast, overrides) => {
|
|
|
129
129
|
});
|
|
130
130
|
};
|
|
131
131
|
|
|
132
|
+
const endOfFile = () => {
|
|
133
|
+
addToken({
|
|
134
|
+
type: TYPES.END_OF_FILE,
|
|
135
|
+
value: format.endOfFile,
|
|
136
|
+
});
|
|
137
|
+
};
|
|
138
|
+
|
|
132
139
|
assign(write, {
|
|
133
140
|
indent,
|
|
134
141
|
newline,
|
|
@@ -137,6 +144,7 @@ module.exports.tokenize = (ast, overrides) => {
|
|
|
137
144
|
space,
|
|
138
145
|
splitter,
|
|
139
146
|
quote,
|
|
147
|
+
endOfFile,
|
|
140
148
|
});
|
|
141
149
|
|
|
142
150
|
assign(maybeWrite, {
|
package/lib/types.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/printer",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.1",
|
|
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",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"escover": "^3.0.0",
|
|
59
59
|
"eslint": "^8.0.1",
|
|
60
60
|
"eslint-plugin-n": "^16.0.0",
|
|
61
|
-
"eslint-plugin-putout": "^
|
|
61
|
+
"eslint-plugin-putout": "^21.0.1",
|
|
62
62
|
"estree-to-babel": "^8.0.0",
|
|
63
63
|
"just-kebab-case": "^4.2.0",
|
|
64
64
|
"madrun": "^9.0.0",
|