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 + few best practices

Liyas Thomas010be95ed5ff
diff --git a/components/environments/addEnvironment.vue b/components/environments/addEnvironment.vue
index b68768213..23c53d1ac 100644
--- a/components/environments/addEnvironment.vue
+++ b/components/environments/addEnvironment.vue
@@ -43,7 +43,6 @@
</template>
<script>
-
export default {
props: {
show: Boolean
@@ -62,10 +61,12 @@ export default {
this.$toast.info($t("invalid_environment_name"));
return;
}
- let newEnvironment = [{
- name: this.$data.name,
- variables: []
- }]
+ let newEnvironment = [
+ {
+ name: this.$data.name,
+ variables: []
+ }
+ ];
this.$store.commit("postwoman/importAddEnvironments", newEnvironment);
this.$emit("hide-modal");
},
diff --git a/components/environments/editEnvironment.vue b/components/environments/editEnvironment.vue
index adb3dc920..01308fccf 100644
--- a/components/environments/editEnvironment.vue
+++ b/components/environments/editEnvironment.vue
@@ -49,18 +49,21 @@
></textarea>
</li>
</ul>
- <ul v-for="(variable, index) in this.editingEnvCopy.variables" :key="index">
+ <ul
+ v-for="(variable, index) in this.editingEnvCopy.variables"
+ :key="index"
+ >
<li>
<input
:placeholder="$t('parameter_count', { count: index + 1 })"
:name="'param' + index"
:value="variable.key"
@change="
- $store.commit('postwoman/setVariableKey', {
- index,
- value: $event.target.value
- })
- "
+ $store.commit('postwoman/setVariableKey', {
+ index,
+ value: $event.target.value
+ })
+ "
autofocus
/>
</li>
@@ -70,11 +73,11 @@
:name="'value' + index"
:value="variable.value"
@change="
- $store.commit('postwoman/setVariableValue', {
- index,
- value: $event.target.value
- })
- "
+ $store.commit('postwoman/setVariableValue', {
+ index,
+ value: $event.target.value
+ })
+ "
/>
</li>
<div>
@@ -137,21 +140,24 @@ export default {
},
watch: {
editingEnvironment: function(update) {
- this.$store.commit("postwoman/setEditingEnvironment", this.$props.editingEnvironment);
+ this.$store.commit(
+ "postwoman/setEditingEnvironment",
+ this.$props.editingEnvironment
+ );
}
},
computed: {
editingEnvCopy() {
- return this.$store.state.postwoman.editingEnvironment
+ return this.$store.state.postwoman.editingEnvironment;
},
variableString() {
- const result = this.editingEnvCopy.variables
+ const result = this.editingEnvCopy.variables;
return result === "" ? "" : JSON.stringify(result);
}
},
methods: {
clearContent(e) {
- this.$store.commit("postwoman/removeVariables", [])
+ this.$store.commit("postwoman/removeVariables", []);
e.target.innerHTML = this.doneButton;
this.$toast.info(this.$t("cleared"), {
icon: "clear_all"
@@ -162,15 +168,17 @@ export default {
);
},
addEnvironmentVariable() {
- let value = { key: "", value: "" }
+ let value = { key: "", value: "" };
this.$store.commit("postwoman/addVariable", value);
},
removeEnvironmentVariable(index) {
- let variableIndex = index
- const oldVariables = this.editingEnvCopy.variables.slice()
- const newVariables = this.editingEnvCopy.variables.filter((variable, index) => variableIndex !== index)
+ let variableIndex = index;
+ const oldVariables = this.editingEnvCopy.variables.slice();
+ const newVariables = this.editingEnvCopy.variables.filter(
+ (variable, index) => variableIndex !== index
+ );
- this.$store.commit("postwoman/removeVariable", newVariables)
+ this.$store.commit("postwoman/removeVariable", newVariables);
this.$toast.error(this.$t("deleted"), {
icon: "delete",
action: {
@@ -198,7 +206,7 @@ export default {
this.$emit("hide-modal");
},
hideModal() {
- this.$data.name = undefined
+ this.$data.name = undefined;
this.$emit("hide-modal");
}
}
diff --git a/components/environments/importExportEnvironment.vue b/components/environments/importExportEnvironment.vue
index 3072f6ad4..0f0e340a0 100644
--- a/components/environments/importExportEnvironment.vue
+++ b/components/environments/importExportEnvironment.vue
@@ -23,11 +23,7 @@
: $t('replace_current')
}"
>
- <button
- :disabled="true"
- class="icon"
- @click="syncEnvironments"
- >
+ <button :disabled="true" class="icon" @click="syncEnvironments">
<i class="material-icons">folder_shared</i>
<span>{{ $t("import_from_sync") }}</span>
</button>
diff --git a/components/environments/index.vue b/components/environments/index.vue
index c66e2fd0f..72e90c645 100644
--- a/components/environments/index.vue
+++ b/components/environments/index.vue
@@ -1,5 +1,10 @@
<template>
- <pw-section class="green" icon="history" :label="$t('environment')" ref="environment">
+ <pw-section
+ class="green"
+ icon="history"
+ :label="$t('environment')"
+ ref="environment"
+ >
<addEnvironment :show="showModalAdd" @hide-modal="displayModalAdd(false)" />
<editEnvironment
:show="showModalEdit"
@@ -11,7 +16,6 @@
:show="showModalImportExport"
@hide-modal="displayModalImportExport(false)"
/>
-
<div class="flex-wrap">
<div>
<button class="icon" @click="displayModalAdd(true)">
@@ -35,7 +39,10 @@
:remain="Math.min(5, environments.length)"
>
<ul>
- <li v-for="(environment, index) in environments" :key="environment.name">
+ <li
+ v-for="(environment, index) in environments"
+ :key="environment.name"
+ >
<environment
:environmentIndex="index"
:environment="environment"
@@ -84,7 +91,7 @@ export default {
showModalAdd: false,
showModalEdit: false,
editingEnvironment: undefined,
- editingEnvironmentIndex: undefined,
+ editingEnvironmentIndex: undefined
};
},
computed: {
@@ -125,9 +132,9 @@ export default {
syncEnvironments() {
// TODO
},
- beforeDestroy() {
- document.removeEventListener("keydown", this._keyListener);
+ beforeDestroy() {
+ document.removeEventListener("keydown", this._keyListener);
+ }
}
-}
-}
+};
</script>
diff --git a/store/postwoman.js b/store/postwoman.js
index 951cf4027..afffa7528 100644
--- a/store/postwoman.js
+++ b/store/postwoman.js
@@ -110,11 +110,11 @@ export const mutations = {
},
removeVariables({ editingEnvironment }, value) {
- editingEnvironment.variables = value
+ editingEnvironment.variables = value;
},
- setEditingEnvironment(state, value ) {
- state.editingEnvironment = {...value}
+ setEditingEnvironment(state, value) {
+ state.editingEnvironment = { ...value };
},
setVariableKey({ editingEnvironment }, { index, value }) {
@@ -154,9 +154,11 @@ export const mutations = {
saveEnvironment({ environments }, payload) {
const { environment, environmentIndex } = payload;
const { name } = environment;
- const duplicateEnvironment = environments.some(item => {
- return item.environmentIndex !== environmentIndex && item.name.toLowerCase() === name.toLowerCase()
- });
+ const duplicateEnvironment = environments.some(
+ item =>
+ item.environmentIndex !== environmentIndex &&
+ item.name.toLowerCase() === name.toLowerCase()
+ );
if (duplicateEnvironment) {
this.$toast.info("Duplicate environment");
return;
@@ -201,7 +203,10 @@ export const mutations = {
},
editCollection({ collections }, payload) {
- const { collection: { name }, collectionIndex } = payload;
+ const {
+ collection: { name },
+ collectionIndex
+ } = payload;
const duplicateCollection = collections.some(
item => item.name.toLowerCase() === name.toLowerCase()
);