use typed imports

This commit is contained in:
Hayden 2024-03-01 11:21:45 -06:00
parent 5440fc60e1
commit 26b17e5cf8
No known key found for this signature in database
GPG key ID: 17CF79474E257545
54 changed files with 80 additions and 77 deletions

View file

@ -25,6 +25,7 @@ module.exports = {
"vue/no-setup-props-destructure": 0,
"vue/no-multiple-template-root": 0,
"vue/no-v-model-argument": 0,
"@typescript-eslint/consistent-type-imports": "error",
"@typescript-eslint/ban-ts-comment": 0,
"@typescript-eslint/no-unused-vars": [
"error",

View file

@ -1,5 +1,5 @@
<script lang="ts" setup>
import MdiPlus from "~icons/mdi/mdi-plus";
import MdiPlus from "~icons/mdi/plus";
const ctx = useAuthContext();
const api = useUserApi();

View file

@ -22,7 +22,7 @@
</template>
<script setup lang="ts">
import { ItemAttachment } from "~~/lib/api/types/data-contracts";
import type { ItemAttachment } from "~~/lib/api/types/data-contracts";
import MdiPaperclip from "~icons/mdi/paperclip";
import MdiDownload from "~icons/mdi/download";
import MdiOpenInNew from "~icons/mdi/open-in-new";

View file

@ -34,7 +34,7 @@
</template>
<script setup lang="ts">
import { ItemOut, ItemSummary } from "~~/lib/api/types/data-contracts";
import type { ItemOut, ItemSummary } from "~~/lib/api/types/data-contracts";
import MdiShieldCheck from "~icons/mdi/shield-check";
const api = useUserApi();

View file

@ -35,7 +35,7 @@
</template>
<script setup lang="ts">
import { ItemCreate, LabelOut, LocationOut } from "~~/lib/api/types/data-contracts";
import type { ItemCreate, LabelOut, LocationOut } from "~~/lib/api/types/data-contracts";
import { useLabelStore } from "~~/stores/labels";
import { useLocationStore } from "~~/stores/locations";
import MdiPackageVariant from "~icons/mdi/package-variant";

View file

@ -1,6 +1,6 @@
<script setup lang="ts">
import { ViewType } from "~~/composables/use-preferences";
import { ItemSummary } from "~~/lib/api/types/data-contracts";
import type { ViewType } from "~~/composables/use-preferences";
import type { ItemSummary } from "~~/lib/api/types/data-contracts";
import MdiDotsVertical from "~icons/mdi/dots-vertical";
import MdiCardTextOutline from "~icons/mdi/card-text-outline";
import MdiTable from "~icons/mdi/table";

View file

@ -1,4 +1,4 @@
import { ItemSummary } from "~~/lib/api/types/data-contracts";
import type { ItemSummary } from "~~/lib/api/types/data-contracts";
export type TableHeader = {
text: string;

View file

@ -74,8 +74,8 @@
</template>
<script setup lang="ts">
import { TableData, TableHeader } from "./Table.types";
import { ItemSummary } from "~~/lib/api/types/data-contracts";
import type { TableData, TableHeader } from "./Table.types";
import type { ItemSummary } from "~~/lib/api/types/data-contracts";
import MdiArrowDown from "~icons/mdi/arrow-down";
import MdiArrowUp from "~icons/mdi/arrow-up";
import MdiCheck from "~icons/mdi/check";

View file

@ -1,5 +1,5 @@
<script setup lang="ts">
import { LabelOut, LabelSummary } from "~~/lib/api/types/data-contracts";
import type { LabelOut, LabelSummary } from "~~/lib/api/types/data-contracts";
import MdiArrowRight from "~icons/mdi/arrow-right";
import MdiTagOutline from "~icons/mdi/tag-outline";

View file

@ -28,7 +28,7 @@
</template>
<script lang="ts" setup>
import { LocationOut, LocationOutCount, LocationSummary } from "~~/lib/api/types/data-contracts";
import type { LocationOut, LocationOutCount, LocationSummary } from "~~/lib/api/types/data-contracts";
import MdiArrowRight from "~icons/mdi/arrow-right";
import MdiMapMarkerOutline from "~icons/mdi/map-marker-outline";

View file

@ -34,7 +34,7 @@
</template>
<script setup lang="ts">
import { LocationSummary } from "~~/lib/api/types/data-contracts";
import type { LocationSummary } from "~~/lib/api/types/data-contracts";
import MdiChevronDown from "~icons/mdi/chevron-down";
const props = defineProps({
modelValue: {

View file

@ -20,8 +20,9 @@
</template>
<script lang="ts" setup>
import { FlatTreeItem, useFlatLocations } from "~~/composables/use-location-helpers";
import { LocationSummary } from "~~/lib/api/types/data-contracts";
import type { FlatTreeItem } from "~~/composables/use-location-helpers";
import { useFlatLocations } from "~~/composables/use-location-helpers";
import type { LocationSummary } from "~~/lib/api/types/data-contracts";
import MdiCheck from "~icons/mdi/check";
type Props = {

View file

@ -1,6 +1,6 @@
<script setup lang="ts">
import { useTreeState } from "./tree-state";
import { TreeItem } from "~~/lib/api/types/data-contracts";
import type { TreeItem } from "~~/lib/api/types/data-contracts";
import MdiChevronDown from "~icons/mdi/chevron-down";
import MdiChevronRight from "~icons/mdi/chevron-right";
import MdiMapMarker from "~icons/mdi/map-marker";

View file

@ -1,5 +1,5 @@
<script setup lang="ts">
import { TreeItem } from "~~/lib/api/types/data-contracts";
import type { TreeItem } from "~~/lib/api/types/data-contracts";
type Props = {
locs: TreeItem[];

View file

@ -3,7 +3,7 @@
</template>
<script setup lang="ts">
import { DateTimeFormat, DateTimeType } from "~~/composables/use-formatters";
import type { DateTimeFormat, DateTimeType } from "~~/composables/use-formatters";
type Props = {
date?: Date | string;

View file

@ -12,7 +12,7 @@
</template>
<script setup lang="ts">
import { StatsFormat } from "./types";
import type { StatsFormat } from "./types";
type Props = {
title: string;

View file

@ -42,7 +42,7 @@
</template>
<script setup lang="ts">
import { TableData, TableHeader } from "./Table.types";
import type { TableData, TableHeader } from "./Table.types";
type Props = {
headers: TableHeader[];

View file

@ -1,7 +1,7 @@
import { CookieRef } from "nuxt/app";
import { PublicApi } from "~~/lib/api/public";
import { UserOut } from "~~/lib/api/types/data-contracts";
import { UserClient } from "~~/lib/api/user";
import type { CookieRef } from "nuxt/app";
import type { PublicApi } from "~~/lib/api/public";
import type { UserOut } from "~~/lib/api/types/data-contracts";
import type { UserClient } from "~~/lib/api/user";
export interface IAuthContext {
get token(): boolean | null;

View file

@ -1,5 +1,5 @@
import { UseConfirmDialogRevealResult, UseConfirmDialogReturn } from "@vueuse/core";
import { Ref } from "vue";
import type { UseConfirmDialogRevealResult, UseConfirmDialogReturn } from "@vueuse/core";
import type { Ref } from "vue";
type Store = UseConfirmDialogReturn<any, boolean, boolean> & {
text: Ref<string>;

View file

@ -1,5 +1,5 @@
import { ItemSummary, LabelSummary, LocationSummary } from "~~/lib/api/types/data-contracts";
import { UserClient } from "~~/lib/api/user";
import type { ItemSummary, LabelSummary, LocationSummary } from "~~/lib/api/types/data-contracts";
import type { UserClient } from "~~/lib/api/user";
type SearchOptions = {
immediate?: boolean;

View file

@ -1,5 +1,5 @@
import { Ref } from "vue";
import { TreeItem } from "~~/lib/api/types/data-contracts";
import type { Ref } from "vue";
import type { TreeItem } from "~~/lib/api/types/data-contracts";
export interface FlatTreeItem {
id: string;

View file

@ -1,4 +1,4 @@
import { WritableComputedRef } from "vue";
import type { WritableComputedRef } from "vue";
export function useMinLoader(ms = 500): WritableComputedRef<boolean> {
const loading = ref(false);

View file

@ -1,5 +1,5 @@
import { Ref } from "vue";
import { DaisyTheme } from "~~/lib/data/themes";
import type { Ref } from "vue";
import type { DaisyTheme } from "~~/lib/data/themes";
export type ViewType = "table" | "card" | "tree";

View file

@ -1,7 +1,7 @@
import { useRouteQuery as useRouteQueryBase } from "@vueuse/router";
/* eslint no-redeclare: 0 */
import { WritableComputedRef } from "vue";
import type { WritableComputedRef } from "vue";
export function useRouteQuery(q: string, def: string[]): WritableComputedRef<string[]>;
export function useRouteQuery(q: string, def: string): WritableComputedRef<string>;

View file

@ -1,5 +1,5 @@
import { ComputedRef } from "vue";
import { DaisyTheme } from "~~/lib/data/themes";
import type { ComputedRef } from "vue";
import type { DaisyTheme } from "~~/lib/data/themes";
export interface UseTheme {
theme: ComputedRef<DaisyTheme>;

View file

@ -2,7 +2,7 @@ import { faker } from "@faker-js/faker";
import { expect } from "vitest";
import { overrideParts } from "../../base/urls";
import { PublicApi } from "../../public";
import { ItemField, LabelCreate, LocationCreate, UserRegistration } from "../../types/data-contracts";
import type { ItemField, LabelCreate, LocationCreate, UserRegistration } from "../../types/data-contracts";
import * as config from "../../../../test/config";
import { UserClient } from "../../user";
import { Requests } from "../../../requests";

View file

@ -1,6 +1,6 @@
import { beforeAll, expect } from "vitest";
import { faker } from "@faker-js/faker";
import { UserClient } from "../user";
import type { UserClient } from "../user";
import { factories } from "./factories";
const cache = {

View file

@ -1,8 +1,8 @@
import { faker } from "@faker-js/faker";
import { describe, test, expect } from "vitest";
import { ItemField, ItemUpdate, LocationOut } from "../../types/data-contracts";
import type { ItemField, ItemUpdate, LocationOut } from "../../types/data-contracts";
import { AttachmentTypes } from "../../types/non-generated";
import { UserClient } from "../../user";
import type { UserClient } from "../../user";
import { factories } from "../factories";
import { sharedUserClient } from "../test-utils";

View file

@ -1,6 +1,6 @@
import { describe, expect, test } from "vitest";
import { LabelOut } from "../../types/data-contracts";
import { UserClient } from "../../user";
import type { LabelOut } from "../../types/data-contracts";
import type { UserClient } from "../../user";
import { factories } from "../factories";
import { sharedUserClient } from "../test-utils";

View file

@ -1,6 +1,6 @@
import { describe, expect, test } from "vitest";
import { LocationOut } from "../../types/data-contracts";
import { UserClient } from "../../user";
import type { LocationOut } from "../../types/data-contracts";
import type { UserClient } from "../../user";
import { factories } from "../factories";
import { sharedUserClient } from "../test-utils";

View file

@ -1,6 +1,6 @@
import { faker } from "@faker-js/faker";
import { beforeAll, describe, expect, test } from "vitest";
import { UserClient } from "../../user";
import type { UserClient } from "../../user";
import { factories } from "../factories";
type ImportObj = {

View file

@ -1,4 +1,4 @@
import { Requests } from "../../requests";
import type { Requests } from "../../requests";
import { route } from ".";
const ZERO_DATE = "0001-01-01T00:00:00Z";

View file

@ -1,5 +1,5 @@
import { BaseAPI, route } from "../base";
import { ActionAmountResult } from "../types/data-contracts";
import type { ActionAmountResult } from "../types/data-contracts";
export class ActionsAPI extends BaseAPI {
ensureAssetIDs() {

View file

@ -1,6 +1,6 @@
import { BaseAPI, route } from "../base";
import { ItemSummary } from "../types/data-contracts";
import { PaginationResult } from "../types/non-generated";
import type { ItemSummary } from "../types/data-contracts";
import type { PaginationResult } from "../types/non-generated";
export class AssetsApi extends BaseAPI {
async get(id: string, page = 1, pageSize = 50) {

View file

@ -1,5 +1,5 @@
import { BaseAPI, route } from "../base";
import {
import type {
CurrenciesCurrency,
Group,
GroupInvitation,

View file

@ -1,6 +1,6 @@
import { BaseAPI, route } from "../base";
import { parseDate } from "../base/base-api";
import {
import type {
ItemAttachmentUpdate,
ItemCreate,
ItemOut,
@ -13,8 +13,8 @@ import {
MaintenanceEntryUpdate,
MaintenanceLog,
} from "../types/data-contracts";
import { AttachmentTypes, PaginationResult } from "../types/non-generated";
import { Requests } from "~~/lib/requests";
import type { AttachmentTypes, PaginationResult } from "../types/non-generated";
import type { Requests } from "~~/lib/requests";
export type ItemsQuery = {
orderBy?: string;

View file

@ -1,5 +1,5 @@
import { BaseAPI, route } from "../base";
import { LabelCreate, LabelOut } from "../types/data-contracts";
import type { LabelCreate, LabelOut } from "../types/data-contracts";
export class LabelsApi extends BaseAPI {
getAll() {

View file

@ -1,5 +1,5 @@
import { BaseAPI, route } from "../base";
import { LocationOutCount, LocationCreate, LocationOut, LocationUpdate, TreeItem } from "../types/data-contracts";
import type { LocationOutCount, LocationCreate, LocationOut, LocationUpdate, TreeItem } from "../types/data-contracts";
export type LocationsQuery = {
filterChildren: boolean;

View file

@ -1,5 +1,5 @@
import { BaseAPI, route } from "../base";
import { NotifierCreate, NotifierOut, NotifierUpdate } from "../types/data-contracts";
import type { NotifierCreate, NotifierOut, NotifierUpdate } from "../types/data-contracts";
export class NotifiersAPI extends BaseAPI {
getAll() {

View file

@ -1,5 +1,5 @@
import { BaseAPI, route } from "../base";
import { GroupStatistics, TotalsByOrganizer, ValueOverTime } from "../types/data-contracts";
import type { GroupStatistics, TotalsByOrganizer, ValueOverTime } from "../types/data-contracts";
function YYYY_MM_DD(date?: Date): string {
if (!date) {

View file

@ -1,6 +1,6 @@
import { BaseAPI, route } from "../base";
import { ChangePassword, UserOut } from "../types/data-contracts";
import { Result } from "../types/non-generated";
import type { ChangePassword, UserOut } from "../types/data-contracts";
import type { Result } from "../types/non-generated";
export class UserApi extends BaseAPI {
public self() {

View file

@ -1,5 +1,5 @@
import { BaseAPI, route } from "./base";
import { APISummary, LoginForm, TokenResponse, UserRegistration } from "./types/data-contracts";
import type { APISummary, LoginForm, TokenResponse, UserRegistration } from "./types/data-contracts";
export type StatusResult = {
health: boolean;

View file

@ -9,7 +9,7 @@ import { StatsAPI } from "./classes/stats";
import { AssetsApi } from "./classes/assets";
import { ReportsAPI } from "./classes/reports";
import { NotifiersAPI } from "./classes/notifiers";
import { Requests } from "~~/lib/requests";
import type { Requests } from "~~/lib/requests";
export class UserClient extends BaseAPI {
locations: LocationsApi;

View file

@ -1,6 +1,6 @@
// https://gist.github.com/ucw/67f7291c64777fb24341e8eae72bcd24
import { IncomingMessage } from "http";
import internal from "stream";
import type { IncomingMessage } from "http";
import type internal from "stream";
import { defineNuxtModule, logger } from "@nuxt/kit";
// Related To
// - https://github.com/nuxt/nuxt/issues/15417
@ -8,7 +8,7 @@ import { defineNuxtModule, logger } from "@nuxt/kit";
//
// fix from
// - https://gist.github.com/ucw/67f7291c64777fb24341e8eae72bcd24
import { createProxyServer } from "http-proxy"; // eslint-disable-line import/named
import { createProxyServer } from "http-proxy";
export default defineNuxtModule({
defaults: {

View file

@ -1,4 +1,4 @@
import { UserClient } from "~~/lib/api/user";
import type { UserClient } from "~~/lib/api/user";
type StatCard = {
label: string;

View file

@ -1,4 +1,4 @@
import { UserClient } from "~~/lib/api/user";
import type { UserClient } from "~~/lib/api/user";
export function itemsTable(api: UserClient) {
const { data: items, refresh } = useAsyncData(async () => {

View file

@ -1,6 +1,7 @@
<script setup lang="ts">
import { AnyDetail, Detail, Details, filterZeroValues } from "~~/components/global/DetailsSection/types";
import { ItemAttachment } from "~~/lib/api/types/data-contracts";
import type { AnyDetail, Detail, Details } from "~~/components/global/DetailsSection/types";
import { filterZeroValues } from "~~/components/global/DetailsSection/types";
import type { ItemAttachment } from "~~/lib/api/types/data-contracts";
import MdiClose from "~icons/mdi/close";
import MdiPackageVariant from "~icons/mdi/package-variant";
import MdiPlus from "~icons/mdi/plus";

View file

@ -1,5 +1,5 @@
<script setup lang="ts">
import { ItemAttachment, ItemField, ItemOut, ItemUpdate } from "~~/lib/api/types/data-contracts";
import type { ItemAttachment, ItemField, ItemOut, ItemUpdate } from "~~/lib/api/types/data-contracts";
import { AttachmentTypes } from "~~/lib/api/types/non-generated";
import { useLabelStore } from "~~/stores/labels";
import { useLocationStore } from "~~/stores/locations";

View file

@ -1,7 +1,7 @@
<script setup lang="ts">
import DatePicker from "~~/components/Form/DatePicker.vue";
import { StatsFormat } from "~~/components/global/StatCard/types";
import { ItemOut, MaintenanceEntry } from "~~/lib/api/types/data-contracts";
import type { StatsFormat } from "~~/components/global/StatCard/types";
import type { ItemOut, MaintenanceEntry } from "~~/lib/api/types/data-contracts";
import MdiPost from "~icons/mdi/post";
import MdiPlus from "~icons/mdi/plus";
import MdiCheck from "~icons/mdi/check";

View file

@ -1,5 +1,5 @@
<script setup lang="ts">
import { ItemSummary, LabelSummary, LocationOutCount } from "~~/lib/api/types/data-contracts";
import type { ItemSummary, LabelSummary, LocationOutCount } from "~~/lib/api/types/data-contracts";
import { useLabelStore } from "~~/stores/labels";
import { useLocationStore } from "~~/stores/locations";
import MdiLoading from "~icons/mdi/loading";

View file

@ -1,5 +1,5 @@
<script setup lang="ts">
import { LocationSummary, LocationUpdate } from "~~/lib/api/types/data-contracts";
import type { LocationSummary, LocationUpdate } from "~~/lib/api/types/data-contracts";
import { useLocationStore } from "~~/stores/locations";
import MdiPackageVariant from "~icons/mdi/package-variant";
import MdiPencil from "~icons/mdi/pencil";

View file

@ -1,7 +1,7 @@
<script setup lang="ts">
import { Detail } from "~~/components/global/DetailsSection/types";
import type { Detail } from "~~/components/global/DetailsSection/types";
import { themes } from "~~/lib/data/themes";
import { CurrenciesCurrency, NotifierCreate, NotifierOut } from "~~/lib/api/types/data-contracts";
import type { CurrenciesCurrency, NotifierCreate, NotifierOut } from "~~/lib/api/types/data-contracts";
import MdiAccount from "~icons/mdi/account";
import MdiMegaphone from "~icons/mdi/megaphone";
import MdiDelete from "~icons/mdi/delete";

View file

@ -1,5 +1,5 @@
import { defineStore } from "pinia";
import { LabelOut } from "~~/lib/api/types/data-contracts";
import type { LabelOut } from "~~/lib/api/types/data-contracts";
export const useLabelStore = defineStore("labels", {
state: () => ({

View file

@ -1,6 +1,6 @@
import { defineStore } from "pinia";
import { LocationsApi } from "~~/lib/api/classes/locations";
import { LocationOutCount, TreeItem } from "~~/lib/api/types/data-contracts";
import type { LocationsApi } from "~~/lib/api/classes/locations";
import type { LocationOutCount, TreeItem } from "~~/lib/api/types/data-contracts";
export const useLocationStore = defineStore("locations", {
state: () => ({