Skip to content

Commit dfe6708

Browse files
committed
feature: @putout/plugin-printer: remove-useless-spaces-from-type-checker: sequence
1 parent 0a6e538 commit dfe6708

4 files changed

Lines changed: 21 additions & 2 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const isNextStatementWithBlockComment = createTypeChecker([
2+
'+: node.trailingComments.0 -> CommentBlock',
3+
]);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const isNextStatementWithBlockComment = createTypeChecker([
2+
'+: node.trailingComments.0 -> CommentBlock',
3+
]);

packages/plugin-printer/lib/remove-useless-spaces-from-type-checker/index.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,17 @@ function createWhere(value) {
5151
endsWith,
5252
};
5353

54-
if (includes(' :'))
55-
traceColon(tools);
54+
traceColon(tools);
55+
traceSpaces(tools);
5656

5757
return where;
5858
}
5959

60+
function traceSpaces({push, includes}) {
61+
if (includes(' '))
62+
push('double-spaces');
63+
}
64+
6065
function traceColon({push, includes}) {
6166
if (includes(' :'))
6267
push('before-colon');
@@ -66,5 +71,8 @@ function removeSpaces(value, where) {
6671
if (where.includes('before-colon'))
6772
value = value.replace(' :', ':');
6873

74+
if (where.includes('double-spaces'))
75+
value = value.replaceAll(' ', ' ');
76+
6977
return value;
7078
}

packages/plugin-printer/lib/remove-useless-spaces-from-type-checker/index.spec.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,8 @@ test('printer: remove-useless-spaces-from-type-checker: transform', (t) => {
1616
t.transform('remove-useless-spaces-from-type-checker');
1717
t.end();
1818
});
19+
20+
test('printer: remove-useless-spaces-from-type-checker: transform: sequence', (t) => {
21+
t.transform('sequence');
22+
t.end();
23+
});

0 commit comments

Comments
 (0)