Skip to content

Commit fe14f4a

Browse files
committed
since we are not supporting prettier 2, getNode will not return undefined
1 parent 5f5ad17 commit fe14f4a

2 files changed

Lines changed: 4 additions & 5 deletions

File tree

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const parsers = {
5151
[antlrParserId]: antlrParser
5252
};
5353

54-
const solidityCanAttachComment = (node: { type: string }): boolean =>
54+
const antlrCanAttachComment = (node: { type: string }): boolean =>
5555
typeof node.type === 'string' &&
5656
node.type !== 'BlockComment' &&
5757
node.type !== 'LineComment';
@@ -63,7 +63,7 @@ const canAttachComment = (node: AstNode): boolean =>
6363

6464
// https://prettier.io/docs/en/plugins.html#printers
6565
const antlrPrinter = {
66-
canAttachComment: solidityCanAttachComment,
66+
canAttachComment: antlrCanAttachComment,
6767
handleComments: {
6868
ownLine: comments.solidityHandleOwnLineComment,
6969
endOfLine: comments.solidityHandleEndOfLineComment,

src/slangPrinter.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,9 @@ function hasNodeIgnoreComment(node: StrictAstNode): boolean {
2020
}
2121

2222
function ignoreComments(path: AstPath<AstNode>): void {
23-
// TODO: remove undefined once we stop supporting prettier 2
2423
const node = path.getNode();
2524
// We ignore anything that is not an object
26-
if (node === null || node === undefined || typeof node !== 'object') return;
25+
if (node === null || typeof node !== 'object') return;
2726

2827
const keys = Object.keys(node) as (keyof StrictAstNode)[];
2928
for (const key of keys) {
@@ -64,7 +63,7 @@ function genericPrint(
6463
): Doc {
6564
const node = path.getNode();
6665

67-
if (typeof node === 'undefined' || node === null) {
66+
if (node === null) {
6867
return '';
6968
}
7069

0 commit comments

Comments
 (0)