prettier-plugin-solidity
Version:
A Prettier Plugin for automatically formatting your Solidity code.
29 lines (26 loc) • 522 B
JavaScript
import { doc } from 'prettier';
const { group, line, indent } = doc.builders;
export const assignment = {
match: (op) =>
[
'=',
'|=',
'^=',
'&=',
'<<=',
'>>=',
'+=',
'-=',
'*=',
'/=',
'%='
].includes(op),
print: (node, path, print) => [
path.call(print, 'left'),
' ',
node.operator,
node.right.type === 'BinaryOperation'
? group(indent([line, path.call(print, 'right')]))
: [' ', path.call(print, 'right')]
]
};