From 730e58b030658edef0aa904218156042d53d8316 Mon Sep 17 00:00:00 2001 From: Jovi De Croock Date: Fri, 5 Aug 2022 21:11:21 +0200 Subject: [PATCH] prettier --- src/execution/collectFields.ts | 4 +- src/execution/execute.ts | 10 +++-- src/execution/values.ts | 4 +- src/jsutils/groupBy.ts | 2 +- src/jsutils/keyMap.ts | 2 +- src/jsutils/keyValMap.ts | 2 +- src/jsutils/mapValue.ts | 4 +- src/jsutils/toObjMap.ts | 4 +- src/language/visitor.ts | 10 ++--- src/type/schema.ts | 26 +++++------ src/type/validate.ts | 44 +++++++++---------- src/utilities/astFromValue.ts | 4 +- src/utilities/buildASTSchema.ts | 2 +- src/utilities/buildClientSchema.ts | 4 +- src/utilities/coerceInputValue.ts | 8 ++-- src/utilities/extendSchema.ts | 26 +++++------ src/utilities/getOperationAST.ts | 2 +- src/utilities/valueFromAST.ts | 4 +- src/validation/ValidationContext.ts | 15 ++++--- .../rules/ProvidedRequiredArgumentsRule.ts | 4 +- .../rules/UniqueVariableNamesRule.ts | 5 ++- 21 files changed, 98 insertions(+), 88 deletions(-) diff --git a/src/execution/collectFields.ts b/src/execution/collectFields.ts index 86cb800e95..fa7e999430 100644 --- a/src/execution/collectFields.ts +++ b/src/execution/collectFields.ts @@ -71,7 +71,7 @@ export function collectSubfields( const subFieldNodes = new AccumulatorMap(); const visitedFragmentNames = new Set(); for (let i = 0; i < fieldNodes.length; i++) { - const node = fieldNodes[i] + const node = fieldNodes[i]; if (node.selectionSet) { collectFieldsImpl( schema, @@ -98,7 +98,7 @@ function collectFieldsImpl( visitedFragmentNames: Set, ): void { for (let i = 0; i < selectionSet.selections.length; i++) { - const selection = selectionSet.selections[i] + const selection = selectionSet.selections[i]; switch (selection.kind) { case Kind.FIELD: { if (!shouldIncludeNode(variableValues, selection)) { diff --git a/src/execution/execute.ts b/src/execution/execute.ts index b5a16807f7..885a9fd87c 100644 --- a/src/execution/execute.ts +++ b/src/execution/execute.ts @@ -266,7 +266,7 @@ export function buildExecutionContext( let operation: OperationDefinitionNode | undefined; const fragments: ObjMap = Object.create(null); for (let i = 0; i < document.definitions.length; i++) { - const definition = document.definitions[i] + const definition = document.definitions[i]; switch (definition.kind) { case Kind.OPERATION_DEFINITION: if (operationName == null) { @@ -432,9 +432,9 @@ function executeFields( const results = Object.create(null); let containsPromise = false; - const fieldsEntries = Array.from(fields.entries()) + const fieldsEntries = Array.from(fields.entries()); for (let i = 0; i < fieldsEntries.length; i++) { - const { 0: responseName, 1: fieldNodes } = fieldsEntries[i] + const { 0: responseName, 1: fieldNodes } = fieldsEntries[i]; const fieldPath = addPath(path, responseName, parentType.name); const result = executeField( exeContext, @@ -1230,7 +1230,9 @@ function executeSubscription( rootType, operation.selectionSet, ); - const {0:responseName, 1:fieldNodes} = Array.from(rootFields.entries())[0]; + const { 0: responseName, 1: fieldNodes } = Array.from( + rootFields.entries(), + )[0]; const fieldName = fieldNodes[0].name.value; const fieldDef = schema.getField(rootType, fieldName); diff --git a/src/execution/values.ts b/src/execution/values.ts index 154cf342f5..5e2fb3a157 100644 --- a/src/execution/values.ts +++ b/src/execution/values.ts @@ -77,7 +77,7 @@ function coerceVariableValues( ): { [variable: string]: unknown } { const coercedValues: { [variable: string]: unknown } = {}; for (let i = 0; i < varDefNodes.length; i++) { - const varDefNode = varDefNodes[i] + const varDefNode = varDefNodes[i]; const varName = varDefNode.variable.name.value; const varType = typeFromAST(schema, varDefNode.type); if (!isInputType(varType)) { @@ -163,7 +163,7 @@ export function getArgumentValues( const argNodeMap = keyMap(argumentNodes, (arg) => arg.name.value); for (let i = 0; i < def.args.length; i++) { - const argDef = def.args[i] + const argDef = def.args[i]; const name = argDef.name; const argType = argDef.type; const argumentNode = argNodeMap[name]; diff --git a/src/jsutils/groupBy.ts b/src/jsutils/groupBy.ts index 88a933d44f..c56b249336 100644 --- a/src/jsutils/groupBy.ts +++ b/src/jsutils/groupBy.ts @@ -9,7 +9,7 @@ export function groupBy( ): Map> { const result = new AccumulatorMap(); for (let i = 0; i < list.length; i++) { - const item = list[i] + const item = list[i]; result.add(keyFn(item), item); } return result; diff --git a/src/jsutils/keyMap.ts b/src/jsutils/keyMap.ts index 28ca94ab65..bb25904212 100644 --- a/src/jsutils/keyMap.ts +++ b/src/jsutils/keyMap.ts @@ -33,7 +33,7 @@ export function keyMap( ): ObjMap { const result = Object.create(null); for (let i = 0; i < list.length; i++) { - const key = list[i] + const key = list[i]; result[keyFn(key)] = key; } return result; diff --git a/src/jsutils/keyValMap.ts b/src/jsutils/keyValMap.ts index d7ace7d6b1..e4e1f7e181 100644 --- a/src/jsutils/keyValMap.ts +++ b/src/jsutils/keyValMap.ts @@ -24,7 +24,7 @@ export function keyValMap( ): ObjMap { const result = Object.create(null); for (let i = 0; i < list.length; i++) { - const item = list[i] + const item = list[i]; result[keyFn(item)] = valFn(item); } return result; diff --git a/src/jsutils/mapValue.ts b/src/jsutils/mapValue.ts index 989daf6539..61a4dfb135 100644 --- a/src/jsutils/mapValue.ts +++ b/src/jsutils/mapValue.ts @@ -9,9 +9,9 @@ export function mapValue( fn: (value: T, key: string) => V, ): ObjMap { const result = Object.create(null); - const keys = Object.keys(map) + const keys = Object.keys(map); for (let i = 0; i < keys.length; i++) { - const key = keys[i] + const key = keys[i]; result[key] = fn(map[key], key); } return result; diff --git a/src/jsutils/toObjMap.ts b/src/jsutils/toObjMap.ts index 18ece32181..72f6c86b46 100644 --- a/src/jsutils/toObjMap.ts +++ b/src/jsutils/toObjMap.ts @@ -13,9 +13,9 @@ export function toObjMap( } const map = Object.create(null); - const entries = Object.entries(obj) + const entries = Object.entries(obj); for (let i = 0; i < entries.length; i++) { - const { 0: key, 1: value } = entries[i] + const { 0: key, 1: value } = entries[i]; map[key] = value; } return map; diff --git a/src/language/visitor.ts b/src/language/visitor.ts index b7317781b9..10f8dd5cd6 100644 --- a/src/language/visitor.ts +++ b/src/language/visitor.ts @@ -85,7 +85,7 @@ export type ASTVisitorKeyMap = { }; export const BREAK: unknown = Object.freeze({}); -const KINDS = Object.values(Kind) +const KINDS = Object.values(Kind); /** * visit() will walk through an AST using a depth-first traversal, calling @@ -182,7 +182,7 @@ export function visit( ): any { const enterLeaveMap = new Map>(); for (let i = 0; i < KINDS.length; i++) { - const kind = KINDS[i] + const kind = KINDS[i]; enterLeaveMap.set(kind, getEnterLeaveForKind(visitor, kind)); } @@ -213,7 +213,7 @@ export function visit( let editOffset = 0; for (let i = 0; i < edits.length; i++) { - const { 0: editKey, 1: editValue } = edits[i] + const { 0: editKey, 1: editValue } = edits[i]; const arrayKey = editKey - editOffset; if (editValue === null) { node.splice(arrayKey, 1); @@ -228,7 +228,7 @@ export function visit( Object.getOwnPropertyDescriptors(node), ); for (let i = 0; i < edits.length; i++) { - const { 0: editKey, 1: editValue } = edits[i] + const { 0: editKey, 1: editValue } = edits[i]; node[editKey] = editValue; } } @@ -319,7 +319,7 @@ export function visitInParallel( const mergedVisitor = Object.create(null); for (let j = 0; j < KINDS.length; j++) { - const kind = KINDS[j] + const kind = KINDS[j]; let hasVisitor = false; const enterList = new Array(visitors.length).fill(undefined); const leaveList = new Array(visitors.length).fill(undefined); diff --git a/src/type/schema.ts b/src/type/schema.ts index f8a1806697..5bca9f38a6 100644 --- a/src/type/schema.ts +++ b/src/type/schema.ts @@ -173,7 +173,7 @@ export class GraphQLSchema { const allReferencedTypes = new Set(config.types); if (config.types != null) { for (let i = 0; i < config.types.length; i++) { - const type = config.types[i] + const type = config.types[i]; // When we ready to process this type, we remove it from "collected" types // and then add it together with all dependent types in the correct position. allReferencedTypes.delete(type); @@ -192,11 +192,11 @@ export class GraphQLSchema { } for (let i = 0; i < this._directives.length; i++) { - const directive = this._directives[i] + const directive = this._directives[i]; // Directives are not validated until validateSchema() is called. if (isDirective(directive)) { - for (let j = 0; j < directive.args.length; j++) { - const arg = directive.args[j] + for (let j = 0; j < directive.args.length; j++) { + const arg = directive.args[j]; collectReferencedTypes(arg.type, allReferencedTypes); } } @@ -209,9 +209,9 @@ export class GraphQLSchema { // Keep track of all implementations by interface name. this._implementationsMap = Object.create(null); - const refTypes = Array.from(allReferencedTypes) + const refTypes = Array.from(allReferencedTypes); for (let j = 0; j < refTypes.length; j++) { - const namedType = refTypes[j] + const namedType = refTypes[j]; if (namedType == null) { continue; } @@ -228,7 +228,7 @@ export class GraphQLSchema { // Store implementations by interface. const interfaces = namedType.getInterfaces(); for (let i = 0; i < interfaces.length; i++) { - const iface = interfaces[i] + const iface = interfaces[i]; if (isInterfaceType(iface)) { let implementations = this._implementationsMap[iface.name]; if (implementations === undefined) { @@ -245,7 +245,7 @@ export class GraphQLSchema { // Store implementations by objects. const interfaces = namedType.getInterfaces(); for (let i = 0; i < interfaces.length; i++) { - const iface = interfaces[i] + const iface = interfaces[i]; if (isInterfaceType(iface)) { let implementations = this._implementationsMap[iface.name]; if (implementations === undefined) { @@ -322,7 +322,7 @@ export class GraphQLSchema { map = Object.create(null); if (isUnionType(abstractType)) { - const types = abstractType.getTypes() + const types = abstractType.getTypes(); for (let i = 0; i < types.length; i++) { map[types[i].name] = true; } @@ -452,21 +452,21 @@ function collectReferencedTypes( collectReferencedTypes(types[i], typeSet); } } else if (isObjectType(namedType) || isInterfaceType(namedType)) { - const interfaces = namedType.getInterfaces() + const interfaces = namedType.getInterfaces(); for (let i = 0; i < interfaces.length; i++) { collectReferencedTypes(interfaces[i], typeSet); } - const fields = Object.values(namedType.getFields()) + const fields = Object.values(namedType.getFields()); for (let i = 0; i < fields.length; i++) { - const field = fields[i] + const field = fields[i]; collectReferencedTypes(field.type, typeSet); for (let j = 0; j < field.args.length; j++) { collectReferencedTypes(field.args[j].type, typeSet); } } } else if (isInputObjectType(namedType)) { - const fields = Object.values(namedType.getFields()) + const fields = Object.values(namedType.getFields()); for (let i = 0; i < fields.length; i++) { collectReferencedTypes(fields[i].type, typeSet); } diff --git a/src/type/validate.ts b/src/type/validate.ts index 413e2fecd5..75384832e6 100644 --- a/src/type/validate.ts +++ b/src/type/validate.ts @@ -124,9 +124,9 @@ function validateRootTypes(context: SchemaValidationContext): void { GraphQLObjectType, OperationTypeNode >(); - const operationTypeNodes = Object.values(OperationTypeNode) + const operationTypeNodes = Object.values(OperationTypeNode); for (let i = 0; i < operationTypeNodes.length; i++) { - const operationType = operationTypeNodes[i] + const operationType = operationTypeNodes[i]; const rootType = schema.getRootType(operationType); if (rootType != null) { @@ -146,9 +146,9 @@ function validateRootTypes(context: SchemaValidationContext): void { } } - const rootTypeEntries = Array.from(rootTypesMap.entries()) + const rootTypeEntries = Array.from(rootTypesMap.entries()); for (let i = 0; i < rootTypeEntries.length; i++) { - const { 0: rootType, 1: operationTypes } = rootTypeEntries[i] + const { 0: rootType, 1: operationTypes } = rootTypeEntries[i]; if (operationTypes.length > 1) { const operationList = andList(operationTypes); context.reportError( @@ -174,9 +174,9 @@ function getOperationTypeNode( } function validateDirectives(context: SchemaValidationContext): void { - const directives = context.schema.getDirectives() + const directives = context.schema.getDirectives(); for (let i = 0; i < directives.length; i++) { - const directive = directives[i] + const directive = directives[i]; // Ensure all directives are in fact GraphQL directives. if (!isDirective(directive)) { context.reportError( @@ -193,7 +193,7 @@ function validateDirectives(context: SchemaValidationContext): void { // Ensure the arguments are valid. for (let j = 0; j < directive.args.length; j++) { - const arg = directive.args[j] + const arg = directive.args[j]; // Ensure they are named correctly. validateName(context, arg); @@ -234,7 +234,7 @@ function validateTypes(context: SchemaValidationContext): void { createInputObjectCircularRefsValidator(context); const types = Object.values(context.schema.getTypeMap()); for (let i = 0; i < types.length; i++) { - const type = types[i] + const type = types[i]; // Ensure all provided types are in fact GraphQL type. if (!isNamedType(type)) { context.reportError( @@ -292,7 +292,7 @@ function validateFields( } for (let i = 0; i < fields.length; i++) { - const field = fields[i] + const field = fields[i]; // Ensure they are named correctly. validateName(context, field); @@ -307,7 +307,7 @@ function validateFields( // Ensure the arguments are valid for (let j = 0; j < field.args.length; j++) { - const arg = field.args[j] + const arg = field.args[j]; const argName = arg.name; // Ensure they are named correctly. @@ -339,7 +339,7 @@ function validateInterfaces( const ifaceTypeNames = Object.create(null); const interfaces = type.getInterfaces(); for (let i = 0; i < interfaces.length; i++) { - const iface = interfaces[i] + const iface = interfaces[i]; if (!isInterfaceType(iface)) { context.reportError( `Type ${inspect(type)} must only implement Interface types, ` + @@ -380,9 +380,9 @@ function validateTypeImplementsInterface( const typeFieldMap = type.getFields(); // Assert each interface field is implemented. - const interfaceFields = Object.values(iface.getFields()) + const interfaceFields = Object.values(iface.getFields()); for (let i = 0; i < interfaceFields.length; i++) { - const ifaceField = interfaceFields[i] + const ifaceField = interfaceFields[i]; const fieldName = ifaceField.name; const typeField = typeFieldMap[fieldName]; @@ -407,8 +407,8 @@ function validateTypeImplementsInterface( } // Assert each interface field arg is implemented. - for (let j = 0; j < ifaceField.args.length; j++) { - const ifaceArg = ifaceField.args[j] + for (let j = 0; j < ifaceField.args.length; j++) { + const ifaceArg = ifaceField.args[j]; const argName = ifaceArg.name; const typeArg = typeField.args.find((arg) => arg.name === argName); @@ -438,8 +438,8 @@ function validateTypeImplementsInterface( } // Assert additional arguments must not be required. - for (let j = 0; j < typeField.args.length; j++) { - const typeArg = typeField.args[j] + for (let j = 0; j < typeField.args.length; j++) { + const typeArg = typeField.args[j]; const argName = typeArg.name; const ifaceArg = ifaceField.args.find((arg) => arg.name === argName); if (!ifaceArg && isRequiredArgument(typeArg)) { @@ -458,9 +458,9 @@ function validateTypeImplementsAncestors( iface: GraphQLInterfaceType, ): void { const ifaceInterfaces = type.getInterfaces(); - const interfaces = iface.getInterfaces() + const interfaces = iface.getInterfaces(); for (let i = 0; i < interfaces.length; i++) { - const transitive = interfaces[i] + const transitive = interfaces[i]; if (!ifaceInterfaces.includes(transitive)) { context.reportError( transitive === type @@ -490,7 +490,7 @@ function validateUnionMembers( const includedTypeNames = Object.create(null); for (let i = 0; i < memberTypes.length; i++) { - const memberType = memberTypes[i] + const memberType = memberTypes[i]; if (includedTypeNames[memberType.name]) { context.reportError( `Union type ${union.name} can only include type ${memberType.name} once.`, @@ -543,7 +543,7 @@ function validateInputFields( // Ensure the arguments are valid for (let i = 0; i < fields.length; i++) { - const field = fields[i] + const field = fields[i]; // Ensure they are named correctly. validateName(context, field); @@ -594,7 +594,7 @@ function createInputObjectCircularRefsValidator( const fields = Object.values(inputObj.getFields()); for (let i = 0; i < fields.length; i++) { - const field = fields[i] + const field = fields[i]; if (isNonNullType(field.type) && isInputObjectType(field.type.ofType)) { const fieldType = field.type.ofType; const cycleIndex = fieldPathIndexByTypeName[fieldType.name]; diff --git a/src/utilities/astFromValue.ts b/src/utilities/astFromValue.ts index 92a02a083f..b8c2fd3adb 100644 --- a/src/utilities/astFromValue.ts +++ b/src/utilities/astFromValue.ts @@ -84,9 +84,9 @@ export function astFromValue( return null; } const fieldNodes: Array = []; - const fields = Object.values(type.getFields()) + const fields = Object.values(type.getFields()); for (let i = 0; i < fields.length; i++) { - const field = fields[i] + const field = fields[i]; const fieldValue = astFromValue(value[field.name], field.type); if (fieldValue) { fieldNodes.push({ diff --git a/src/utilities/buildASTSchema.ts b/src/utilities/buildASTSchema.ts index c44b2efa47..3137d2f73b 100644 --- a/src/utilities/buildASTSchema.ts +++ b/src/utilities/buildASTSchema.ts @@ -50,7 +50,7 @@ export function buildASTSchema( if (config.astNode == null) { for (let i = 0; i < config.types.length; i++) { - const type = config.types[i] + const type = config.types[i]; switch (type.name) { // Note: While this could make early assertions to get the correctly // typed values below, that would throw immediately while type system diff --git a/src/utilities/buildClientSchema.ts b/src/utilities/buildClientSchema.ts index acefa2381c..4330e8ea6f 100644 --- a/src/utilities/buildClientSchema.ts +++ b/src/utilities/buildClientSchema.ts @@ -85,9 +85,9 @@ export function buildClientSchema( ); // Include standard types only if they are used. - const stdTypes = [...specifiedScalarTypes, ...introspectionTypes] + const stdTypes = [...specifiedScalarTypes, ...introspectionTypes]; for (let i = 0; i < stdTypes.length; i++) { - const stdType = stdTypes[i] + const stdType = stdTypes[i]; if (typeMap[stdType.name]) { typeMap[stdType.name] = stdType; } diff --git a/src/utilities/coerceInputValue.ts b/src/utilities/coerceInputValue.ts index a00c9abb4c..1d32099991 100644 --- a/src/utilities/coerceInputValue.ts +++ b/src/utilities/coerceInputValue.ts @@ -97,10 +97,10 @@ function coerceInputValueImpl( const coercedValue: any = {}; const fieldDefs = type.getFields(); - const fields = Object.values(fieldDefs) + const fields = Object.values(fieldDefs); for (let i = 0; i < fields.length; i++) { - const field = fields[i] + const field = fields[i]; const fieldValue = inputValue[field.name]; if (fieldValue === undefined) { @@ -128,9 +128,9 @@ function coerceInputValueImpl( } // Ensure every provided field is defined. - const inputKeys = Object.keys(inputValue) + const inputKeys = Object.keys(inputValue); for (let i = 0; i < inputKeys.length; i++) { - const fieldName = inputKeys[i] + const fieldName = inputKeys[i]; if (!fieldDefs[fieldName]) { const suggestions = suggestionList( fieldName, diff --git a/src/utilities/extendSchema.ts b/src/utilities/extendSchema.ts index 420b5074dc..ac19049fc1 100644 --- a/src/utilities/extendSchema.ts +++ b/src/utilities/extendSchema.ts @@ -142,7 +142,7 @@ export function extendSchemaImpl( const schemaExtensions: Array = []; for (let i = 0; i < documentAST.definitions.length; i++) { - const def = documentAST.definitions[i] + const def = documentAST.definitions[i]; if (def.kind === Kind.SCHEMA_DEFINITION) { schemaDef = def; } else if (def.kind === Kind.SCHEMA_EXTENSION) { @@ -174,12 +174,12 @@ export function extendSchemaImpl( const typeMap = Object.create(null); for (let i = 0; i < schemaConfig.types.length; i++) { - const existingType = schemaConfig.types[i] + const existingType = schemaConfig.types[i]; typeMap[existingType.name] = extendNamedType(existingType); } for (let i = 0; i < typeDefs.length; i++) { - const typeNode = typeDefs[i] + const typeNode = typeDefs[i]; const name = typeNode.name.value; typeMap[name] = stdTypeMap[name] ?? buildType(typeNode); } @@ -313,7 +313,7 @@ export function extendSchemaImpl( let specifiedByURL = config.specifiedByURL; for (let i = 0; i < extensions.length; i++) { - const extensionNode = extensions[i] + const extensionNode = extensions[i]; specifiedByURL = getSpecifiedByURL(extensionNode) ?? specifiedByURL; } @@ -402,13 +402,13 @@ export function extendSchemaImpl( } { const opTypes = {}; for (let i = 0; i < nodes.length; i++) { - const node = nodes[i] + const node = nodes[i]; // FIXME: https://github.com/graphql/graphql-js/issues/2203 const operationTypesNodes = /* c8 ignore next */ node.operationTypes ?? []; for (let j = 0; j < operationTypesNodes.length; j++) { - const operationType = operationTypesNodes[j] + const operationType = operationTypesNodes[j]; // Note: While this could make early assertions to get the correctly // typed values below, that would throw immediately while type system // validation with validateSchema() will produce more actionable results. @@ -462,12 +462,12 @@ export function extendSchemaImpl( ): GraphQLFieldConfigMap { const fieldConfigMap = Object.create(null); for (let i = 0; i < nodes.length; i++) { - const node = nodes[i] + const node = nodes[i]; // FIXME: https://github.com/graphql/graphql-js/issues/2203 const nodeFields = /* c8 ignore next */ node.fields ?? []; for (let j = 0; j < nodeFields.length; j++) { - const field = nodeFields[j] + const field = nodeFields[j]; fieldConfigMap[field.name.value] = { // Note: While this could make assertions to get the correctly typed // value, that would throw immediately while type system validation @@ -491,7 +491,7 @@ export function extendSchemaImpl( const argConfigMap = Object.create(null); for (let i = 0; i < argsNodes.length; i++) { - const arg = argsNodes[i] + const arg = argsNodes[i]; // Note: While this could make assertions to get the correctly typed // value, that would throw immediately while type system validation // with validateSchema() will produce more actionable results. @@ -515,12 +515,12 @@ export function extendSchemaImpl( ): GraphQLInputFieldConfigMap { const inputFieldMap = Object.create(null); for (let i = 0; i < nodes.length; i++) { - const node = nodes[i] + const node = nodes[i]; // FIXME: https://github.com/graphql/graphql-js/issues/2203 const fieldsNodes = /* c8 ignore next */ node.fields ?? []; for (let j = 0; j < fieldsNodes.length; j++) { - const field = fieldsNodes[j] + const field = fieldsNodes[j]; // Note: While this could make assertions to get the correctly typed // value, that would throw immediately while type system validation // with validateSchema() will produce more actionable results. @@ -543,12 +543,12 @@ export function extendSchemaImpl( ): GraphQLEnumValueConfigMap { const enumValueMap = Object.create(null); for (let i = 0; i < nodes.length; i++) { - const node = nodes[i] + const node = nodes[i]; // FIXME: https://github.com/graphql/graphql-js/issues/2203 const valuesNodes = /* c8 ignore next */ node.values ?? []; for (let j = 0; j < valuesNodes.length; j++) { - const value = valuesNodes[j] + const value = valuesNodes[j]; enumValueMap[value.name.value] = { description: value.description?.value, deprecationReason: getDeprecationReason(value), diff --git a/src/utilities/getOperationAST.ts b/src/utilities/getOperationAST.ts index 48a6733c1c..de1da0747a 100644 --- a/src/utilities/getOperationAST.ts +++ b/src/utilities/getOperationAST.ts @@ -14,7 +14,7 @@ export function getOperationAST( ): Maybe { let operation = null; for (let i = 0; i < documentAST.definitions.length; i++) { - const definition = documentAST.definitions[i] + const definition = documentAST.definitions[i]; if (definition.kind === Kind.OPERATION_DEFINITION) { if (operationName == null) { // If no operation name was provided, only return an Operation if there diff --git a/src/utilities/valueFromAST.ts b/src/utilities/valueFromAST.ts index 3a32d947c4..db31754840 100644 --- a/src/utilities/valueFromAST.ts +++ b/src/utilities/valueFromAST.ts @@ -110,9 +110,9 @@ export function valueFromAST( } const coercedObj = Object.create(null); const fieldNodes = keyMap(valueNode.fields, (field) => field.name.value); - const typeFields = Object.values(type.getFields()) + const typeFields = Object.values(type.getFields()); for (let i = 0; i < typeFields.length; i++) { - const field = typeFields[i] + const field = typeFields[i]; const fieldNode = fieldNodes[field.name]; if (!fieldNode || isMissingVariable(fieldNode.value, variables)) { if (field.defaultValue !== undefined) { diff --git a/src/validation/ValidationContext.ts b/src/validation/ValidationContext.ts index 4f3520924f..68257dd832 100644 --- a/src/validation/ValidationContext.ts +++ b/src/validation/ValidationContext.ts @@ -78,7 +78,7 @@ export class ASTValidationContext { fragments = Object.create(null); const docDefs = this.getDocument().definitions; for (let i = 0; i < docDefs.length; i++) { - const defNode = docDefs[i] + const defNode = docDefs[i]; if (defNode.kind === Kind.FRAGMENT_DEFINITION) { fragments[defNode.name.value] = defNode; } @@ -98,7 +98,7 @@ export class ASTValidationContext { let set: SelectionSetNode | undefined; while ((set = setsToVisit.pop())) { for (let i = 0; i < set.selections.length; i++) { - const selection = set.selections[i] + const selection = set.selections[i]; if (selection.kind === Kind.FRAGMENT_SPREAD) { spreads.push(selection); } else if (selection.selectionSet) { @@ -121,9 +121,9 @@ export class ASTValidationContext { const nodesToVisit: Array = [operation.selectionSet]; let node: SelectionSetNode | undefined; while ((node = nodesToVisit.pop())) { - const spreads = this.getFragmentSpreads(node) + const spreads = this.getFragmentSpreads(node); for (let i = 0; i < spreads.length; i++) { - const spread = spreads[i] + const spread = spreads[i]; const fragName = spread.name.value; if (collectedNames[fragName] !== true) { collectedNames[fragName] = true; @@ -230,9 +230,12 @@ export class ValidationContext extends ASTValidationContext { let usages = this._recursiveVariableUsages.get(operation); if (!usages) { usages = this.getVariableUsages(operation); - const recursivelyReferencedFragments = this.getRecursivelyReferencedFragments(operation) + const recursivelyReferencedFragments = + this.getRecursivelyReferencedFragments(operation); for (let i = 0; i < recursivelyReferencedFragments.length; i++) { - usages = usages.concat(this.getVariableUsages(recursivelyReferencedFragments[i])); + usages = usages.concat( + this.getVariableUsages(recursivelyReferencedFragments[i]), + ); } this._recursiveVariableUsages.set(operation, usages); } diff --git a/src/validation/rules/ProvidedRequiredArgumentsRule.ts b/src/validation/rules/ProvidedRequiredArgumentsRule.ts index 4b6a477985..a281d5b0b1 100644 --- a/src/validation/rules/ProvidedRequiredArgumentsRule.ts +++ b/src/validation/rules/ProvidedRequiredArgumentsRule.ts @@ -103,7 +103,9 @@ export function ProvidedRequiredArgumentsOnDirectivesRule( /* c8 ignore next */ const argNodes = directiveNode.arguments ?? []; const argNodeMap = new Set(argNodes.map((arg) => arg.name.value)); - for (const { 0: argName, 1: argDef } of Object.entries(requiredArgs)) { + for (const { 0: argName, 1: argDef } of Object.entries( + requiredArgs, + )) { if (!argNodeMap.has(argName)) { const argType = isType(argDef.type) ? inspect(argDef.type) diff --git a/src/validation/rules/UniqueVariableNamesRule.ts b/src/validation/rules/UniqueVariableNamesRule.ts index 3514aa1cd1..8a4c87c074 100644 --- a/src/validation/rules/UniqueVariableNamesRule.ts +++ b/src/validation/rules/UniqueVariableNamesRule.ts @@ -25,7 +25,10 @@ export function UniqueVariableNamesRule( (node) => node.variable.name.value, ); - for (const { 0: variableName, 1: variableNodes} of seenVariableDefinitions) { + for (const { + 0: variableName, + 1: variableNodes, + } of seenVariableDefinitions) { if (variableNodes.length > 1) { context.reportError( new GraphQLError(