diff --git a/.changeset/strange-cheetahs-change.md b/.changeset/strange-cheetahs-change.md new file mode 100644 index 00000000000..845d65ac2a8 --- /dev/null +++ b/.changeset/strange-cheetahs-change.md @@ -0,0 +1,10 @@ +--- +'codemirror-graphql': patch +'graphiql': patch +'@graphiql/react': patch +'graphql-language-service': patch +'graphql-language-service-server': patch +'vscode-graphql-execution': patch +--- + +enable `prefer-destructuring` rule diff --git a/.eslintrc.js b/.eslintrc.js index e1d354ca99e..13f972a12c6 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -187,7 +187,8 @@ module.exports = { 'no-continue': 0, 'no-inline-comments': 0, 'no-mixed-operators': 0, - 'no-negated-condition': 'error', + 'no-negated-condition': 'off', + 'unicorn/no-negated-condition': 'error', 'no-nested-ternary': 0, 'no-new-object': 1, 'no-plusplus': 0, @@ -260,6 +261,7 @@ module.exports = { // Jest rules 'jest/no-conditional-expect': 0, + 'prefer-destructuring': ['error', { VariableDeclarator: { object: true } }], 'promise/no-multiple-resolved': 'error', 'sonarjs/no-redundant-jump': 'error', 'unicorn/prefer-logical-operator-over-ternary': 'error', diff --git a/packages/codemirror-graphql/src/hint.ts b/packages/codemirror-graphql/src/hint.ts index 53277c6f9ef..7d5a32fb4ac 100644 --- a/packages/codemirror-graphql/src/hint.ts +++ b/packages/codemirror-graphql/src/hint.ts @@ -70,7 +70,7 @@ CodeMirror.registerHelper( editor: CodeMirror.Editor, options: GraphQLHintOptions, ): IHints | undefined => { - const schema = options.schema; + const { schema } = options; if (!schema) { return; } diff --git a/packages/codemirror-graphql/src/info.ts b/packages/codemirror-graphql/src/info.ts index a589bbfd9c3..f8557c0d3c1 100644 --- a/packages/codemirror-graphql/src/info.ts +++ b/packages/codemirror-graphql/src/info.ts @@ -61,10 +61,7 @@ CodeMirror.registerHelper( if (!options.schema || !token.state) { return; } - - const state = token.state; - const kind = state.kind; - const step = state.step; + const { kind, step } = token.state; const typeInfo = getTypeInfo(options.schema, token.state); // Given a Schema and a Token, produce the contents of an info tooltip. @@ -238,7 +235,7 @@ function renderDescription( | GraphQLEnumValue | GraphQLType, ) { - const description = (def as GraphQLInputField).description; + const { description } = def as GraphQLInputField; if (description) { const descriptionDiv = document.createElement('div'); descriptionDiv.className = 'info-description'; @@ -293,7 +290,7 @@ function text( ref: Maybe = null, ) { if (className) { - const onClick = options.onClick; + const { onClick } = options; let node; if (onClick) { node = document.createElement('a'); diff --git a/packages/codemirror-graphql/src/jump.ts b/packages/codemirror-graphql/src/jump.ts index dbcb0bba0b8..7a0be9ca03a 100644 --- a/packages/codemirror-graphql/src/jump.ts +++ b/packages/codemirror-graphql/src/jump.ts @@ -53,9 +53,8 @@ CodeMirror.registerHelper( // Given a Schema and a Token, produce a "SchemaReference" which refers to // the particular artifact from the schema (such as a type, field, argument, // or directive) that token references. - const state = token.state; - const kind = state.kind; - const step = state.step; + const { state } = token; + const { kind, step } = state; const typeInfo = getTypeInfo(options.schema, state); if ( diff --git a/packages/codemirror-graphql/src/lint.ts b/packages/codemirror-graphql/src/lint.ts index 4134a50e991..b9ccb1c4280 100644 --- a/packages/codemirror-graphql/src/lint.ts +++ b/packages/codemirror-graphql/src/lint.ts @@ -42,7 +42,7 @@ CodeMirror.registerHelper( 'lint', 'graphql', (text: string, options: GraphQLLintOptions): CodeMirror.Annotation[] => { - const schema = options.schema; + const { schema } = options; const rawResults = getDiagnostics( text, schema, diff --git a/packages/codemirror-graphql/src/results/mode.ts b/packages/codemirror-graphql/src/results/mode.ts index 799d4233894..5daff808853 100644 --- a/packages/codemirror-graphql/src/results/mode.ts +++ b/packages/codemirror-graphql/src/results/mode.ts @@ -52,7 +52,7 @@ function indent( state: State, textAfter: string, ) { - const levels = state.levels; + const { levels } = state; // If there is no stack of levels, use the current level. // Otherwise, use the top level, preemptively dedenting for close braces. const level = diff --git a/packages/codemirror-graphql/src/utils/collectVariables.ts b/packages/codemirror-graphql/src/utils/collectVariables.ts index abda6569a7a..2af3796773f 100644 --- a/packages/codemirror-graphql/src/utils/collectVariables.ts +++ b/packages/codemirror-graphql/src/utils/collectVariables.ts @@ -24,7 +24,7 @@ export default function collectVariables( const variableToType = Object.create(null); documentAST.definitions.forEach(definition => { if (definition.kind === 'OperationDefinition') { - const variableDefinitions = definition.variableDefinitions; + const { variableDefinitions } = definition; if (variableDefinitions) { variableDefinitions.forEach(({ variable, type }) => { const inputType = typeFromAST(schema, type as NamedTypeNode); diff --git a/packages/codemirror-graphql/src/utils/info-addon.ts b/packages/codemirror-graphql/src/utils/info-addon.ts index 030003ed155..6fb4fe39bc3 100644 --- a/packages/codemirror-graphql/src/utils/info-addon.ts +++ b/packages/codemirror-graphql/src/utils/info-addon.ts @@ -45,7 +45,7 @@ function createState(options: GraphQLInfoOptions) { } function getHoverTime(cm: CodeMirror.Editor) { - const options = cm.state.info.options; + const { options } = cm.state.info; return options?.hoverTime || 500; } @@ -96,7 +96,7 @@ function onMouseHover(cm: CodeMirror.Editor, box: DOMRect) { }); const state = cm.state.info; - const options = state.options; + const { options } = state; const render = options.render || cm.getHelper(pos, 'info'); if (render) { const token = cm.getTokenAt(pos, true); diff --git a/packages/codemirror-graphql/src/utils/jump-addon.ts b/packages/codemirror-graphql/src/utils/jump-addon.ts index 742741a91cf..7ee5ce495da 100644 --- a/packages/codemirror-graphql/src/utils/jump-addon.ts +++ b/packages/codemirror-graphql/src/utils/jump-addon.ts @@ -103,7 +103,7 @@ function onKeyDown(cm: CodeMirror.Editor, event: KeyboardEvent) { }; const onClick = (clickEvent: MouseEvent) => { - const destination = cm.state.jump.destination; + const { destination } = cm.state.jump; if (destination) { cm.state.jump.options.onClick(destination, clickEvent); } @@ -134,11 +134,9 @@ function enableJumpMode(cm: CodeMirror.Editor) { return; } - const cursor = cm.state.jump.cursor; + const { cursor, options } = cm.state.jump; const pos = cm.coordsChar(cursor); const token = cm.getTokenAt(pos, true); - - const options = cm.state.jump.options; const getDestination = options.getDestination || cm.getHelper(pos, 'jump'); if (getDestination) { const destination = getDestination(token, options, cm); @@ -156,7 +154,7 @@ function enableJumpMode(cm: CodeMirror.Editor) { } function disableJumpMode(cm: CodeMirror.Editor) { - const marker = cm.state.jump.marker; + const { marker } = cm.state.jump; cm.state.jump.marker = null; cm.state.jump.destination = null; diff --git a/packages/codemirror-graphql/src/utils/mode-indent.ts b/packages/codemirror-graphql/src/utils/mode-indent.ts index df690413614..5c2eaefb8b8 100644 --- a/packages/codemirror-graphql/src/utils/mode-indent.ts +++ b/packages/codemirror-graphql/src/utils/mode-indent.ts @@ -19,7 +19,7 @@ export default function indent( state: State, textAfter: string, ) { - const levels = state.levels; + const { levels } = state; // If there is no stack of levels, use the current level. // Otherwise, use the top level, preemptively dedenting for close braces. const level = diff --git a/packages/codemirror-graphql/src/variables/hint.ts b/packages/codemirror-graphql/src/variables/hint.ts index 413e1e6fa13..25eeb65f3ae 100644 --- a/packages/codemirror-graphql/src/variables/hint.ts +++ b/packages/codemirror-graphql/src/variables/hint.ts @@ -89,15 +89,13 @@ function getVariablesHint( const state = token.state.kind === 'Invalid' ? token.state.prevState : token.state; - const kind = state.kind; - const step = state.step; - + const { kind, step } = state; // Variables can only be an object literal. if (kind === 'Document' && step === 0) { return hintList(cur, token, [{ text: '{' }]); } - const variableToType = options.variableToType; + const { variableToType } = options; if (!variableToType) { return; } diff --git a/packages/codemirror-graphql/src/variables/lint.ts b/packages/codemirror-graphql/src/variables/lint.ts index 27f3a43c11a..38e240640b9 100644 --- a/packages/codemirror-graphql/src/variables/lint.ts +++ b/packages/codemirror-graphql/src/variables/lint.ts @@ -66,7 +66,7 @@ CodeMirror.registerHelper( } // If there are not yet known variables, do nothing. - const variableToType = options.variableToType; + const { variableToType } = options; if (!variableToType) { return []; } diff --git a/packages/codemirror-graphql/src/variables/mode.ts b/packages/codemirror-graphql/src/variables/mode.ts index daf39251d33..229350a946e 100644 --- a/packages/codemirror-graphql/src/variables/mode.ts +++ b/packages/codemirror-graphql/src/variables/mode.ts @@ -53,7 +53,7 @@ function indent( state: State, textAfter: string, ) { - const levels = state.levels; + const { levels } = state; // If there is no stack of levels, use the current level. // Otherwise, use the top level, preemptively dedenting for close braces. const level = diff --git a/packages/graphiql-react/src/editor/components/image-preview.tsx b/packages/graphiql-react/src/editor/components/image-preview.tsx index 76c5536f7c4..b330f7bb01a 100644 --- a/packages/graphiql-react/src/editor/components/image-preview.tsx +++ b/packages/graphiql-react/src/editor/components/image-preview.tsx @@ -76,7 +76,7 @@ function tokenToURL(token: Token) { const value = token.string.slice(1).slice(0, -1).trim(); try { - const location = window.location; + const { location } = window; return new URL(value, location.protocol + '//' + location.host); } catch { return; diff --git a/packages/graphiql/src/components/GraphiQL.tsx b/packages/graphiql/src/components/GraphiQL.tsx index cd42ddd470c..fcaf397c1cd 100644 --- a/packages/graphiql/src/components/GraphiQL.tsx +++ b/packages/graphiql/src/components/GraphiQL.tsx @@ -787,7 +787,7 @@ export function GraphiQLInterface(props: GraphiQLInterfaceProps) { type="button" id="disable-persist-headers" className={ - !editorContext.shouldPersistHeaders ? 'active' : undefined + editorContext.shouldPersistHeaders ? undefined : 'active' } onClick={() => { editorContext.setShouldPersistHeaders(false); diff --git a/packages/graphiql/src/components/__tests__/GraphiQL.spec.tsx b/packages/graphiql/src/components/__tests__/GraphiQL.spec.tsx index 57046becd33..06e6a9655f0 100644 --- a/packages/graphiql/src/components/__tests__/GraphiQL.spec.tsx +++ b/packages/graphiql/src/components/__tests__/GraphiQL.spec.tsx @@ -424,7 +424,7 @@ describe('GraphiQL', () => { const callback = async () => { try { await findByText('Persist headers'); - } catch (e) { + } catch { // eslint-disable-next-line no-throw-literal throw 'failed'; } diff --git a/packages/graphiql/test/e2e-server.js b/packages/graphiql/test/e2e-server.js index 224612797c8..221b0dd63ce 100644 --- a/packages/graphiql/test/e2e-server.js +++ b/packages/graphiql/test/e2e-server.js @@ -43,7 +43,7 @@ app.post('/graphql-error/graphql', (_req, res, next) => { app.use(express.static(path.resolve(__dirname, '../'))); app.listen(process.env.PORT || 0, function () { - const port = this.address().port; + const { port } = this.address(); console.log(`Started on http://localhost:${port}/`); console.log('PID', process.pid); diff --git a/packages/graphql-language-service-server/src/Logger.ts b/packages/graphql-language-service-server/src/Logger.ts index 0c7a7f230cd..de2451ae853 100644 --- a/packages/graphql-language-service-server/src/Logger.ts +++ b/packages/graphql-language-service-server/src/Logger.ts @@ -65,7 +65,7 @@ export class Logger implements VSCodeLogger { _log(message: string, severityKey: SeverityEnum): void { const timestamp = new Date().toLocaleString(undefined); const severity = DIAGNOSTIC_SEVERITY[severityKey]; - const pid = process.pid; + const { pid } = process; const stringMessage = String(message).trim(); const logMessage = `${timestamp} [${severity}] (pid: ${pid}) graphql-language-service-usage-logs: ${stringMessage}\n`; diff --git a/packages/graphql-language-service-server/src/MessageProcessor.ts b/packages/graphql-language-service-server/src/MessageProcessor.ts index fb80dd0aea6..e2b15ddf33d 100644 --- a/packages/graphql-language-service-server/src/MessageProcessor.ts +++ b/packages/graphql-language-service-server/src/MessageProcessor.ts @@ -429,14 +429,14 @@ export class MessageProcessor { '`textDocument`, `textDocument.uri`, and `contentChanges` arguments are required.', ); } - const textDocument = params.textDocument; - const uri = textDocument.uri; + const { textDocument } = params; + const { uri } = textDocument; const project = this._graphQLCache.getProjectForFile(uri); try { - const contentChanges = params.contentChanges; + const { contentChanges } = params; const contentChange = contentChanges[contentChanges.length - 1]; - // As `contentChanges` is an array and we just want the + // As `contentChanges` is an array, and we just want the // latest update to the text, grab the last entry from the array. // If it's a .js file, try parsing the contents to see if GraphQL queries @@ -512,8 +512,8 @@ export class MessageProcessor { if (!params || !params.textDocument) { throw new Error('`textDocument` is required.'); } - const textDocument = params.textDocument; - const uri = textDocument.uri; + const { textDocument } = params; + const { uri } = textDocument; if (this._textDocumentCache.has(uri)) { this._textDocumentCache.delete(uri); @@ -560,8 +560,7 @@ export class MessageProcessor { this.validateDocumentAndPosition(params); - const textDocument = params.textDocument; - const position = params.position; + const { textDocument, position } = params; // `textDocument/completion` event takes advantage of the fact that // `textDocument/didChange` event always fires before, which would have @@ -617,8 +616,7 @@ export class MessageProcessor { this.validateDocumentAndPosition(params); - const textDocument = params.textDocument; - const position = params.position; + const { textDocument, position } = params; const cachedDocument = this._getCachedDocument(textDocument.uri); if (!cachedDocument) { @@ -679,7 +677,7 @@ export class MessageProcessor { change.type === FileChangeTypeKind.Created || change.type === FileChangeTypeKind.Changed ) { - const uri = change.uri; + const { uri } = change; const text = readFileSync(URI.parse(uri).fsPath, 'utf-8'); const contents = this._parser(text, uri); @@ -747,8 +745,7 @@ export class MessageProcessor { if (!params || !params.textDocument || !params.position) { throw new Error('`textDocument` and `position` arguments are required.'); } - const textDocument = params.textDocument; - const position = params.position; + const { textDocument, position } = params; const project = this._graphQLCache.getProjectForFile(textDocument.uri); if (project) { await this._cacheSchemaFilesForProject(project); @@ -846,7 +843,7 @@ export class MessageProcessor { throw new Error('`textDocument` argument is required.'); } - const textDocument = params.textDocument; + const { textDocument } = params; const cachedDocument = this._getCachedDocument(textDocument.uri); if (!cachedDocument || !cachedDocument.contents[0]) { return []; diff --git a/packages/graphql-language-service-server/src/findGraphQLTags.ts b/packages/graphql-language-service-server/src/findGraphQLTags.ts index 31f5a118c2f..f4af43009cd 100644 --- a/packages/graphql-language-service-server/src/findGraphQLTags.ts +++ b/packages/graphql-language-service-server/src/findGraphQLTags.ts @@ -156,7 +156,7 @@ export function findGraphQLTags( const asts = parsedASTs; const parseTemplateLiteral = (node: TemplateLiteral) => { - const loc = node.quasis[0].loc; + const { loc } = node.quasis[0]; if (loc) { if (node.quasis.length > 1) { const last = node.quasis.pop(); @@ -183,7 +183,7 @@ export function findGraphQLTags( const visitors = { CallExpression: (node: Expression) => { if ('callee' in node) { - const callee = node.callee; + const { callee } = node; if ( callee.type === 'Identifier' && @@ -203,7 +203,7 @@ export function findGraphQLTags( TaggedTemplateExpression: (node: TaggedTemplateExpression) => { const tagName = getGraphQLTagName(node.tag); if (tagName) { - const loc = node.quasi.quasis[0].loc; + const { loc } = node.quasi.quasis[0]; const template = node.quasi.quasis.length > 1 ? node.quasi.quasis.map(quasi => quasi.value.raw).join('') diff --git a/packages/graphql-language-service-server/src/startServer.ts b/packages/graphql-language-service-server/src/startServer.ts index fd683099c77..fd65bbb2b78 100644 --- a/packages/graphql-language-service-server/src/startServer.ts +++ b/packages/graphql-language-service-server/src/startServer.ts @@ -168,8 +168,7 @@ export default async function startServer( process.exit(1); } - const port = options.port; - const hostname = options.hostname; + const { port, hostname } = options; const socket = net .createServer(client => { client.setEncoding('utf8'); diff --git a/packages/graphql-language-service/src/interface/getAutocompleteSuggestions.ts b/packages/graphql-language-service/src/interface/getAutocompleteSuggestions.ts index bd4692ff62a..12d5a2efa9d 100644 --- a/packages/graphql-language-service/src/interface/getAutocompleteSuggestions.ts +++ b/packages/graphql-language-service/src/interface/getAutocompleteSuggestions.ts @@ -177,8 +177,7 @@ export function getAutocompleteSuggestions( return []; } - const kind = state.kind; - const step = state.step; + const { kind, step } = state; const typeInfo = getTypeInfo(schema, token.state); // Definition kinds @@ -306,7 +305,7 @@ export function getAutocompleteSuggestions( kind === RuleKinds.ARGUMENTS || (kind === RuleKinds.ARGUMENT && step === 0) ) { - const argDefs = typeInfo.argDefs; + const { argDefs } = typeInfo; if (argDefs) { return hintList( token, @@ -460,7 +459,7 @@ const insertSuffix = ` {\n $1\n}`; * @returns */ const getInsertText = (field: GraphQLField) => { - const type = field.type; + const { type } = field; if (isCompositeType(type)) { return insertSuffix; } @@ -518,7 +517,7 @@ function getSuggestionsForFieldNames( options?: AutocompleteSuggestionOptions, ): Array { if (typeInfo.parentType) { - const parentType = typeInfo.parentType; + const { parentType } = typeInfo; let fields: GraphQLField[] = []; if ('getFields' in parentType) { fields = objectValues>( @@ -1052,8 +1051,8 @@ export function canUseDirective( if (!state || !state.kind) { return false; } - const kind = state.kind; - const locations = directive.locations; + const { kind } = state; + const { locations } = directive; switch (kind) { case RuleKinds.QUERY: return locations.includes(DirectiveLocation.QUERY); diff --git a/packages/graphql-language-service/src/interface/getDefinition.ts b/packages/graphql-language-service/src/interface/getDefinition.ts index ef47e2a9eb4..7d45f026f14 100644 --- a/packages/graphql-language-service/src/interface/getDefinition.ts +++ b/packages/graphql-language-service/src/interface/getDefinition.ts @@ -148,7 +148,7 @@ function getDefinitionForFragmentDefinition( text: string, definition: FragmentDefinitionNode | OperationDefinitionNode, ): Definition { - const name = definition.name; + const { name } = definition; if (!name) { throw new Error('Expected ASTNode to have a Name.'); } @@ -171,7 +171,7 @@ function getDefinitionForNodeDefinition( text: string, definition: TypeDefinitionNode, ): Definition { - const name = definition.name; + const { name } = definition; assert(name, 'Expected ASTNode to have a Name.'); return { path, @@ -189,7 +189,7 @@ function getDefinitionForFieldDefinition( text: string, definition: FieldDefinitionNode, ): Definition { - const name = definition.name; + const { name } = definition; assert(name, 'Expected ASTNode to have a Name.'); return { path, diff --git a/packages/graphql-language-service/src/interface/getHoverInformation.ts b/packages/graphql-language-service/src/interface/getHoverInformation.ts index 3b5c5258cf6..c857bfc6359 100644 --- a/packages/graphql-language-service/src/interface/getHoverInformation.ts +++ b/packages/graphql-language-service/src/interface/getHoverInformation.ts @@ -41,9 +41,8 @@ export function getHoverInformation( return ''; } - const state = token.state; - const kind = state.kind; - const step = state.step; + const { state } = token; + const { kind, step } = state; const typeInfo = getTypeInfo(schema, token.state); const options = { ...config, schema }; @@ -151,7 +150,7 @@ function renderArg(into: string[], typeInfo: AllTypeInfo, options: any) { return; } - const name = typeInfo.argDef.name; + const { name } = typeInfo.argDef; text(into, '('); text(into, name); renderTypeAnnotation( @@ -177,7 +176,7 @@ function renderEnumValue(into: string[], typeInfo: AllTypeInfo, options: any) { if (!typeInfo.enumValue) { return; } - const name = typeInfo.enumValue.name; + const { name } = typeInfo.enumValue; renderType(into, typeInfo, options, typeInfo.inputType as GraphQLType); text(into, '.'); text(into, name); diff --git a/packages/graphql-language-service/src/parser/onlineParser.ts b/packages/graphql-language-service/src/parser/onlineParser.ts index 6b2c471375b..dd9ae1100af 100644 --- a/packages/graphql-language-service/src/parser/onlineParser.ts +++ b/packages/graphql-language-service/src/parser/onlineParser.ts @@ -268,7 +268,7 @@ function advanceRule(state: State, successful: boolean): undefined { // TODO: ParseRules as numerical index const step = state.rule[state.step]; if (step.separator) { - const separator = step.separator; + const { separator } = step; state.needsSeparator = !state.needsSeparator; // If the separator was optional, then give it an opportunity to repeat. if (!state.needsSeparator && separator.ofRule) { diff --git a/packages/graphql-language-service/src/utils/collectVariables.ts b/packages/graphql-language-service/src/utils/collectVariables.ts index 699dd601804..d9fd0e587bd 100644 --- a/packages/graphql-language-service/src/utils/collectVariables.ts +++ b/packages/graphql-language-service/src/utils/collectVariables.ts @@ -28,7 +28,7 @@ export function collectVariables( // it would be more ideal to use visitWithTypeInfo here but it's very simple documentAST.definitions.forEach(definition => { if (definition.kind === 'OperationDefinition') { - const variableDefinitions = definition.variableDefinitions; + const { variableDefinitions } = definition; if (variableDefinitions) { variableDefinitions.forEach(({ variable, type }) => { const inputType = typeFromAST( diff --git a/packages/vscode-graphql-execution/src/helpers/source.ts b/packages/vscode-graphql-execution/src/helpers/source.ts index 633109d8493..d2fc1c03bd2 100644 --- a/packages/vscode-graphql-execution/src/helpers/source.ts +++ b/packages/vscode-graphql-execution/src/helpers/source.ts @@ -125,7 +125,7 @@ export class SourceHelper { projectConfig: GraphQLProjectConfig, ): Promise> { const sources = await projectConfig.getDocuments(); - const fragmentDefinitions = this.fragmentDefinitions; + const { fragmentDefinitions } = this; sources.forEach(source => { visit(source.document as DocumentNode, { diff --git a/packages/vscode-graphql-execution/src/providers/exec-content.ts b/packages/vscode-graphql-execution/src/providers/exec-content.ts index 27c4981e3b9..64cfccfbc96 100644 --- a/packages/vscode-graphql-execution/src/providers/exec-content.ts +++ b/packages/vscode-graphql-execution/src/providers/exec-content.ts @@ -73,7 +73,7 @@ export class GraphQLContentProvider implements TextDocumentContentProvider { async getEndpointName(endpointNames: string[]) { // Endpoints extensions docs say that at least "default" will be there - let endpointName = endpointNames[0]; + let [endpointName] = endpointNames; if (endpointNames.length > 1) { const pickedValue = await window.showQuickPick(endpointNames, { canPickMany: false, @@ -142,7 +142,7 @@ export class GraphQLContentProvider implements TextDocumentContentProvider { this.outputChannel.appendLine( `Warning: endpoints missing from graphql config. will try 'schema' value(s) instead`, ); - const schema = projectConfig.schema; + const { schema } = projectConfig; if (schema && Array.isArray(schema)) { schema.map(s => { if (this.validUrlFromSchema(s as string)) { @@ -241,7 +241,7 @@ export class GraphQLContentProvider implements TextDocumentContentProvider { } } async loadConfig() { - const rootDir = this.rootDir; + const { rootDir } = this; if (!rootDir) { this.reportError(`Error: this file is outside the workspace.`); return;