diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 040790f49..3ec254b57 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -1,8 +1,8 @@ /* eslint-disable @typescript-eslint/no-var-requires */ const { readFileSync } = require('fs'); -const dotenv = require('dotenv'); +const { parse } = require('dotenv'); -const envConfig = dotenv.parse(readFileSync('.env')); +const envConfig = parse(readFileSync('.env')); for (const k in envConfig) { process.env[k] = envConfig[k]; } diff --git a/_data/serverState.ts b/_data/serverState.ts index 543dd8855..38becccd4 100644 --- a/_data/serverState.ts +++ b/_data/serverState.ts @@ -1,17 +1,17 @@ import type { Server, ServerState } from '~/types/server'; -function makeid(length: number) { +function makeid (length: number) { const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'; const charactersLength = characters.length; let result = ''; - for (let i = 0; i < length; i++) result += characters.charAt(Math.floor(Math.random() * charactersLength)); + for (let i = 0; i < length; i++) { result += characters.charAt(Math.floor(Math.random() * charactersLength)); } return result; } const randomGuid = `1111-1111-${makeid(4)}-123412341234`; // this guid is registered in key server -const newGuid = `1234-1234-${makeid(4)}-123412341234`; // this is a new USB, not registered -const regWizTime = `1616711990500_${randomGuid}`; -const blacklistedGuid = '154B-00EE-0700-9B50CF819816'; +// const newGuid = `1234-1234-${makeid(4)}-123412341234`; // this is a new USB, not registered +// const regWizTime = `1616711990500_${randomGuid}`; +// const blacklistedGuid = '154B-00EE-0700-9B50CF819816'; // ENOKEYFILE // TRIAL @@ -29,51 +29,50 @@ const blacklistedGuid = '154B-00EE-0700-9B50CF819816'; // EBLACKLISTED1 // EBLACKLISTED2 // ENOCONN -const state: string = 'BASIC'; +const state: ServerState = 'BASIC'; const uptime = Date.now() - 60 * 60 * 1000; // 1 hour ago let expireTime = 0; -if (state === 'TRIAL') expireTime = Date.now() + 60 * 60 * 1000; // in 1 hour -if (state === 'EEXPIRED') expireTime = uptime; // 1 hour ago +if (state === 'TRIAL') { expireTime = Date.now() + 60 * 60 * 1000; } // in 1 hour +if (state === 'EEXPIRED') { expireTime = uptime; } // 1 hour ago -const serverState = { - "apiKey": "unupc_fab6ff6ffe51040595c6d9ffb63a353ba16cc2ad7d93f813a2e80a5810", - "avatar": "https://source.unsplash.com/300x300/?portrait", - "config": { +export const serverState: Server = { + apiKey: 'unupc_fab6ff6ffe51040595c6d9ffb63a353ba16cc2ad7d93f813a2e80a5810', + avatar: 'https://source.unsplash.com/300x300/?portrait', + config: { // error: 'INVALID', valid: true, }, - "description": "DevServer9000", - "deviceCount": "3", + description: 'DevServer9000', + deviceCount: 3, expireTime, - "flashProduct": "SanDisk_3.2Gen1", - "flashVendor": "USB", - "guid": randomGuid, + flashProduct: 'SanDisk_3.2Gen1', + flashVendor: 'USB', + guid: randomGuid, // "guid": "0781-5583-8355-81071A2B0211", - "keyfile": "DUMMY_KEYFILE", - "lanIp": "192.168.254.36", - "license": "", - "locale": "en_US", - "name": "fuji", + inIframe: false, + keyfile: 'DUMMY_KEYFILE', + lanIp: '192.168.254.36', + license: '', + locale: 'en_US', + name: 'fuji', // "connectPluginInstalled": "dynamix.unraid.net.staging.plg", - "connectPluginInstalled": "", - "registered": false, - "regGen": 0, + connectPluginInstalled: '', + registered: false, + regGen: 0, // "regGuid": "0781-5583-8355-81071A2B0211", - "site": "http://localhost:4321", - "state": state, - "theme": { - "banner": false, - "bannerGradient": false, - "bgColor": "", - "descriptionShow": true, - "metaColor": "", - "name": "black", - "textColor": "" + site: 'http://localhost:4321', + state, + theme: { + banner: false, + bannerGradient: false, + bgColor: '', + descriptionShow: true, + metaColor: '', + name: 'black', + textColor: '' }, uptime, - "username": "zspearmint", - "wanFQDN": "" + username: 'zspearmint', + wanFQDN: '' }; - -export default serverState; \ No newline at end of file diff --git a/codegen.ts b/codegen.ts index e7b5551e4..2c099d294 100644 --- a/codegen.ts +++ b/codegen.ts @@ -1,12 +1,5 @@ import type { CodegenConfig } from '@graphql-codegen/cli'; -const getApiCodegenUrl = () => { - if (process.env.USE_LOCAL_CODEGEN === 'true') { - return 'http://localhost:3001/graphql'; - } - return ''; -}; - const config: CodegenConfig = { overwrite: true, documents: ['./**/**/*.ts'], @@ -34,7 +27,7 @@ const config: CodegenConfig = { { 'http://localhost:3001/graphql': { headers: { - origin: `/var/run/unraid-php.sock`, + origin: '/var/run/unraid-php.sock', 'x-api-key': 'unupc_fab6ff6ffe51040595c6d9ffb63a353ba16cc2ad7d93f813a2e80a5810', }, }, diff --git a/components/UserProfile/DropdownConnectStatus.fragment.ts b/components/UserProfile/DropdownConnectStatus.fragment.ts index b58e38435..3d91d29e2 100644 --- a/components/UserProfile/DropdownConnectStatus.fragment.ts +++ b/components/UserProfile/DropdownConnectStatus.fragment.ts @@ -1,4 +1,4 @@ -import { graphql } from "~/composables/gql/gql"; +import { graphql } from '~/composables/gql/gql'; export const TEST_FRAGMENT = graphql(/* GraphQL */` fragment TestFragment on Cloud { diff --git a/composables/gql/fragment-masking.ts b/composables/gql/fragment-masking.ts index c000279ac..cf750b0c6 100644 --- a/composables/gql/fragment-masking.ts +++ b/composables/gql/fragment-masking.ts @@ -2,7 +2,6 @@ import type { ResultOf, DocumentTypeDecoration, TypedDocumentNode } from '@graph import type { FragmentDefinitionNode } from 'graphql'; import type { Incremental } from './graphql'; - export type FragmentType> = TDocumentType extends DocumentTypeDecoration< infer TType, any @@ -34,21 +33,20 @@ export function useFragment( _documentNode: DocumentTypeDecoration, fragmentType: ReadonlyArray>> | null | undefined ): ReadonlyArray | null | undefined; -export function useFragment( +export function useFragment ( _documentNode: DocumentTypeDecoration, fragmentType: FragmentType> | ReadonlyArray>> | null | undefined ): TType | ReadonlyArray | null | undefined { return fragmentType as any; } - export function makeFragmentData< F extends DocumentTypeDecoration, FT extends ResultOf ->(data: FT, _fragment: F): FragmentType { +> (data: FT, _fragment: F): FragmentType { return data as FragmentType; } -export function isFragmentReady( +export function isFragmentReady ( queryNode: DocumentTypeDecoration, fragmentNode: TypedDocumentNode, data: FragmentType, any>> | null | undefined @@ -56,7 +54,7 @@ export function isFragmentReady( const deferredFields = (queryNode as { __meta__?: { deferredFields: Record } }).__meta__ ?.deferredFields; - if (!deferredFields) return true; + if (!deferredFields) { return true; } const fragDef = fragmentNode.definitions[0] as FragmentDefinitionNode | undefined; const fragName = fragDef?.name?.value; diff --git a/composables/gql/index.ts b/composables/gql/index.ts index f51599168..c682b1e2f 100644 --- a/composables/gql/index.ts +++ b/composables/gql/index.ts @@ -1,2 +1,2 @@ -export * from "./fragment-masking"; -export * from "./gql"; \ No newline at end of file +export * from './fragment-masking'; +export * from './gql'; diff --git a/composables/installPlugin.ts b/composables/installPlugin.ts index 56f1127b4..1db521fb1 100644 --- a/composables/installPlugin.ts +++ b/composables/installPlugin.ts @@ -10,11 +10,11 @@ const useInstallPlugin = () => { sessionStorage.setItem('clickedInstallPlugin', '1'); } const modalTitle = payload.update ? 'Updating Connect (beta)' : 'Installing Connect (beta)'; - // eslint-disable-next-line no-undef + // @ts-ignore – `openPlugin` will be included in 6.10.4+ DefaultPageLayout if (typeof openPlugin === 'function') { console.debug('[useInstallPlugin.install] using openPlugin', file); - // eslint-disable-next-line no-undef + // @ts-ignore openPlugin( `plugin ${payload.update ? 'update' : 'install'} ${file}`, @@ -25,7 +25,7 @@ const useInstallPlugin = () => { } else { console.debug('[useInstallPlugin.install] using openBox', file); // `openBox()` is defined in the webgui's DefaultPageLayout.php and used when openPlugin is not available - // eslint-disable-next-line no-undef + // @ts-ignore openBox( `/plugins/dynamix.plugin.manager/scripts/plugin&arg1=install&arg2=${file}`, @@ -38,11 +38,11 @@ const useInstallPlugin = () => { } catch (error) { console.error(error); } - } + }; return { install, }; }; -export default useInstallPlugin; \ No newline at end of file +export default useInstallPlugin; diff --git a/composables/preventClose.ts b/composables/preventClose.ts index 37e61e773..3f067f50a 100644 --- a/composables/preventClose.ts +++ b/composables/preventClose.ts @@ -1,8 +1,6 @@ export const preventClose = (e: { preventDefault: () => void; returnValue: string; }) => { e.preventDefault(); - // eslint-disable-next-line no-param-reassign e.returnValue = ''; - // eslint-disable-next-line no-alert alert('Closing this pop-up window while actions are being preformed may lead to unintended errors.'); }; @@ -12,4 +10,4 @@ export const addPreventClose = () => { export const removePreventClose = () => { window.removeEventListener('beforeunload', preventClose); -}; \ No newline at end of file +}; diff --git a/composables/services/keyServer.ts b/composables/services/keyServer.ts index 01afb3016..83c1b2926 100644 --- a/composables/services/keyServer.ts +++ b/composables/services/keyServer.ts @@ -7,9 +7,9 @@ export interface StartTrialPayload { timestamp: number; // timestamp in seconds } export interface StartTrialResponse { - license?: string; + license?: string; trial?: string -}; +} export const startTrial = (payload: StartTrialPayload) => KeyServer .url('/account/trial') .formUrl(payload) diff --git a/composables/services/request.ts b/composables/services/request.ts index 4edfc380f..27e912f99 100644 --- a/composables/services/request.ts +++ b/composables/services/request.ts @@ -1,23 +1,23 @@ import wretch from 'wretch'; -import FormUrlAddon from 'wretch/addons/formUrl'; -import QueryStringAddon from 'wretch/addons/queryString'; +import formUrl from 'wretch/addons/formUrl'; +import queryString from 'wretch/addons/queryString'; import { useErrorsStore } from '~/store/errors'; const errorsStore = useErrorsStore(); export const request = wretch() - .addon(FormUrlAddon) - .addon(QueryStringAddon) + .addon(formUrl) + .addon(queryString) .errorType('json') .resolve((response) => { return ( response - .error("Error", (error) => { + .error('Error', (error) => { console.log('global catch (Error class)', error); errorsStore.setError(error); }) - .error("TypeError", (error) => { + .error('TypeError', (error) => { console.log('global type error catch (TypeError class)', error); errorsStore.setError(error); }) diff --git a/composables/useFocusTrap.js b/composables/useFocusTrap.js index 8848dddeb..d49337e9c 100644 --- a/composables/useFocusTrap.js +++ b/composables/useFocusTrap.js @@ -2,17 +2,18 @@ * @see https://www.telerik.com/blogs/how-to-trap-focus-modal-vue-3 */ import { customRef } from 'vue'; +// eslint-disable-next-line import/named import { createFocusTrap } from 'focus-trap'; -const useFocusTrap = focusTrapArgs => { +const useFocusTrap = (focusTrapArgs) => { const trapRef = customRef((track, trigger) => { let $trapEl = null; return { - get() { + get () { track(); return $trapEl; }, - set(value) { + set (value) { $trapEl = value; value ? initFocusTrap(focusTrapArgs) : clearFocusTrap(); trigger(); @@ -21,8 +22,8 @@ const useFocusTrap = focusTrapArgs => { }); let trap = null; - const initFocusTrap = focusTrapArgs => { - if (!trapRef.value) return; + const initFocusTrap = (focusTrapArgs) => { + if (!trapRef.value) { return; } trap = createFocusTrap(trapRef.value, focusTrapArgs); trap.activate(); }; diff --git a/fix-array-type.ts b/fix-array-type.ts index fc08e7bd3..88274266f 100644 --- a/fix-array-type.ts +++ b/fix-array-type.ts @@ -6,7 +6,7 @@ * @param {string*} str * @return {string} */ -function FixArrayType(str) { +function FixArrayType (str) { if (str === 'Array') { return 'ArrayType'; } diff --git a/helpers/time/buildTimeString.ts b/helpers/time/buildTimeString.ts index 1856b8e15..e2d0eeffe 100644 --- a/helpers/time/buildTimeString.ts +++ b/helpers/time/buildTimeString.ts @@ -29,14 +29,14 @@ const buildStringFromValues = ({ return `${num} ${dateStrings[index]}`; }; - if (years) result.push(pluralize(years, 'year')); - if (months) result.push(pluralize(months, 'month')); - if (days) result.push(pluralize(days, 'day')); - if (hours) result.push(pluralize(hours, 'hour')); - if (minutes) result.push(pluralize(minutes, 'minute')); - if (seconds && ((!years && !months && !days && !hours && !minutes) || displaySeconds)) result.push(pluralize(seconds, 'second')); - if (firstDateWasLater) result.push(dateStrings.firstDateWasLater); + if (years) { result.push(pluralize(years, 'year')); } + if (months) { result.push(pluralize(months, 'month')); } + if (days) { result.push(pluralize(days, 'day')); } + if (hours) { result.push(pluralize(hours, 'hour')); } + if (minutes) { result.push(pluralize(minutes, 'minute')); } + if (seconds && ((!years && !months && !days && !hours && !minutes) || displaySeconds)) { result.push(pluralize(seconds, 'second')); } + if (firstDateWasLater) { result.push(dateStrings.firstDateWasLater); } return result.join(dateStrings.delimiter); -} +}; -export default buildStringFromValues; \ No newline at end of file +export default buildStringFromValues; diff --git a/helpers/time/dateFormat.ts b/helpers/time/dateFormat.ts index 943542da0..1117e284c 100644 --- a/helpers/time/dateFormat.ts +++ b/helpers/time/dateFormat.ts @@ -1,8 +1,8 @@ -import dayjs from 'dayjs'; +import dayjs, { extend } from 'dayjs'; import localizedFormat from 'dayjs/plugin/localizedFormat'; /** @see https://day.js.org/docs/en/display/format#localized-formats */ -dayjs.extend(localizedFormat); +extend(localizedFormat); const formatDate = (date: number): string => dayjs(date).format('llll'); diff --git a/helpers/urls.ts b/helpers/urls.ts index eaf08fb45..e2da754b6 100644 --- a/helpers/urls.ts +++ b/helpers/urls.ts @@ -20,4 +20,4 @@ export { PURCHASE, PLUGIN_SETTINGS, SETTINGS_MANAGMENT_ACCESS, -}; \ No newline at end of file +}; diff --git a/layouts/default.vue b/layouts/default.vue index 2c35f64b5..8a893595f 100644 --- a/layouts/default.vue +++ b/layouts/default.vue @@ -1,8 +1,12 @@