Add support for --no-bracket-spacing for GraphQL (#2255)

Fixes #2252
master
Christopher Chedeau 2017-06-24 11:06:56 -07:00 committed by GitHub
parent 2f96357884
commit 59b3a9bc56
4 changed files with 39 additions and 2 deletions

View File

@ -143,7 +143,7 @@ function genericPrint(path, options, print) {
return group(
concat([
"{",
n.fields.length > 0 ? " " : "",
options.bracketSpacing && n.fields.length > 0 ? " " : "",
indent(
concat([
softline,
@ -154,7 +154,7 @@ function genericPrint(path, options, print) {
])
),
softline,
ifBreak("", n.fields.length > 0 ? " " : ""),
ifBreak("", options.bracketSpacing && n.fields.length > 0 ? " " : ""),
"}"
])
);

View File

@ -0,0 +1,29 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`bracket_spacing.graphql 1`] = `
fragment Visit on HighlightedVisit
@argumentDefinitions(
count: {type: "Int", defaultValue: 20}
) {
name
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fragment Visit on HighlightedVisit
@argumentDefinitions(count: { type: "Int", defaultValue: 20 }) {
name
}
`;
exports[`bracket_spacing.graphql 2`] = `
fragment Visit on HighlightedVisit
@argumentDefinitions(
count: {type: "Int", defaultValue: 20}
) {
name
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fragment Visit on HighlightedVisit
@argumentDefinitions(count: {type: "Int", defaultValue: 20}) {
name
}
`;

View File

@ -0,0 +1,6 @@
fragment Visit on HighlightedVisit
@argumentDefinitions(
count: {type: "Int", defaultValue: 20}
) {
name
}

View File

@ -0,0 +1,2 @@
run_spec(__dirname, { parser: "graphql" });
run_spec(__dirname, { parser: "graphql", bracketSpacing: false });