Skip to content

Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia

Lint

Liyas Thomas9c09a8128a22
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 });
-
- callback(null,
- completions.map((completion) => {
- return {
- name: completion.label,
- value: completion.label,
- score: 1.0,
- meta: completion.detail
- };
- })
+ const completions = getAutocompleteSuggestions(
+ this.validationSchema,
+ editor.getValue(),
+ { line: row, character: column }
+ );
+
+ 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) {