Skip to content

Commit

Permalink
Use Flow shorcut for importing types and enable related ESLint rules (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov committed Apr 29, 2019
1 parent dfcdce7 commit 6dfc94c
Show file tree
Hide file tree
Showing 92 changed files with 476 additions and 471 deletions.
4 changes: 2 additions & 2 deletions .eslintrc.yml
Expand Up @@ -69,7 +69,7 @@ rules:
flowtype/space-before-type-colon: off
flowtype/spread-exact-type: off
flowtype/type-id-match: off
#flowtype/type-import-style: undecided
flowtype/type-import-style: [error, identifier, { ignoreTypeDefault: true }]
flowtype/union-intersection-spacing: off
flowtype/use-flow-type: error
flowtype/valid-syntax: off
Expand Down Expand Up @@ -340,7 +340,7 @@ rules:
no-confusing-arrow: off
no-const-assign: error
no-dupe-class-members: error
#no-duplicate-imports: undecided
no-duplicate-imports: error
no-new-symbol: error
no-restricted-imports: off
no-this-before-super: error
Expand Down
7 changes: 3 additions & 4 deletions src/error/GraphQLError.js
Expand Up @@ -8,10 +8,9 @@
*/

import { printError } from './printError';
import { getLocation } from '../language/location';
import type { SourceLocation } from '../language/location';
import type { ASTNode } from '../language/ast';
import type { Source } from '../language/source';
import { type ASTNode } from '../language/ast';
import { type Source } from '../language/source';
import { type SourceLocation, getLocation } from '../language/location';

/**
* A GraphQLError describes an Error found during the parse, validate, or
Expand Down
4 changes: 2 additions & 2 deletions src/error/formatError.js
Expand Up @@ -8,8 +8,8 @@
*/

import invariant from '../jsutils/invariant';
import type { GraphQLError } from './GraphQLError';
import type { SourceLocation } from '../language/location';
import { type GraphQLError } from './GraphQLError';
import { type SourceLocation } from '../language/location';

/**
* Given a GraphQLError, format it according to the rules described by the
Expand Down
2 changes: 1 addition & 1 deletion src/error/locatedError.js
Expand Up @@ -8,7 +8,7 @@
*/

import { GraphQLError } from './GraphQLError';
import type { ASTNode } from '../language/ast';
import { type ASTNode } from '../language/ast';

/**
* Given an arbitrary Error, presumably thrown while attempting to execute a
Expand Down
7 changes: 3 additions & 4 deletions src/error/printError.js
Expand Up @@ -7,10 +7,9 @@
* @flow strict
*/

import { getLocation } from '../language/location';
import type { SourceLocation } from '../language/location';
import type { Source } from '../language/source';
import type { GraphQLError } from './GraphQLError';
import { type SourceLocation, getLocation } from '../language/location';
import { type Source } from '../language/source';
import { type GraphQLError } from './GraphQLError';

/**
* Prints a GraphQLError to a string, representing useful location information
Expand Down
2 changes: 1 addition & 1 deletion src/error/syntaxError.js
Expand Up @@ -7,7 +7,7 @@
* @flow strict
*/

import type { Source } from '../language/source';
import { type Source } from '../language/source';
import { GraphQLError } from './GraphQLError';

/**
Expand Down
44 changes: 21 additions & 23 deletions src/execution/execute.js
Expand Up @@ -18,8 +18,8 @@ import isPromise from '../jsutils/isPromise';
import memoize3 from '../jsutils/memoize3';
import promiseForObject from '../jsutils/promiseForObject';
import promiseReduce from '../jsutils/promiseReduce';
import type { ObjMap } from '../jsutils/ObjMap';
import type { PromiseOrValue } from '../jsutils/PromiseOrValue';
import { type ObjMap } from '../jsutils/ObjMap';
import { type PromiseOrValue } from '../jsutils/PromiseOrValue';

import { getOperationRootType } from '../utilities/getOperationRootType';
import { typeFromAST } from '../utilities/typeFromAST';
Expand All @@ -30,25 +30,23 @@ import {
getDirectiveValues,
} from './values';
import {
type GraphQLObjectType,
type GraphQLOutputType,
type GraphQLLeafType,
type GraphQLAbstractType,
type GraphQLField,
type GraphQLFieldResolver,
type GraphQLResolveInfo,
type GraphQLTypeResolver,
type ResponsePath,
type GraphQLList,
isObjectType,
isAbstractType,
isLeafType,
isListType,
isNonNullType,
} from '../type/definition';
import type {
GraphQLObjectType,
GraphQLOutputType,
GraphQLLeafType,
GraphQLAbstractType,
GraphQLField,
GraphQLFieldResolver,
GraphQLResolveInfo,
GraphQLTypeResolver,
ResponsePath,
GraphQLList,
} from '../type/definition';
import type { GraphQLSchema } from '../type/schema';
import { type GraphQLSchema } from '../type/schema';
import {
SchemaMetaFieldDef,
TypeMetaFieldDef,
Expand All @@ -59,14 +57,14 @@ import {
GraphQLSkipDirective,
} from '../type/directives';
import { assertValidSchema } from '../type/validate';
import type {
DocumentNode,
OperationDefinitionNode,
SelectionSetNode,
FieldNode,
FragmentSpreadNode,
InlineFragmentNode,
FragmentDefinitionNode,
import {
type DocumentNode,
type OperationDefinitionNode,
type SelectionSetNode,
type FieldNode,
type FragmentSpreadNode,
type InlineFragmentNode,
type FragmentDefinitionNode,
} from '../language/ast';

/**
Expand Down
21 changes: 12 additions & 9 deletions src/execution/values.js
Expand Up @@ -17,15 +17,18 @@ import { typeFromAST } from '../utilities/typeFromAST';
import { valueFromAST } from '../utilities/valueFromAST';
import { Kind } from '../language/kinds';
import { print } from '../language/printer';
import { isInputType, isNonNullType } from '../type/definition';
import type { ObjMap } from '../jsutils/ObjMap';
import type { GraphQLField } from '../type/definition';
import type { GraphQLDirective } from '../type/directives';
import type { GraphQLSchema } from '../type/schema';
import type {
FieldNode,
DirectiveNode,
VariableDefinitionNode,
import {
type GraphQLField,
isInputType,
isNonNullType,
} from '../type/definition';
import { type GraphQLDirective } from '../type/directives';
import { type ObjMap } from '../jsutils/ObjMap';
import { type GraphQLSchema } from '../type/schema';
import {
type FieldNode,
type DirectiveNode,
type VariableDefinitionNode,
} from '../language/ast';

type CoercedVariableValues = {|
Expand Down
17 changes: 8 additions & 9 deletions src/graphql.js
Expand Up @@ -10,16 +10,15 @@
import { validateSchema } from './type/validate';
import { parse } from './language/parser';
import { validate } from './validation/validate';
import { execute } from './execution/execute';
import type { ObjMap } from './jsutils/ObjMap';
import type { Source } from './language/source';
import type {
GraphQLFieldResolver,
GraphQLTypeResolver,
import { type ExecutionResult, execute } from './execution/execute';
import { type ObjMap } from './jsutils/ObjMap';
import { type Source } from './language/source';
import {
type GraphQLFieldResolver,
type GraphQLTypeResolver,
} from './type/definition';
import type { GraphQLSchema } from './type/schema';
import type { ExecutionResult } from './execution/execute';
import type { PromiseOrValue } from './jsutils/PromiseOrValue';
import { type GraphQLSchema } from './type/schema';
import { type PromiseOrValue } from './jsutils/PromiseOrValue';

/**
* This is the primary entry point function for fulfilling GraphQL operations
Expand Down
2 changes: 1 addition & 1 deletion src/jsutils/keyMap.js
Expand Up @@ -7,7 +7,7 @@
* @flow strict
*/

import type { ObjMap } from './ObjMap';
import { type ObjMap } from './ObjMap';

/**
* Creates a keyed JS object from an array, given a function to produce the keys
Expand Down
2 changes: 1 addition & 1 deletion src/jsutils/keyValMap.js
Expand Up @@ -7,7 +7,7 @@
* @flow strict
*/

import type { ObjMap } from './ObjMap';
import { type ObjMap } from './ObjMap';

/**
* Creates a keyed JS object from an array, given a function to produce the keys
Expand Down
2 changes: 1 addition & 1 deletion src/jsutils/mapValue.js
Expand Up @@ -7,7 +7,7 @@
* @flow strict
*/

import type { ObjMap } from './ObjMap';
import { type ObjMap } from './ObjMap';
import objectEntries from '../polyfills/objectEntries';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/jsutils/promiseForObject.js
Expand Up @@ -7,7 +7,7 @@
* @flow strict
*/

import type { ObjMap } from './ObjMap';
import { type ObjMap } from './ObjMap';

/**
* This function transforms a JS object `ObjMap<Promise<T>>` into
Expand Down
2 changes: 1 addition & 1 deletion src/jsutils/promiseReduce.js
Expand Up @@ -8,7 +8,7 @@
*/

import isPromise from './isPromise';
import type { PromiseOrValue } from './PromiseOrValue';
import { type PromiseOrValue } from './PromiseOrValue';

/**
* Similar to Array.prototype.reduce(), however the reducing callback may return
Expand Down
4 changes: 2 additions & 2 deletions src/language/ast.js
Expand Up @@ -7,8 +7,8 @@
* @flow strict
*/

import type { Source } from './source';
import type { TokenKindEnum } from './lexer';
import { type Source } from './source';
import { type TokenKindEnum } from './lexer';

/**
* Contains a range of UTF-8 character offsets and token references that
Expand Down
4 changes: 2 additions & 2 deletions src/language/lexer.js
Expand Up @@ -8,8 +8,8 @@
*/

import defineToJSON from '../jsutils/defineToJSON';
import type { Token } from './ast';
import type { Source } from './source';
import { type Token } from './ast';
import { type Source } from './source';
import { syntaxError } from '../error';
import { dedentBlockStringValue } from './blockString';

Expand Down
2 changes: 1 addition & 1 deletion src/language/location.js
Expand Up @@ -7,7 +7,7 @@
* @flow strict
*/

import type { Source } from './source';
import { type Source } from './source';

/**
* Represents a location in a Source.
Expand Down
110 changes: 57 additions & 53 deletions src/language/parser.js
Expand Up @@ -10,59 +10,63 @@
import inspect from '../jsutils/inspect';
import defineToJSON from '../jsutils/defineToJSON';
import { Source } from './source';
import { syntaxError } from '../error';
import type { GraphQLError } from '../error';
import { createLexer, TokenKind, getTokenDesc } from './lexer';
import type { Lexer, TokenKindEnum } from './lexer';
import type {
Location,
Token,
NameNode,
VariableNode,
DocumentNode,
DefinitionNode,
ExecutableDefinitionNode,
OperationDefinitionNode,
OperationTypeNode,
VariableDefinitionNode,
SelectionSetNode,
SelectionNode,
FieldNode,
ArgumentNode,
FragmentSpreadNode,
InlineFragmentNode,
FragmentDefinitionNode,
ValueNode,
StringValueNode,
ListValueNode,
ObjectValueNode,
ObjectFieldNode,
DirectiveNode,
TypeNode,
NamedTypeNode,
ListTypeNode,
NonNullTypeNode,
TypeSystemDefinitionNode,
SchemaDefinitionNode,
OperationTypeDefinitionNode,
ScalarTypeDefinitionNode,
ObjectTypeDefinitionNode,
FieldDefinitionNode,
InputValueDefinitionNode,
InterfaceTypeDefinitionNode,
UnionTypeDefinitionNode,
EnumTypeDefinitionNode,
EnumValueDefinitionNode,
InputObjectTypeDefinitionNode,
DirectiveDefinitionNode,
TypeSystemExtensionNode,
SchemaExtensionNode,
ScalarTypeExtensionNode,
ObjectTypeExtensionNode,
InterfaceTypeExtensionNode,
UnionTypeExtensionNode,
EnumTypeExtensionNode,
InputObjectTypeExtensionNode,
import { type GraphQLError, syntaxError } from '../error';
import {
type Lexer,
type TokenKindEnum,
TokenKind,
getTokenDesc,
createLexer,
} from './lexer';
import {
type Location,
type Token,
type NameNode,
type VariableNode,
type DocumentNode,
type DefinitionNode,
type ExecutableDefinitionNode,
type OperationDefinitionNode,
type OperationTypeNode,
type VariableDefinitionNode,
type SelectionSetNode,
type SelectionNode,
type FieldNode,
type ArgumentNode,
type FragmentSpreadNode,
type InlineFragmentNode,
type FragmentDefinitionNode,
type ValueNode,
type StringValueNode,
type ListValueNode,
type ObjectValueNode,
type ObjectFieldNode,
type DirectiveNode,
type TypeNode,
type NamedTypeNode,
type ListTypeNode,
type NonNullTypeNode,
type TypeSystemDefinitionNode,
type SchemaDefinitionNode,
type OperationTypeDefinitionNode,
type ScalarTypeDefinitionNode,
type ObjectTypeDefinitionNode,
type FieldDefinitionNode,
type InputValueDefinitionNode,
type InterfaceTypeDefinitionNode,
type UnionTypeDefinitionNode,
type EnumTypeDefinitionNode,
type EnumValueDefinitionNode,
type InputObjectTypeDefinitionNode,
type DirectiveDefinitionNode,
type TypeSystemExtensionNode,
type SchemaExtensionNode,
type ScalarTypeExtensionNode,
type ObjectTypeExtensionNode,
type InterfaceTypeExtensionNode,
type UnionTypeExtensionNode,
type EnumTypeExtensionNode,
type InputObjectTypeExtensionNode,
} from './ast';

import { Kind } from './kinds';
Expand Down

0 comments on commit 6dfc94c

Please sign in to comment.