Skip to content

Commit

Permalink
Update prettier to 2.3 (#3094)
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov committed May 15, 2021
1 parent 11d71e4 commit e94c2fa
Show file tree
Hide file tree
Showing 22 changed files with 71 additions and 76 deletions.
3 changes: 2 additions & 1 deletion benchmark/benchmark.js
Expand Up @@ -117,7 +117,8 @@ async function collectSamples(modulePath) {

// T-Distribution two-tailed critical values for 95% confidence.
// See http://www.itl.nist.gov/div898/handbook/eda/section3/eda3672.htm.
const tTable = /* prettier-ignore */ {
// prettier-ignore
const tTable = {
'1': 12.706, '2': 4.303, '3': 3.182, '4': 2.776, '5': 2.571, '6': 2.447,
'7': 2.365, '8': 2.306, '9': 2.262, '10': 2.228, '11': 2.201, '12': 2.179,
'13': 2.16, '14': 2.145, '15': 2.131, '16': 2.12, '17': 2.11, '18': 2.101,
Expand Down
2 changes: 1 addition & 1 deletion integrationTests/ts/index.ts
Expand Up @@ -21,7 +21,7 @@ declare module 'graphql' {
interface GraphQLFieldExtensions<
_TSource,
_TContext,
_TArgs = { [argName: string]: any }
_TArgs = { [argName: string]: any },
> {
someFieldExtension?: SomeExtension;
}
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -62,7 +62,7 @@
"flow-bin": "0.150.0",
"mocha": "8.3.2",
"nyc": "15.1.0",
"prettier": "2.2.1",
"prettier": "2.3.0",
"typescript": "4.2.4"
}
}
7 changes: 4 additions & 3 deletions resources/gen-changelog.js
Expand Up @@ -47,9 +47,10 @@ if (!packageJSON.repository || typeof packageJSON.repository.url !== 'string') {
process.exit(1);
}

const repoURLMatch = /https:\/\/github.com\/(?<githubOrg>[^/]+)\/(?<githubRepo>[^/]+).git/.exec(
packageJSON.repository.url,
);
const repoURLMatch =
/https:\/\/github.com\/(?<githubOrg>[^/]+)\/(?<githubRepo>[^/]+).git/.exec(
packageJSON.repository.url,
);
if (repoURLMatch == null) {
console.error('Cannot extract organization and repo name from repo URL!');
process.exit(1);
Expand Down
2 changes: 1 addition & 1 deletion src/error/formatError.d.ts
Expand Up @@ -12,7 +12,7 @@ export function formatError(error: GraphQLError): GraphQLFormattedError;
* @see https://github.com/graphql/graphql-spec/blob/master/spec/Section%207%20--%20Response.md#errors
*/
export interface GraphQLFormattedError<
TExtensions extends Record<string, unknown> = Record<string, unknown>
TExtensions extends Record<string, unknown> = Record<string, unknown>,
> {
/**
* A short, human-readable summary of the problem that **SHOULD NOT** change
Expand Down
4 changes: 2 additions & 2 deletions src/execution/execute.d.ts
Expand Up @@ -70,7 +70,7 @@ export interface ExecutionContext {
*/
export interface ExecutionResult<
TData = { [key: string]: any },
TExtensions = { [key: string]: any }
TExtensions = { [key: string]: any },
> {
errors?: ReadonlyArray<GraphQLError>;
// TS_SPECIFIC: TData. Motivation: https://github.com/graphql/graphql-js/pull/2490#issuecomment-639154229
Expand All @@ -80,7 +80,7 @@ export interface ExecutionResult<

export interface FormattedExecutionResult<
TData = { [key: string]: any },
TExtensions = { [key: string]: any }
TExtensions = { [key: string]: any },
> {
errors?: ReadonlyArray<GraphQLFormattedError>;
// TS_SPECIFIC: TData. Motivation: https://github.com/graphql/graphql-js/pull/2490#issuecomment-639154229
Expand Down
22 changes: 10 additions & 12 deletions src/execution/execute.js
Expand Up @@ -1140,19 +1140,17 @@ export const defaultTypeResolver: GraphQLTypeResolver<mixed, mixed> = function (
* and returns it as the result, or if it's a function, returns the result
* of calling that function while passing along args and context value.
*/
export const defaultFieldResolver: GraphQLFieldResolver<
mixed,
mixed,
> = function (source: any, args, contextValue, info) {
// ensure source is a value for which property access is acceptable.
if (isObjectLike(source) || typeof source === 'function') {
const property = source[info.fieldName];
if (typeof property === 'function') {
return source[info.fieldName](args, contextValue, info);
export const defaultFieldResolver: GraphQLFieldResolver<mixed, mixed> =
function (source: any, args, contextValue, info) {
// ensure source is a value for which property access is acceptable.
if (isObjectLike(source) || typeof source === 'function') {
const property = source[info.fieldName];
if (typeof property === 'function') {
return source[info.fieldName](args, contextValue, info);
}
return property;
}
return property;
}
};
};

/**
* This method looks up the field on the given type definition.
Expand Down
2 changes: 1 addition & 1 deletion src/jsutils/memoize3.d.ts
Expand Up @@ -6,5 +6,5 @@ export function memoize3<
A1 extends object,
A2 extends object,
A3 extends object,
R
R,
>(fn: (a1: A1, a2: A2, a3: A3) => R): (a1: A1, a2: A2, a3: A3) => R;
3 changes: 2 additions & 1 deletion src/language/directiveLocation.d.ts
Expand Up @@ -29,4 +29,5 @@ export const DirectiveLocation: Readonly<{
/**
* The enum type representing the directive location values.
*/
export type DirectiveLocationEnum = typeof DirectiveLocation[keyof typeof DirectiveLocation];
export type DirectiveLocationEnum =
typeof DirectiveLocation[keyof typeof DirectiveLocation];
8 changes: 4 additions & 4 deletions src/type/definition.d.ts
Expand Up @@ -472,7 +472,7 @@ export type GraphQLIsTypeOfFn<TSource, TContext> = (
export type GraphQLFieldResolver<
TSource,
TContext,
TArgs = { [argName: string]: any }
TArgs = { [argName: string]: any },
> = (
source: TSource,
args: TArgs,
Expand Down Expand Up @@ -508,15 +508,15 @@ export interface GraphQLResolveInfo {
export interface GraphQLFieldExtensions<
_TSource,
_TContext,
_TArgs = { [argName: string]: any }
_TArgs = { [argName: string]: any },
> {
[attributeName: string]: unknown;
}

export interface GraphQLFieldConfig<
TSource,
TContext,
TArgs = { [argName: string]: any }
TArgs = { [argName: string]: any },
> {
description?: Maybe<string>;
type: GraphQLOutputType;
Expand Down Expand Up @@ -561,7 +561,7 @@ export type GraphQLFieldConfigMap<TSource, TContext> = ObjMap<
export interface GraphQLField<
TSource,
TContext,
TArgs = { [key: string]: any }
TArgs = { [key: string]: any },
> {
name: string;
description: Maybe<string>;
Expand Down
3 changes: 2 additions & 1 deletion src/type/definition.js
Expand Up @@ -1430,7 +1430,8 @@ type GraphQLEnumTypeNormalizedConfig = {
extensionASTNodes: $ReadOnlyArray<EnumTypeExtensionNode>,
};

export type GraphQLEnumValueConfigMap /* <T> */ = ObjMap<GraphQLEnumValueConfig /* <T> */>;
export type GraphQLEnumValueConfigMap /* <T> */ =
ObjMap<GraphQLEnumValueConfig /* <T> */>;

export type GraphQLEnumValueConfig /* <T> */ = {
description?: ?string,
Expand Down
21 changes: 9 additions & 12 deletions src/type/directives.js
Expand Up @@ -167,8 +167,8 @@ export const DEFAULT_DEPRECATION_REASON = 'No longer supported';
/**
* Used to declare element of a GraphQL schema as deprecated.
*/
export const GraphQLDeprecatedDirective: GraphQLDirective = new GraphQLDirective(
{
export const GraphQLDeprecatedDirective: GraphQLDirective =
new GraphQLDirective({
name: 'deprecated',
description: 'Marks an element of a GraphQL schema as no longer supported.',
locations: [
Expand All @@ -185,14 +185,13 @@ export const GraphQLDeprecatedDirective: GraphQLDirective = new GraphQLDirective
defaultValue: DEFAULT_DEPRECATION_REASON,
},
},
},
);
});

/**
* Used to provide a URL for specifying the behaviour of custom scalar definitions.
*/
export const GraphQLSpecifiedByDirective: GraphQLDirective = new GraphQLDirective(
{
export const GraphQLSpecifiedByDirective: GraphQLDirective =
new GraphQLDirective({
name: 'specifiedBy',
description: 'Exposes a URL that specifies the behaviour of this scalar.',
locations: [DirectiveLocation.SCALAR],
Expand All @@ -202,20 +201,18 @@ export const GraphQLSpecifiedByDirective: GraphQLDirective = new GraphQLDirectiv
description: 'The URL that specifies the behaviour of this scalar.',
},
},
},
);
});

/**
* The full list of specified directives.
*/
export const specifiedDirectives: $ReadOnlyArray<GraphQLDirective> = Object.freeze(
[
export const specifiedDirectives: $ReadOnlyArray<GraphQLDirective> =
Object.freeze([
GraphQLIncludeDirective,
GraphQLSkipDirective,
GraphQLDeprecatedDirective,
GraphQLSpecifiedByDirective,
],
);
]);

export function isSpecifiedDirective(directive: GraphQLDirective): boolean {
return specifiedDirectives.some(({ name }) => name === directive.name);
Expand Down
7 changes: 3 additions & 4 deletions src/type/introspection.js
Expand Up @@ -528,8 +528,8 @@ export const TypeNameMetaFieldDef: GraphQLField<mixed, mixed> = {
astNode: undefined,
};

export const introspectionTypes: $ReadOnlyArray<GraphQLNamedType> = Object.freeze(
[
export const introspectionTypes: $ReadOnlyArray<GraphQLNamedType> =
Object.freeze([
__Schema,
__Directive,
__DirectiveLocation,
Expand All @@ -538,8 +538,7 @@ export const introspectionTypes: $ReadOnlyArray<GraphQLNamedType> = Object.freez
__InputValue,
__EnumValue,
__TypeKind,
],
);
]);

export function isIntrospectionType(type: GraphQLNamedType): boolean {
return introspectionTypes.some(({ name }) => type.name === name);
Expand Down
11 changes: 8 additions & 3 deletions src/type/scalars.js
Expand Up @@ -270,9 +270,14 @@ export const GraphQLID: GraphQLScalarType = new GraphQLScalarType({
},
});

export const specifiedScalarTypes: $ReadOnlyArray<GraphQLScalarType> = Object.freeze(
[GraphQLString, GraphQLInt, GraphQLFloat, GraphQLBoolean, GraphQLID],
);
export const specifiedScalarTypes: $ReadOnlyArray<GraphQLScalarType> =
Object.freeze([
GraphQLString,
GraphQLInt,
GraphQLFloat,
GraphQLBoolean,
GraphQLID,
]);

export function isSpecifiedScalarType(type: GraphQLNamedType): boolean {
return specifiedScalarTypes.some(({ name }) => type.name === name);
Expand Down
4 changes: 1 addition & 3 deletions src/type/schema.js
Expand Up @@ -282,9 +282,7 @@ export class GraphQLSchema {
: this.getImplementations(abstractType).objects;
}

getImplementations(
interfaceType: GraphQLInterfaceType,
): {
getImplementations(interfaceType: GraphQLInterfaceType): {
objects: /* $ReadOnly */ Array<GraphQLObjectType>,
interfaces: /* $ReadOnly */ Array<GraphQLInterfaceType>,
} {
Expand Down
5 changes: 2 additions & 3 deletions src/type/validate.js
Expand Up @@ -202,9 +202,8 @@ function validateName(
}

function validateTypes(context: SchemaValidationContext): void {
const validateInputObjectCircularRefs = createInputObjectCircularRefsValidator(
context,
);
const validateInputObjectCircularRefs =
createInputObjectCircularRefsValidator(context);
const typeMap = context.schema.getTypeMap();
for (const type of Object.values(typeMap)) {
// Ensure all provided types are in fact GraphQL type.
Expand Down
7 changes: 2 additions & 5 deletions src/utilities/__tests__/getOperationRootType-test.js
Expand Up @@ -77,11 +77,8 @@ describe('getOperationRootType', () => {

const schemaNode = doc.definitions[0];
invariant(schemaNode.kind === Kind.SCHEMA_DEFINITION);
const [
queryNode,
mutationNode,
subscriptionNode,
] = schemaNode.operationTypes;
const [queryNode, mutationNode, subscriptionNode] =
schemaNode.operationTypes;

expect(getOperationRootType(testSchema, queryNode)).to.equal(queryType);
expect(getOperationRootType(testSchema, mutationNode)).to.equal(
Expand Down
6 changes: 3 additions & 3 deletions src/utilities/getIntrospectionQuery.d.ts
Expand Up @@ -117,14 +117,14 @@ export interface IntrospectionInputObjectType {
}

export interface IntrospectionListTypeRef<
T extends IntrospectionTypeRef = IntrospectionTypeRef
T extends IntrospectionTypeRef = IntrospectionTypeRef,
> {
readonly kind: 'LIST';
readonly ofType: T;
}

export interface IntrospectionNonNullTypeRef<
T extends IntrospectionTypeRef = IntrospectionTypeRef
T extends IntrospectionTypeRef = IntrospectionTypeRef,
> {
readonly kind: 'NON_NULL';
readonly ofType: T;
Expand Down Expand Up @@ -154,7 +154,7 @@ export type IntrospectionInputTypeRef =
>;

export interface IntrospectionNamedTypeRef<
T extends IntrospectionType = IntrospectionType
T extends IntrospectionType = IntrospectionType,
> {
readonly kind: T['kind'];
readonly name: string;
Expand Down
2 changes: 1 addition & 1 deletion src/utilities/typedQueryDocumentNode.d.ts
Expand Up @@ -5,7 +5,7 @@ import { DocumentNode, ExecutableDefinitionNode } from '../language/ast';
*/
export interface TypedQueryDocumentNode<
TResponseData = Record<string, any>,
TRequestVariables = Record<string, any>
TRequestVariables = Record<string, any>,
> extends DocumentNode {
readonly definitions: ReadonlyArray<ExecutableDefinitionNode>;
// FIXME: remove once TS implements proper way to enforce nominal typing
Expand Down
5 changes: 2 additions & 3 deletions src/validation/rules/FieldsOnCorrectTypeRule.js
Expand Up @@ -80,9 +80,8 @@ function getSuggestedTypeNames(
return [];
}

const suggestedTypes: Set<
GraphQLObjectType | GraphQLInterfaceType,
> = new Set();
const suggestedTypes: Set<GraphQLObjectType | GraphQLInterfaceType> =
new Set();
const usageCount = Object.create(null);
for (const possibleType of schema.getPossibleTypes(type)) {
if (!possibleType.getFields()[fieldName]) {
Expand Down
7 changes: 3 additions & 4 deletions src/validation/specifiedRules.js
Expand Up @@ -131,8 +131,8 @@ export const specifiedRules: $ReadOnlyArray<ValidationRule> = Object.freeze([
/**
* @internal
*/
export const specifiedSDLRules: $ReadOnlyArray<SDLValidationRule> = Object.freeze(
[
export const specifiedSDLRules: $ReadOnlyArray<SDLValidationRule> =
Object.freeze([
LoneSchemaDefinitionRule,
UniqueOperationTypesRule,
UniqueTypeNamesRule,
Expand All @@ -147,5 +147,4 @@ export const specifiedSDLRules: $ReadOnlyArray<SDLValidationRule> = Object.freez
UniqueArgumentNamesRule,
UniqueInputFieldNamesRule,
ProvidedRequiredArgumentsOnDirectivesRule,
],
);
]);

0 comments on commit e94c2fa

Please sign in to comment.