From 9c09a8128a222c2c5a9774b090863f4b6412fb06 Mon Sep 17 00:00:00 2001 From: Liyas Thomas Date: Sun, 23 Feb 2020 06:58:13 +0530 Subject: [PATCH] Lint --- components/graphql/queryeditor.vue | 53 +++++++++++++++++------------- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/components/graphql/queryeditor.vue b/components/graphql/queryeditor.vue index 5a83bc5fa..56fe6bc35 100644 --- a/components/graphql/queryeditor.vue +++ b/components/graphql/queryeditor.vue @@ -48,10 +48,10 @@ export default { } }, theme() { - this.editor.setTheme("ace/theme/" + this.defineTheme()); + this.editor.setTheme(`ace/theme/${this.defineTheme()}`); }, lang(value) { - this.editor.getSession().setMode("ace/mode/" + value); + this.editor.getSession().setMode(`ace/mode/${value}`); }, options(value) { this.editor.setOptions(value); @@ -62,27 +62,36 @@ export default { let langTools = ace.require("ace/ext/language_tools"); const editor = ace.edit(this.$refs.editor, { - theme: "ace/theme/" + this.defineTheme(), - mode: "ace/mode/" + this.lang, + theme: `ace/theme/${this.defineTheme()}`, + mode: `ace/mode/${this.lang}`, enableBasicAutocompletion: true, enableLiveAutocompletion: true, ...this.options }); const completer = { - getCompletions: (editor, _session, pos, _prefix, callback) => { + getCompletions: ( + editor, + _session, + { row, column }, + _prefix, + callback + ) => { if (this.validationSchema) { - const completions = getAutocompleteSuggestions(this.validationSchema, editor.getValue(), { line: pos.row, character: pos.column }); + const completions = getAutocompleteSuggestions( + this.validationSchema, + editor.getValue(), + { line: row, character: column } + ); - callback(null, - completions.map((completion) => { - return { - name: completion.label, - value: completion.label, - score: 1.0, - meta: completion.detail - }; - }) + callback( + null, + completions.map(({ label, detail }) => ({ + name: label, + value: label, + score: 1.0, + meta: detail + })) ); } else { callback(null, []); @@ -130,14 +139,14 @@ export default { if (this.validationSchema) { this.editor.session.setAnnotations( - gql.validate(this.validationSchema, doc).map(err => { - return { - row: err.locations[0].line - 1, - column: err.locations[0].column - 1, - text: err.message, + gql + .validate(this.validationSchema, doc) + .map(({ locations, message }) => ({ + row: locations[0].line - 1, + column: locations[0].column - 1, + text: message, type: "error" - }; - }) + })) ); } } catch (e) {