Skip to content

Commit 6ba3d52

Browse files
committed
refactor: fix code smells
1 parent 25a9448 commit 6ba3d52

File tree

11 files changed

+30
-28
lines changed

11 files changed

+30
-28
lines changed

examples/2.x-basic/src/main.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import Vue from "vue";
2-
import { createApp, h } from "@vue/composition-api";
3-
import VueCompositionApi from "@vue/composition-api";
2+
import VueCompositionApi, { createApp, h } from "@vue/composition-api";
43

54
import App from "./App.vue";
65

examples/basic/src/App.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<script lang="ts">
2-
import { ref } from "vue";
3-
import { defineComponent } from "vue";
2+
import { defineComponent, ref } from "vue";
43
import { useQueryProvider } from "vue-query";
54
import { VueQueryDevTools } from "vue-query/devtools";
65

examples/multi-page/src/Page.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ export default defineComponent({
4040

4141
<template>
4242
<h1>{{ title }}</h1>
43-
<p>Turn on <b>Slow 3G</b> or <b>Offline</b> in dev-tools and hit Refetch</p>
43+
<p>
44+
Turn on <strong>Slow 3G</strong> or <strong>Offline</strong> in dev-tools
45+
and hit Refetch
46+
</p>
4447
<button @click="refetch" :disabled="isFetching">
4548
{{ isFetching ? "Refetching..." : "Refetch" }}
4649
</button>

examples/simple/src/Todos.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ export default defineComponent({
2828
</script>
2929

3030
<template>
31-
<p>Turn on <b>network throttling</b> in dev-tools and press Refetch</p>
31+
<p>
32+
Turn on <strong>network throttling</strong> in dev-tools and press Refetch
33+
</p>
3234
<button @click="refetch" :disabled="isFetching">
3335
{{ isFetching ? "Refetching..." : "Refetch" }}
3436
</button>

examples/suspense/src/App.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ export default defineComponent({
1616

1717
<template>
1818
<h1>vue-query example</h1>
19-
<p>Turn on <b>Slow 3G</b> or <b>Offline</b> in dev-tools and hit Refetch</p>
19+
<p>
20+
Turn on <strong>Slow 3G</strong> or <strong>Offline</strong> in dev-tools
21+
and hit Refetch
22+
</p>
2023
<Suspense>
2124
<template #default>
2225
<Content />

src/devtools/active-query-panel/Explorer.vue

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -251,11 +251,8 @@ export default defineComponent({
251251
)
252252
);
253253
254-
const expanded = this.expanded
255-
? this.subEntryPages.length === 1
256-
? singlePage
257-
: multiPage
258-
: undefined;
254+
const page = this.subEntryPages?.length === 1 ? singlePage : multiPage;
255+
const expanded = this.expanded ? page : undefined;
259256
260257
const noPages = [
261258
h("span", { class: "expandable" }, this.label),

src/devtools/components/QueryOptions.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ export default defineComponent({
136136
)
137137
: undefined;
138138
139+
const sortDesc = this.options.sortDesc ? "⬇ Desc" : "⬆ Asc";
139140
const button = !this.options.filter
140141
? h(
141142
"button",
@@ -155,7 +156,7 @@ export default defineComponent({
155156
click: this.onSortDescChange,
156157
},
157158
},
158-
this.options.sortDesc ? "⬇ Desc" : "⬆ Asc"
159+
sortDesc
159160
)
160161
: undefined;
161162

src/devtools/utils.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,13 @@ const queryHashSort: SortFn = (a, b) => (a.queryHash > b.queryHash ? 1 : -1);
6767
const dateSort: SortFn = (a, b) =>
6868
a.state.dataUpdatedAt < b.state.dataUpdatedAt ? 1 : -1;
6969

70-
const statusAndDateSort: SortFn = (a, b) =>
71-
getStatusRank(a) === getStatusRank(b)
72-
? dateSort(a, b)
73-
: getStatusRank(a) > getStatusRank(b)
74-
? 1
75-
: -1;
70+
const statusAndDateSort: SortFn = (a, b) => {
71+
if (getStatusRank(a) === getStatusRank(b)) {
72+
return dateSort(a, b);
73+
}
74+
75+
return getStatusRank(a) > getStatusRank(b) ? 1 : -1;
76+
};
7677

7778
export const sortFns: Record<string, SortFn> = {
7879
"Status > Last Updated": statusAndDateSort,

src/test-utils.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,5 @@ export function successMutator<T>(param: T): Promise<T> {
4646

4747
// eslint-disable-next-line @typescript-eslint/no-unused-vars
4848
export function errorMutator<T>(param: T): Promise<Error> {
49-
return new Promise((resolve, reject) => {
50-
setTimeout(() => {
51-
return reject(new Error("Some error"));
52-
}, 0);
53-
});
49+
return rejectFetcher();
5450
}

src/vue/useIsFetching.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ export function useIsFetching(
3030
});
3131

3232
watchEffect(() => {
33-
const parsedFilters = parseFilterArgs(arg1, arg2);
34-
filters.value = parsedFilters;
33+
const parsedFiltersUpdate = parseFilterArgs(arg1, arg2);
34+
filters.value = parsedFiltersUpdate;
3535
});
3636

3737
onUnmounted(() => {

0 commit comments

Comments
 (0)