diff --git a/src/nodes/AssemblyLocalDefinition.js b/src/nodes/AssemblyLocalDefinition.js index 9e2c17e76..8046c557a 100644 --- a/src/nodes/AssemblyLocalDefinition.js +++ b/src/nodes/AssemblyLocalDefinition.js @@ -4,17 +4,9 @@ import { printSeparatedList } from '../common/printer-helpers.js'; const { line } = doc.builders; export const AssemblyLocalDefinition = { - print: ({ node, path, print }) => { - const parts = [ - 'let', - printSeparatedList(path.map(print, 'names'), { firstSeparator: line }) - ]; - - if (node.expression !== null) { - parts.push(':= '); - parts.push(path.call(print, 'expression')); - } - - return parts; - } + print: ({ node, path, print }) => [ + 'let', + printSeparatedList(path.map(print, 'names'), { firstSeparator: line }), + node.expression ? [':= ', path.call(print, 'expression')] : [] + ] }; diff --git a/src/nodes/ExpressionStatement.js b/src/nodes/ExpressionStatement.js index 6149028c4..a808d25db 100644 --- a/src/nodes/ExpressionStatement.js +++ b/src/nodes/ExpressionStatement.js @@ -5,23 +5,15 @@ const { hardline } = doc.builders; export const ExpressionStatement = { print: ({ node, options, path, print }) => { - const parts = []; + const comments = + path.getParentNode().type === 'IfStatement' + ? printComments(node, path, options) + : []; - const parent = path.getParentNode(); - - if (parent.type === 'IfStatement') { - if (node.comments?.length) { - const comments = printComments(node, path, options); - if (comments?.length) { - parts.push(comments); - parts.push(hardline); - } - } - } - - parts.push(path.call(print, 'expression')); - parts.push(node.omitSemicolon ? [] : ';'); - - return parts; + return [ + comments.length ? [comments, hardline] : [], + path.call(print, 'expression'), + node.omitSemicolon ? [] : ';' + ]; } };