From b24d4a86a43c5fbf791d420b10ae4c1291faaf75 Mon Sep 17 00:00:00 2001 From: Ivan Goncharov Date: Sun, 2 Sep 2018 20:31:54 +0300 Subject: [PATCH] Cleanup formatting of string literals --- src/__tests__/starWarsIntrospection-test.js | 5 ++-- src/__tests__/starWarsSchema.js | 7 +++-- src/error/__tests__/printError-test.js | 14 +++++----- src/execution/execute.js | 6 ++--- src/execution/values.js | 4 +-- src/jsutils/__tests__/dedent-test.js | 26 +++++++++---------- src/jsutils/dedent.js | 2 +- src/type/__tests__/introspection-test.js | 9 +++---- .../__tests__/buildASTSchema-test.js | 12 ++++----- .../__tests__/lexicographicSortSchema-test.js | 20 +++++++------- src/utilities/__tests__/schemaPrinter-test.js | 8 +++--- .../rules/OverlappingFieldsCanBeMerged.js | 5 ++-- 12 files changed, 56 insertions(+), 62 deletions(-) diff --git a/src/__tests__/starWarsIntrospection-test.js b/src/__tests__/starWarsIntrospection-test.js index dc35f05759..34adf7aa19 100644 --- a/src/__tests__/starWarsIntrospection-test.js +++ b/src/__tests__/starWarsIntrospection-test.js @@ -346,9 +346,8 @@ describe('Star Wars Introspection Tests', () => { { defaultValue: null, description: - 'If omitted, returns the hero of the whole ' + - 'saga. If provided, returns the hero of ' + - 'that particular episode.', + 'If omitted, returns the hero of the whole saga. ' + + 'If provided, returns the hero of that particular episode.', name: 'episode', type: { kind: 'ENUM', diff --git a/src/__tests__/starWarsSchema.js b/src/__tests__/starWarsSchema.js index 74e4ad3333..0ccaa509b4 100644 --- a/src/__tests__/starWarsSchema.js +++ b/src/__tests__/starWarsSchema.js @@ -120,8 +120,7 @@ const characterInterface = new GraphQLInterfaceType({ friends: { type: GraphQLList(characterInterface), description: - 'The friends of the character, or an empty list if they ' + - 'have none.', + 'The friends of the character, or an empty list if they have none.', }, appearsIn: { type: GraphQLList(episodeEnum), @@ -263,8 +262,8 @@ const queryType = new GraphQLObjectType({ args: { episode: { description: - 'If omitted, returns the hero of the whole saga. If ' + - 'provided, returns the hero of that particular episode.', + 'If omitted, returns the hero of the whole saga. ' + + 'If provided, returns the hero of that particular episode.', type: episodeEnum, }, }, diff --git a/src/error/__tests__/printError-test.js b/src/error/__tests__/printError-test.js index 804e6f452a..bb1f084e06 100644 --- a/src/error/__tests__/printError-test.js +++ b/src/error/__tests__/printError-test.js @@ -49,9 +49,10 @@ describe('printError', () => { const sourceA = parse( new Source( dedent` - type Foo { - field: String - }`, + type Foo { + field: String + } + `, 'SourceA', ), ); @@ -60,9 +61,10 @@ describe('printError', () => { const sourceB = parse( new Source( dedent` - type Foo { - field: Int - }`, + type Foo { + field: Int + } + `, 'SourceB', ), ); diff --git a/src/execution/execute.js b/src/execution/execute.js index 77f95103d2..a76377b7d1 100644 --- a/src/execution/execute.js +++ b/src/execution/execute.js @@ -336,8 +336,7 @@ export function buildExecutionContext( } else if (hasMultipleAssumedOperations) { errors.push( new GraphQLError( - 'Must provide operation name if query contains ' + - 'multiple operations.', + 'Must provide operation name if query contains multiple operations.', ), ); } @@ -1049,8 +1048,7 @@ function ensureValidRuntimeType( `runtime for field ${info.parentType.name}.${info.fieldName} with ` + `value ${inspect(result)}, received "${inspect(runtimeType)}". ` + `Either the ${returnType.name} type should provide a "resolveType" ` + - 'function or each possible type should provide an ' + - '"isTypeOf" function.', + 'function or each possible type should provide an "isTypeOf" function.', fieldNodes, ); } diff --git a/src/execution/values.js b/src/execution/values.js index f0ee5e2c06..db9bef6de5 100644 --- a/src/execution/values.js +++ b/src/execution/values.js @@ -98,8 +98,8 @@ export function getVariableValues( if (coercionErrors) { for (const error of coercionErrors) { error.message = - `Variable "$${varName}" got invalid ` + - `value ${inspect(value)}; ${error.message}`; + `Variable "$${varName}" got invalid value ${inspect(value)}; ` + + error.message; } errors.push(...coercionErrors); } else { diff --git a/src/jsutils/__tests__/dedent-test.js b/src/jsutils/__tests__/dedent-test.js index b1b93e42f5..b10887df09 100644 --- a/src/jsutils/__tests__/dedent-test.js +++ b/src/jsutils/__tests__/dedent-test.js @@ -15,12 +15,12 @@ describe('dedent', () => { type Query { me: User } - + type User { id: ID name: String } - `; + `; expect(output).to.equal( [ 'type Query {', @@ -42,7 +42,7 @@ describe('dedent', () => { quux quuux quuuux - `; + `; expect(output).to.equal( ['qux', ' quux', ' quuux', ' quuuux', ''].join('\n'), ); @@ -53,7 +53,7 @@ describe('dedent', () => { type Root { field(arg: String = "wi\th de\fault"): String } - `; + `; expect(output).to.equal( [ 'type Root {', @@ -69,7 +69,7 @@ describe('dedent', () => { type Query { me: User } - `); + `); expect(output).to.equal(['type Query {', ' me: User', '}', ''].join('\n')); }); @@ -78,7 +78,7 @@ describe('dedent', () => { \t\t type Query { \t\t me: User \t\t } - `; + `; expect(output).to.equal(['type Query {', ' me: User', '}', ''].join('\n')); }); @@ -98,7 +98,7 @@ describe('dedent', () => { me: User } - `; + `; expect(output).to.equal( ['type Query {', ' me: User', '}', '', ''].join('\n'), ); @@ -124,13 +124,13 @@ describe('dedent', () => { const name = 'Luke Skywalker'; const age = 42; const output = dedent` - { - "me": { - "name": "${name}" - "age": ${age} - } + { + "me": { + "name": "${name}" + "age": ${age} } - `; + } + `; expect(output).to.equal( [ '{', diff --git a/src/jsutils/dedent.js b/src/jsutils/dedent.js index 8158198313..540f65ebb0 100644 --- a/src/jsutils/dedent.js +++ b/src/jsutils/dedent.js @@ -31,7 +31,7 @@ function fixIndent(str: string): string { * { * test * } - * ` + * `; * str === "{\n test\n}\n"; */ export default function dedent( diff --git a/src/type/__tests__/introspection-test.js b/src/type/__tests__/introspection-test.js index 2ffb1f9f8c..5e7cc46038 100644 --- a/src/type/__tests__/introspection-test.js +++ b/src/type/__tests__/introspection-test.js @@ -1293,8 +1293,7 @@ describe('Introspection', () => { 'A GraphQL Schema defines the capabilities of a ' + 'GraphQL server. It exposes all available types and ' + 'directives on the server, as well as the entry ' + - 'points for query, mutation, ' + - 'and subscription operations.', + 'points for query, mutation, and subscription operations.', fields: [ { name: 'types', @@ -1391,14 +1390,12 @@ describe('Introspection', () => { }, { description: - 'Indicates this type is a list. ' + - '`ofType` is a valid field.', + 'Indicates this type is a list. `ofType` is a valid field.', name: 'LIST', }, { description: - 'Indicates this type is a non-null. ' + - '`ofType` is a valid field.', + 'Indicates this type is a non-null. `ofType` is a valid field.', name: 'NON_NULL', }, ], diff --git a/src/utilities/__tests__/buildASTSchema-test.js b/src/utilities/__tests__/buildASTSchema-test.js index d041f35db6..b0f64b24b6 100644 --- a/src/utilities/__tests__/buildASTSchema-test.js +++ b/src/utilities/__tests__/buildASTSchema-test.js @@ -144,7 +144,7 @@ describe('Schema Builder', () => { }); it('Maintains @skip & @include', () => { - const body = dedent` + const body = ` type Query { str: String } @@ -159,7 +159,7 @@ describe('Schema Builder', () => { }); it('Overriding directives excludes specified', () => { - const body = dedent` + const body = ` directive @skip on FIELD directive @include on FIELD directive @deprecated on FIELD_DEFINITION @@ -180,7 +180,7 @@ describe('Schema Builder', () => { }); it('Adding directives maintains @skip & @include', () => { - const body = dedent` + const body = ` directive @foo(arg: Int) on FIELD type Query { @@ -357,7 +357,7 @@ describe('Schema Builder', () => { }); it('Can build recursive Union', () => { - const schema = buildSchema(dedent` + const schema = buildSchema(` union Hello = Hello type Query { @@ -369,7 +369,7 @@ describe('Schema Builder', () => { }); it('Specifying Union type using __typename', () => { - const schema = buildSchema(dedent` + const schema = buildSchema(` type Query { fruits: [Fruit] } @@ -426,7 +426,7 @@ describe('Schema Builder', () => { }); it('Specifying Interface type using __typename', () => { - const schema = buildSchema(dedent` + const schema = buildSchema(` type Query { characters: [Character] } diff --git a/src/utilities/__tests__/lexicographicSortSchema-test.js b/src/utilities/__tests__/lexicographicSortSchema-test.js index b6565f7a3d..9f87590228 100644 --- a/src/utilities/__tests__/lexicographicSortSchema-test.js +++ b/src/utilities/__tests__/lexicographicSortSchema-test.js @@ -19,7 +19,7 @@ function sortSDL(sdl) { describe('lexicographicSortSchema', () => { it('sort fields', () => { - const sorted = sortSDL(dedent` + const sorted = sortSDL(` input Bar { barB: String barA: String @@ -69,7 +69,7 @@ describe('lexicographicSortSchema', () => { }); it('sort implemented interfaces', () => { - const sorted = sortSDL(dedent` + const sorted = sortSDL(` interface FooA { dummy: String } @@ -107,7 +107,7 @@ describe('lexicographicSortSchema', () => { }); it('sort types in union', () => { - const sorted = sortSDL(dedent` + const sorted = sortSDL(` type FooA { dummy: String } @@ -149,7 +149,7 @@ describe('lexicographicSortSchema', () => { }); it('sort enum values', () => { - const sorted = sortSDL(dedent` + const sorted = sortSDL(` enum Foo { B C @@ -175,7 +175,7 @@ describe('lexicographicSortSchema', () => { }); it('sort field arguments', () => { - const sorted = sortSDL(dedent` + const sorted = sortSDL(` type Query { dummy(argB: Int, argA: String, argC: Float): ID } @@ -189,7 +189,7 @@ describe('lexicographicSortSchema', () => { }); it('sort types', () => { - const sorted = sortSDL(dedent` + const sorted = sortSDL(` type Query { dummy(arg1: FooF, arg2: FooA, arg3: FooG): FooD } @@ -251,7 +251,7 @@ describe('lexicographicSortSchema', () => { }); it('sort directive arguments', () => { - const sorted = sortSDL(dedent` + const sorted = sortSDL(` directive @test(argC: Float, argA: String, argB: Int) on FIELD type Query { @@ -269,7 +269,7 @@ describe('lexicographicSortSchema', () => { }); it('sort directive locations', () => { - const sorted = sortSDL(dedent` + const sorted = sortSDL(` directive @test(argC: Float, argA: String, argB: Int) on UNION | FIELD | ENUM type Query { @@ -287,7 +287,7 @@ describe('lexicographicSortSchema', () => { }); it('sort directives', () => { - const sorted = sortSDL(dedent` + const sorted = sortSDL(` directive @fooC on FIELD directive @fooB on UNION @@ -313,7 +313,7 @@ describe('lexicographicSortSchema', () => { }); it('sort recursive types', () => { - const sorted = sortSDL(dedent` + const sorted = sortSDL(` interface FooC { fooB: FooB fooA: FooA diff --git a/src/utilities/__tests__/schemaPrinter-test.js b/src/utilities/__tests__/schemaPrinter-test.js index 0881162703..cc2177eed2 100644 --- a/src/utilities/__tests__/schemaPrinter-test.js +++ b/src/utilities/__tests__/schemaPrinter-test.js @@ -172,10 +172,10 @@ describe('Type System Printer', () => { }); expect(output).to.equal( dedent(String.raw` - type Query { - singleField(argOne: String = "tes\t de\fault"): String - } - `), + type Query { + singleField(argOne: String = "tes\t de\fault"): String + } + `), ); }); diff --git a/src/validation/rules/OverlappingFieldsCanBeMerged.js b/src/validation/rules/OverlappingFieldsCanBeMerged.js index d0547f0c6c..7a15f4d6f6 100644 --- a/src/validation/rules/OverlappingFieldsCanBeMerged.js +++ b/src/validation/rules/OverlappingFieldsCanBeMerged.js @@ -42,9 +42,8 @@ export function fieldsConflictMessage( reason: ConflictReasonMessage, ): string { return ( - `Fields "${responseName}" conflict because ${reasonMessage(reason)}` + - '. Use different aliases on the fields to fetch both if this was ' + - 'intentional.' + `Fields "${responseName}" conflict because ${reasonMessage(reason)}. ` + + 'Use different aliases on the fields to fetch both if this was intentional.' ); }