Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions web/eslint.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,21 @@ export default defineConfig([
'react-hooks/set-state-in-render': 'off',
'react-hooks/incompatible-library': 'off',
'@typescript-eslint/no-explicit-any': 'off',

// Prevent directly importing react as a lint rule
'no-restricted-syntax': [
'error',
{
selector: 'ImportDeclaration[source.value="react"] ImportDefaultSpecifier',
message:
'Do not directly import React. Add specific named imports instead (`import { useState, FC } from "react"`).',
},
{
selector: 'ImportDeclaration[source.value="react"] ImportNamespaceSpecifier',
message:
'Do not directly namespace import React (`import * as React`). Add specific named imports instead (`import { useState, FC } from "react"`).',
},
],
},
},
{
Expand Down
4 changes: 2 additions & 2 deletions web/src/components/topology/Korrel8rTopology.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import { useNavigateToQuery } from '../../hooks/useNavigateToQuery';
import * as korrel8r from '../../korrel8r/types';
import { getIcon } from '../icons';
import './korrel8rtopology.css';
import { FC, useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { FC, ReactElement, useCallback, useEffect, useMemo, useRef, useState } from 'react';

// DagreLayout with straight edges (no angular bendpoints).
class StraightEdgeDagreLayout extends DagreLayout {
Expand Down Expand Up @@ -157,7 +157,7 @@ export const Korrel8rTopology: FC<{
);

const nodeMenu = useCallback(
(e: GraphElement<ElementModel, korrel8r.Node>): React.ReactElement[] => {
(e: GraphElement<ElementModel, korrel8r.Node>): ReactElement[] => {
const node = e.getData();
const menu = [
<ContextMenuItem isDisabled={true} key={node.class.toString()}>
Expand Down
10 changes: 5 additions & 5 deletions web/src/hooks/useAgentNavigation.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as React from 'react';
import { useEffect, useRef } from 'react';
import { shallowEqual, useDispatch, useSelector } from 'react-redux';
import { getConsoleUpdates, sendConsoleUpdate } from '../korrel8r-client';
import * as api from '../korrel8r/client';
Expand Down Expand Up @@ -27,13 +27,13 @@ const useAgentNavigation = ({
const dispatch = useDispatch();
const navigateToQuery = useNavigateToQuery();

const navigateToQueryRef = React.useRef(navigateToQuery);
React.useEffect(() => {
const navigateToQueryRef = useRef(navigateToQuery);
useEffect(() => {
navigateToQueryRef.current = navigateToQuery;
});

// Handle console update events via an SSE request.
React.useEffect(() => {
useEffect(() => {
if (!agentEnabled) {
dispatch(setAgentError(''));
return;
Expand Down Expand Up @@ -68,7 +68,7 @@ const useAgentNavigation = ({
}, [agentEnabled, minDelay, maxDelay, dispatch]);

// Send console updates when view or search changes.
React.useEffect(() => {
useEffect(() => {
if (!agentEnabled) return;
const body = {
view,
Expand Down