Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup #618

Draft
wants to merge 13 commits into
base: dev
Choose a base branch
from
Prev Previous commit
Next Next commit
cleanup: wip 3.1
mostly misc cleanups
mochaaP committed Feb 24, 2024
commit 9524a234cfe0c3addc6ed947ed89ae757964e3a1
2 changes: 1 addition & 1 deletion resources/assets/src/components/Alert.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import type React from 'react';

type AlertType = 'success' | 'info' | 'warning' | 'danger';

2 changes: 1 addition & 1 deletion resources/assets/src/components/ButtonEdit.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import type React from 'react';

type Properties = {
readonly title?: string;
3 changes: 2 additions & 1 deletion resources/assets/src/components/EmailSuggestion.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/** @jsxImportSource @emotion/react */
import React, {useState, useEffect} from 'react';
import type React from 'react';
import {useState, useEffect} from 'react';
import Autosuggest from 'react-autosuggest';
import {css} from '@emotion/react';
import {emit} from '@/scripts/event';
3 changes: 1 addition & 2 deletions resources/assets/src/components/Modal.tsx
Original file line number Diff line number Diff line change
@@ -94,7 +94,7 @@ const Modal: React.FC<ModalOptions & Properties> = properties => {
$(reference.current!).modal('hide');

// The "hidden.bs.modal" event can't be trigged automatically when testing.
/* istanbul ignore next */

if (process.env.NODE_ENV === 'test') {
$(reference.current!).trigger('hidden.bs.modal');
}
@@ -104,7 +104,6 @@ const Modal: React.FC<ModalOptions & Properties> = properties => {
properties.onDismiss?.();
$(reference.current!).modal('hide');

/* istanbul ignore next */
if (process.env.NODE_ENV === 'test') {
$(reference.current!).trigger('hidden.bs.modal');
}
2 changes: 1 addition & 1 deletion resources/assets/src/components/ModalBody.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import type React from 'react';
import ModalContent, {type Props as ContentProperties} from './ModalContent';
import ModalInput, {
type
2 changes: 1 addition & 1 deletion resources/assets/src/components/ModalContent.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import type React from 'react';

export type Props = {
readonly text?: string;
2 changes: 1 addition & 1 deletion resources/assets/src/components/ModalFooter.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import type React from 'react';

export type Props = {
readonly flexFooter?: boolean;
2 changes: 1 addition & 1 deletion resources/assets/src/components/ModalHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import type React from 'react';

export type Props = {
readonly title?: string;
2 changes: 1 addition & 1 deletion resources/assets/src/components/ModalInput.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {type HTMLAttributes} from 'react';
import type React, {type HTMLAttributes} from 'react';

export type Props = {
readonly inputType?: string;
2 changes: 1 addition & 1 deletion resources/assets/src/components/Pagination.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import type React from 'react';
import PaginationItem from './PaginationItem';
import {t} from '@/scripts/i18n';

2 changes: 1 addition & 1 deletion resources/assets/src/components/PaginationItem.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import type React from 'react';

type Properties = {
readonly disabled?: boolean;
3 changes: 2 additions & 1 deletion resources/assets/src/components/Toast.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/** @jsxImportSource @emotion/react */
import React, {useState, useEffect} from 'react';
import type React from 'react';
import {useState, useEffect} from 'react';
import {css} from '@emotion/react';

export type ToastType = 'success' | 'info' | 'warning' | 'error';
3 changes: 2 additions & 1 deletion resources/assets/src/components/Viewer.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/** @jsxImportSource @emotion/react */
import React, {useState, useEffect, useRef} from 'react';
import type React from 'react';
import {useState, useEffect, useRef} from 'react';
import {useMeasure} from 'react-use';
import {css} from '@emotion/react';
import styled from '@emotion/styled';
2 changes: 0 additions & 2 deletions resources/assets/src/scripts/cli/configureStdio.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type {Stdio} from 'blessing-skin-shell';
import * as event from '../event';

/* istanbul ignore next */
export function hackStdin() {
if (process.env.NODE_ENV === 'test') {
return process.stdin;
@@ -24,7 +23,6 @@ export function hackStdin() {
} as NodeJS.ReadStream & {_off(): void};
}

/* istanbul ignore next */
export function hackStdout(stdio: Stdio) {
return {
write(message: string) {
2 changes: 1 addition & 1 deletion resources/assets/src/scripts/extra.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export function getExtraData(): Record<string, any> {
const jsonElement = document.querySelector('#blessing-extra');
/* istanbul ignore next */

if (jsonElement) {
return JSON.parse(jsonElement.textContent ?? '{}');
}
1 change: 0 additions & 1 deletion resources/assets/src/scripts/homePage.ts
Original file line number Diff line number Diff line change
@@ -14,7 +14,6 @@ export function scrollHander() {
}
}

/* istanbul ignore next */
if (process.env.NODE_ENV !== 'test') {
const {transparent_navbar} = getExtraData() as {
transparent_navbar: boolean;
1 change: 0 additions & 1 deletion resources/assets/src/scripts/i18n.ts
Original file line number Diff line number Diff line change
@@ -8,7 +8,6 @@ export function t(key: string, parameters: Record<string, string> = Object.creat
let result = '';

for (const segment of segments) {
/* istanbul ignore next */
const middle = temporary?.[segment];
if (!middle) {
return key;
2 changes: 1 addition & 1 deletion resources/assets/src/scripts/logout.ts
Original file line number Diff line number Diff line change
@@ -18,5 +18,5 @@ export async function logout() {
}

const button = document.querySelector('#logout-button');
/* istanbul ignore next */

button?.addEventListener('click', logout);
1 change: 0 additions & 1 deletion resources/assets/src/scripts/notify.ts
Original file line number Diff line number Diff line change
@@ -3,7 +3,6 @@ import {Toast} from './toast';

export const toast = new Toast();

/* istanbul ignore next */
if (process.env.NODE_ENV === 'test') {
afterEach(() => {
toast.clear();
2 changes: 0 additions & 2 deletions resources/assets/src/scripts/textureUtils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {loadSkinToCanvas} from 'skinview-utils';

/* istanbul ignore next */
function checkPixel(
context: CanvasRenderingContext2D,
x: number,
@@ -15,7 +14,6 @@ function checkPixel(
);
}

/* istanbul ignore next */
export async function isAlex(texture: string): Promise<boolean> {
return new Promise(resolve => {
const image = new Image();
2 changes: 1 addition & 1 deletion resources/assets/src/scripts/toast.tsx
Original file line number Diff line number Diff line change
@@ -54,7 +54,7 @@ export function ToastContainer() {
))}
</>
);
};
}

export class Toast {
private readonly container: HTMLDivElement;
4 changes: 2 additions & 2 deletions resources/assets/src/views/admin/Customization.ts
Original file line number Diff line number Diff line change
@@ -38,7 +38,7 @@ export function registerNavbarPicker(

const navbar = document.querySelector<HTMLElement>('.wrapper > nav');
const picker = document.querySelector<HTMLDivElement>('#navbar-color-picker');
/* istanbul ignore next */

if (navbar && picker) {
registerNavbarPicker(navbar, picker, blessing.extra.navbar as string || 'white');
}
@@ -73,7 +73,7 @@ const darkPicker = document.querySelector<HTMLDivElement>(
const lightPicker = document.querySelector<HTMLDivElement>(
'#sidebar-light-picker',
);
/* istanbul ignore next */

if (sidebar && darkPicker && lightPicker) {
registerSidebarPicker(
sidebar,
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import type React from 'react';
import clsx from 'clsx';
import {Box} from './styles';
import {t} from '@/scripts/i18n';
2 changes: 1 addition & 1 deletion resources/assets/src/views/admin/PlayersManagement/Row.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import type React from 'react';
import {t} from '@/scripts/i18n';
import type {Player} from '@/scripts/types';
import ButtonEdit from '@/components/ButtonEdit';
3 changes: 1 addition & 2 deletions resources/assets/src/views/admin/PlayersManagement/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, {useState, useEffect, useLayoutEffect} from 'react';
;
import {useImmer} from 'use-immer';
import Header from '../UsersManagement/Header';
import Card from './Card';
@@ -272,6 +271,6 @@ function PlayersManagement() {
/>
</div>
);
};
}

export default PlayersManagement;
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import type React from 'react';
import styled from '@emotion/styled';
import clsx from 'clsx';
import type {Plugin} from './types';
3 changes: 1 addition & 2 deletions resources/assets/src/views/admin/PluginsManagement/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, {useState, useEffect} from 'react';
;
import {useImmer} from 'use-immer';
import InfoBox from './InfoBox';
import type {Plugin} from './types';
@@ -243,6 +242,6 @@ function PluginsManagement() {
</div>
</div>
);
};
}

export default PluginsManagement;
2 changes: 1 addition & 1 deletion resources/assets/src/views/admin/PluginsMarket/Row.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import type React from 'react';
import type {Plugin} from './types';
import {t} from '@/scripts/i18n';

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import type React from 'react';
import styled from '@emotion/styled';
import {type Report, Status} from './types';
import {t} from '@/scripts/i18n';
3 changes: 1 addition & 2 deletions resources/assets/src/views/admin/ReportsManagement/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, {useState, useEffect} from 'react';
;
import {useImmer} from 'use-immer';
import type {Report, Status} from './types';
import ImageBox from './ImageBox';
@@ -150,6 +149,6 @@ function ReportsManagement() {
</div>
</div>
);
};
}

export default ReportsManagement;
2 changes: 1 addition & 1 deletion resources/assets/src/views/admin/Translations/Row.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import styled from '@emotion/styled';
import React from 'react';
import type React from 'react';
import type {Line} from './types';
import {t} from '@/scripts/i18n';

3 changes: 1 addition & 2 deletions resources/assets/src/views/admin/Translations/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, {useState, useEffect} from 'react';
;
import {useImmer} from 'use-immer';
import type {Line} from './types';
import Row from './Row';
@@ -116,6 +115,6 @@ function Translations() {
</div>
</>
);
};
}

export default Translations;
2 changes: 1 addition & 1 deletion resources/assets/src/views/admin/UsersManagement/Card.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import type React from 'react';
import clsx from 'clsx';
import {Box, Icon, InfoTable} from './styles';
import {
2 changes: 1 addition & 1 deletion resources/assets/src/views/admin/UsersManagement/Row.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import type React from 'react';
import {
humanizePermission,
verificationStatusText,
3 changes: 1 addition & 2 deletions resources/assets/src/views/admin/UsersManagement/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, {useState, useEffect, useLayoutEffect} from 'react';
;
import {useImmer} from 'use-immer';
import Header from './Header';
import Card from './Card';
@@ -364,6 +363,6 @@ function UsersManagement() {
</div>
</div>
);
};
}

export default UsersManagement;
3 changes: 1 addition & 2 deletions resources/assets/src/views/skinlib/Show/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, {useState, useEffect} from 'react';
import {createPortal} from 'react-dom';
;
import Skeleton from 'react-loading-skeleton';
import addClosetItem from './addClosetItem';
import useBlessingExtra from '@/scripts/hooks/useBlessingExtra';
@@ -493,6 +492,6 @@ function Show() {
/>
</>
);
};
}

export default Show;
2 changes: 1 addition & 1 deletion resources/assets/src/views/skinlib/SkinLibrary/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import type React from 'react';

type Properties = {
readonly active?: boolean;
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import type React from 'react';
import Button from './Button';
import type {Filter} from './types';
import {humanizeType} from './utils';
2 changes: 1 addition & 1 deletion resources/assets/src/views/skinlib/SkinLibrary/Item.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import type React from 'react';
import styled from '@emotion/styled';
import type {LibraryItem} from './types';
import {humanizeType} from './utils';
3 changes: 1 addition & 2 deletions resources/assets/src/views/skinlib/SkinLibrary/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, {useState, useEffect} from 'react';
;
import addClosetItem from '../Show/addClosetItem';
import FilterSelector from './FilterSelector';
import Button from './Button';
@@ -299,6 +298,6 @@ function SkinLibrary() {
</section>
</div>
);
};
}

export default SkinLibrary;
3 changes: 1 addition & 2 deletions resources/assets/src/views/skinlib/Upload.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, {useState} from 'react';
import ReactDOM from 'react-dom';
;
import {t} from '@/scripts/i18n';
import useBlessingExtra from '@/scripts/hooks/useBlessingExtra';
import useEmitMounted from '@/scripts/hooks/useEmitMounted';
@@ -255,6 +254,6 @@ function Upload() {
)}
</>
);
};
}

export default Upload;
2 changes: 1 addition & 1 deletion resources/assets/src/views/user/Closet/ClosetItem.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import type React from 'react';
import setAsAvatar from './setAsAvatar';
import {Card, DropdownButton} from './styles';
import {t} from '@/scripts/i18n';
2 changes: 1 addition & 1 deletion resources/assets/src/views/user/Closet/index.tsx
Original file line number Diff line number Diff line change
@@ -49,7 +49,7 @@ function Closet() {

useEffect(() => {
const element = containerReference.current;
/* istanbul ignore next */

if (element) {
const {width} = element.getBoundingClientRect();
if (width >= 500) {
2 changes: 1 addition & 1 deletion resources/assets/src/views/user/OAuth/Row.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import type React from 'react';
import type {App} from './types';
import {t} from '@/scripts/i18n';
import ButtonEdit from '@/components/ButtonEdit';
Loading