Add support for range-formatting GraphQL (#2319)
* Add test for range-formatting GraphQL See https://github.com/prettier/prettier/issues/2296#issue-238985580 * Pass test for range-formatting GraphQL See https://facebook.github.io/graphql/#sec-Appendix-Grammar-Summary.Query-Document This fixes https://github.com/prettier/prettier/issues/2296 * Consider *Definition GraphQL nodes to be formattable See https://github.com/prettier/prettier/pull/2319#discussion_r124569400master
parent
9ee3e581d4
commit
8e37fd76e9
18
index.js
18
index.js
|
@ -172,7 +172,7 @@ function isSourceElement(opts, node) {
|
|||
if (node == null) {
|
||||
return false;
|
||||
}
|
||||
switch (node.type) {
|
||||
switch (node.type || node.kind) {
|
||||
case "ObjectExpression": // JSON
|
||||
case "ArrayExpression": // JSON
|
||||
case "StringLiteral": // JSON
|
||||
|
@ -210,6 +210,22 @@ function isSourceElement(opts, node) {
|
|||
case "TypeAliasDeclaration": // Typescript
|
||||
case "ExportAssignment": // Typescript
|
||||
case "ExportDeclaration": // Typescript
|
||||
case "OperationDefinition": // GraphQL
|
||||
case "FragmentDefinition": // GraphQL
|
||||
case "VariableDefinition": // GraphQL
|
||||
case "TypeExtensionDefinition": // GraphQL
|
||||
case "ObjectTypeDefinition": // GraphQL
|
||||
case "FieldDefinition": // GraphQL
|
||||
case "DirectiveDefinition": // GraphQL
|
||||
case "EnumTypeDefinition": // GraphQL
|
||||
case "EnumValueDefinition": // GraphQL
|
||||
case "InputValueDefinition": // GraphQL
|
||||
case "InputObjectTypeDefinition": // GraphQL
|
||||
case "SchemaDefinition": // GraphQL
|
||||
case "OperationTypeDefinition": // GraphQL
|
||||
case "InterfaceTypeDefinition": // GraphQL
|
||||
case "UnionTypeDefinition": // GraphQL
|
||||
case "ScalarTypeDefinition": // GraphQL
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`issue2296.graphql 1`] = `
|
||||
{NPC{life}}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
{
|
||||
NPC {
|
||||
life
|
||||
}
|
||||
}
|
||||
|
||||
`;
|
|
@ -0,0 +1 @@
|
|||
{NP<<<PRETTIER_RANGE_END>>>C{life}}
|
|
@ -0,0 +1 @@
|
|||
run_spec(__dirname, { parser: "graphql" });
|
Loading…
Reference in New Issue