Skip to content

Commit 6dfc94c

Browse files
Use Flow shorcut for importing types and enable related ESLint rules (#1836)
1 parent dfcdce7 commit 6dfc94c

File tree

92 files changed

+476
-471
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+476
-471
lines changed

.eslintrc.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ rules:
6969
flowtype/space-before-type-colon: off
7070
flowtype/spread-exact-type: off
7171
flowtype/type-id-match: off
72-
#flowtype/type-import-style: undecided
72+
flowtype/type-import-style: [error, identifier, { ignoreTypeDefault: true }]
7373
flowtype/union-intersection-spacing: off
7474
flowtype/use-flow-type: error
7575
flowtype/valid-syntax: off
@@ -340,7 +340,7 @@ rules:
340340
no-confusing-arrow: off
341341
no-const-assign: error
342342
no-dupe-class-members: error
343-
#no-duplicate-imports: undecided
343+
no-duplicate-imports: error
344344
no-new-symbol: error
345345
no-restricted-imports: off
346346
no-this-before-super: error

src/error/GraphQLError.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@
88
*/
99

1010
import { printError } from './printError';
11-
import { getLocation } from '../language/location';
12-
import type { SourceLocation } from '../language/location';
13-
import type { ASTNode } from '../language/ast';
14-
import type { Source } from '../language/source';
11+
import { type ASTNode } from '../language/ast';
12+
import { type Source } from '../language/source';
13+
import { type SourceLocation, getLocation } from '../language/location';
1514

1615
/**
1716
* A GraphQLError describes an Error found during the parse, validate, or

src/error/formatError.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
*/
99

1010
import invariant from '../jsutils/invariant';
11-
import type { GraphQLError } from './GraphQLError';
12-
import type { SourceLocation } from '../language/location';
11+
import { type GraphQLError } from './GraphQLError';
12+
import { type SourceLocation } from '../language/location';
1313

1414
/**
1515
* Given a GraphQLError, format it according to the rules described by the

src/error/locatedError.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*/
99

1010
import { GraphQLError } from './GraphQLError';
11-
import type { ASTNode } from '../language/ast';
11+
import { type ASTNode } from '../language/ast';
1212

1313
/**
1414
* Given an arbitrary Error, presumably thrown while attempting to execute a

src/error/printError.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@
77
* @flow strict
88
*/
99

10-
import { getLocation } from '../language/location';
11-
import type { SourceLocation } from '../language/location';
12-
import type { Source } from '../language/source';
13-
import type { GraphQLError } from './GraphQLError';
10+
import { type SourceLocation, getLocation } from '../language/location';
11+
import { type Source } from '../language/source';
12+
import { type GraphQLError } from './GraphQLError';
1413

1514
/**
1615
* Prints a GraphQLError to a string, representing useful location information

src/error/syntaxError.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @flow strict
88
*/
99

10-
import type { Source } from '../language/source';
10+
import { type Source } from '../language/source';
1111
import { GraphQLError } from './GraphQLError';
1212

1313
/**

src/execution/execute.js

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import isPromise from '../jsutils/isPromise';
1818
import memoize3 from '../jsutils/memoize3';
1919
import promiseForObject from '../jsutils/promiseForObject';
2020
import promiseReduce from '../jsutils/promiseReduce';
21-
import type { ObjMap } from '../jsutils/ObjMap';
22-
import type { PromiseOrValue } from '../jsutils/PromiseOrValue';
21+
import { type ObjMap } from '../jsutils/ObjMap';
22+
import { type PromiseOrValue } from '../jsutils/PromiseOrValue';
2323

2424
import { getOperationRootType } from '../utilities/getOperationRootType';
2525
import { typeFromAST } from '../utilities/typeFromAST';
@@ -30,25 +30,23 @@ import {
3030
getDirectiveValues,
3131
} from './values';
3232
import {
33+
type GraphQLObjectType,
34+
type GraphQLOutputType,
35+
type GraphQLLeafType,
36+
type GraphQLAbstractType,
37+
type GraphQLField,
38+
type GraphQLFieldResolver,
39+
type GraphQLResolveInfo,
40+
type GraphQLTypeResolver,
41+
type ResponsePath,
42+
type GraphQLList,
3343
isObjectType,
3444
isAbstractType,
3545
isLeafType,
3646
isListType,
3747
isNonNullType,
3848
} from '../type/definition';
39-
import type {
40-
GraphQLObjectType,
41-
GraphQLOutputType,
42-
GraphQLLeafType,
43-
GraphQLAbstractType,
44-
GraphQLField,
45-
GraphQLFieldResolver,
46-
GraphQLResolveInfo,
47-
GraphQLTypeResolver,
48-
ResponsePath,
49-
GraphQLList,
50-
} from '../type/definition';
51-
import type { GraphQLSchema } from '../type/schema';
49+
import { type GraphQLSchema } from '../type/schema';
5250
import {
5351
SchemaMetaFieldDef,
5452
TypeMetaFieldDef,
@@ -59,14 +57,14 @@ import {
5957
GraphQLSkipDirective,
6058
} from '../type/directives';
6159
import { assertValidSchema } from '../type/validate';
62-
import type {
63-
DocumentNode,
64-
OperationDefinitionNode,
65-
SelectionSetNode,
66-
FieldNode,
67-
FragmentSpreadNode,
68-
InlineFragmentNode,
69-
FragmentDefinitionNode,
60+
import {
61+
type DocumentNode,
62+
type OperationDefinitionNode,
63+
type SelectionSetNode,
64+
type FieldNode,
65+
type FragmentSpreadNode,
66+
type InlineFragmentNode,
67+
type FragmentDefinitionNode,
7068
} from '../language/ast';
7169

7270
/**

src/execution/values.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,18 @@ import { typeFromAST } from '../utilities/typeFromAST';
1717
import { valueFromAST } from '../utilities/valueFromAST';
1818
import { Kind } from '../language/kinds';
1919
import { print } from '../language/printer';
20-
import { isInputType, isNonNullType } from '../type/definition';
21-
import type { ObjMap } from '../jsutils/ObjMap';
22-
import type { GraphQLField } from '../type/definition';
23-
import type { GraphQLDirective } from '../type/directives';
24-
import type { GraphQLSchema } from '../type/schema';
25-
import type {
26-
FieldNode,
27-
DirectiveNode,
28-
VariableDefinitionNode,
20+
import {
21+
type GraphQLField,
22+
isInputType,
23+
isNonNullType,
24+
} from '../type/definition';
25+
import { type GraphQLDirective } from '../type/directives';
26+
import { type ObjMap } from '../jsutils/ObjMap';
27+
import { type GraphQLSchema } from '../type/schema';
28+
import {
29+
type FieldNode,
30+
type DirectiveNode,
31+
type VariableDefinitionNode,
2932
} from '../language/ast';
3033

3134
type CoercedVariableValues = {|

src/graphql.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,15 @@
1010
import { validateSchema } from './type/validate';
1111
import { parse } from './language/parser';
1212
import { validate } from './validation/validate';
13-
import { execute } from './execution/execute';
14-
import type { ObjMap } from './jsutils/ObjMap';
15-
import type { Source } from './language/source';
16-
import type {
17-
GraphQLFieldResolver,
18-
GraphQLTypeResolver,
13+
import { type ExecutionResult, execute } from './execution/execute';
14+
import { type ObjMap } from './jsutils/ObjMap';
15+
import { type Source } from './language/source';
16+
import {
17+
type GraphQLFieldResolver,
18+
type GraphQLTypeResolver,
1919
} from './type/definition';
20-
import type { GraphQLSchema } from './type/schema';
21-
import type { ExecutionResult } from './execution/execute';
22-
import type { PromiseOrValue } from './jsutils/PromiseOrValue';
20+
import { type GraphQLSchema } from './type/schema';
21+
import { type PromiseOrValue } from './jsutils/PromiseOrValue';
2322

2423
/**
2524
* This is the primary entry point function for fulfilling GraphQL operations

src/jsutils/keyMap.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @flow strict
88
*/
99

10-
import type { ObjMap } from './ObjMap';
10+
import { type ObjMap } from './ObjMap';
1111

1212
/**
1313
* Creates a keyed JS object from an array, given a function to produce the keys

src/jsutils/keyValMap.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @flow strict
88
*/
99

10-
import type { ObjMap } from './ObjMap';
10+
import { type ObjMap } from './ObjMap';
1111

1212
/**
1313
* Creates a keyed JS object from an array, given a function to produce the keys

src/jsutils/mapValue.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @flow strict
88
*/
99

10-
import type { ObjMap } from './ObjMap';
10+
import { type ObjMap } from './ObjMap';
1111
import objectEntries from '../polyfills/objectEntries';
1212

1313
/**

src/jsutils/promiseForObject.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @flow strict
88
*/
99

10-
import type { ObjMap } from './ObjMap';
10+
import { type ObjMap } from './ObjMap';
1111

1212
/**
1313
* This function transforms a JS object `ObjMap<Promise<T>>` into

src/jsutils/promiseReduce.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*/
99

1010
import isPromise from './isPromise';
11-
import type { PromiseOrValue } from './PromiseOrValue';
11+
import { type PromiseOrValue } from './PromiseOrValue';
1212

1313
/**
1414
* Similar to Array.prototype.reduce(), however the reducing callback may return

src/language/ast.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
* @flow strict
88
*/
99

10-
import type { Source } from './source';
11-
import type { TokenKindEnum } from './lexer';
10+
import { type Source } from './source';
11+
import { type TokenKindEnum } from './lexer';
1212

1313
/**
1414
* Contains a range of UTF-8 character offsets and token references that

src/language/lexer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
*/
99

1010
import defineToJSON from '../jsutils/defineToJSON';
11-
import type { Token } from './ast';
12-
import type { Source } from './source';
11+
import { type Token } from './ast';
12+
import { type Source } from './source';
1313
import { syntaxError } from '../error';
1414
import { dedentBlockStringValue } from './blockString';
1515

src/language/location.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @flow strict
88
*/
99

10-
import type { Source } from './source';
10+
import { type Source } from './source';
1111

1212
/**
1313
* Represents a location in a Source.

src/language/parser.js

Lines changed: 57 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -10,59 +10,63 @@
1010
import inspect from '../jsutils/inspect';
1111
import defineToJSON from '../jsutils/defineToJSON';
1212
import { Source } from './source';
13-
import { syntaxError } from '../error';
14-
import type { GraphQLError } from '../error';
15-
import { createLexer, TokenKind, getTokenDesc } from './lexer';
16-
import type { Lexer, TokenKindEnum } from './lexer';
17-
import type {
18-
Location,
19-
Token,
20-
NameNode,
21-
VariableNode,
22-
DocumentNode,
23-
DefinitionNode,
24-
ExecutableDefinitionNode,
25-
OperationDefinitionNode,
26-
OperationTypeNode,
27-
VariableDefinitionNode,
28-
SelectionSetNode,
29-
SelectionNode,
30-
FieldNode,
31-
ArgumentNode,
32-
FragmentSpreadNode,
33-
InlineFragmentNode,
34-
FragmentDefinitionNode,
35-
ValueNode,
36-
StringValueNode,
37-
ListValueNode,
38-
ObjectValueNode,
39-
ObjectFieldNode,
40-
DirectiveNode,
41-
TypeNode,
42-
NamedTypeNode,
43-
ListTypeNode,
44-
NonNullTypeNode,
45-
TypeSystemDefinitionNode,
46-
SchemaDefinitionNode,
47-
OperationTypeDefinitionNode,
48-
ScalarTypeDefinitionNode,
49-
ObjectTypeDefinitionNode,
50-
FieldDefinitionNode,
51-
InputValueDefinitionNode,
52-
InterfaceTypeDefinitionNode,
53-
UnionTypeDefinitionNode,
54-
EnumTypeDefinitionNode,
55-
EnumValueDefinitionNode,
56-
InputObjectTypeDefinitionNode,
57-
DirectiveDefinitionNode,
58-
TypeSystemExtensionNode,
59-
SchemaExtensionNode,
60-
ScalarTypeExtensionNode,
61-
ObjectTypeExtensionNode,
62-
InterfaceTypeExtensionNode,
63-
UnionTypeExtensionNode,
64-
EnumTypeExtensionNode,
65-
InputObjectTypeExtensionNode,
13+
import { type GraphQLError, syntaxError } from '../error';
14+
import {
15+
type Lexer,
16+
type TokenKindEnum,
17+
TokenKind,
18+
getTokenDesc,
19+
createLexer,
20+
} from './lexer';
21+
import {
22+
type Location,
23+
type Token,
24+
type NameNode,
25+
type VariableNode,
26+
type DocumentNode,
27+
type DefinitionNode,
28+
type ExecutableDefinitionNode,
29+
type OperationDefinitionNode,
30+
type OperationTypeNode,
31+
type VariableDefinitionNode,
32+
type SelectionSetNode,
33+
type SelectionNode,
34+
type FieldNode,
35+
type ArgumentNode,
36+
type FragmentSpreadNode,
37+
type InlineFragmentNode,
38+
type FragmentDefinitionNode,
39+
type ValueNode,
40+
type StringValueNode,
41+
type ListValueNode,
42+
type ObjectValueNode,
43+
type ObjectFieldNode,
44+
type DirectiveNode,
45+
type TypeNode,
46+
type NamedTypeNode,
47+
type ListTypeNode,
48+
type NonNullTypeNode,
49+
type TypeSystemDefinitionNode,
50+
type SchemaDefinitionNode,
51+
type OperationTypeDefinitionNode,
52+
type ScalarTypeDefinitionNode,
53+
type ObjectTypeDefinitionNode,
54+
type FieldDefinitionNode,
55+
type InputValueDefinitionNode,
56+
type InterfaceTypeDefinitionNode,
57+
type UnionTypeDefinitionNode,
58+
type EnumTypeDefinitionNode,
59+
type EnumValueDefinitionNode,
60+
type InputObjectTypeDefinitionNode,
61+
type DirectiveDefinitionNode,
62+
type TypeSystemExtensionNode,
63+
type SchemaExtensionNode,
64+
type ScalarTypeExtensionNode,
65+
type ObjectTypeExtensionNode,
66+
type InterfaceTypeExtensionNode,
67+
type UnionTypeExtensionNode,
68+
type EnumTypeExtensionNode,
69+
type InputObjectTypeExtensionNode,
6670
} from './ast';
6771

6872
import { Kind } from './kinds';

0 commit comments

Comments
 (0)