Fix formatting

This commit is contained in:
Adam Wathan 2019-04-16 11:49:12 -04:00
parent c98cc12d35
commit de1884fdd9

View file

@ -1,11 +1,12 @@
function indentRecursive(node, indentLevel = 0) {
node.each && node.each((child, i) => {
if (!child.raws.before || child.raws.before.includes('\n')) {
child.raws.before = `${ node.type === 'rule' || i === 0 ? '\n' : '\n\n'}${' '.repeat(indentLevel)}`
}
child.raws.after = `\n${' '.repeat(indentLevel)}`
indentRecursive(child, indentLevel + 1)
})
function indentRecursive(node, indent = 0) {
node.each &&
node.each((child, i) => {
if (!child.raws.before || child.raws.before.includes('\n')) {
child.raws.before = `\n${node.type !== 'rule' && i > 0 ? '\n' : ''}${' '.repeat(indent)}`
}
child.raws.after = `\n${' '.repeat(indent)}`
indentRecursive(child, indent + 1)
})
}
export default function formatNodes(root) {