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

Bump the eslint-plugins group with 3 updates #1258

Merged
merged 2 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
646 changes: 351 additions & 295 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@
"workbox-strategies": "^7.1.0"
},
"devDependencies": {
"@shlinkio/eslint-config-js-coding-standard": "~3.0.0",
"@shlinkio/eslint-config-js-coding-standard": "~3.0.1",
"@shlinkio/stylelint-config-css-coding-standard": "~1.1.1",
"@stylistic/eslint-plugin": "^2.3.0",
"@stylistic/eslint-plugin": "^2.6.1",
"@testing-library/jest-dom": "^6.4.8",
"@testing-library/react": "^16.0.0",
"@testing-library/user-event": "^14.5.2",
Expand All @@ -82,7 +82,7 @@
"sass": "^1.77.8",
"stylelint": "^15.11.0",
"typescript": "^5.5.4",
"typescript-eslint": "^7.17.0",
"typescript-eslint": "^8.0.0",
"vite": "^5.3.5",
"vite-plugin-pwa": "^0.20.1",
"vitest": "^2.0.2"
Expand Down
2 changes: 1 addition & 1 deletion src/common/AppUpdateBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import './AppUpdateBanner.scss';
interface AppUpdateBannerProps {
isOpen: boolean;
toggle: MouseEventHandler<any>;
forceUpdate: Function;
forceUpdate: () => void;
}

export const AppUpdateBanner = forwardRef<HTMLElement, AppUpdateBannerProps>(({ isOpen, toggle, forceUpdate }, ref) => {
Expand Down
4 changes: 3 additions & 1 deletion src/common/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ export const Home = ({ servers }: HomeProps) => {
useEffect(() => {
// Try to redirect to the first server marked as auto-connect
const autoConnectServer = serversList.find(({ autoConnect }) => autoConnect);
autoConnectServer && navigate(`/server/${autoConnectServer.id}`);
if (autoConnectServer) {
navigate(`/server/${autoConnectServer.id}`);
}
}, [serversList, navigate]);

return (
Expand Down
2 changes: 1 addition & 1 deletion src/common/MainHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type MainHeaderDeps = {
ServersDropdown: FC;
};

const MainHeader: FCWithDeps<{}, MainHeaderDeps> = () => {
const MainHeader: FCWithDeps<unknown, MainHeaderDeps> = () => {
const { ServersDropdown } = useDependencies(MainHeader);
const [isNotCollapsed, toggleCollapse, , collapse] = useToggle();
const location = useLocation();
Expand Down
4 changes: 2 additions & 2 deletions src/container/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import { provideServices as provideSettingsServices } from '../settings/services
import { provideServices as provideUtilsServices } from '../utils/services/provideServices';
import type { ConnectDecorator } from './types';

type LazyActionMap = Record<string, Function>;
type LazyActionMap = Record<string, (...args: unknown[]) => unknown>;

const bottle = new Bottle();

export const { container } = bottle;

const lazyService = <T extends Function, K>(cont: IContainer, serviceName: string) =>
const lazyService = <T extends (...args: unknown[]) => unknown, K>(cont: IContainer, serviceName: string) =>
(...args: any[]) => (cont[serviceName] as T)(...args) as K;

const mapActionService = (map: LazyActionMap, actionName: string): LazyActionMap => ({
Expand Down
6 changes: 5 additions & 1 deletion src/servers/CreateServer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ const CreateServer: FCWithDeps<CreateServerProps, CreateServerDeps> = ({ servers
({ url, apiKey }) => serverData?.url === url && serverData?.apiKey === apiKey,
);

serverExists ? toggleConfirmModal() : saveNewServer(serverData);
if (serverExists) {
toggleConfirmModal();
} else {
saveNewServer(serverData);
}
}, [saveNewServer, serverData, servers, toggleConfirmModal]);

return (
Expand Down
4 changes: 3 additions & 1 deletion src/servers/DeleteServerModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ export const DeleteServerModal: FC<DeleteServerModalConnectProps> = (
}

deleteServer(server);
redirectHome && navigate('/');
if (redirectHome) {
navigate('/');
}
};

return (
Expand Down
4 changes: 3 additions & 1 deletion src/servers/EditServer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ const EditServer: FCWithDeps<EditServerProps, EditServerDeps> = withSelectedServ

const handleSubmit = (serverData: ServerData) => {
editServer(selectedServer.id, serverData);
reconnect === 'true' && selectServer(selectedServer.id);
if (reconnect === 'true') {
selectServer(selectedServer.id);
}
goBack();
};

Expand Down
8 changes: 6 additions & 2 deletions src/servers/helpers/ImportServersBtn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,12 @@ const ImportServersBtn: FCWithDeps<ImportServersBtnConnectProps, ImportServersBt
const dupServers = newServers.filter((server) => serversInclude(existingServers, server));
const hasDuplicatedServers = !!dupServers.length;

!hasDuplicatedServers ? create(newServers) : setDuplicatedServers(dupServers);
hasDuplicatedServers && showModal();
if (!hasDuplicatedServers) {
create(newServers);
} else {
setDuplicatedServers(dupServers);
showModal();
}
})
.then(() => {
// Reset input after processing file
Expand Down
8 changes: 5 additions & 3 deletions src/servers/helpers/ServerForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ export const ServerForm: FC<ServerFormProps> = ({ onSubmit, initialValues, child
const handleSubmit = handleEventPreventingDefault(() => onSubmit({ name, url, apiKey }));

useEffect(() => {
initialValues && setName(initialValues.name);
initialValues && setUrl(initialValues.url);
initialValues && setApiKey(initialValues.apiKey);
if (initialValues) {
setName(initialValues.name);
setUrl(initialValues.url);
setApiKey(initialValues.apiKey);
}
}, [initialValues]);

return (
Expand Down
6 changes: 4 additions & 2 deletions src/servers/helpers/withSelectedServer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type WithSelectedServerPropsDeps = {
ServerError: FC;
};

export function withSelectedServer<T = {}>(
export function withSelectedServer<T extends object>(
WrappedComponent: FCWithDeps<WithSelectedServerProps & T, WithSelectedServerPropsDeps>,
) {
const ComponentWrapper: FCWithDeps<WithSelectedServerProps & T, WithSelectedServerPropsDeps> = (props) => {
Expand All @@ -26,7 +26,9 @@ export function withSelectedServer<T = {}>(
const { selectServer, selectedServer } = props;

useEffect(() => {
params.serverId && selectServer(params.serverId);
if (params.serverId) {
selectServer(params.serverId);
}
}, [params.serverId, selectServer]);

if (!selectedServer) {
Expand Down
4 changes: 2 additions & 2 deletions src/servers/helpers/withoutSelectedServer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import type { FC } from 'react';
import { useEffect } from 'react';

interface WithoutSelectedServerProps {
resetSelectedServer: Function;
resetSelectedServer: () => unknown;
}

export function withoutSelectedServer<T = {}>(WrappedComponent: FC<WithoutSelectedServerProps & T>) {
export function withoutSelectedServer<T extends object>(WrappedComponent: FC<WithoutSelectedServerProps & T>) {
return (props: WithoutSelectedServerProps & T) => {
const { resetSelectedServer } = props;
useEffect(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/servers/reducers/selectedServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const selectServer = (buildShlinkApiClient: ShlinkApiClientBuilder) => cr
version,
printableVersion,
};
} catch (e) {
} catch {
return { ...selectedServer, serverNotReachable: true };
}
},
Expand Down
4 changes: 2 additions & 2 deletions src/settings/helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ export const migrateDeprecatedSettings = (state: Partial<ShlinkState>): Partial<
}

// The "last180Days" interval had a typo, with a lowercase d
if ((state.settings.visits?.defaultInterval as any) === 'last180days') {
state.settings.visits && (state.settings.visits.defaultInterval = 'last180Days');
if (state.settings.visits && (state.settings.visits.defaultInterval as any) === 'last180days') {
state.settings.visits.defaultInterval = 'last180Days';
}

return state;
Expand Down
2 changes: 1 addition & 1 deletion src/utils/helpers/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const versionMatch = (versionToMatch: SemVer | Empty, { maxVersion, minVe
const versionIsValidSemVer = memoizeWith((v) => v, (version: string): version is SemVer => {
try {
return compare(version, version, '=');
} catch (e) {
} catch {
return false;
}
});
Expand Down
4 changes: 3 additions & 1 deletion test/servers/DeleteServerButton.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ describe('<DeleteServerButton />', () => {

expect(screen.getByText(/DeleteServerModal/)).toHaveTextContent(/Closed/);
expect(screen.getByText(/DeleteServerModal/)).not.toHaveTextContent(/Open/);
container.firstElementChild && await user.click(container.firstElementChild);
if (container.firstElementChild) {
await user.click(container.firstElementChild);
}

await waitFor(() => expect(screen.getByText(/DeleteServerModal/)).toHaveTextContent(/Open/));
});
Expand Down
8 changes: 6 additions & 2 deletions test/servers/helpers/ImportServersBtn.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ describe('<ImportServersBtn />', () => {
const { container } = setUp();
const input = container.querySelector('[type=file]');

input && fireEvent.change(input, { target: { files: [''] } });
if (input) {
fireEvent.change(input, { target: { files: [''] } });
}
expect(importServersFromFile).toHaveBeenCalledTimes(1);
await waitFor(() => expect(createServersMock).toHaveBeenCalledTimes(1));
});
Expand All @@ -73,7 +75,9 @@ describe('<ImportServersBtn />', () => {
importServersFromFile.mockResolvedValue([existingServer, newServer]);

expect(screen.queryByRole('dialog')).not.toBeInTheDocument();
input && fireEvent.change(input, { target: { files: [''] } });
if (input) {
fireEvent.change(input, { target: { files: [''] } });
}
await waitFor(() => expect(screen.getByRole('dialog')).toBeInTheDocument());
await user.click(screen.getByRole('button', { name: btnName }));

Expand Down
Loading