Skip to content

Commit

Permalink
style: run prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
saihaj committed Nov 18, 2020
1 parent d0112ad commit 23a8baa
Show file tree
Hide file tree
Showing 30 changed files with 365 additions and 325 deletions.
4 changes: 2 additions & 2 deletions src/error/GraphQLError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export class GraphQLError extends Error {
source?: Maybe<Source>,
positions?: Maybe<ReadonlyArray<number>>,
path?: Maybe<ReadonlyArray<string | number>>,
originalError?: Maybe<(Error & { readonly extensions?: unknown })>,
originalError?: Maybe<Error & { readonly extensions?: unknown }>,
extensions?: Maybe<{ [key: string]: unknown }>,
) {
super(message);
Expand Down Expand Up @@ -134,7 +134,7 @@ export class GraphQLError extends Error {
}
}

Object.defineProperties((this as any), {
Object.defineProperties(this as any, {
name: { value: 'GraphQLError' },
message: {
value: message,
Expand Down
2 changes: 1 addition & 1 deletion src/error/locatedError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function locatedError(

// Note: this uses a brand-check to support GraphQL errors originating from other contexts.
if (Array.isArray(originalError.path)) {
return (originalError as any);
return originalError as any;
}

return new GraphQLError(
Expand Down
6 changes: 3 additions & 3 deletions src/execution/__tests__/abstract-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ import { buildSchema } from '../../utilities/buildASTSchema';
import { executeSync, execute } from '../execute';

async function executeQuery(args: {
schema: GraphQLSchema,
query: string,
rootValue?: unknown,
schema: GraphQLSchema;
query: string;
rootValue?: unknown;
}) {
const { schema, query, rootValue } = args;
const document = parse(query);
Expand Down
63 changes: 32 additions & 31 deletions src/execution/execute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,15 @@ import { Maybe } from '../jsutils/Maybe';
* and the fragments defined in the query document
*/
export type ExecutionContext = {
schema: GraphQLSchema,
fragments: ObjMap<FragmentDefinitionNode>,
rootValue: unknown,
contextValue: unknown,
operation: OperationDefinitionNode,
variableValues: { [variable: string]: unknown },
fieldResolver: GraphQLFieldResolver<any, any>,
typeResolver: GraphQLTypeResolver<any, any>,
errors: Array<GraphQLError>,
schema: GraphQLSchema;
fragments: ObjMap<FragmentDefinitionNode>;
rootValue: unknown;
contextValue: unknown;
operation: OperationDefinitionNode;
variableValues: { [variable: string]: unknown };
fieldResolver: GraphQLFieldResolver<any, any>;
typeResolver: GraphQLTypeResolver<any, any>;
errors: Array<GraphQLError>;
};

/**
Expand All @@ -113,26 +113,26 @@ export type ExecutionContext = {
* - `extensions` is reserved for adding non-standard properties.
*/
export type ExecutionResult = {
errors?: ReadonlyArray<GraphQLError>,
data?: ObjMap<unknown> | null,
extensions?: ObjMap<unknown>,
errors?: ReadonlyArray<GraphQLError>;
data?: ObjMap<unknown> | null;
extensions?: ObjMap<unknown>;
};

export type FormattedExecutionResult = {
errors?: ReadonlyArray<GraphQLFormattedError>,
data?: ObjMap<unknown> | null,
extensions?: ObjMap<unknown>,
errors?: ReadonlyArray<GraphQLFormattedError>;
data?: ObjMap<unknown> | null;
extensions?: ObjMap<unknown>;
};

export type ExecutionArgs = {
schema: GraphQLSchema,
document: DocumentNode,
rootValue?: unknown,
contextValue?: unknown,
variableValues?: Maybe<{ readonly [variable: string]: unknown }>,
operationName?: Maybe<string>,
fieldResolver?: Maybe<GraphQLFieldResolver<any, any>>,
typeResolver?: Maybe<GraphQLTypeResolver<any, any>>,
schema: GraphQLSchema;
document: DocumentNode;
rootValue?: unknown;
contextValue?: unknown;
variableValues?: Maybe<{ readonly [variable: string]: unknown }>;
operationName?: Maybe<string>;
fieldResolver?: Maybe<GraphQLFieldResolver<any, any>>;
typeResolver?: Maybe<GraphQLTypeResolver<any, any>>;
};

/**
Expand Down Expand Up @@ -887,7 +887,10 @@ function completeListValue(
* Complete a Scalar or Enum by serializing to a valid value, returning
* null if serialization is not possible.
*/
function completeLeafValue(returnType: GraphQLLeafType, result: unknown): unknown {
function completeLeafValue(
returnType: GraphQLLeafType,
result: unknown,
): unknown {
const serializedResult = returnType.serialize(result);
if (serializedResult === undefined) {
throw new Error(
Expand Down Expand Up @@ -1112,12 +1115,10 @@ function _collectSubfields(
* Otherwise, test each possible type for the abstract type by calling
* isTypeOf for the object being coerced, returning the first type that matches.
*/
export const defaultTypeResolver: GraphQLTypeResolver<unknown, unknown> = function (
value,
contextValue,
info,
abstractType,
) {
export const defaultTypeResolver: GraphQLTypeResolver<
unknown,
unknown
> = function (value, contextValue, info, abstractType) {
// First, look for `__typename`.
if (isObjectLike(value) && typeof value.__typename === 'string') {
return value.__typename;
Expand Down Expand Up @@ -1160,7 +1161,7 @@ export const defaultTypeResolver: GraphQLTypeResolver<unknown, unknown> = functi
*/
export const defaultFieldResolver: GraphQLFieldResolver<
unknown,
unknown,
unknown
> = function (source: any, args, contextValue, info) {
// ensure source is a value for which property access is acceptable.
if (isObjectLike(source) || typeof source === 'function') {
Expand Down
4 changes: 3 additions & 1 deletion src/jsutils/Path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ export function addPath(
/**
* Given a Path, return an Array of the path keys.
*/
export function pathToArray(path: Maybe<Readonly<Path>>): Array<string | number> {
export function pathToArray(
path: Maybe<Readonly<Path>>,
): Array<string | number> {
const flattened = [];
let curr = path;
while (curr) {
Expand Down
12 changes: 9 additions & 3 deletions src/jsutils/didYouMean.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@ const MAX_SUGGESTIONS = 5;
* Given [ A, B, C ] return ' Did you mean A, B, or C?'.
*/
function didYouMean(suggestions: ReadonlyArray<string>): string;
function didYouMean(subMessage: string, suggestions: ReadonlyArray<string>): string;
function didYouMean(firstArg:string|ReadonlyArray<string>, secondArg?: ReadonlyArray<string>):string {
function didYouMean(
subMessage: string,
suggestions: ReadonlyArray<string>,
): string;
function didYouMean(
firstArg: string | ReadonlyArray<string>,
secondArg?: ReadonlyArray<string>,
): string {
const [subMessage, suggestionsArg] =
typeof firstArg === 'string'
? [firstArg, secondArg]
Expand Down Expand Up @@ -33,4 +39,4 @@ function didYouMean(firstArg:string|ReadonlyArray<string>, secondArg?: ReadonlyA
return message + selected.join(', ') + ', or ' + lastItem + '?';
}

export default didYouMean
export default didYouMean;
3 changes: 2 additions & 1 deletion src/jsutils/instanceOf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ declare function instanceOf(value: unknown, constructor: unknown): boolean;
export default process.env.NODE_ENV === 'production'
? // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2317')
// eslint-disable-next-line no-shadow
function instanceOf(value: unknown, constructor: unknown): boolean { // FIXME: TS_CONVERTION %check
function instanceOf(value: unknown, constructor: unknown): boolean {
// FIXME: TS_CONVERTION %check
return value instanceof constructor;
}
: // eslint-disable-next-line no-shadow
Expand Down
4 changes: 3 additions & 1 deletion src/jsutils/isAsyncIterable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
* Returns true if the provided object implements the AsyncIterator protocol via
* either implementing a `Symbol.asyncIterator` or `"@@asyncIterator"` method.
*/
export default function isAsyncIterable(maybeAsyncIterable:unknown): maybeAsyncIterable is AsyncIterable<unknown> {
export default function isAsyncIterable(
maybeAsyncIterable: unknown,
): maybeAsyncIterable is AsyncIterable<unknown> {
if (maybeAsyncIterable == null || typeof maybeAsyncIterable !== 'object') {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/jsutils/isCollection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* An Object value which might implement the Iterable or Array-like protocols.
* @return {boolean} true if Iterable or Array-like Object.
*/
export default function isCollection(obj: unknown): obj is object| Symbol {
export default function isCollection(obj: unknown): obj is object | Symbol {
if (obj == null || typeof obj !== 'object') {
return false;
}
Expand Down
10 changes: 5 additions & 5 deletions src/jsutils/memoize3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
* Memoizes the provided three-argument function.
*/
export default function memoize3<
A1 extends WeakMap<{},ReadonlyArray<unknown>>,
A2 extends WeakMap<{},ReadonlyArray<unknown>>,
A3 extends WeakMap<{},ReadonlyArray<unknown>>,
R extends unknown,
>( fn: (a1: A1, a2: A2, a3: A3) => R): (a1: A1, a2: A2, a3: A3) => R {
A1 extends WeakMap<{}, ReadonlyArray<unknown>>,
A2 extends WeakMap<{}, ReadonlyArray<unknown>>,
A3 extends WeakMap<{}, ReadonlyArray<unknown>>,
R extends unknown
>(fn: (a1: A1, a2: A2, a3: A3) => R): (a1: A1, a2: A2, a3: A3) => R {
let cache0;

return function memoized(a1, a2, a3) {
Expand Down
10 changes: 5 additions & 5 deletions src/language/experimentalOnlineParser/grammar.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Maybe } from "../../jsutils/Maybe";
import { Maybe } from '../../jsutils/Maybe';

export type GraphQLGrammarType = {
[name: string]: GraphQLGrammarRule,
[name: string]: GraphQLGrammarRule;
};
export type GraphQLGrammarRuleName = string;
export type GraphQLGrammarRuleConstraint =
Expand All @@ -10,7 +10,7 @@ export type GraphQLGrammarRuleConstraint =
| GraphQLGrammarListOfTypeConstraint
| GraphQLGrammarPeekConstraint;
export type GraphQLGrammarConstraintsSet = Array<
GraphQLGrammarRuleName | GraphQLGrammarRuleConstraint,
GraphQLGrammarRuleName | GraphQLGrammarRuleConstraint
>;
export type GraphQLGrammarRule =
| GraphQLGrammarRuleName
Expand Down Expand Up @@ -71,7 +71,7 @@ export interface GraphQLGrammarPeekConstraintCondition {
end?: boolean;
}

const grammar: GraphQLGrammarType = ({
const grammar: GraphQLGrammarType = {
Name: { token: 'Name' },
String: { token: 'String' },
BlockString: { token: 'BlockString' },
Expand Down Expand Up @@ -996,6 +996,6 @@ const grammar: GraphQLGrammarType = ({
tokenName: 'EnumValue',
},
// FIXME: enforce proper typing
} as any);
} as any;

export default grammar;
48 changes: 24 additions & 24 deletions src/language/experimentalOnlineParser/onlineParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,33 +75,33 @@ type OnlineParserRule =
| ConstraintsSetOnlineParserRule;

export type OnlineParserState = {
rules: Array<OnlineParserRule>,
kind: () => string,
step: () => number,
levels: Array<number>,
indentLevel: number,
name: string | null,
type: string | null,
rules: Array<OnlineParserRule>;
kind: () => string;
step: () => number;
levels: Array<number>;
indentLevel: number;
name: string | null;
type: string | null;
};

type Token = {
kind: string,
value: string,
tokenName?: Maybe<string>,
ruleName?: Maybe<string>,
kind: string;
value: string;
tokenName?: Maybe<string>;
ruleName?: Maybe<string>;
};

type LexerToken = {
kind: string,
value: Maybe<string>,
kind: string;
value: Maybe<string>;
};

type OnlineParserConfig = {
tabSize: number,
tabSize: number;
};

type OnlineParserConfigOption = {
tabSize: Maybe<number>,
tabSize: Maybe<number>;
};

export class OnlineParser {
Expand Down Expand Up @@ -172,7 +172,7 @@ export class OnlineParser {
}

parseToken(): Token {
const rule = (this._getNextRule() as any);
const rule = this._getNextRule() as any;

if (this.sol()) {
this.state.indentLevel = Math.floor(
Expand Down Expand Up @@ -551,7 +551,7 @@ export class OnlineParser {

switch (this._getRuleKind(rule)) {
case RuleKind.RULE_NAME:
rule = (rule as GraphQLGrammarRuleName);
rule = rule as GraphQLGrammarRuleName;
this._pushRule(
GraphQLGrammar[rule],
depth,
Expand All @@ -561,7 +561,7 @@ export class OnlineParser {
);
break;
case RuleKind.CONSTRAINTS_SET:
rule = (rule as GraphQLGrammarConstraintsSet);
rule = rule as GraphQLGrammarConstraintsSet;
this.state.rules.push({
name: name || '',
depth,
Expand All @@ -581,7 +581,7 @@ export class OnlineParser {
});
break;
case RuleKind.OF_TYPE_CONSTRAINT:
rule = (rule as GraphQLGrammarOfTypeConstraint);
rule = rule as GraphQLGrammarOfTypeConstraint;
this.state.rules.push({
name: name || '',
ofType: rule.ofType,
Expand All @@ -604,7 +604,7 @@ export class OnlineParser {
});
break;
case RuleKind.LIST_OF_TYPE_CONSTRAINT:
rule = (rule as GraphQLGrammarListOfTypeConstraint);
rule = rule as GraphQLGrammarListOfTypeConstraint;
this.state.rules.push({
listOfType: rule.listOfType,
optional: Boolean(rule.optional),
Expand All @@ -626,7 +626,7 @@ export class OnlineParser {
});
break;
case RuleKind.TOKEN_CONSTRAINT:
rule = (rule as GraphQLGrammarTokenConstraint);
rule = rule as GraphQLGrammarTokenConstraint;
this.state.rules.push({
token: rule.token,
ofValue: rule.ofValue,
Expand All @@ -652,7 +652,7 @@ export class OnlineParser {
});
break;
case RuleKind.PEEK_CONSTRAINT:
rule = (rule as GraphQLGrammarPeekConstraint);
rule = rule as GraphQLGrammarPeekConstraint;
this.state.rules.push({
peek: rule.peek,
optional: Boolean(rule.optional),
Expand Down Expand Up @@ -710,12 +710,12 @@ export class OnlineParser {
}

_advanceToken(): LexerToken {
return (this._lexer.advance() as any);
return this._lexer.advance() as any;
}

_lookAhead(): LexerToken {
try {
return (this._lexer.lookahead() as any);
return this._lexer.lookahead() as any;
} catch (err) {
return { kind: TokenKind.INVALID, value: '' };
}
Expand Down
4 changes: 3 additions & 1 deletion src/language/lexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ export class Lexer {
/**
* @internal
*/
export function isPunctuatorTokenKind(kind: TokenKindEnum): kind is typeof TokenKind {
export function isPunctuatorTokenKind(
kind: TokenKindEnum,
): kind is typeof TokenKind {
return (
kind === TokenKind.BANG ||
kind === TokenKind.DOLLAR ||
Expand Down
Loading

0 comments on commit 23a8baa

Please sign in to comment.