UNPKG

prettier-plugin-solidity

Version:

A Prettier Plugin for automatically formatting your Solidity code.

20 lines (15 loc) 484 B
import { doc } from 'prettier'; import type { Doc } from 'prettier'; import type { BlockComment } from '../slang-nodes/types.d.ts'; const { hardline, join } = doc.builders; export function printIndentableBlockComment(comment: BlockComment): Doc { const lines = comment.value.split('\n'); return join( hardline, lines.map((line, index) => index === 0 ? line.trimEnd() : ` ${index < lines.length - 1 ? line.trim() : line.trimStart()}` ) ); }