fix(multiparser): no additional trailing newline for graphql in js (#4616)
Fixes #4615
The root cause is the output doc from graphql printer does not match the desired input from `stripTrailingHardline`.
a9b21a01e2/src/doc/doc-utils.js (L167-L180)
master
parent
e74e6565b4
commit
b55997eb3d
|
@ -28,15 +28,16 @@ function genericPrint(path, options, print) {
|
|||
const parts = [];
|
||||
path.map((pathChild, index) => {
|
||||
parts.push(concat([pathChild.call(print)]));
|
||||
parts.push(hardline);
|
||||
if (
|
||||
index !== n.definitions.length - 1 &&
|
||||
isNextLineEmpty(options.originalText, pathChild.getValue(), options)
|
||||
) {
|
||||
if (index !== n.definitions.length - 1) {
|
||||
parts.push(hardline);
|
||||
if (
|
||||
isNextLineEmpty(options.originalText, pathChild.getValue(), options)
|
||||
) {
|
||||
parts.push(hardline);
|
||||
}
|
||||
}
|
||||
}, "definitions");
|
||||
return concat(parts, hardline);
|
||||
return concat([concat(parts), hardline]);
|
||||
}
|
||||
case "OperationDefinition": {
|
||||
const hasOperation = options.originalText[options.locStart(n)] !== "{";
|
||||
|
|
|
@ -40,6 +40,29 @@ const query = /* GraphQL */ \`
|
|||
|
||||
`;
|
||||
|
||||
exports[`definitions.js 1`] = `
|
||||
graphql\`
|
||||
fragment x on y {
|
||||
z
|
||||
}
|
||||
|
||||
fragment a on b {
|
||||
c
|
||||
}
|
||||
\`;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
graphql\`
|
||||
fragment x on y {
|
||||
z
|
||||
}
|
||||
|
||||
fragment a on b {
|
||||
c
|
||||
}
|
||||
\`;
|
||||
|
||||
`;
|
||||
|
||||
exports[`expressions.js 1`] = `
|
||||
graphql(schema, \`
|
||||
query allPartsByManufacturerName($name: String!) {
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
graphql`
|
||||
fragment x on y {
|
||||
z
|
||||
}
|
||||
|
||||
fragment a on b {
|
||||
c
|
||||
}
|
||||
`;
|
Loading…
Reference in New Issue