refactor(massageAst): move target props to corresponding plugins (#4430)
parent
218abba141
commit
df3eb0cf68
|
@ -3,6 +3,12 @@
|
|||
const htmlTagNames = require("html-tag-names");
|
||||
|
||||
function clean(ast, newObj) {
|
||||
["raws", "sourceIndex", "source", "before", "after", "trailingComma"].forEach(
|
||||
name => {
|
||||
delete newObj[name];
|
||||
}
|
||||
);
|
||||
|
||||
if (
|
||||
ast.type === "media-query" ||
|
||||
ast.type === "media-query-list" ||
|
||||
|
|
|
@ -1,6 +1,17 @@
|
|||
"use strict";
|
||||
|
||||
function clean(ast, newObj, parent) {
|
||||
[
|
||||
"leadingComments",
|
||||
"trailingComments",
|
||||
"extra",
|
||||
"start",
|
||||
"end",
|
||||
"flags"
|
||||
].forEach(name => {
|
||||
delete newObj[name];
|
||||
});
|
||||
|
||||
// We remove extra `;` and add them when needed
|
||||
if (ast.type === "EmptyStatement") {
|
||||
return null;
|
||||
|
|
|
@ -796,6 +796,8 @@ function clamp(value, min, max) {
|
|||
}
|
||||
|
||||
function clean(ast, newObj, parent) {
|
||||
delete newObj.position;
|
||||
|
||||
// for codeblock
|
||||
if (ast.type === "code") {
|
||||
delete newObj.value;
|
||||
|
|
|
@ -31,6 +31,8 @@ function genericPrint(path, options, print) {
|
|||
}
|
||||
|
||||
const clean = (ast, newObj) => {
|
||||
delete newObj.start;
|
||||
delete newObj.end;
|
||||
delete newObj.contentStart;
|
||||
delete newObj.contentEnd;
|
||||
};
|
||||
|
|
|
@ -16,32 +16,6 @@ function massageAST(ast, options, parent) {
|
|||
}
|
||||
}
|
||||
|
||||
[
|
||||
"loc",
|
||||
"range",
|
||||
"raw",
|
||||
"comments",
|
||||
"leadingComments",
|
||||
"trailingComments",
|
||||
"extra",
|
||||
"start",
|
||||
"end",
|
||||
"tokens",
|
||||
"flags",
|
||||
"raws",
|
||||
"sourceIndex",
|
||||
"id",
|
||||
"source",
|
||||
"before",
|
||||
"after",
|
||||
"trailingComma",
|
||||
"parent",
|
||||
"prev",
|
||||
"position"
|
||||
].forEach(name => {
|
||||
delete newObj[name];
|
||||
});
|
||||
|
||||
if (options.printer.massageAstNode) {
|
||||
const result = options.printer.massageAstNode(ast, newObj, parent);
|
||||
if (result === null) {
|
||||
|
|
Loading…
Reference in New Issue