Skip to content

Commit

Permalink
Activate more ESLint rules (#789)
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Weimann <michael.weimann@nordeck.net>
  • Loading branch information
weeman1337 authored Sep 26, 2024
1 parent 9b2dcd1 commit e10672b
Show file tree
Hide file tree
Showing 32 changed files with 85 additions and 64 deletions.
6 changes: 0 additions & 6 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,6 @@ export default ts.config(
// Disable for the migration to prevent a lot of errors.
// Should be revisisted
'@typescript-eslint/ban-types': 'off',
// FIXME: Came in an update and should be fixed properly
'@typescript-eslint/no-empty-object-type': 'off',
'@typescript-eslint/no-wrapper-object-types': 'off',
},
},
{
Expand Down Expand Up @@ -112,9 +109,6 @@ export default ts.config(
...vitest.configs.recommended.rules,
...testingLibrary.configs['flat/react'].rules,
'react/display-name': 'off',
// FIXME: Came in an update and should be fixed properly
'@typescript-eslint/no-empty-object-type': 'off',
'@typescript-eslint/no-wrapper-object-types': 'off',
},
},
eslintConfigPrettier,
Expand Down
4 changes: 2 additions & 2 deletions example-widget-mui/src/AllRoomsPage/AllRoomsPage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ function mockRoomNameEvent({
}

let widgetApi: MockedWidgetApi;
let wrapper: ComponentType<PropsWithChildren<{}>>;
let wrapper: ComponentType<PropsWithChildren>;

afterEach(() => widgetApi.stop());

beforeEach(() => {
widgetApi = mockWidgetApi();

wrapper = ({ children }: PropsWithChildren<{}>) => (
wrapper = ({ children }: PropsWithChildren) => (
<WidgetApiMockProvider value={widgetApi}>
<MemoryRouter>{children}</MemoryRouter>
</WidgetApiMockProvider>
Expand Down
4 changes: 2 additions & 2 deletions example-widget-mui/src/DicePage/DicePage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ import { afterEach, beforeEach, describe, expect, it } from 'vitest';
import { DicePage } from './DicePage';

let widgetApi: MockedWidgetApi;
let wrapper: ComponentType<PropsWithChildren<{}>>;
let wrapper: ComponentType<PropsWithChildren>;

afterEach(() => widgetApi.stop());

beforeEach(() => {
widgetApi = mockWidgetApi();

wrapper = ({ children }: PropsWithChildren<{}>) => (
wrapper = ({ children }: PropsWithChildren) => (
<WidgetApiMockProvider value={widgetApi}>
<MemoryRouter>{children}</MemoryRouter>
</WidgetApiMockProvider>
Expand Down
4 changes: 2 additions & 2 deletions example-widget-mui/src/IdentityPage/IdentityPage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ import {
import { IdentityPage } from './IdentityPage';

let widgetApi: MockedWidgetApi;
let wrapper: ComponentType<PropsWithChildren<{}>>;
let wrapper: ComponentType<PropsWithChildren>;

afterEach(() => widgetApi.stop());

beforeEach(() => {
widgetApi = mockWidgetApi();

wrapper = ({ children }: PropsWithChildren<{}>) => (
wrapper = ({ children }: PropsWithChildren) => (
<WidgetApiMockProvider value={widgetApi}>
<MemoryRouter>{children}</MemoryRouter>
</WidgetApiMockProvider>
Expand Down
4 changes: 2 additions & 2 deletions example-widget-mui/src/ImagePage/ImagePage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import { StoreProvider } from '../store';
import { ImagePage } from './ImagePage';

let widgetApi: MockedWidgetApi;
let wrapper: ComponentType<PropsWithChildren<{}>>;
let wrapper: ComponentType<PropsWithChildren>;

afterEach(() => widgetApi.stop());

Expand All @@ -40,7 +40,7 @@ beforeEach(() => {

global.URL.createObjectURL = vi.fn().mockReturnValue('http://...');

wrapper = ({ children }: PropsWithChildren<{}>) => (
wrapper = ({ children }: PropsWithChildren) => (
<WidgetApiMockProvider value={widgetApi}>
<StoreProvider>
<MemoryRouter>{children}</MemoryRouter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ import { afterEach, beforeEach, describe, expect, it } from 'vitest';
import { InvitationsPage } from './InvitationsPage';

let widgetApi: MockedWidgetApi;
let wrapper: ComponentType<PropsWithChildren<{}>>;
let wrapper: ComponentType<PropsWithChildren>;

afterEach(() => widgetApi.stop());

beforeEach(() => {
widgetApi = mockWidgetApi();

wrapper = ({ children }: PropsWithChildren<{}>) => (
wrapper = ({ children }: PropsWithChildren) => (
<WidgetApiMockProvider value={widgetApi}>
<MemoryRouter>{children}</MemoryRouter>
</WidgetApiMockProvider>
Expand Down
4 changes: 2 additions & 2 deletions example-widget-mui/src/ModalPage/ModalDialog.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ import { afterEach, beforeEach, describe, expect, it } from 'vitest';
import { ModalDialog, ModalInputData } from './ModalDialog';

let widgetApi: MockedWidgetApi;
let wrapper: ComponentType<PropsWithChildren<{}>>;
let wrapper: ComponentType<PropsWithChildren>;

afterEach(() => widgetApi.stop());

beforeEach(() => {
widgetApi = mockWidgetApi();

wrapper = ({ children }: PropsWithChildren<{}>) => (
wrapper = ({ children }: PropsWithChildren) => (
<WidgetApiMockProvider value={widgetApi}>
<MemoryRouter>{children}</MemoryRouter>
</WidgetApiMockProvider>
Expand Down
4 changes: 2 additions & 2 deletions example-widget-mui/src/ModalPage/ModalPage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ import { ModalResult } from './ModalDialog';
import { ModalPage } from './ModalPage';

let widgetApi: MockedWidgetApi;
let wrapper: ComponentType<PropsWithChildren<{}>>;
let wrapper: ComponentType<PropsWithChildren>;

afterEach(() => widgetApi.stop());

beforeEach(() => {
widgetApi = mockWidgetApi();

wrapper = ({ children }: PropsWithChildren<{}>) => (
wrapper = ({ children }: PropsWithChildren) => (
<WidgetApiMockProvider value={widgetApi}>
<MemoryRouter>{children}</MemoryRouter>
</WidgetApiMockProvider>
Expand Down
4 changes: 2 additions & 2 deletions example-widget-mui/src/NavigationPage/NavigationPage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import { beforeEach, describe, expect, it } from 'vitest';
import { NavigationPage } from './NavigationPage';

describe('<NavigationPage>', () => {
let wrapper: ComponentType<PropsWithChildren<{}>>;
let wrapper: ComponentType<PropsWithChildren>;

beforeEach(() => {
wrapper = ({ children }: PropsWithChildren<{}>) => (
wrapper = ({ children }: PropsWithChildren) => (
<MemoryRouter>{children}</MemoryRouter>
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { StoreProvider } from '../store';
import { PowerLevelsPage } from './PowerLevelsPage';

let widgetApi: MockedWidgetApi;
let wrapper: ComponentType<PropsWithChildren<{}>>;
let wrapper: ComponentType<PropsWithChildren>;

afterEach(() => widgetApi.stop());

Expand Down Expand Up @@ -64,7 +64,7 @@ beforeEach(() => {
room_id: '!room-id',
});

wrapper = ({ children }: PropsWithChildren<{}>) => (
wrapper = ({ children }: PropsWithChildren) => (
<WidgetApiMockProvider value={widgetApi}>
<StoreProvider>
<MemoryRouter>{children}</MemoryRouter>
Expand Down
4 changes: 2 additions & 2 deletions example-widget-mui/src/RelationsPage/RelationsPage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
} from './testUtils';

let widgetApi: MockedWidgetApi;
let wrapper: ComponentType<PropsWithChildren<{}>>;
let wrapper: ComponentType<PropsWithChildren>;

afterEach(() => widgetApi.stop());

Expand All @@ -54,7 +54,7 @@ beforeEach(() => {
);
widgetApi.mockSendStateEvent(mockMessageCollectionEvent());

wrapper = ({ children }: PropsWithChildren<{}>) => (
wrapper = ({ children }: PropsWithChildren) => (
<WidgetApiMockProvider value={widgetApi}>
<StoreProvider>
<MemoryRouter>{children}</MemoryRouter>
Expand Down
14 changes: 10 additions & 4 deletions example-widget-mui/src/RelationsPage/roomMessagesApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ export const roomMessagesApi = baseApi.injectEndpoints({
}),

/** Send a new message to the room and register it in the message collection */
sendMessage: builder.mutation<{}, { message: string }>({
sendMessage: builder.mutation<EmptyObject, { message: string }>({
// do the mutation
queryFn: async ({ message }, { extra }) => {
const { widgetApi } = extra as ThunkExtraArgument;
Expand Down Expand Up @@ -253,7 +253,10 @@ export const roomMessagesApi = baseApi.injectEndpoints({
}),

/** Send a reaction to another event */
sendReaction: builder.mutation<{}, { eventId: string; reaction: string }>({
sendReaction: builder.mutation<
EmptyObject,
{ eventId: string; reaction: string }
>({
// do the mutation
queryFn: async ({ eventId, reaction }, { extra }) => {
const { widgetApi } = extra as ThunkExtraArgument;
Expand Down Expand Up @@ -282,7 +285,7 @@ export const roomMessagesApi = baseApi.injectEndpoints({
}),

/** Redact an event */
sendRedaction: builder.mutation<{}, { eventId: string }>({
sendRedaction: builder.mutation<EmptyObject, { eventId: string }>({
queryFn: async ({ eventId }, { extra }) => {
const { widgetApi } = extra as ThunkExtraArgument;

Expand All @@ -304,7 +307,10 @@ export const roomMessagesApi = baseApi.injectEndpoints({
}),

/** Remove a message from the collection */
dropMessageFromCollection: builder.mutation<{}, { eventId: string }>({
dropMessageFromCollection: builder.mutation<
EmptyObject,
{ eventId: string }
>({
// do the mutation
queryFn: async ({ eventId }, { extra }) => {
const { widgetApi } = extra as ThunkExtraArgument;
Expand Down
4 changes: 2 additions & 2 deletions example-widget-mui/src/RoomPage/RoomPage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { afterEach, beforeEach, describe, expect, it } from 'vitest';
import { RoomPage } from './RoomPage';

let widgetApi: MockedWidgetApi;
let wrapper: ComponentType<PropsWithChildren<{}>>;
let wrapper: ComponentType<PropsWithChildren>;

afterEach(() => widgetApi.stop());

Expand All @@ -45,7 +45,7 @@ beforeEach(() => {
room_id: '!room-id',
});

wrapper = ({ children }: PropsWithChildren<{}>) => (
wrapper = ({ children }: PropsWithChildren) => (
<WidgetApiMockProvider value={widgetApi}>
<MemoryRouter>{children}</MemoryRouter>
</WidgetApiMockProvider>
Expand Down
4 changes: 2 additions & 2 deletions example-widget-mui/src/ThemePage/ThemePage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import { beforeEach, describe, expect, it } from 'vitest';
import { ThemePage } from './ThemePage';

describe('<ThemePage>', () => {
let wrapper: ComponentType<PropsWithChildren<{}>>;
let wrapper: ComponentType<PropsWithChildren>;

beforeEach(() => {
wrapper = ({ children }: PropsWithChildren<{}>) => (
wrapper = ({ children }: PropsWithChildren) => (
<MemoryRouter>{children}</MemoryRouter>
);
});
Expand Down
2 changes: 1 addition & 1 deletion example-widget-mui/src/ThemePage/ThemePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export const ThemePage = (): ReactElement => {
);
};

export function DemoContainer({ children }: PropsWithChildren<{}>) {
export function DemoContainer({ children }: PropsWithChildren) {
return (
<Box display="flex" flexWrap="wrap" gap={1} m={1}>
{children}
Expand Down
4 changes: 2 additions & 2 deletions example-widget-mui/src/WelcomePage/WelcomePage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ import { afterEach, beforeEach, describe, expect, it } from 'vitest';
import { WelcomePage } from './WelcomePage';

let widgetApi: MockedWidgetApi;
let wrapper: ComponentType<PropsWithChildren<{}>>;
let wrapper: ComponentType<PropsWithChildren>;

afterEach(() => widgetApi.stop());

beforeEach(() => {
widgetApi = mockWidgetApi();

wrapper = ({ children }: PropsWithChildren<{}>) => (
wrapper = ({ children }: PropsWithChildren) => (
<WidgetApiMockProvider value={widgetApi}>
<MemoryRouter>{children}</MemoryRouter>
</WidgetApiMockProvider>
Expand Down
4 changes: 2 additions & 2 deletions example-widget-mui/src/events/messageCollectionEvent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ describe('isValidMessageCollectionEvent', () => {
).toBe(true);
});

it.each<Object>([
it.each<object>([
{ eventIds: undefined },
{ eventIds: null },
{ eventIds: 'text' },
{ eventIds: [undefined] },
{ eventIds: [null] },
])('should reject event with patch %j', (patch: Object) => {
])('should reject event with patch %j', (patch: object) => {
expect(
isValidMessageCollectionEvent({
content: {
Expand Down
8 changes: 4 additions & 4 deletions example-widget-mui/src/events/reactionEvent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ describe('isValidReactionEvent', () => {
).toBe(true);
});

it.each<Object>([
it.each<object>([
{ 'm.relates_to': undefined },
{ 'm.relates_to': null },
{ 'm.relates_to': 'text' },
])('should reject event with patch %j', (patch: Object) => {
])('should reject event with patch %j', (patch: object) => {
expect(
isValidReactionEvent({
content: {
Expand All @@ -82,7 +82,7 @@ describe('isValidReactionEvent', () => {
).toBe(false);
});

it.each<Object>([
it.each<object>([
{ rel_type: undefined },
{ rel_type: null },
{ rel_type: 5 },
Expand All @@ -92,7 +92,7 @@ describe('isValidReactionEvent', () => {
{ key: undefined },
{ key: null },
{ key: 5 },
])('should reject relation with patch %j', (patch: Object) => {
])('should reject relation with patch %j', (patch: object) => {
expect(
isValidReactionEvent({
content: {
Expand Down
4 changes: 2 additions & 2 deletions example-widget-mui/src/events/roomMessageEvent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ describe('isValidRoomMessageEvent', () => {
).toBe(true);
});

it.each<Object>([
it.each<object>([
{ msgtype: undefined },
{ msgtype: null },
{ msgtype: 5 },
{ body: undefined },
{ body: null },
{ body: 5 },
])('should reject event with patch %j', (patch: Object) => {
])('should reject event with patch %j', (patch: object) => {
expect(
isValidRoomMessageEvent({
content: {
Expand Down
4 changes: 2 additions & 2 deletions example-widget-mui/src/events/roomNameEvent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ describe('isValidRoomNameEvent', () => {
).toBe(true);
});

it.each<Object>([{ name: undefined }, { name: null }, { name: 111 }])(
it.each<object>([{ name: undefined }, { name: null }, { name: 111 }])(
'should reject event with patch %j',
(patch: Object) => {
(patch: object) => {
expect(
isValidRoomNameEvent({
content: {
Expand Down
4 changes: 2 additions & 2 deletions example-widget-mui/src/events/uploadImageEvent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ describe('isValidUploadedImage', () => {
).toBe(true);
});

it.each<Object>([
it.each<object>([
{ name: undefined, size: undefined, url: undefined },
{ name: undefined, size: 564, url: 'https://example.org' },
{ name: 'image', size: undefined, url: 'https://example.org' },
{ name: 'image', size: undefined, url: undefined },
])('should reject event with patch %j', (patch: Object) => {
])('should reject event with patch %j', (patch: object) => {
expect(
isValidUploadedImage({
content: {
Expand Down
4 changes: 1 addition & 3 deletions example-widget-mui/src/store/StoreProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ import { createStore } from './store';
/**
* Create and provide the redux store
*/
export function StoreProvider({
children,
}: PropsWithChildren<{}>): ReactElement {
export function StoreProvider({ children }: PropsWithChildren): ReactElement {
const widgetApi = useWidgetApi();
const [store] = useState(() => createStore({ widgetApi }));

Expand Down
2 changes: 1 addition & 1 deletion example-widget-mui/src/store/baseApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import {
*/
export const baseApi: Api<
BaseQueryFn<void, unknown, SerializedError>,
{},
EmptyObject,
'baseApi',
never,
typeof coreModuleName | typeof reactHooksModuleName
Expand Down
Loading

0 comments on commit e10672b

Please sign in to comment.