prettier-plugin-solidity
Version:
A Prettier Plugin for automatically formatting your Solidity code.
27 lines (24 loc) • 688 B
JavaScript
import { doc } from 'prettier';
import {
printComments,
printPreservingEmptyLines,
printSeparatedItem
} from '../common/printer-helpers.js';
const { hardline } = doc.builders;
export const AssemblyBlock = {
print: ({ node, options, path, print }) =>
// if block is empty, just return the pair of braces
node.operations.length === 0 && !node.comments
? '{}'
: [
'{',
printSeparatedItem(
[
printPreservingEmptyLines(path, 'operations', options, print),
printComments(node, path, options)
],
{ firstSeparator: hardline, grouped: false }
),
'}'
]
};