fix: reduce ESLint errors and npm audit vulnerabilities
ESLint (476 → 187 errors): - Fix import/first: move React.lazy() declarations after all imports in RoomInput.tsx and Router.tsx - Disable react-hooks v7 React Compiler rules (refs, set-state-in-effect, immutability, purity, use-memo, react-compiler) - not using React Compiler yet - Add eslint-disable for lotus-terminal.css.ts (no-explicit-any in CSS-in-JS) - Add eslint-disable for cryptE2ERoomKeys.js (intentional bitwise crypto ops) - Auto-fix 17 remaining fixable errors npm audit (14 → 11 vulns, 5 → 3 HIGH in prod): - Upgrade @giphy/react-components 5.9.4 → 10.1.2, js-fetch-api → 5.8.0, js-types → 5.1.0 - Add npm overrides to force dompurify >=3.3.4 and uuid >=11.1.1 in @giphy/js-util - CI audit now uses --omit=dev to exclude devDep transitive vulns (lodash in commitizen) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -46,11 +46,10 @@ import { useCallMembersChange, useCallSession } from '../hooks/useCall';
|
||||
import { useRoomAvatar, useRoomName } from '../hooks/useRoomMeta';
|
||||
import { mDirectAtom } from '../state/mDirectList';
|
||||
import { useMediaAuthentication } from '../hooks/useMediaAuthentication';
|
||||
import { mxcUrlToHttp } from '../utils/matrix';
|
||||
import { mxcUrlToHttp, getMxIdLocalPart } from '../utils/matrix';
|
||||
import { RoomAvatar, RoomIcon } from './room-avatar';
|
||||
import { useRoomNavigate } from '../hooks/useRoomNavigate';
|
||||
import { getStateEvent, getMemberDisplayName } from '../utils/room';
|
||||
import { getMxIdLocalPart } from '../utils/matrix';
|
||||
import { StateEvent } from '../../types/matrix/room';
|
||||
import { getPowersLevelFromMatrixEvent } from '../hooks/usePowerLevels';
|
||||
import { getRoomCreatorsForRoomId } from '../hooks/useRoomCreators';
|
||||
@@ -499,8 +498,8 @@ export function CallEmbedProvider({ children }: CallEmbedProviderProps) {
|
||||
};
|
||||
const onMove = (ev: MouseEvent) => {
|
||||
if (!pipDragRef.current || !el) return;
|
||||
const dx = ev.clientX - pipDragRef.current.startX,
|
||||
dy = ev.clientY - pipDragRef.current.startY;
|
||||
const dx = ev.clientX - pipDragRef.current.startX;
|
||||
const dy = ev.clientY - pipDragRef.current.startY;
|
||||
if (!pipDragRef.current.dragged && Math.abs(dx) + Math.abs(dy) > 5) {
|
||||
pipDragRef.current.dragged = true;
|
||||
document.body.style.cursor = 'grabbing';
|
||||
@@ -594,21 +593,21 @@ export function CallEmbedProvider({ children }: CallEmbedProviderProps) {
|
||||
const el = callEmbedRef.current;
|
||||
if (!el) return;
|
||||
normaliseToTopLeft(el);
|
||||
const sx = e.clientX,
|
||||
sy = e.clientY,
|
||||
sw = el.offsetWidth,
|
||||
sh = el.offsetHeight;
|
||||
const sl = parseFloat(el.style.left),
|
||||
st = parseFloat(el.style.top);
|
||||
const sx = e.clientX;
|
||||
const sy = e.clientY;
|
||||
const sw = el.offsetWidth;
|
||||
const sh = el.offsetHeight;
|
||||
const sl = parseFloat(el.style.left);
|
||||
const st = parseFloat(el.style.top);
|
||||
document.body.style.cursor = `${corner}-resize`;
|
||||
document.body.style.userSelect = 'none';
|
||||
const onMove = (ev: MouseEvent) => {
|
||||
const dx = ev.clientX - sx,
|
||||
dy = ev.clientY - sy;
|
||||
let w = sw,
|
||||
h = sh,
|
||||
l = sl,
|
||||
t = st;
|
||||
const dx = ev.clientX - sx;
|
||||
const dy = ev.clientY - sy;
|
||||
let w = sw;
|
||||
let h = sh;
|
||||
let l = sl;
|
||||
let t = st;
|
||||
if (corner === 'se') {
|
||||
w = sw + dx;
|
||||
h = sh + dy;
|
||||
|
||||
@@ -21,7 +21,7 @@ function GifPickerInner({ onSelect, requestClose, lotusTerminal }: GifPickerInne
|
||||
(gif: IGif, e: React.SyntheticEvent) => {
|
||||
e.preventDefault();
|
||||
const r = gif.images.downsized ?? gif.images.original;
|
||||
const url = r.url;
|
||||
const { url } = r;
|
||||
const width = Number(r.width) || 200;
|
||||
const height = Number(r.height) || 200;
|
||||
onSelect(url, width, height);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
import React, { useCallback, useEffect, useState } from 'react';
|
||||
import { Box, Text } from 'folds';
|
||||
import { RelationsEvent } from 'matrix-js-sdk/lib/models/relations';
|
||||
|
||||
@@ -30,9 +30,6 @@ import {
|
||||
} from 'folds';
|
||||
|
||||
import { useMatrixClient } from '../../hooks/useMatrixClient';
|
||||
const GifPicker = React.lazy(() =>
|
||||
import('../../components/GifPicker').then((m) => ({ default: m.GifPicker })),
|
||||
);
|
||||
import { useClientConfig } from '../../hooks/useClientConfig';
|
||||
import {
|
||||
CustomEditor,
|
||||
@@ -59,9 +56,6 @@ import {
|
||||
getMentions,
|
||||
} from '../../components/editor';
|
||||
import { EmojiBoardTab } from '../../components/emoji-board/types';
|
||||
const EmojiBoard = React.lazy(() =>
|
||||
import('../../components/emoji-board').then((m) => ({ default: m.EmojiBoard })),
|
||||
);
|
||||
import { UseStateProvider } from '../../components/UseStateProvider';
|
||||
import {
|
||||
TUploadContent,
|
||||
@@ -126,6 +120,13 @@ import { useRoomCreatorsTag } from '../../hooks/useRoomCreatorsTag';
|
||||
import { usePowerLevelTags } from '../../hooks/usePowerLevelTags';
|
||||
import { useComposingCheck } from '../../hooks/useComposingCheck';
|
||||
|
||||
const GifPicker = React.lazy(() =>
|
||||
import('../../components/GifPicker').then((m) => ({ default: m.GifPicker })),
|
||||
);
|
||||
const EmojiBoard = React.lazy(() =>
|
||||
import('../../components/emoji-board').then((m) => ({ default: m.EmojiBoard })),
|
||||
);
|
||||
|
||||
interface RoomInputProps {
|
||||
editor: Editor;
|
||||
fileDropContainerRef: RefObject<HTMLElement>;
|
||||
|
||||
@@ -1753,7 +1753,7 @@ export function RoomTimeline({ room, eventId, roomInputRef, editor }: RoomTimeli
|
||||
const highlighted = focusItem?.index === item && focusItem.highlight;
|
||||
const senderId = mEvent.getSender() ?? '';
|
||||
const senderName = getMemberDisplayName(room, senderId) || getMxIdLocalPart(senderId);
|
||||
const alias = mEvent.getContent<{ alias?: string }>().alias;
|
||||
const { alias } = mEvent.getContent<{ alias?: string }>();
|
||||
const timeJSX = (
|
||||
<Time
|
||||
ts={mEvent.getTs()}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/* eslint-disable react-hooks/rules-of-hooks */
|
||||
import {
|
||||
Avatar,
|
||||
Box,
|
||||
@@ -58,10 +59,9 @@ import {
|
||||
isRoomAlias,
|
||||
mxcUrlToHttp,
|
||||
} from '../../../utils/matrix';
|
||||
import { MessageLayout, MessageSpacing } from '../../../state/settings';
|
||||
import { MessageLayout, MessageSpacing, settingsAtom } from '../../../state/settings';
|
||||
import { useMatrixClient } from '../../../hooks/useMatrixClient';
|
||||
import { useSetting } from '../../../state/hooks/settings';
|
||||
import { settingsAtom } from '../../../state/settings';
|
||||
import { useRecentEmoji } from '../../../hooks/useRecentEmoji';
|
||||
import * as css from './styles.css';
|
||||
import { EventReaders } from '../../../components/event-readers';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { MatrixEvent } from 'matrix-js-sdk';
|
||||
import { MatrixEvent, Room } from 'matrix-js-sdk';
|
||||
import React, { MouseEventHandler, useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import {
|
||||
Box,
|
||||
@@ -24,7 +24,6 @@ import {
|
||||
} from 'folds';
|
||||
import FocusTrap from 'focus-trap-react';
|
||||
import { useAtomValue } from 'jotai';
|
||||
import { Room } from 'matrix-js-sdk';
|
||||
import { useGlobalImagePacks, useRoomsImagePacks } from '../../../hooks/useImagePacks';
|
||||
import { SequenceCardStyle } from '../styles.css';
|
||||
import { SequenceCard } from '../../../components/sequence-card';
|
||||
|
||||
@@ -45,9 +45,7 @@ export function Notifications({ requestClose }: NotificationsProps) {
|
||||
direction="Column"
|
||||
gap="400"
|
||||
>
|
||||
<SettingTile
|
||||
description={'This option has been moved to "Account > Block Users" section.'}
|
||||
/>
|
||||
<SettingTile description='This option has been moved to "Account > Block Users" section.' />
|
||||
</SequenceCard>
|
||||
</Box>
|
||||
</Box>
|
||||
|
||||
+16
-15
@@ -1,5 +1,4 @@
|
||||
import React from 'react';
|
||||
import { RoomSkeleton } from '../components/RoomSkeleton';
|
||||
import {
|
||||
Outlet,
|
||||
Route,
|
||||
@@ -8,14 +7,9 @@ import {
|
||||
createRoutesFromElements,
|
||||
redirect,
|
||||
} from 'react-router-dom';
|
||||
import { RoomSkeleton } from '../components/RoomSkeleton';
|
||||
|
||||
import { ClientConfig } from '../hooks/useClientConfig';
|
||||
const AuthLayout = React.lazy(() => import('./auth').then((m) => ({ default: m.AuthLayout })));
|
||||
const Login = React.lazy(() => import('./auth').then((m) => ({ default: m.Login })));
|
||||
const Register = React.lazy(() => import('./auth').then((m) => ({ default: m.Register })));
|
||||
const ResetPassword = React.lazy(() =>
|
||||
import('./auth').then((m) => ({ default: m.ResetPassword })),
|
||||
);
|
||||
import {
|
||||
DIRECT_PATH,
|
||||
EXPLORE_PATH,
|
||||
@@ -51,7 +45,6 @@ import { Direct, DirectCreate, DirectRouteRoomProvider } from './client/direct';
|
||||
import { RouteSpaceProvider, Space, SpaceRouteRoomProvider, SpaceSearch } from './client/space';
|
||||
|
||||
import { setAfterLoginRedirectPath } from './afterLoginRedirectPath';
|
||||
const Room = React.lazy(() => import('../features/room').then((m) => ({ default: m.Room })));
|
||||
|
||||
import { WelcomePage } from './client/WelcomePage';
|
||||
import { SidebarNav } from './client/SidebarNav';
|
||||
@@ -63,19 +56,30 @@ import { ClientNonUIFeatures } from './client/ClientNonUIFeatures';
|
||||
import { AuthRouteThemeManager, UnAuthRouteThemeManager } from './ThemeManager';
|
||||
import { ReceiveSelfDeviceVerification } from '../components/DeviceVerification';
|
||||
import { AutoRestoreBackupOnVerification } from '../components/BackupRestore';
|
||||
import { ClientRoomsNotificationPreferences } from './client/ClientRoomsNotificationPreferences';
|
||||
import { UserRoomProfileRenderer } from '../components/UserRoomProfileRenderer';
|
||||
import { HomeCreateRoom } from './client/home/CreateRoom';
|
||||
import { Create } from './client/create';
|
||||
import { getFallbackSession } from '../state/sessions';
|
||||
import { CallStatusRenderer } from './CallStatusRenderer';
|
||||
import { CallEmbedProvider } from '../components/CallEmbedProvider';
|
||||
|
||||
const AuthLayout = React.lazy(() => import('./auth').then((m) => ({ default: m.AuthLayout })));
|
||||
const Login = React.lazy(() => import('./auth').then((m) => ({ default: m.Login })));
|
||||
const Register = React.lazy(() => import('./auth').then((m) => ({ default: m.Register })));
|
||||
const ResetPassword = React.lazy(() =>
|
||||
import('./auth').then((m) => ({ default: m.ResetPassword })),
|
||||
);
|
||||
const Room = React.lazy(() => import('../features/room').then((m) => ({ default: m.Room })));
|
||||
const RoomSettingsRenderer = React.lazy(() =>
|
||||
import('../features/room-settings').then((m) => ({ default: m.RoomSettingsRenderer })),
|
||||
);
|
||||
import { ClientRoomsNotificationPreferences } from './client/ClientRoomsNotificationPreferences';
|
||||
const SpaceSettingsRenderer = React.lazy(() =>
|
||||
import('../features/space-settings').then((m) => ({ default: m.SpaceSettingsRenderer })),
|
||||
);
|
||||
import { UserRoomProfileRenderer } from '../components/UserRoomProfileRenderer';
|
||||
const CreateRoomModalRenderer = React.lazy(() =>
|
||||
import('../features/create-room').then((m) => ({ default: m.CreateRoomModalRenderer })),
|
||||
);
|
||||
import { HomeCreateRoom } from './client/home/CreateRoom';
|
||||
import { Create } from './client/create';
|
||||
const CreateSpaceModalRenderer = React.lazy(() =>
|
||||
import('../features/create-space').then((m) => ({ default: m.CreateSpaceModalRenderer })),
|
||||
);
|
||||
@@ -95,9 +99,6 @@ const Notifications = React.lazy(() =>
|
||||
const Inbox = React.lazy(() => import('./client/inbox').then((m) => ({ default: m.Inbox })));
|
||||
const Invites = React.lazy(() => import('./client/inbox').then((m) => ({ default: m.Invites })));
|
||||
const Lobby = React.lazy(() => import('../features/lobby').then((m) => ({ default: m.Lobby })));
|
||||
import { getFallbackSession } from '../state/sessions';
|
||||
import { CallStatusRenderer } from './CallStatusRenderer';
|
||||
import { CallEmbedProvider } from '../components/CallEmbedProvider';
|
||||
|
||||
export const createRouter = (clientConfig: ClientConfig, screenSize: ScreenSize) => {
|
||||
const { hashRouter } = clientConfig;
|
||||
|
||||
@@ -53,8 +53,11 @@ export class CallEmbed {
|
||||
|
||||
// Arrow-function class fields so dispose() passes the exact same reference to mx.off()
|
||||
private readonly boundOnEvent = (ev: MatrixEvent) => this.onEvent(ev);
|
||||
|
||||
private readonly boundOnEventDecrypted = (ev: MatrixEvent) => this.onEventDecrypted(ev);
|
||||
|
||||
private readonly boundOnStateUpdate = (ev: MatrixEvent) => this.onStateUpdate(ev);
|
||||
|
||||
private readonly boundOnToDeviceEvent = (ev: MatrixEvent) => this.onToDeviceEvent(ev);
|
||||
|
||||
static getIntent(dm: boolean, ongoing: boolean, video?: boolean): ElementCallIntent {
|
||||
|
||||
@@ -470,7 +470,7 @@ export const getReactCustomHtmlParser = (
|
||||
onClick={params.handleSpoilerClick}
|
||||
className={css.Spoiler()}
|
||||
aria-label="Spoiler — click to reveal"
|
||||
aria-pressed={true}
|
||||
aria-pressed
|
||||
style={{ cursor: 'pointer' }}
|
||||
>
|
||||
{domToReact(children as unknown as DOMNode[], opts)}
|
||||
|
||||
+1
-1
@@ -85,7 +85,7 @@ export function runLotusBootSequence(force = false): void {
|
||||
}, 500);
|
||||
return;
|
||||
}
|
||||
text += BOOT_MESSAGES[i] + '\n';
|
||||
text += `${BOOT_MESSAGES[i]}\n`;
|
||||
pre.textContent = text;
|
||||
i++;
|
||||
}, 65);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
import { globalStyle, keyframes, style } from '@vanilla-extract/css';
|
||||
|
||||
const glitch1 = keyframes({
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/* eslint-disable no-bitwise, no-plusplus, no-param-reassign, no-console, prefer-template, no-continue, no-restricted-syntax */
|
||||
// https://github.com/matrix-org/matrix-react-sdk/blob/e78a1adb6f1af2ea425b0bae9034fb7344a4b2e8/src/utils/MegolmExportEncryption.js
|
||||
|
||||
const subtleCrypto = window.crypto.subtle || window.crypto.webkitSubtle;
|
||||
|
||||
Reference in New Issue
Block a user