UNPKG

prettierx

Version:

prettierX - a less opinionated fork of the Prettier code formatter

35 lines (26 loc) 644 B
"use strict"; const { isFrontMatterNode } = require("../common/util"); const ignoredProperties = new Set([ "sourceSpan", "startSourceSpan", "endSourceSpan", "nameSpan", "valueSpan", ]); function clean(ast, newNode) { if (ast.type === "text" || ast.type === "comment") { return null; } // may be formatted by multiparser if (isFrontMatterNode(ast) || ast.type === "yaml" || ast.type === "toml") { return null; } if (ast.type === "attribute") { delete newNode.value; } if (ast.type === "docType") { delete newNode.value; } } clean.ignoredProperties = ignoredProperties; module.exports = clean;