fix: eslint fixes rd.3

This commit is contained in:
Zack Spear
2023-07-21 12:06:07 -07:00
parent 1e0cb2ca68
commit 33763b5809
20 changed files with 114 additions and 121 deletions

View File

@@ -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];
}

View File

@@ -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;

View File

@@ -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',
},
},

View File

@@ -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 {

View File

@@ -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<any, any>> = TDocumentType extends DocumentTypeDecoration<
infer TType,
any
@@ -34,21 +33,20 @@ export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>> | null | undefined
): ReadonlyArray<TType> | null | undefined;
export function useFragment<TType>(
export function useFragment<TType> (
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType: FragmentType<DocumentTypeDecoration<TType, any>> | ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>> | null | undefined
): TType | ReadonlyArray<TType> | null | undefined {
return fragmentType as any;
}
export function makeFragmentData<
F extends DocumentTypeDecoration<any, any>,
FT extends ResultOf<F>
>(data: FT, _fragment: F): FragmentType<F> {
> (data: FT, _fragment: F): FragmentType<F> {
return data as FragmentType<F>;
}
export function isFragmentReady<TQuery, TFrag>(
export function isFragmentReady<TQuery, TFrag> (
queryNode: DocumentTypeDecoration<TQuery, any>,
fragmentNode: TypedDocumentNode<TFrag>,
data: FragmentType<TypedDocumentNode<Incremental<TFrag>, any>> | null | undefined
@@ -56,7 +54,7 @@ export function isFragmentReady<TQuery, TFrag>(
const deferredFields = (queryNode as { __meta__?: { deferredFields: Record<string, (keyof TFrag)[]> } }).__meta__
?.deferredFields;
if (!deferredFields) return true;
if (!deferredFields) { return true; }
const fragDef = fragmentNode.definitions[0] as FragmentDefinitionNode | undefined;
const fragName = fragDef?.name?.value;

View File

@@ -1,2 +1,2 @@
export * from "./fragment-masking";
export * from "./gql";
export * from './fragment-masking';
export * from './gql';

View File

@@ -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;
export default useInstallPlugin;

View File

@@ -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);
};
};

View File

@@ -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)

View File

@@ -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);
})

View File

@@ -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();
};

View File

@@ -6,7 +6,7 @@
* @param {string*} str
* @return {string}
*/
function FixArrayType(str) {
function FixArrayType (str) {
if (str === 'Array') {
return 'ArrayType';
}

View File

@@ -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;
export default buildStringFromValues;

View File

@@ -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');

View File

@@ -20,4 +20,4 @@ export {
PURCHASE,
PLUGIN_SETTINGS,
SETTINGS_MANAGMENT_ACCESS,
};
};

View File

@@ -1,8 +1,12 @@
<template>
<client-only>
<div class="flex flex-row items-center justify-center gap-6 p-6 text-gray-200 bg-zinc-800">
<NuxtLink to="/" class="underline hover:no-underline focus:no-underline">Test Vue Components</NuxtLink>
<NuxtLink to="/webComponents" class="underline hover:no-underline focus:no-underline">Test Web Components</NuxtLink>
<NuxtLink to="/" class="underline hover:no-underline focus:no-underline">
Test Vue Components
</NuxtLink>
<NuxtLink to="/webComponents" class="underline hover:no-underline focus:no-underline">
Test Web Components
</NuxtLink>
</div>
<slot />
</client-only>

View File

@@ -1,8 +1,8 @@
import dotenv from 'dotenv';
import { readFileSync } from 'fs';
const envConfig = dotenv.parse(readFileSync('.env'))
import { parse } from 'dotenv';
const envConfig = parse(readFileSync('.env'));
for (const k in envConfig) {
process.env[k] = envConfig[k]
process.env[k] = envConfig[k];
}
// https://nuxt.com/docs/api/configuration/nuxt-config
@@ -61,6 +61,6 @@ export default defineNuxtConfig({
},
],
},
],
},
],
},
});

View File

@@ -1,5 +1,5 @@
<script lang="ts" setup>
import serverState from '../_data/serverState';
import { serverState } from '~/_data/serverState';
const nuxtApp = useNuxtApp();
onBeforeMount(() => {
@@ -15,19 +15,19 @@ onBeforeMount(() => {
<h2>Vue Components</h2>
<h3>UserProfileCe</h3>
<UserProfileCe :server="serverState" />
<hr />
<hr>
<h3>DownloadApiLogsCe</h3>
<DownloadApiLogsCe />
<hr />
<hr>
<h3>AuthCe</h3>
<AuthCe />
<hr />
<hr>
<h3>KeyActionsCe</h3>
<KeyActionsCe />
<hr />
<hr>
<h3>WanIpCheckCe</h3>
<WanIpCheckCe php-wan-ip="47.184.85.45" />
<hr />
<hr>
<h3>ModalsCe</h3>
<ModalsCe />
</div>
@@ -48,4 +48,4 @@ h3 {
hr {
@apply border-black;
}
</style>
</style>

View File

@@ -1,5 +1,5 @@
<script lang="ts" setup>
import serverState from '../_data/serverState';
import { serverState } from '~/_data/serverState';
const nuxtApp = useNuxtApp();
onBeforeMount(() => {
@@ -14,22 +14,22 @@ onBeforeMount(() => {
<div class="flex flex-col gap-6 p-6">
<h2>Web Components</h2>
<h3>UserProfileCe</h3>
<connect-user-profile :server="JSON.stringify(serverState)"></connect-user-profile>
<hr />
<connect-user-profile :server="JSON.stringify(serverState)" />
<hr>
<h3>DownloadApiLogsCe</h3>
<connect-download-api-logs></connect-download-api-logs>
<hr />
<connect-download-api-logs />
<hr>
<h3>AuthCe</h3>
<connect-auth></connect-auth>
<hr />
<connect-auth />
<hr>
<h3>KeyActionsCe</h3>
<connect-key-actions></connect-key-actions>
<hr />
<connect-key-actions />
<hr>
<h3>WanIpCheckCe</h3>
<connect-wan-ip-check php-wan-ip="47.184.85.45"></connect-wan-ip-check>
<hr />
<connect-wan-ip-check php-wan-ip="47.184.85.45" />
<hr>
<h3>ModalsCe</h3>
<connect-modals></connect-modals>
<connect-modals />
</div>
</div>
</div>
@@ -48,4 +48,4 @@ h3 {
hr {
@apply border-black;
}
</style>
</style>

View File

@@ -8,8 +8,8 @@ import hexToRgba from 'hex-to-rgba';
setActivePinia(createPinia());
export interface Theme {
banner: string;
bannerGradient: string;
banner: boolean;
bannerGradient: boolean;
bgColor: string;
descriptionShow: boolean;
metaColor: string;