Skip to content

Commit d6e464a

Browse files
EriikahCamille Moussu
andauthored
[#421] added eslint check to CI (#534)
Co-authored-by: Camille Moussu <cmoussu@linagora.com>
1 parent 8a6ec8f commit d6e464a

File tree

116 files changed

+1232
-801
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

116 files changed

+1232
-801
lines changed

.eslintrc.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

Jenkinsfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ pipeline {
3333
sh 'npm run test'
3434
}
3535
}
36+
stage('Check Lint') {
37+
steps {
38+
sh 'npm run lint'
39+
}
40+
}
3641
stage('Check Formatting') {
3742
steps {
3843
sh 'npx prettier --check .'

__test__/components/Calendar.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ describe("calendar Availability search", () => {
532532
})
533533
);
534534

535-
const calendarRef = (window as any).__calendarRef;
535+
const calendarRef = window.__calendarRef;
536536

537537
await waitFor(() => {
538538
expect(calendarRef.current).not.toBeNull();
@@ -573,7 +573,7 @@ describe("calendar Availability search", () => {
573573
expect(spy).toHaveBeenCalled();
574574
});
575575

576-
const calendarRef = (window as any).__calendarRef;
576+
const calendarRef = window.__calendarRef;
577577
const calendarApi = calendarRef.current;
578578
const view = calendarApi?.view;
579579
await act(async () => {

__test__/features/Calendars/CalendarModal.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ describe("CalendarPopover - Tabs Scenarios", () => {
309309
});
310310

311311
it("copies CalDAV link from Access tab", async () => {
312-
(window as any).CALENDAR_BASE_URL = "https://cal.example.org";
312+
window.CALENDAR_BASE_URL = "https://cal.example.org";
313313
Object.assign(navigator, {
314314
clipboard: { writeText: jest.fn() },
315315
});
@@ -443,7 +443,7 @@ describe("CalendarPopover - Tabs Scenarios", () => {
443443
});
444444

445445
it("fetches and resets the secret link", async () => {
446-
(window as any).CALENDAR_BASE_URL = "https://cal.example.org";
446+
window.CALENDAR_BASE_URL = "https://cal.example.org";
447447

448448
(getSecretLink as jest.Mock)
449449
.mockResolvedValueOnce({

__test__/features/Calendars/CalendarSlice.test.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,12 @@ import { Calendar } from "@/features/Calendars/CalendarTypes";
1010
import {
1111
addSharedCalendarAsync,
1212
createCalendarAsync,
13-
deleteEventAsync,
1413
getCalendarDetailAsync,
1514
getCalendarsListAsync,
1615
getEventAsync,
1716
getTempCalendarsListAsync,
18-
moveEventAsync,
1917
patchACLCalendarAsync,
2018
patchCalendarAsync,
21-
putEventAsync,
2219
removeCalendarAsync,
2320
} from "@/features/Calendars/services";
2421
import { CalendarEvent } from "@/features/Events/EventsTypes";

__test__/features/Events/EventApi.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,18 @@ describe("eventApi", () => {
6868
});
6969

7070
it("putEvent logs when status is 201", async () => {
71-
const consoleLogSpy = jest.spyOn(console, "log").mockImplementation();
71+
const consoleInfoSpy = jest.spyOn(console, "info").mockImplementation();
7272
const mockResponse = { status: 201, url: "/dav/cals/test.ics" };
7373
(api as unknown as jest.Mock).mockReturnValue(mockResponse);
7474

7575
await putEvent(mockEvent);
7676

77-
expect(consoleLogSpy).toHaveBeenCalledWith(
77+
expect(consoleInfoSpy).toHaveBeenCalledWith(
7878
"Event created successfully:",
7979
"/dav/cals/test.ics"
8080
);
8181

82-
consoleLogSpy.mockRestore();
82+
consoleInfoSpy.mockRestore();
8383
});
8484

8585
test("moveEvent sends MOVE request with destination header", async () => {

__test__/features/Events/EventDisplay.test.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ describe("Event Preview Display", () => {
2727
beforeEach(() => {
2828
jest.clearAllMocks();
2929
sessionStorage.clear();
30-
(window as any).MAIL_SPA_URL = null;
30+
window.MAIL_SPA_URL = null;
3131
});
3232

3333
const preloadedState = {
@@ -598,7 +598,7 @@ describe("Event Preview Display", () => {
598598
});
599599
});
600600
it("properly render message button when MAIL_SPA_URL is not null and event has attendees", () => {
601-
(window as any).MAIL_SPA_URL = "test";
601+
window.MAIL_SPA_URL = "test";
602602
renderWithProviders(
603603
<EventPreviewModal
604604
open={true}
@@ -612,7 +612,7 @@ describe("Event Preview Display", () => {
612612
expect(screen.getByText("eventPreview.emailAttendees")).toBeInTheDocument();
613613
});
614614
it("doesnt render message button when MAIL_SPA_URL is not null and event has no attendees", () => {
615-
(window as any).MAIL_SPA_URL = "test";
615+
window.MAIL_SPA_URL = "test";
616616
renderWithProviders(
617617
<EventPreviewModal
618618
open={true}
@@ -637,7 +637,7 @@ describe("Event Preview Display", () => {
637637
expect(screen.queryByTestId("EmailIcon")).not.toBeInTheDocument();
638638
});
639639
it("message button opens url with attendees as uri and title as subject", () => {
640-
(window as any).MAIL_SPA_URL = "test";
640+
window.MAIL_SPA_URL = "test";
641641
const mockOpen = jest.fn();
642642
window.open = mockOpen;
643643

@@ -669,7 +669,7 @@ describe("Event Preview Display", () => {
669669
});
670670

671671
it("message button encodes special characters in event title correctly", () => {
672-
(window as any).MAIL_SPA_URL = "test";
672+
window.MAIL_SPA_URL = "test";
673673
const mockOpen = jest.fn();
674674
window.open = mockOpen;
675675

@@ -952,7 +952,7 @@ describe("Event Preview Display", () => {
952952

953953
beforeEach(() => {
954954
jest.clearAllMocks();
955-
(window as any).MAIL_SPA_URL = null;
955+
window.MAIL_SPA_URL = null;
956956
});
957957

958958
const createStateWithAttendees = (attendees: any[]) => ({

__test__/features/websocket/WebSocketGate.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ describe("WebSocketGate", () => {
322322

323323
it("should reset reconnection attempts counter on successful connection", async () => {
324324
jest.useFakeTimers();
325-
const consoleLog = jest.spyOn(console, "log").mockImplementation();
325+
const consoleLog = jest.spyOn(console, "info").mockImplementation();
326326
let onCloseCallback: Function | undefined;
327327

328328
(createWebSocketConnection as jest.Mock).mockImplementation(
@@ -576,7 +576,7 @@ describe("WebSocketGate", () => {
576576

577577
it("should reset attempt counter when online event fires", async () => {
578578
jest.useFakeTimers();
579-
const consoleLog = jest.spyOn(console, "log").mockImplementation();
579+
const consoleLog = jest.spyOn(console, "info").mockImplementation();
580580
let onCloseCallback: Function | undefined;
581581

582582
(createWebSocketConnection as jest.Mock).mockImplementation(

__test__/features/websocket/createWebSocketConnection.test.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,22 +49,22 @@ describe("createWebSocketConnection", () => {
4949

5050
beforeEach(() => {
5151
({ webSocketInstances, mockWebSocket, cleanup } = setupWebsocket());
52-
(window as any).WEBSOCKET_URL = "wss://calendar.example.com";
52+
window.WEBSOCKET_URL = "wss://calendar.example.com";
5353

5454
(fetchWebSocketTicket as jest.Mock).mockResolvedValue(mockTicket);
5555
});
5656

5757
afterEach(() => {
5858
jest.clearAllMocks();
59-
delete (window as any).WEBSOCKET_URL;
60-
delete (window as any).CALENDAR_BASE_URL;
59+
delete window.WEBSOCKET_URL;
60+
delete window.CALENDAR_BASE_URL;
6161
cleanup();
6262
});
6363

6464
/** ---------- Tests ---------- */
6565

6666
it("throws when WEBSOCKET_URL is not defined", async () => {
67-
delete (window as any).WEBSOCKET_URL;
67+
delete window.WEBSOCKET_URL;
6868
const mockCallbacks = {
6969
onMessage: jest.fn(),
7070
};
@@ -88,8 +88,8 @@ describe("createWebSocketConnection", () => {
8888
});
8989

9090
it("creates WebSocket with correct URL and ticket without the WEBSOCKET_URL", async () => {
91-
delete (window as any).WEBSOCKET_URL;
92-
(window as any).CALENDAR_BASE_URL = "https://calendar.example.com";
91+
delete window.WEBSOCKET_URL;
92+
window.CALENDAR_BASE_URL = "https://calendar.example.com";
9393
await createAndOpenConnection();
9494

9595
expect(mockWebSocket).toHaveBeenCalledWith(

__test__/features/websocket/utils/notificationStorm.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ describe("websocket messages storm", () => {
5757
jest.resetModules();
5858
(getDisplayedCalendarRange as jest.Mock).mockReturnValue(mockRange);
5959
(store.getState as jest.Mock).mockReturnValue(mockState);
60-
(window as any).WS_DEBOUNCE_PERIOD_MS = 500;
60+
window.WS_DEBOUNCE_PERIOD_MS = 500;
6161
mockAccumulators.calendarsToRefresh = new Map<string, any>();
6262
mockAccumulators.calendarsToHide = new Set();
6363
mockAccumulators.currentDebouncePeriod = 0;
@@ -118,7 +118,7 @@ describe("websocket messages storm", () => {
118118
});
119119

120120
it("executes immediately when debounce is disabled", () => {
121-
(window as any).WS_DEBOUNCE_PERIOD_MS = 0;
121+
window.WS_DEBOUNCE_PERIOD_MS = 0;
122122

123123
updateCalendars(
124124
{ "/calendars/cal1/entry1": { syncToken: "abc" } },

0 commit comments

Comments
 (0)