Skip to content

Commit

Permalink
Last round of lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tstirrat15 committed Jan 23, 2025
1 parent fa89362 commit c1a0eaf
Show file tree
Hide file tree
Showing 18 changed files with 74 additions and 92 deletions.
2 changes: 1 addition & 1 deletion cypress/support/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import './commands';

// Handle uncaught exceptions
Cypress.on('uncaught:exception', (err, runnable) => {
Cypress.on('uncaught:exception', (err) => {
// TODO: Ignore transient network errors until either browser caching
// or js fixtures are supported
// https://github.com/cypress-io/cypress/issues/18335
Expand Down
16 changes: 8 additions & 8 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useGoogleAnalytics } from './playground-ui/GoogleAnalyticsHook';
import PlaygroundUIThemed from './playground-ui/PlaygroundUIThemed';
import 'react-reflex/styles.css';
import { BrowserRouter } from 'react-router-dom';
import { type ReactNode } from 'react';
import 'typeface-roboto-mono/index.css'; // Import the Roboto Mono font.
import './App.css';
import { EmbeddedPlayground } from './components/EmbeddedPlayground';
Expand All @@ -13,11 +14,6 @@ import AppConfig from './services/configservice';
import { PLAYGROUND_UI_COLORS } from './theme';

export interface AppProps {
/**
* withRouter, it specified, is the router to wrap the application with.
*/
withRouter?: any;

/**
* forTesting indicates whether the app is for testing.
*/
Expand All @@ -29,7 +25,7 @@ function ForTesting() {
}

function ThemedApp(props: {
withRouter?: any;
withRouter?: () => ReactNode;
forTesting: boolean | undefined;
}) {
if (window.location.pathname.indexOf('/i/') >= 0) {
Expand All @@ -55,7 +51,12 @@ function ThemedApp(props: {
<ForTesting />
);
} else {
return <FullPlayground withRouter={props.withRouter} />;
return (
// @ts-expect-error RRv5 types are jank
<BrowserRouter>
<FullPlayground />
</BrowserRouter>
);
}
}

Expand All @@ -72,7 +73,6 @@ function App(props: AppProps) {
<AlertProvider>
<ConfirmDialogProvider>
<ThemedApp
withRouter={props.withRouter}
forTesting={props.forTesting}
/>
</ConfirmDialogProvider>
Expand Down
37 changes: 14 additions & 23 deletions src/components/FullPlayground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { useZedTerminalService } from '../spicedb-common/services/zedterminalser
import { parseValidationYAML } from '../spicedb-common/validationfileformat';
import { LinearProgress, Tab, Tabs, Tooltip } from '@material-ui/core';
import AppBar from '@material-ui/core/AppBar';
import Box from '@material-ui/core/Box';
import Button from '@material-ui/core/Button';
import ButtonGroup from '@material-ui/core/ButtonGroup';
import TextField from '@material-ui/core/TextField';
Expand Down Expand Up @@ -41,7 +40,7 @@ import ToggleButtonGroup from '@material-ui/lab/ToggleButtonGroup';
import clsx from 'clsx';
import { saveAs } from 'file-saver';
import { fileDialog } from 'file-select-dialog';
import React, { useEffect, useMemo, useState } from 'react';
import { useEffect, useMemo, useState, type ReactNode } from 'react';
import { useCookies } from 'react-cookie';
import 'react-reflex/styles.css';
import { useHistory, useLocation } from 'react-router-dom';
Expand Down Expand Up @@ -90,13 +89,6 @@ import { ValidationPanel, ValidationSummary } from './panels/validation';
import { VisualizerPanel, VisualizerSummary } from './panels/visualizer';
import { WatchesPanel, WatchesSummary } from './panels/watches';

export interface AppProps {
/**
* withRouter, it specified, is the router to wrap the application with.
*/
withRouter?: any;
}

const TOOLBAR_BREAKPOINT = 1550; // pixels

interface StyleProps {
Expand Down Expand Up @@ -361,29 +353,26 @@ interface SharingState {
shareReference?: string;
}

export function FullPlayground(props: { withRouter?: any }) {
export function FullPlayground() {
return <>
<DiscordChatCrate
serverId={AppConfig().discord.serverId}
channelId={AppConfig().discord.channelId}
/>
<ApolloedPlayground withRouter={props.withRouter} />
<ApolloedPlayground />
</>
}

function ApolloedPlayground(props: { withRouter?: any }) {
function ApolloedPlayground() {
const datastore = usePlaygroundDatastore();
const Router = props.withRouter ? props.withRouter : Box;
return (
<Router>
<ShareLoader
datastore={datastore}
shareUrlRoot="s"
sharedRequired={false}
>
<ThemedAppView key="app" datastore={datastore} />
</ShareLoader>
</Router>
);
}

Expand Down Expand Up @@ -615,7 +604,7 @@ export function ThemedAppView(props: { datastore: DataStore }) {

setPreviousValidationForDiff(undefined);
validationService.conductValidation(
(validated: boolean, result: ValidationResult) => {
(_validated: boolean, result: ValidationResult) => {
if (result.updatedValidationYaml) {
const updatedYaml = normalizeValidationYAML(
result.updatedValidationYaml
Expand Down Expand Up @@ -670,7 +659,7 @@ export function ThemedAppView(props: { datastore: DataStore }) {
const validationState = validationService.state;

const handleChangeTab = (
event: React.ChangeEvent<{}>,
_event: React.ChangeEvent<HTMLElement>,
selectedTabValue: string
) => {
const item = datastore.getById(selectedTabValue)!;
Expand Down Expand Up @@ -702,8 +691,8 @@ export function ThemedAppView(props: { datastore: DataStore }) {
return cookieService.relationshipsEditorType;
});
const handleChangeRelationshipEditor = (
event: React.MouseEvent<HTMLElement, MouseEvent>,
value: any
_event: React.MouseEvent<HTMLElement, MouseEvent>,
value: unknown
) => {
const type = value ? value.toString() : 'grid';
if (
Expand All @@ -713,8 +702,10 @@ export function ThemedAppView(props: { datastore: DataStore }) {
return;
}

cookieService.setRelationshipsEditorType(type);
setRelationshipEditor(type);
if (type === 'grid' || type === 'code') {
cookieService.setRelationshipsEditorType(type);
setRelationshipEditor(type);
}
};

const appConfig = AppConfig();
Expand Down Expand Up @@ -1081,7 +1072,7 @@ export function ThemedAppView(props: { datastore: DataStore }) {
const TabLabelWithCount = (props: {
problemService: ProblemService;
kind: DataStoreItemKind;
icon: React.ReactChild;
icon: ReactNode;
title: string;
}) => {
const classes = useSummaryStyles();
Expand Down Expand Up @@ -1262,7 +1253,7 @@ const getFileContentsAsText = async (file: File): Promise<string> => {
return new Promise(
(
resolve: (value: string | PromiseLike<string>) => void,
reject: (reason?: any) => void
reject: () => void
) => {
const reader = new FileReader();
reader.onloadend = function (e: ProgressEvent<FileReader>) {
Expand Down
14 changes: 6 additions & 8 deletions src/components/GuidedTour.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { Theme, useTheme } from '@material-ui/core/styles';
import React from 'react';
import Joyride, { ACTIONS, EVENTS, Step } from 'react-joyride';

const _ = React;
import Joyride, { ACTIONS, EVENTS, type Step } from 'react-joyride';

export const TourElementClass = {
schema: 'tec-schema',
Expand Down Expand Up @@ -92,11 +89,10 @@ const handleEvents = (
index: number;
size: number;
type: string;
step: any;
step: Step;
}) => {
const { action, index, size, type, step } = data;
const { action, type, step } = data;

const properties = { Step: step.title, StepIndex: index, StepsCount: size };
// Tour start
if (ACTIONS.START === action && EVENTS.TOUR_START === type) {
// No-op
Expand All @@ -107,7 +103,9 @@ const handleEvents = (
}
// Tour before step
if (ACTIONS.NEXT === action && EVENTS.STEP_BEFORE === type) {
onEnterStep(step.target);
if (typeof step.target === "string") {
onEnterStep(step.target);
}
}
// Tour step
if (ACTIONS.UPDATE === action && EVENTS.TOOLTIP === type) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/InlinePlayground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ function InlinePlaygroundUI(props: { datastore: DataStore }) {
);

const handleChangeTab = (
event: React.ChangeEvent<{}>,
_event: React.ChangeEvent<HTMLElement>,
selectedTabName: string
) => {
setCurrentTabName(selectedTabName);
Expand Down
5 changes: 2 additions & 3 deletions src/components/KindIcons.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { faDatabase } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { createStyles, makeStyles, Theme } from '@material-ui/core/styles';
import { createStyles, makeStyles } from '@material-ui/core/styles';
import WarningIcon from '@material-ui/icons/Warning';
import React from 'react';
import 'react-reflex/styles.css';

interface StyleProps {
small?: boolean
}

const useStyles = makeStyles((theme: Theme) =>
const useStyles = makeStyles(() =>
createStyles({
ns: {
fontFamily: 'Roboto Mono, monospace',
Expand Down
3 changes: 0 additions & 3 deletions src/components/ValidationButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,11 @@ import CheckCircleOutlineIcon from '@material-ui/icons/CheckCircleOutline';
import ErrorIcon from '@material-ui/icons/Error';
import PlayCircleFilledIcon from '@material-ui/icons/PlayCircleFilled';
import clsx from 'clsx';
import React from 'react';
import 'react-reflex/styles.css';
import { DataStore } from '../services/datastore';
import { ValidationState, ValidationStatus } from '../services/validation';
import { TourElementClass } from './GuidedTour';

const _ = React;

const useStyles = makeStyles((theme: Theme) =>
createStyles({
gcm: {
Expand Down
8 changes: 4 additions & 4 deletions src/components/panels/base/components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Tabs from '@material-ui/core/Tabs';
import Toolbar from '@material-ui/core/Toolbar';
import { Theme, createStyles, makeStyles } from '@material-ui/core/styles';
import CloseIcon from '@material-ui/icons/Close';
import React, { useCallback } from 'react';
import { useCallback, type ReactNode } from 'react';
import { DataStore } from '../../../services/datastore';
import { Services } from '../../../services/services';
import { Panel, useSummaryStyles } from './common';
Expand All @@ -24,7 +24,7 @@ export function PanelSummaryBar<L extends string>(props: {
coordinator: PanelsCoordinator<L>;
services: Services;
disabled?: boolean | undefined;
overrideSummaryDisplay?: React.ReactChild;
overrideSummaryDisplay?: ReactNode;
}) {
const classes = useSummaryStyles();

Expand All @@ -40,7 +40,7 @@ export function PanelSummaryBar<L extends string>(props: {
className={classes.summaryBar}
style={{
gridTemplateColumns: `${panels
.map((panel: Panel<L>) => 'auto')
.map(() => 'auto')
.join(' ')} 1fr auto`,
}}
variant="dense"
Expand Down Expand Up @@ -132,7 +132,7 @@ export function PanelDisplay<L extends string>(
const currentTabName = coordinator.getActivePanel(props.location)?.id || '';

const handleChangeTab = useCallback(
(event: React.ChangeEvent<{}>, selectedPanelId: string) => {
(_event: React.ChangeEvent<HTMLElement>, selectedPanelId: string) => {
coordinator.setActivePanel(selectedPanelId, props.location);
},
[coordinator, props.location]
Expand Down
3 changes: 2 additions & 1 deletion src/components/panels/base/coordinator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ export function usePanelsCoordinator<L extends string>(props: PanelCoordinatorPr
}
} catch (e) {
// Do nothing.
console.error(e)
}

const locations: Record<string, L> = {};
Expand Down Expand Up @@ -333,4 +334,4 @@ export function usePanelsCoordinator<L extends string>(props: PanelCoordinatorPr
isDisplayVisible: isDisplayVisible,
listLocations: listLocations,
};
}
}
14 changes: 7 additions & 7 deletions src/components/panels/base/reflexed.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createStyles, makeStyles, Theme } from "@material-ui/core/styles";
import { createStyles, makeStyles } from "@material-ui/core/styles";
import HorizontalSplitIcon from "@material-ui/icons/HorizontalSplit";
import VerticalSplitIcon from "@material-ui/icons/VerticalSplit";
import React, { PropsWithChildren, useEffect, useState } from "react";
import { PropsWithChildren, useEffect, useState, Children, isValidElement, cloneElement, type ReactNode } from "react";
import {
HandlerProps,
ReflexContainer,
Expand Down Expand Up @@ -31,7 +31,7 @@ const MINIMUM_VERTICAL_FLEX = 0.2;
const MINIMUM_HORIZONTAL_SIZE = 200;
const MINIMUM_VERTICAL_SIZE = 200;

const useStyles = makeStyles((theme: Theme) =>
const useStyles = makeStyles(() =>
createStyles({
noOverflow: {
overflow: "hidden !important",
Expand All @@ -53,7 +53,7 @@ interface PanelDefProps<E> {
panels: Panel<ReflexedPanelLocation>[];
extraProps?: E | undefined;
disabled?: boolean | undefined;
overrideSummaryDisplay?: React.ReactChild;
overrideSummaryDisplay?: ReactNode;
}

interface Dimensions {
Expand Down Expand Up @@ -263,14 +263,14 @@ function MainDisplayAndVertical<E>(
? { width: props.dimensions.width, height: contentHeight }
: undefined;

const adjustedChildren = React.Children.map(props.children, (child) => {
const adjustedChildren = Children.map(props.children, (child) => {
// Based on: https://stackoverflow.com/a/55486160
if (!React.isValidElement<EnrichedChildren>(child)) {
if (!isValidElement<EnrichedChildren>(child)) {
return child;
}

const elementChild: React.ReactElement<EnrichedChildren> = child;
return React.cloneElement(
return cloneElement(
elementChild,
{ dimensions: contentDimensions, ...child.props },
null
Expand Down
Loading

0 comments on commit c1a0eaf

Please sign in to comment.