Remove whitespace generation (#5833)
* Remove whitespace generation and rely on default printing Changes to printing: * Add newline after last empty SwitchCase * Add newlines around block comments if they are non-flow comments or contain newlines * Fix a few more fixtures
This commit is contained in:
committed by
Brian Ng
parent
bc29145465
commit
b3372a572d
@@ -86,9 +86,12 @@ export const nodes = {
|
||||
* Test if SwitchCase needs whitespace.
|
||||
*/
|
||||
|
||||
SwitchCase(node: Object, parent: Object): ?WhitespaceObject {
|
||||
SwitchCase(node: Object, parent: Object): WhitespaceObject {
|
||||
return {
|
||||
before: node.consequent.length || parent.cases[0] === node,
|
||||
after:
|
||||
!node.consequent.length &&
|
||||
parent.cases[parent.cases.length - 1] === node,
|
||||
};
|
||||
},
|
||||
|
||||
@@ -181,6 +184,32 @@ nodes.ObjectProperty = nodes.ObjectTypeProperty = nodes.ObjectMethod = function(
|
||||
}
|
||||
};
|
||||
|
||||
nodes.ObjectTypeCallProperty = function(
|
||||
node: Object,
|
||||
parent,
|
||||
): ?WhitespaceObject {
|
||||
if (
|
||||
parent.callProperties[0] === node &&
|
||||
(!parent.properties || !parent.properties.length)
|
||||
) {
|
||||
return {
|
||||
before: true,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
nodes.ObjectTypeIndexer = function(node: Object, parent): ?WhitespaceObject {
|
||||
if (
|
||||
parent.indexers[0] === node &&
|
||||
(!parent.properties || !parent.properties.length) &&
|
||||
(!parent.callProperties || !parent.callProperties.length)
|
||||
) {
|
||||
return {
|
||||
before: true,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns lists from node types that need whitespace.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user