Skip to content

Commit

Permalink
Use upgraded @rocket.chat/eslint-config
Browse files Browse the repository at this point in the history
  • Loading branch information
tassoevan committed Nov 15, 2023
1 parent e996a1d commit 74fbea9
Show file tree
Hide file tree
Showing 30 changed files with 990 additions and 549 deletions.
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/node_modules
/app
/workspaces/desktop-release-action/dist
/workspaces/*
31 changes: 29 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,37 @@
{
"extends": "@rocket.chat/eslint-config-alt/react",
"extends": ["@rocket.chat/eslint-config"],
"plugins": ["react", "react-hooks"],
"env": {
"browser": true,
"commonjs": true,
"es6": true,
"node": true,
"jest": true
}
},
"rules": {
"react-hooks/exhaustive-deps": "error",
"react-hooks/rules-of-hooks": "error",
"react/display-name": "error",
"react/jsx-curly-brace-presence": "error",
"react/jsx-fragments": ["error", "syntax"],
"react/jsx-key": ["error", { "checkFragmentShorthand": true, "checkKeyMustBeforeSpread": true, "warnOnDuplicates": true }],
"react/jsx-no-undef": "error",
"react/jsx-uses-react": "error",
"react/jsx-uses-vars": "error",
"react/no-multi-comp": "error"
},
"settings": {
"react": {
"version": "detect"
}
},
"overrides": [
{
"files": ["**/*.stories.js", "**/*.stories.jsx", "**/*.stories.ts", "**/*.stories.tsx", "**/*.spec.tsx"],
"rules": {
"react/display-name": "off",
"react/no-multi-comp": "off"
}
}
]
}
1 change: 0 additions & 1 deletion .prettierrc.js

This file was deleted.

1 change: 1 addition & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"@rocket.chat/prettier-config/fuselage"
13 changes: 13 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"eslint.workingDirectories": [
{
"pattern": "workspaces/*",
"changeProcessCWD": true
},
{
"pattern": ".",
"changeProcessCWD": true
}
],
"typescript.tsdk": "./node_modules/typescript/lib"
}
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@
"@fiahfy/icns-convert": "^0.0.12",
"@fiahfy/ico-convert": "^0.0.12",
"@kayahr/jest-electron-runner": "~29.10.0",
"@rocket.chat/eslint-config": "^0.4.0",
"@rocket.chat/eslint-config-alt": "~0.31.25",
"@rocket.chat/eslint-config": "~0.6.0",
"@rocket.chat/prettier-config": "~0.31.25",
"@rollup/plugin-babel": "~5.3.1",
"@rollup/plugin-commonjs": "~21.1.0",
Expand Down Expand Up @@ -122,13 +121,17 @@
"electron-devtools-installer": "^3.2.0",
"electron-notarize": "^1.2.2",
"eslint": "~8.53.0",
"eslint-config-prettier": "~9.0.0",
"eslint-import-resolver-typescript": "~3.6.1",
"eslint-plugin-import": "~2.26.0",
"eslint-plugin-prettier": "~4.2.1",
"eslint-plugin-react": "~7.33.2",
"eslint-plugin-react-hooks": "~4.6.0",
"jest": "~29.7.0",
"jest-environment-jsdom": "~29.7.0",
"jimp": "~0.16.13",
"npm-run-all": "^4.1.5",
"prettier": "^2.5.1",
"prettier": "~2.8.8",
"puppeteer": "^13.1.2",
"rollup": "~2.79.1",
"rollup-plugin-copy": "~3.4.0",
Expand Down
2 changes: 1 addition & 1 deletion src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const listenToBugsnagEnabledToggle = async (appType: AppType) => {
bugsnagInstance || initBugsnag(apiKey, appVersion, appType);
bugsnagInstance.startSession();
} else {
bugsnagInstance && bugsnagInstance.pauseSession();
bugsnagInstance?.pauseSession();
}
});
};
Expand Down
1 change: 1 addition & 0 deletions src/injected.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { RocketChatDesktopAPI } from './servers/preload/api';

declare global {
// eslint-disable-next-line @typescript-eslint/naming-convention
interface Window {
RocketChatDesktop: RocketChatDesktopAPI;
}
Expand Down
14 changes: 7 additions & 7 deletions src/outlookCalendar/getOutlookEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,18 @@ export const getOutlookEvents = async (
exchange.Credentials = new WebCredentials(login, password);
exchange.Url = new Uri(`${serverUrl}/ews/exchange.asmx`);

const validated_date = new Date(date);
const validatedDate = new Date(date);

const folderId = new FolderId(WellKnownFolderName.Calendar);
const minTime = new DateTime(
validated_date.getFullYear(),
validated_date.getMonth() + 1,
validated_date.getDate()
validatedDate.getFullYear(),
validatedDate.getMonth() + 1,
validatedDate.getDate()
);
const maxTime = new DateTime(
validated_date.getFullYear(),
validated_date.getMonth() + 1,
validated_date.getDate(),
validatedDate.getFullYear(),
validatedDate.getMonth() + 1,
validatedDate.getDate(),
23,
59,
59
Expand Down
1 change: 1 addition & 0 deletions src/outlookCalendar/ipc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ export const startOutlookCalendarUrlHandler = (): void => {
const server = getServerInformationByWebContentsId(event.id);
const { outlookCredentials } = server;
if (
// eslint-disable-next-line @typescript-eslint/prefer-optional-chain
!outlookCredentials ||
!outlookCredentials.userId ||
!outlookCredentials.serverUrl
Expand Down
1 change: 1 addition & 0 deletions src/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { handleTrafficLightsSpacing } from './ui/preload/sidebar';
import { whenReady } from './whenReady';

declare global {
// eslint-disable-next-line @typescript-eslint/naming-convention
interface Window {
JitsiMeetElectron: JitsiMeetElectronAPI;
RocketChatDesktop: RocketChatDesktopAPI;
Expand Down
6 changes: 3 additions & 3 deletions src/servers/supportedVersions/downloadFromCloud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ const apiUrl =
'https://releases.rocket.chat/v2/server/supportedVersions?source=desktop';
const outputFilePath = path.join('.', 'app', 'supportedVersions.jwt');

interface SupportedVersionsResponse {
type SupportedVersionsResponse = {
signed?: string;
}
};

export async function downloadAndSaveSupportedVersionsFromCloud(): Promise<void> {
console.log('Getting Supported Versions from Cloud...');
Expand All @@ -22,7 +22,7 @@ export async function downloadAndSaveSupportedVersionsFromCloud(): Promise<void>
if (response.status === 200) {
const jsonData: SupportedVersionsResponse = response.data;

if (jsonData && jsonData.signed) {
if (jsonData?.signed) {
const signedContent: string = jsonData.signed;
const directory = path.dirname(outputFilePath);
if (!fs.existsSync(directory)) {
Expand Down
2 changes: 1 addition & 1 deletion src/servers/supportedVersions/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export const getSupportedVersionsData = async (
serverDomain,
serverUniqueID
);
if (cloudSupportedVersions && cloudSupportedVersions.signed) {
if (cloudSupportedVersions?.signed) {
const decodedCloudSupportedVersions = decode(
cloudSupportedVersions.signed
) as SupportedVersions;
Expand Down
12 changes: 6 additions & 6 deletions src/servers/supportedVersions/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export type Version = {
messages?: Message[];
};

export interface SupportedVersions {
export type SupportedVersions = {
enforcementStartDate: string;
timestamp: string;
messages?: Message[];
Expand All @@ -42,9 +42,9 @@ export interface SupportedVersions {
versions: Version[];
};
i18n?: Dictionary;
}
};

export interface ServerInfo {
export type ServerInfo = {
version: string;
uniqueId: string;
build: {
Expand Down Expand Up @@ -74,9 +74,9 @@ export interface ServerInfo {
desktop: string;
mobile: string;
};
}
};

export interface CloudInfo {
export type CloudInfo = {
enforcementStartDate: string;
signed: string;
timestamp: string;
Expand All @@ -88,4 +88,4 @@ export interface CloudInfo {
messages?: Message[];
versions: Version[];
};
}
};
4 changes: 2 additions & 2 deletions src/ui/components/CertificatesManager/CertificatesManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const CertificatesManager: FC = () => {
</TableHead>
<TableBody>
{Object.keys(trustedCertificates).map((url) => (
<CertificateItem url={url} />
<CertificateItem key={url} url={url} />
))}
</TableBody>
</Table>
Expand All @@ -58,7 +58,7 @@ export const CertificatesManager: FC = () => {
</TableHead>
<TableBody>
{Object.keys(notTrustedCertificates).map((url) => (
<CertificateItem url={url} />
<CertificateItem key={url} url={url} />
))}
</TableBody>
</Table>
Expand Down
9 changes: 0 additions & 9 deletions src/ui/components/Dialog/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
import type { Ref } from 'react';
import { useEffect, useRef } from 'react';

// TODO: Remove this interface or understand why they removed it https://github.com/microsoft/TypeScript-DOM-lib-generator/issues/1029
interface HTMLDialogElement extends HTMLElement {
open: boolean;
returnValue: string;
close(returnValue?: string): void;
show(): void;
showModal(): void;
}

export const useDialog = (
visible: boolean,
onClose = (): void => undefined
Expand Down
2 changes: 1 addition & 1 deletion src/ui/components/DownloadsManagerView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ const DownloadsManagerView: FC = () => {
divider
current={currentPagination}
itemsPerPage={itemsPerPage}
count={(downloads && downloads.length) || 0}
count={downloads?.length || 0}
showingResultsLabel={showingResultsLabel}
onSetItemsPerPage={setItemsPerPage}
onSetCurrent={setCurrentPagination}
Expand Down
2 changes: 1 addition & 1 deletion src/ui/components/OutlookCredentialsDialog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export const OutlookCredentialsDialog: FC = () => {
password,
rememberCredentials,
}: AuthPayload): Promise<void> => {
if (!server || !server?.outlookCredentials) {
if (!server?.outlookCredentials) {
return;
}

Expand Down
4 changes: 2 additions & 2 deletions src/ui/components/SettingsView/features/NTLMCredentials.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ export const NTLMCredentials: FC<Props> = (props) => {
</FieldHint>
</FieldRow>
<FieldRow>
<FieldRow size={'100%'}>
<FieldRow size='100%'>
<InputBox
defaultValue={allowedNTLMCredentialsDomains as string}
onBlur={handleDomainsChange}
type={'text'}
type='text'
disabled={!isNTLMCredentialsEnabled}
placeholder='*example.com, *foobar.com, *baz'
/>
Expand Down
4 changes: 2 additions & 2 deletions src/ui/components/SideBar/customTheme.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type React from 'react';
import { useEffect } from 'react';

interface CustomThemeProps {
type CustomThemeProps = {
customTheme: string;
}
};

const CustomTheme: React.FC<CustomThemeProps> = ({ customTheme }) => {
useEffect(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/ui/components/SupportedVersionDialog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const SupportedVersionDialog: FC = () => {
};

const checkServerVersion = useCallback(async () => {
if (!server || !server?.supportedVersions) return;
if (!server?.supportedVersions) return;

const supported = await isServerVersionSupported(
server,
Expand Down
4 changes: 2 additions & 2 deletions src/ui/components/utils/ErrorCatcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import React, { Component } from 'react';
import { APP_ERROR_THROWN } from '../../../app/actions';
import { dispatch } from '../../../store';

interface ErrorCatcherProps {
type ErrorCatcherProps = {
children?: ReactNode;
}
};

export class ErrorCatcher extends Component<ErrorCatcherProps> {
componentDidCatch(error: Error, errorInfo: ErrorInfo): void {
Expand Down
1 change: 1 addition & 0 deletions src/ui/main/icons.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { getAppIconPath, getTrayIconPath } from './icons';
declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace jest {
// eslint-disable-next-line @typescript-eslint/naming-convention
interface Matchers<R> {
toMatchAppPath(expected: string): R;
}
Expand Down
18 changes: 9 additions & 9 deletions src/ui/main/rootWindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,13 @@ const fetchRootWindowState = async (): Promise<
> => {
const browserWindow = await getRootWindow();
return {
focused: browserWindow && browserWindow.isFocused(),
visible: browserWindow && browserWindow.isVisible(),
maximized: browserWindow && browserWindow.isMaximized(),
minimized: browserWindow && browserWindow.isMinimized(),
fullscreen: browserWindow && browserWindow.isFullScreen(),
normal: browserWindow && browserWindow.isNormal(),
bounds: browserWindow && browserWindow.getNormalBounds(),
focused: browserWindow?.isFocused(),
visible: browserWindow?.isVisible(),
maximized: browserWindow?.isMaximized(),
minimized: browserWindow?.isMinimized(),
fullscreen: browserWindow?.isFullScreen(),
normal: browserWindow?.isNormal(),
bounds: browserWindow?.getNormalBounds(),
};
};

Expand Down Expand Up @@ -211,7 +211,7 @@ export const setupRootWindow = (): void => {
typeof currentView === 'object'
? servers.find(({ url }) => url === currentView.url)
: null;
return (currentServer && currentServer.title) || app.name;
return currentServer?.title || app.name;
},
async (windowTitle) => {
const browserWindow = await getRootWindow();
Expand Down Expand Up @@ -251,7 +251,7 @@ export const setupRootWindow = (): void => {
});

rootWindow.addListener('close', async () => {
if (rootWindow && rootWindow.isFullScreen()) {
if (rootWindow?.isFullScreen()) {
await new Promise((resolve) =>
rootWindow.once('leave-full-screen', resolve)
);
Expand Down
1 change: 1 addition & 0 deletions src/videoCallWindow/screenSharePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ export function ScreenSharePicker() {
>
{sources.map(({ id, name, thumbnail }) => (
<Source
key={id}
display='flex'
flexDirection='column'
onClick={handleScreenSharingSourceClick(id)}
Expand Down
2 changes: 1 addition & 1 deletion src/videoCallWindow/videoCallWindow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function VideoCallWindow() {
<webview
ref={webviewRef}
src={videoCallUrl}
preload={'./preload.js'}
preload='./preload.js'
webpreferences='nodeIntegration,nativeWindowOpen=true'
allowpopups={'true' as any}
/>
Expand Down
2 changes: 2 additions & 0 deletions workspaces/desktop-release-action/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/dist
/node_modules
2 changes: 1 addition & 1 deletion workspaces/desktop-release-action/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "@rocket.chat/eslint-config-alt/typescript",
"extends": "@rocket.chat/eslint-config",
"rules": {
"no-await-in-loop": "off"
}
Expand Down
Loading

0 comments on commit 74fbea9

Please sign in to comment.