From b39fb2635956b677c7c361482a25c5d8135244fd Mon Sep 17 00:00:00 2001 From: Yannik Messerli Date: Wed, 14 Feb 2024 15:59:23 +0100 Subject: [PATCH 1/4] Add no-unused-vars and imports eslint rules and fix the codebase --- .eslintrc.js | 4 ++ package-lock.json | 31 ++++++++++++++ package.json | 3 +- scripts/assets-transformer.js | 2 +- scripts/install-grpc-deps/protoc.mjs | 7 +--- src/api/customprotocol-core/stream.ts | 2 +- src/api/grpc/error.ts | 2 +- src/api/http-client/result.ts | 2 - src/components/ArrowsRenderer/index.tsx | 1 - src/components/Card/index.tsx | 1 - .../DetailsPanel/hooks/usePanelResize.ts | 2 +- src/components/DetailsPanel/index.tsx | 2 +- src/components/EndpointCardHeader/index.tsx | 37 ----------------- src/components/FlowsTable/ColumnsSelector.tsx | 2 +- src/components/FlowsTable/Sidebar.tsx | 4 +- .../FlowsTable/SidebarComponents.tsx | 4 -- .../FlowsTable/__tests__/Row.test.tsx | 8 ++-- src/components/FlowsTable/hooks/useScroll.ts | 2 +- src/components/FlowsTable/index.tsx | 1 - src/components/Map/NamespaceBackplate.tsx | 1 - .../ServiceMapArrowBody.tsx | 14 +------ .../ServiceMapArrowDuckFeet.tsx | 4 +- src/components/ServiceMapCard/http-groups.ts | 1 - src/components/Teleport/index.tsx | 2 +- src/components/TopBar/FlowsFilterInput.tsx | 5 +-- src/components/TopBar/index.tsx | 2 +- src/data-layer/service-map.ts | 4 +- .../aggregation/__tests__/aggregation.test.ts | 3 -- src/domain/diff/index.ts | 9 ++--- .../filtering/__tests__/filter-flow.test.ts | 17 ++++---- .../filtering/__tests__/filter-link.test.ts | 1 - src/domain/filtering/filter-link.ts | 2 +- src/domain/filtering/filter-service.ts | 2 +- src/domain/filtering/index.ts | 2 +- src/domain/geometry/position.ts | 1 - src/domain/geometry/utils.ts | 2 - src/domain/helpers/flows.ts | 1 - src/domain/time/index.ts | 2 - src/index.tsx | 2 +- src/router/Provider.tsx | 1 - src/router/router.ts | 3 +- src/router/state.ts | 2 +- .../local/__tests__/store-restore.test.ts | 2 - src/store/__tests__/frame.test.ts | 40 +++++++++---------- src/store/stores/interaction.ts | 19 --------- src/store/stores/main.ts | 8 ++-- src/store/stores/namespace.ts | 3 +- src/store/stores/service.ts | 2 +- src/testing/helpers.ts | 1 - src/testing/index.tsx | 1 - src/ui-layer/controls.ts | 3 +- .../service-map/coordinates/arrows.ts | 2 +- .../helpers/connector-coords-accumulator.ts | 2 +- .../service-map/coordinates/placement.ts | 1 - src/ui-layer/service-map/index.ts | 8 ++-- src/ui-layer/status-center.ts | 4 +- src/ui-layer/ui-layer.ts | 7 ++-- src/ui/d3/index.ts | 2 +- src/ui/hooks/useElemCoords.ts | 2 +- src/ui/hooks/useIntersectCoords.ts | 2 +- src/ui/hooks/useSizeWatcher.ts | 2 +- src/ui/service-map/collector.ts | 6 +-- 62 files changed, 122 insertions(+), 195 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 949973167..01284f594 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -6,6 +6,7 @@ module.exports = { 'plugin:@typescript-eslint/recommended', 'plugin:prettier/recommended', ], + plugins: ['unused-imports'], parserOptions: { ecmaVersion: 2018, sourceType: 'module', @@ -24,6 +25,9 @@ module.exports = { '@typescript-eslint/no-namespace': 'off', '@typescript-eslint/explicit-module-boundary-types': 'off', '@typescript-eslint/no-unused-vars': 'off', + 'no-unused-vars': 'off', + 'unused-imports/no-unused-imports': 'error', + 'unused-imports/no-unused-vars': ['error', { ignoreRestSiblings: true }], '@typescript-eslint/ban-types': 'off', '@typescript-eslint/no-use-before-define': [ 'error', diff --git a/package-lock.json b/package-lock.json index 6768c8f48..4bfe404b6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -70,6 +70,7 @@ "eslint-config-prettier": "9.1.0", "eslint-plugin-prettier": "5.1.3", "eslint-plugin-react": "7.33.2", + "eslint-plugin-unused-imports": "^3.1.0", "fs-extra": "11.2.0", "html-webpack-plugin": "5.6.0", "husky": "9.0.10", @@ -9136,6 +9137,36 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/eslint-plugin-unused-imports": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-unused-imports/-/eslint-plugin-unused-imports-3.1.0.tgz", + "integrity": "sha512-9l1YFCzXKkw1qtAru1RWUtG2EVDZY0a0eChKXcL+EZ5jitG7qxdctu4RnvhOJHv4xfmUf7h+JJPINlVpGhZMrw==", + "dev": true, + "dependencies": { + "eslint-rule-composer": "^0.3.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "peerDependencies": { + "@typescript-eslint/eslint-plugin": "6 - 7", + "eslint": "8" + }, + "peerDependenciesMeta": { + "@typescript-eslint/eslint-plugin": { + "optional": true + } + } + }, + "node_modules/eslint-rule-composer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/eslint-rule-composer/-/eslint-rule-composer-0.3.0.tgz", + "integrity": "sha512-bt+Sh8CtDmn2OajxvNO+BX7Wn4CIWMpTRm3MaiKPCQcnnlm0CS2mhui6QaoeQugs+3Kj2ESKEEGJUdVafwhiCg==", + "dev": true, + "engines": { + "node": ">=4.0.0" + } + }, "node_modules/eslint-scope": { "version": "7.2.2", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz", diff --git a/package.json b/package.json index b9e39ae07..5d43ad1d7 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ "@blueprintjs/select": "5.1.1", "@improbable-eng/grpc-web": "^0.15.0", "@react-hook/resize-observer": "1.2.6", + "@react-spring/web": "9.7.3", "@use-gesture/react": "10.3.0", "classnames": "2.5.1", "core-js": "3.35.1", @@ -51,7 +52,6 @@ "react": "18.2.0", "react-dom": "18.2.0", "react-router-dom": "6.22.0", - "@react-spring/web": "9.7.3", "react-window": "1.8.10", "url-parse": "1.5.10" }, @@ -91,6 +91,7 @@ "eslint-config-prettier": "9.1.0", "eslint-plugin-prettier": "5.1.3", "eslint-plugin-react": "7.33.2", + "eslint-plugin-unused-imports": "^3.1.0", "fs-extra": "11.2.0", "html-webpack-plugin": "5.6.0", "husky": "9.0.10", diff --git a/scripts/assets-transformer.js b/scripts/assets-transformer.js index 1fc97b673..cc7e955a5 100644 --- a/scripts/assets-transformer.js +++ b/scripts/assets-transformer.js @@ -4,7 +4,7 @@ const path = require('path'); module.exports = { - process(src, filename, config, options) { + process(_, filename) { return 'module.exports = ' + JSON.stringify(path.basename(filename)) + ';'; }, }; diff --git a/scripts/install-grpc-deps/protoc.mjs b/scripts/install-grpc-deps/protoc.mjs index c4f07ef4c..945e3b296 100644 --- a/scripts/install-grpc-deps/protoc.mjs +++ b/scripts/install-grpc-deps/protoc.mjs @@ -5,8 +5,7 @@ import decompress from 'decompress'; const VERSION = '3.11.4'; -const DL_PREFIX = - 'https://github.com/protocolbuffers/protobuf/releases/download'; +const DL_PREFIX = 'https://github.com/protocolbuffers/protobuf/releases/download'; const PLATFORM = { @@ -53,9 +52,7 @@ async function download(url, targetFile) { if (code > 300 && code < 400 && !!response.headers.location) { return resolve(download(response.headers.location, targetFile)); } - const fileWriter = fs - .createWriteStream(targetFile) - .on('finish', () => resolve()); + const fileWriter = fs.createWriteStream(targetFile).on('finish', () => resolve()); response.pipe(fileWriter); }) .on('error', error => reject(error)); diff --git a/src/api/customprotocol-core/stream.ts b/src/api/customprotocol-core/stream.ts index 8997d3a02..0f037477b 100644 --- a/src/api/customprotocol-core/stream.ts +++ b/src/api/customprotocol-core/stream.ts @@ -385,7 +385,7 @@ export class Stream extends EventEmitter ); }); - -interface PolicyProps { - ingress: boolean; - egress: boolean; -} - -const PolicyInfo = memo(function PolicyProps(props: PolicyProps) { - const inLocked = props.ingress ? 'locked' : 'unlocked'; - const eLocked = props.egress ? 'locked' : 'unlocked'; - - const ingressIcon = `icons/misc/ingress-${inLocked}.svg`; - const egressIcon = `icons/misc/ingress-${eLocked}.svg`; - - const ingressCls = classnames({ - [css.left]: true, - [css.active]: props.ingress, - }); - - const egressCls = classnames({ - [css.right]: true, - [css.active]: props.egress, - }); - - return ( -
-
- - Ingress -
- -
- Egress - -
-
- ); -}); diff --git a/src/components/FlowsTable/ColumnsSelector.tsx b/src/components/FlowsTable/ColumnsSelector.tsx index e67398111..219517938 100644 --- a/src/components/FlowsTable/ColumnsSelector.tsx +++ b/src/components/FlowsTable/ColumnsSelector.tsx @@ -3,7 +3,7 @@ import React, { memo, useCallback } from 'react'; import { usePopover } from '~/ui/hooks/usePopover'; -import { CommonProps, Column, columnKeys, getColumnLabel } from './general'; +import { CommonProps, Column, getColumnLabel } from './general'; export interface Props extends CommonProps { visibleColumns: Set; diff --git a/src/components/FlowsTable/Sidebar.tsx b/src/components/FlowsTable/Sidebar.tsx index e30bbd3af..dad255977 100644 --- a/src/components/FlowsTable/Sidebar.tsx +++ b/src/components/FlowsTable/Sidebar.tsx @@ -1,5 +1,5 @@ import { Icon } from '@blueprintjs/core'; -import React, { memo, useCallback, useMemo, useEffect, useState } from 'react'; +import React, { memo, useCallback, useEffect, useState } from 'react'; import { Flow, Verdict } from '~/domain/flows'; import { Filters, FilterEntry, FilterDirection } from '~/domain/filtering'; @@ -51,7 +51,7 @@ export const FlowsTableSidebar = memo(function FlowsTableSidebar(props) { const [podSelection, setPodSelection] = useState>(new Set()); const [identitySelection, setIdSelection] = useState>(new Set()); const [ipSelection, setIpSelection] = useState>(new Set()); - const [tcpFlagSelection, setTCPSelection] = useState>(new Set()); + const [tcpFlagSelection] = useState>(new Set()); const [isDnsSelected, setDnsSelected] = useState(false); diff --git a/src/components/FlowsTable/SidebarComponents.tsx b/src/components/FlowsTable/SidebarComponents.tsx index e1e15432c..b4149c702 100644 --- a/src/components/FlowsTable/SidebarComponents.tsx +++ b/src/components/FlowsTable/SidebarComponents.tsx @@ -138,10 +138,6 @@ export const VerdictEntry = memo(function FlowsTableSidebarVe [css.auditVerdict]: props.verdict === Verdict.Audit, }); - const onClick = useCallback(() => { - props.onClick?.(); - }, [props.onClick]); - return ( {verdictHelpers.toString(props.verdict)} diff --git a/src/components/FlowsTable/__tests__/Row.test.tsx b/src/components/FlowsTable/__tests__/Row.test.tsx index b57744c2a..36425b9f0 100644 --- a/src/components/FlowsTable/__tests__/Row.test.tsx +++ b/src/components/FlowsTable/__tests__/Row.test.tsx @@ -7,8 +7,6 @@ import { Column } from '~/components/FlowsTable'; import { Flow } from '~/domain/flows'; import { HubbleFlow } from '~/domain/hubble'; -const tsUpdateDelay = 5000; - jest.useFakeTimers(); interface Expectations { @@ -63,7 +61,7 @@ const runAppearanceTests = (row: HTMLElement, exps: Expectations, selected: bool } }; -const runTemporalTests = (row: HTMLElement, flow: Flow) => { +const runTemporalTests = (row: HTMLElement) => { jest.clearAllTimers(); const tsLabel = row.querySelector('.cell:nth-child(12)')!; @@ -77,7 +75,7 @@ const runTest = (ntest: number, hf: HubbleFlow, exps: Expectations) => { const isSelected = [false, true]; isSelected.forEach(selected => { - const onSelect = jest.fn((flow: Flow | null) => void 0); + const onSelect = jest.fn(() => void 0); const selectedStr = selected ? 'selected' : 'not-selected'; describe(`FlowsTable: Row (${selectedStr}) / test ${ntest}`, () => { @@ -99,7 +97,7 @@ const runTest = (ntest: number, hf: HubbleFlow, exps: Expectations) => { }); test(`temporal`, () => { - runTemporalTests(row, flow); + runTemporalTests(row); }); test(`interactions`, () => { diff --git a/src/components/FlowsTable/hooks/useScroll.ts b/src/components/FlowsTable/hooks/useScroll.ts index dc336b76a..7c3380275 100644 --- a/src/components/FlowsTable/hooks/useScroll.ts +++ b/src/components/FlowsTable/hooks/useScroll.ts @@ -1,4 +1,4 @@ -import React, { useRef, useEffect, MutableRefObject } from 'react'; +import { useRef, useEffect, MutableRefObject } from 'react'; import { FixedSizeListProps } from 'react-window'; import { sizes } from '~/ui'; diff --git a/src/components/FlowsTable/index.tsx b/src/components/FlowsTable/index.tsx index 2aa780852..0c8b27714 100644 --- a/src/components/FlowsTable/index.tsx +++ b/src/components/FlowsTable/index.tsx @@ -4,7 +4,6 @@ import { FixedSizeList } from 'react-window'; import { Flow } from '~/domain/flows'; import { sizes } from '~/ui'; -import { Ticker } from '~/utils/ticker'; import { CommonProps, TickerEvents } from './general'; import { useScroll, OnFlowsDiffCount } from './hooks/useScroll'; diff --git a/src/components/Map/NamespaceBackplate.tsx b/src/components/Map/NamespaceBackplate.tsx index 7f6081334..71738dc22 100644 --- a/src/components/Map/NamespaceBackplate.tsx +++ b/src/components/Map/NamespaceBackplate.tsx @@ -1,7 +1,6 @@ import React, { memo } from 'react'; import { XYWH } from '~/domain/geometry'; -import { sizes } from '~/ui/vars'; import css from './styles.scss'; diff --git a/src/components/ServiceMapArrowRenderer/ServiceMapArrowBody.tsx b/src/components/ServiceMapArrowRenderer/ServiceMapArrowBody.tsx index a1b486194..339b6a60e 100644 --- a/src/components/ServiceMapArrowRenderer/ServiceMapArrowBody.tsx +++ b/src/components/ServiceMapArrowRenderer/ServiceMapArrowBody.tsx @@ -1,14 +1,12 @@ import React, { useCallback, useEffect, useRef } from 'react'; import { observer } from 'mobx-react-lite'; import classnames from 'classnames'; -import * as mobx from 'mobx'; import * as d3 from 'd3'; import { XY } from '~/domain/geometry'; -import { link } from '~/domain/helpers'; import { ArrowRendererProps } from '~/components/ArrowsRenderer'; -import { ServiceMapArrow, AccessPointArrow } from '~/ui-layer/service-map/coordinates/arrow'; +import { ServiceMapArrow } from '~/ui-layer/service-map/coordinates/arrow'; import { colors, sizes } from '~/ui/vars'; import * as helpers from './helpers'; @@ -22,14 +20,6 @@ export const ServiceMapArrowBody = observer(function ServiceMapArrowBody(props: const endingFigures = useRef(null); const innerArrows = useRef(null); - const arrow = mobx - .computed(() => { - if (!(props.arrow instanceof ServiceMapArrow)) return null; - - return props.arrow; - }) - .get(); - const renderArrow = useCallback((arrow: ServiceMapArrow) => { // NOTE: Here we use data bind with one element in array just to have // NOTE: an access to enter/update sets (see d3 General Update Pattern). @@ -85,7 +75,7 @@ export const ServiceMapArrowBody = observer(function ServiceMapArrowBody(props: const startPlate = d3 .select(endingFigures.current!) .selectAll('path.start-plate') - .data([arrow.start], _ => `${arrow.id}-start-plate`); + .data([arrow.start], () => `${arrow.id}-start-plate`); startPlate.attr('d', helpers.svg.startPlatePath); diff --git a/src/components/ServiceMapArrowRenderer/ServiceMapArrowDuckFeet.tsx b/src/components/ServiceMapArrowRenderer/ServiceMapArrowDuckFeet.tsx index 1f61fdd7d..e6a25c34e 100644 --- a/src/components/ServiceMapArrowRenderer/ServiceMapArrowDuckFeet.tsx +++ b/src/components/ServiceMapArrowRenderer/ServiceMapArrowDuckFeet.tsx @@ -1,4 +1,4 @@ -import React, { useCallback, useEffect, useRef } from 'react'; +import React, { useCallback } from 'react'; import { observer } from 'mobx-react'; import classnames from 'classnames'; import * as d3 from 'd3'; @@ -40,7 +40,7 @@ export const ServiceMapArrowDuckFeet = observer(function ServiceMapArrowDuckFeet const endingConnector = d3 .select(target) .selectAll('circle.ending-connector') - .data([connectorPosition], _ => `${connectorId}-ending-connector`); + .data([connectorPosition], () => `${connectorId}-ending-connector`); endingConnector.attr('cx', d => d.x).attr('cy', d => d.y); diff --git a/src/components/ServiceMapCard/http-groups.ts b/src/components/ServiceMapCard/http-groups.ts index 32f64ea57..d345250bc 100644 --- a/src/components/ServiceMapCard/http-groups.ts +++ b/src/components/ServiceMapCard/http-groups.ts @@ -8,7 +8,6 @@ export class HTTPEndpointGroup { public static createSorted(endpoints?: PartialConnections): HTTPEndpointGroup[] { if (endpoints == null) return []; - const pathGroups: Map = new Map(); const sortedEndpoints: L7Endpoint[] = []; endpoints?.get(L7Kind.HTTP)?.forEach(ep => { diff --git a/src/components/Teleport/index.tsx b/src/components/Teleport/index.tsx index a76c39845..ff236a5e0 100644 --- a/src/components/Teleport/index.tsx +++ b/src/components/Teleport/index.tsx @@ -1,5 +1,5 @@ import _ from 'lodash'; -import React, { useEffect, useLayoutEffect, useMemo, useState } from 'react'; +import React, { useEffect, useState } from 'react'; import ReactDOM from 'react-dom'; export type Props = { diff --git a/src/components/TopBar/FlowsFilterInput.tsx b/src/components/TopBar/FlowsFilterInput.tsx index 070ada192..b13132c12 100644 --- a/src/components/TopBar/FlowsFilterInput.tsx +++ b/src/components/TopBar/FlowsFilterInput.tsx @@ -1,12 +1,11 @@ import { Button, Classes, MenuItem } from '@blueprintjs/core'; import { ItemRenderer, MultiSelect2 } from '@blueprintjs/select'; import { trim } from 'lodash'; -import React, { useCallback, useState, memo } from 'react'; -import classnames from 'classnames'; +import React, { useCallback, useState } from 'react'; import { TagDirection } from './TagDirection'; -import { FilterDirection, FilterEntry, FilterKind } from '~/domain/filtering'; +import { FilterEntry, FilterKind } from '~/domain/filtering'; import { Labels } from '~/domain/labels'; import css from './FlowsFilterInput.scss'; diff --git a/src/components/TopBar/index.tsx b/src/components/TopBar/index.tsx index 23fda6a9a..27caf02ed 100644 --- a/src/components/TopBar/index.tsx +++ b/src/components/TopBar/index.tsx @@ -4,7 +4,7 @@ import { observer } from 'mobx-react'; import { Verdict } from '~/domain/hubble'; import { FilterEntry } from '~/domain/filtering'; import { Status } from '~/domain/status'; -import { DataMode, TransferState } from '~/domain/interactions'; +import { TransferState } from '~/domain/interactions'; import { NamespaceDescriptor } from '~/domain/namespaces'; import { FlowsFilterInput } from './FlowsFilterInput'; diff --git a/src/data-layer/service-map.ts b/src/data-layer/service-map.ts index fb7c2483b..3b6c4b07d 100644 --- a/src/data-layer/service-map.ts +++ b/src/data-layer/service-map.ts @@ -13,8 +13,6 @@ import { Store, StoreFrame } from '~/store'; import { Retries } from '~/utils/retry'; import { EventEmitter } from '~/utils/emitter'; -import { NamespaceDescriptor } from '~/domain/namespaces'; - export enum Event { FlowsDiff = 'flows-diff-count', FlowFiltersShouldBeChanged = 'filter-entries-should-be-changed', @@ -255,7 +253,7 @@ export class ServiceMap extends EventEmitter { this.emit(Event.FlowFiltersShouldBeChanged, flowFilters); } - private pickDataModeForNamespace(ns?: NamespaceDescriptor | null): DataMode { + private pickDataModeForNamespace(): DataMode { return DataMode.CiliumStreaming; } diff --git a/src/domain/aggregation/__tests__/aggregation.test.ts b/src/domain/aggregation/__tests__/aggregation.test.ts index 18cfd7674..9a9f531c3 100644 --- a/src/domain/aggregation/__tests__/aggregation.test.ts +++ b/src/domain/aggregation/__tests__/aggregation.test.ts @@ -1,10 +1,7 @@ import { Aggregation, AggregatorType, - Aggregator, StateChange, - StateChangeKey, - TypeKey, StateChangeSet, AggregatorTypeSet, } from '~/domain/aggregation'; diff --git a/src/domain/diff/index.ts b/src/domain/diff/index.ts index 0b3628e86..99ebcd2ee 100644 --- a/src/domain/diff/index.ts +++ b/src/domain/diff/index.ts @@ -1,7 +1,6 @@ -import _ from 'lodash'; import { equals, clone, CompareFn } from '~/domain/misc'; -export interface IDiff { +export interface IDiff { changed: boolean; // before: T | null | undefined; // after: T | null | undefined; @@ -10,7 +9,7 @@ export interface IDiff { } // NOTE: diff accepts lhs to support diffing between null and Self -export interface Diffable> { +export interface Diffable { diff: (rhs?: Self | null) => D; } @@ -18,7 +17,7 @@ type DiffType = T extends Diffable ? U : never; // NOTE: well, for now it's not actually a diff, this class can just say if // NOTE: values before and after are different -export class Diff implements IDiff { +export class Diff implements IDiff { private _changed?: boolean; private _diff?: DiffType | null; private _compareFn?: CompareFn; @@ -26,7 +25,7 @@ export class Diff implements IDiff { public before: T | null | undefined; public after: T | null | undefined; - public static isDiffable>( + public static isDiffable( obj?: Partial> | null, ): obj is Diffable { if (obj == null || obj.diff == null) return false; diff --git a/src/domain/filtering/__tests__/filter-flow.test.ts b/src/domain/filtering/__tests__/filter-flow.test.ts index 08dc19f9e..40c4cdfaf 100644 --- a/src/domain/filtering/__tests__/filter-flow.test.ts +++ b/src/domain/filtering/__tests__/filter-flow.test.ts @@ -4,7 +4,6 @@ import { Dictionary } from '~/domain/misc'; import { Verdict } from '~/domain/hubble'; import { Flow } from '~/domain/flows'; -import * as combinations from '~/utils/iter-tools/combinations'; import { flows } from '~/testing/data'; import * as thelpers from '~/testing/helpers'; @@ -1156,7 +1155,7 @@ describe('filterFlow', () => { ); testFilterEntry( - (flowName: string, tnum: number) => `workload > to workload matches`, + () => `workload > to workload matches`, FilterEntry.parse(`to:workload=svc:receiver`)!, true, { @@ -1165,7 +1164,7 @@ describe('filterFlow', () => { ); testFilterEntry( - (flowName: string, tnum: number) => `workload > to workload doesn't match`, + () => `workload > to workload doesn't match`, FilterEntry.parse(`to:workload=svc:receiver`)!, false, { @@ -1174,7 +1173,7 @@ describe('filterFlow', () => { ); testFilterEntry( - (flowName: string, tnum: number) => `workload > to workload doesn't match`, + () => `workload > to workload doesn't match`, FilterEntry.parse(`to:workload=svc:sender`)!, false, { @@ -1183,7 +1182,7 @@ describe('filterFlow', () => { ); testFilterEntry( - (flowName: string, tnum: number) => `workload > from workload matches`, + () => `workload > from workload matches`, FilterEntry.parse(`from:workload=svc:sender`)!, true, { @@ -1192,7 +1191,7 @@ describe('filterFlow', () => { ); testFilterEntry( - (flowName: string, tnum: number) => `workload > from workload doesn't match`, + () => `workload > from workload doesn't match`, FilterEntry.parse(`from:workload=svc:receiver`)!, false, { @@ -1201,7 +1200,7 @@ describe('filterFlow', () => { ); testFilterEntry( - (flowName: string, tnum: number) => `workload > either workload matches with receiver`, + () => `workload > either workload matches with receiver`, FilterEntry.parse(`either:workload=svc:receiver`)!, true, { @@ -1210,7 +1209,7 @@ describe('filterFlow', () => { ); testFilterEntry( - (flowName: string, tnum: number) => `workload > either workload matches with sender`, + () => `workload > either workload matches with sender`, FilterEntry.parse(`either:workload=svc:sender`)!, true, { @@ -1219,7 +1218,7 @@ describe('filterFlow', () => { ); testFilterEntry( - (flowName: string, tnum: number) => `workload > either workload doesn't match`, + () => `workload > either workload doesn't match`, FilterEntry.parse(`either:workload=svc:unknown`)!, false, { diff --git a/src/domain/filtering/__tests__/filter-link.test.ts b/src/domain/filtering/__tests__/filter-link.test.ts index aff4092f5..0610c14a7 100644 --- a/src/domain/filtering/__tests__/filter-link.test.ts +++ b/src/domain/filtering/__tests__/filter-link.test.ts @@ -8,7 +8,6 @@ import { import { Verdict } from '~/domain/hubble'; import { Link } from '~/domain/link'; -import { Flow } from '~/domain/flows'; import { Dictionary } from '~/domain/misc'; import { links } from '~/testing/data'; diff --git a/src/domain/filtering/filter-link.ts b/src/domain/filtering/filter-link.ts index 190731752..f85471957 100644 --- a/src/domain/filtering/filter-link.ts +++ b/src/domain/filtering/filter-link.ts @@ -1,5 +1,5 @@ import { Link } from '~/domain/service-map'; -import { FilterEntry, Kind as FilterKind, Direction as FilterDirection } from './filter-entry'; +import { FilterEntry, Kind as FilterKind } from './filter-entry'; import { Filters } from '~/domain/filtering'; diff --git a/src/domain/filtering/filter-service.ts b/src/domain/filtering/filter-service.ts index 811d3e751..c8a4c8b7b 100644 --- a/src/domain/filtering/filter-service.ts +++ b/src/domain/filtering/filter-service.ts @@ -1,4 +1,4 @@ -import { Link, Service, ServiceCard } from '~/domain/service-map'; +import { Service, ServiceCard } from '~/domain/service-map'; import { Labels } from '~/domain/labels'; import * as dhelpers from '~/domain/helpers'; diff --git a/src/domain/filtering/index.ts b/src/domain/filtering/index.ts index 463fe1f38..6306e8b29 100644 --- a/src/domain/filtering/index.ts +++ b/src/domain/filtering/index.ts @@ -107,7 +107,7 @@ export const filter = ( const links = incomings.get(senderId); if (links == null) return; - links.forEach((link, apId) => { + links.forEach(link => { if (blacklistLinks.has(link.id)) return; const passed = filterLink(link, filters); diff --git a/src/domain/geometry/position.ts b/src/domain/geometry/position.ts index 7bf9396dc..285726dcf 100644 --- a/src/domain/geometry/position.ts +++ b/src/domain/geometry/position.ts @@ -7,7 +7,6 @@ // // +Position.Any needs only for jest, as it doesnt recognize toPrimitive coerce /* eslint-disable-next-line @typescript-eslint/no-unused-vars */ -import * as csstype from 'csstype'; export class Position { public static readonly Top = Position.new(0b100000); diff --git a/src/domain/geometry/utils.ts b/src/domain/geometry/utils.ts index a22e3a639..f35feeb74 100644 --- a/src/domain/geometry/utils.ts +++ b/src/domain/geometry/utils.ts @@ -1,6 +1,4 @@ import { XY } from './general'; -import { XYWH, Sides } from './xywh'; -import { Vec2 } from './vec2'; // TODO: optimize it export const angleBetweenSegments = (p0: XY, p1: XY, p2: XY): number => { diff --git a/src/domain/helpers/flows.ts b/src/domain/helpers/flows.ts index 6a5a9ecb4..924c043d3 100644 --- a/src/domain/helpers/flows.ts +++ b/src/domain/helpers/flows.ts @@ -1,4 +1,3 @@ -import _ from 'lodash'; import * as flowpb from '~backend/proto/flow/flow_pb'; import { diff --git a/src/domain/time/index.ts b/src/domain/time/index.ts index 2cdcfa5bf..e4a5370fb 100644 --- a/src/domain/time/index.ts +++ b/src/domain/time/index.ts @@ -1,5 +1,3 @@ -import _ from 'lodash'; - export type Time = { seconds: number; nanos: number; diff --git a/src/index.tsx b/src/index.tsx index 484b06ae0..97bf34bfc 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -70,7 +70,7 @@ const run = async () => { const app = new Application(env, router, store, dataLayer, uiLayer, renderFn); app - .onBeforeMount(_app => { + .onBeforeMount(() => { const env = app.environment; e2e.attributes.setEnabled(env.isDev || env.isTesting); uiLayer.onBeforeMount(); diff --git a/src/router/Provider.tsx b/src/router/Provider.tsx index f80826c85..cb80b38e3 100644 --- a/src/router/Provider.tsx +++ b/src/router/Provider.tsx @@ -1,6 +1,5 @@ import React, { createContext, PropsWithChildren, useContext, useEffect } from 'react'; import { Outlet, useSearchParams, useLocation, useNavigate } from 'react-router-dom'; -import _ from 'lodash'; import { Router } from './router'; import { Routes } from './Routes'; diff --git a/src/router/router.ts b/src/router/router.ts index b477ee787..bb6192e74 100644 --- a/src/router/router.ts +++ b/src/router/router.ts @@ -1,4 +1,3 @@ -import _ from 'lodash'; import { Location, NavigateOptions } from 'react-router-dom'; import { EventEmitter } from '~/utils/emitter'; @@ -152,7 +151,7 @@ export class Router extends EventEmitter { this._transaction.push(RouteAction.dropSearchParams()); } - public commit(_commitOpts?: CommitOptions): this { + public commit(): this { const actions = this._transaction.splice(0, this._transaction.length); if (actions.length === 0) return this; diff --git a/src/router/state.ts b/src/router/state.ts index 64c86936e..137c684f2 100644 --- a/src/router/state.ts +++ b/src/router/state.ts @@ -78,7 +78,7 @@ export class LocationState { return this._id; } - public clone(_deep?: boolean): LocationState { + public clone(): LocationState { const cloned = new LocationState(); cloned._id = this._id; cloned.params = this.params ? new Map(this.params) : void 0; diff --git a/src/storage/local/__tests__/store-restore.test.ts b/src/storage/local/__tests__/store-restore.test.ts index 6ff0772df..145017c3c 100644 --- a/src/storage/local/__tests__/store-restore.test.ts +++ b/src/storage/local/__tests__/store-restore.test.ts @@ -14,7 +14,6 @@ describe('consistency tests for setItem / getItem', () => { }); test('flows table visible columns 2', () => { - const getItem = jest.spyOn(Storage.prototype, 'getItem'); const setItem = jest.spyOn(Storage.prototype, 'setItem'); const arr = [Column.SrcService]; @@ -28,7 +27,6 @@ describe('consistency tests for setItem / getItem', () => { }); test('flows table visible columns 3', () => { - const getItem = jest.spyOn(Storage.prototype, 'getItem'); const setItem = jest.spyOn(Storage.prototype, 'setItem'); const arr = [Column.SrcPod, Column.DstPod]; diff --git a/src/store/__tests__/frame.test.ts b/src/store/__tests__/frame.test.ts index a21cc06c1..a2b061f31 100644 --- a/src/store/__tests__/frame.test.ts +++ b/src/store/__tests__/frame.test.ts @@ -53,7 +53,7 @@ describe('fill empty frame', () => { const rhs = prepareFrame([], [new Flow(tflows.hubbleOne)], [], filterObj); lhs.applyFrame(rhs, Filters.fromObject(filterObj)); - const { flows, links, svcs } = extractData(lhs); + const { flows } = extractData(lhs); expect(flows.length).toBe(1); }); @@ -74,7 +74,7 @@ describe('fill empty frame', () => { const rhs = prepareFrame([], [new Flow(tflows.hubbleOne)], [], filterObj); lhs.applyFrame(rhs, Filters.fromObject(filterObj)); - const { flows, links, svcs } = extractData(lhs); + const { flows } = extractData(lhs); expect(flows.length).toBe(0); }); @@ -3604,7 +3604,7 @@ describe('filter entries > world', () => { }); describe('filter entries > DNS', () => { - const { regular, regular1, kubeDNS, apiTwitter, world } = tsvcs; + const { regular, regular1, apiTwitter } = tsvcs; test('test 1 - regular -> apiTwitter (to filter)', () => { const filterObj = { @@ -3860,12 +3860,12 @@ describe('filter entries > DNS', () => { const lhs = prepareFrame([], [], [], filterObj); - const { fromAtoB: regToTwitter, fromBtoA: twitterToReg } = thelpers + const { fromAtoB: regToTwitter } = thelpers .flowsFromToService(regular, apiTwitter) .tcp(54000, 8081) .forwarded(); - const { fromAtoB: reg1ToTwitter, fromBtoA: twitterToReg1 } = thelpers + const { fromBtoA: twitterToReg1 } = thelpers .flowsFromToService(regular1, apiTwitter) .tcp(54001, 8081) .forwarded(); @@ -3975,12 +3975,12 @@ describe('filter entries > DNS', () => { const lhs = prepareFrame([], [], [], filterObj); - const { fromAtoB: regToTwitter, fromBtoA: twitterToReg } = thelpers + const { fromAtoB: regToTwitter } = thelpers .flowsFromToService(regular, apiTwitter) .tcp(54000, 8081) .forwarded(); - const { fromAtoB: reg1ToTwitter, fromBtoA: twitterToReg1 } = thelpers + const { fromBtoA: twitterToReg1 } = thelpers .flowsFromToService(regular1, apiTwitter) .tcp(54001, 8081) .forwarded(); @@ -4090,12 +4090,12 @@ describe('filter entries > DNS', () => { const lhs = prepareFrame([], [], [], filterObj); - const { fromAtoB: regToTwitter, fromBtoA: twitterToReg } = thelpers + const { fromAtoB: regToTwitter } = thelpers .flowsFromToService(regular, apiTwitter) .tcp(54000, 8081) .forwarded(); - const { fromAtoB: reg1ToTwitter, fromBtoA: twitterToReg1 } = thelpers + const { fromBtoA: twitterToReg1 } = thelpers .flowsFromToService(regular1, apiTwitter) .tcp(54001, 8081) .forwarded(); @@ -4205,12 +4205,12 @@ describe('filter entries > DNS', () => { const lhs = prepareFrame([], [], [], filterObj); - const { fromAtoB: regToTwitter, fromBtoA: twitterToReg } = thelpers + const { fromAtoB: regToTwitter } = thelpers .flowsFromToService(regular, apiTwitter) .tcp(54000, 8081) .forwarded(); - const { fromAtoB: reg1ToTwitter, fromBtoA: twitterToReg1 } = thelpers + const { fromBtoA: twitterToReg1 } = thelpers .flowsFromToService(regular1, apiTwitter) .tcp(54001, 8081) .forwarded(); @@ -4448,7 +4448,7 @@ describe('filter entries > DNS', () => { }); describe('filter entries > pod (only flows)', () => { - const { regular, regular1, kubeDNS, apiTwitter, world } = tsvcs; + const { regular, world } = tsvcs; const [senderPod, receiverPod] = ['crawler-12345', 'service-54321']; const fromSenderPod = FilterEntry.newPod(senderPod).setDirection(FilterDirection.From); @@ -4509,7 +4509,7 @@ describe('filter entries > pod (only flows)', () => { const lhs = prepareFrame([], [], [], filterObj); - const { fromAtoB, fromBtoA } = thelpers.flowsBetweenPods(senderPod, receiverPod); + const { fromBtoA } = thelpers.flowsBetweenPods(senderPod, receiverPod); const rhs = prepareFrame([], [new Flow(fromBtoA)], [], filterObj); @@ -4618,7 +4618,7 @@ describe('filter entries > pod (only flows)', () => { const lhs = prepareFrame([], [], [], filterObj); - const { fromAtoB, fromBtoA } = thelpers.flowsBetweenPods(senderPod, receiverPod); + const { fromBtoA } = thelpers.flowsBetweenPods(senderPod, receiverPod); const rhs = prepareFrame([], [new Flow(fromBtoA)], [], filterObj); @@ -4727,7 +4727,7 @@ describe('filter entries > pod (only flows)', () => { const lhs = prepareFrame([], [], [], filterObj); - const { fromAtoB, fromBtoA } = thelpers.flowsBetweenPods(senderPod, receiverPod); + const { fromBtoA } = thelpers.flowsBetweenPods(senderPod, receiverPod); const rhs = prepareFrame([], [new Flow(fromBtoA)], [], filterObj); @@ -4836,7 +4836,7 @@ describe('filter entries > pod (only flows)', () => { const lhs = prepareFrame([], [], [], filterObj); - const { fromAtoB, fromBtoA } = thelpers.flowsBetweenPods(senderPod, receiverPod); + const { fromBtoA } = thelpers.flowsBetweenPods(senderPod, receiverPod); const rhs = prepareFrame([], [new Flow(fromBtoA)], [], filterObj); @@ -4945,7 +4945,7 @@ describe('filter entries > pod (only flows)', () => { const lhs = prepareFrame([], [], [], filterObj); - const { fromAtoB, fromBtoA } = thelpers.flowsBetweenPods(senderPod, receiverPod); + const { fromBtoA } = thelpers.flowsBetweenPods(senderPod, receiverPod); const rhs = prepareFrame([], [new Flow(fromBtoA)], [], filterObj); @@ -5054,7 +5054,7 @@ describe('filter entries > pod (only flows)', () => { const lhs = prepareFrame([], [], [], filterObj); - const { fromAtoB, fromBtoA } = thelpers.flowsBetweenPods(senderPod, receiverPod); + const { fromBtoA } = thelpers.flowsBetweenPods(senderPod, receiverPod); const rhs = prepareFrame([], [new Flow(fromBtoA)], [], filterObj); @@ -5163,7 +5163,7 @@ describe('filter entries > pod (only flows)', () => { const lhs = prepareFrame([], [], [], filterObj); - const { fromAtoB, fromBtoA } = thelpers.flowsBetweenPods(senderPod, receiverPod); + const { fromBtoA } = thelpers.flowsBetweenPods(senderPod, receiverPod); const rhs = prepareFrame([], [new Flow(fromBtoA)], [], filterObj); @@ -5272,7 +5272,7 @@ describe('filter entries > pod (only flows)', () => { const lhs = prepareFrame([], [], [], filterObj); - const { fromAtoB, fromBtoA } = thelpers.flowsBetweenPods(senderPod, receiverPod); + const { fromBtoA } = thelpers.flowsBetweenPods(senderPod, receiverPod); const rhs = prepareFrame([], [new Flow(fromBtoA)], [], filterObj); diff --git a/src/store/stores/interaction.ts b/src/store/stores/interaction.ts index 01cee4149..b682d373c 100644 --- a/src/store/stores/interaction.ts +++ b/src/store/stores/interaction.ts @@ -123,23 +123,6 @@ export class InteractionStore { } public addFlows(newFlows: Flow[], sortDesc = true) { - // Append new flows by mutating current array - // const flowsMaxCount = Math.min( - // InteractionStore.FLOWS_MAX_COUNT, - // newFlows.length, - // ); - - // for (let i = 0; i < flowsMaxCount; i += 1) { - // const shiftI = i + flowsMaxCount; - // if (this._flows[i] && shiftI < InteractionStore.FLOWS_MAX_COUNT) { - // if (shiftI < this._flows.length) { - // this._flows[shiftI] = this._flows[i]; - // } else { - // this._flows.push(this._flows[i]); - // } - // } - // this._flows[i] = newFlows[i]; - // } const sortFn = sortDesc ? (a: Flow, b: Flow) => b.compare(a) : (a: Flow, b: Flow) => a.compare(b); @@ -158,8 +141,6 @@ export class InteractionStore { const now = Date.now(); const timeDiff = now - this.flowsInfo.lastTime; if (timeDiff >= 1000) { - const flowsDiff = this.flowsInfo.tmpFlowsCnt - this.flowsInfo.flowsCnt; - this.flowsInfo.lastTime = now; this.flowsInfo.flowsCnt = this.flowsInfo.tmpFlowsCnt; diff --git a/src/store/stores/main.ts b/src/store/stores/main.ts index 9328fd60a..2f1e36ef3 100644 --- a/src/store/stores/main.ts +++ b/src/store/stores/main.ts @@ -1,6 +1,6 @@ -import { configure, autorun, toJS, makeAutoObservable } from 'mobx'; +import { configure, toJS, makeAutoObservable } from 'mobx'; -import { Filters, FilterEntry, FiltersDiff } from '~/domain/filtering'; +import { Filters, FiltersDiff } from '~/domain/filtering'; import { ServiceCard, ServiceMap } from '~/domain/service-map'; import { StateChange } from '~/domain/misc'; import { setupDebugProp } from '~/domain/misc'; @@ -22,8 +22,6 @@ export type FlushOptions = { preserveActiveCards?: boolean; }; -export type Props = {}; - export class Store { public controls: ControlStore; @@ -35,7 +33,7 @@ export class Store { public uiSettings: SettingsStore; - constructor(_props?: Props) { + constructor() { makeAutoObservable(this, void 0, { autoBind: true }); this.controls = new ControlStore(); diff --git a/src/store/stores/namespace.ts b/src/store/stores/namespace.ts index 3bfdbc256..252d522b6 100644 --- a/src/store/stores/namespace.ts +++ b/src/store/stores/namespace.ts @@ -1,7 +1,6 @@ import { makeAutoObservable } from 'mobx'; import { NamespaceDescriptor } from '~/domain/namespaces'; -import { StateChange } from '~/domain/misc'; export class NamespaceStore { // private _seenNamespaces: Map = new Map(); @@ -71,7 +70,7 @@ export class NamespaceStore { }); } - public applyChange(ns: NamespaceDescriptor, ch: StateChange) { + public applyChange(ns: NamespaceDescriptor) { this.set(ns); } diff --git a/src/store/stores/service.ts b/src/store/stores/service.ts index 52f75c536..69301d025 100644 --- a/src/store/stores/service.ts +++ b/src/store/stores/service.ts @@ -143,7 +143,7 @@ export class ServiceStore { return this.cardWorkloadsMap.get(key); } - public clear(opts?: ClearOptions) { + public clear() { this.cards = []; } diff --git a/src/testing/helpers.ts b/src/testing/helpers.ts index f4cd5952b..bd44be648 100644 --- a/src/testing/helpers.ts +++ b/src/testing/helpers.ts @@ -1,4 +1,3 @@ -import _ from 'lodash'; import { HubbleService, HubbleFlow, diff --git a/src/testing/index.tsx b/src/testing/index.tsx index dbc09091e..fb3a709a1 100644 --- a/src/testing/index.tsx +++ b/src/testing/index.tsx @@ -2,7 +2,6 @@ import { render, RenderResult } from '@testing-library/react'; import React from 'react'; import { Store } from '~/store'; -import { StoreContext } from '~/store/hooks'; import { Application, ApplicationProvider } from '~/application'; import { Router, RouterKind } from '~/router'; diff --git a/src/ui-layer/controls.ts b/src/ui-layer/controls.ts index 09c2be6cd..5fd9d432f 100644 --- a/src/ui-layer/controls.ts +++ b/src/ui-layer/controls.ts @@ -1,7 +1,7 @@ import * as mobx from 'mobx'; import { DataLayer } from '~/data-layer'; -import { ApplicationPath, Router } from '~/router'; +import { Router } from '~/router'; import * as storage from '~/storage/local'; import { Store } from '~/store'; @@ -11,7 +11,6 @@ import { Verdict } from '~/domain/hubble'; import { DataMode } from '~/domain/interactions'; import { StateChange } from '~/domain/misc'; import { NamespaceDescriptor } from '~/domain/namespaces'; -import { Notification } from '~/domain/notifications'; import { FilterEntry } from '~/domain/filtering/filter-entry'; import { Options } from './common'; diff --git a/src/ui-layer/service-map/coordinates/arrows.ts b/src/ui-layer/service-map/coordinates/arrows.ts index c018e10e4..3110beef6 100644 --- a/src/ui-layer/service-map/coordinates/arrows.ts +++ b/src/ui-layer/service-map/coordinates/arrows.ts @@ -84,7 +84,7 @@ export class ServiceMapArrowStrategy extends ArrowStrategy { return combined; } - arrows.forEach((arrow, _arrowId) => { + arrows.forEach(arrow => { arrow.accessPointArrows.forEach((apArrow, apArrowId) => { if (apArrow.connectorId == null) return; diff --git a/src/ui-layer/service-map/coordinates/helpers/connector-coords-accumulator.ts b/src/ui-layer/service-map/coordinates/helpers/connector-coords-accumulator.ts index 70c3a5381..85856c053 100644 --- a/src/ui-layer/service-map/coordinates/helpers/connector-coords-accumulator.ts +++ b/src/ui-layer/service-map/coordinates/helpers/connector-coords-accumulator.ts @@ -71,7 +71,7 @@ export class ConnectorCoordsAccumulator { // NOTE: We simple subtract a half of entire connectors height here to make // NOTE: them all centered on vertical axis. public adjustVertically() { - this.cardConnectorIds.forEach((connectorIds, _cardId) => { + this.cardConnectorIds.forEach(connectorIds => { connectorIds.forEach(connectorId => { const connectorCoords = this.cardConnectorCoords.get(connectorId); if (connectorCoords == null) { diff --git a/src/ui-layer/service-map/coordinates/placement.ts b/src/ui-layer/service-map/coordinates/placement.ts index ce0ff8ce7..0003d4cc5 100644 --- a/src/ui-layer/service-map/coordinates/placement.ts +++ b/src/ui-layer/service-map/coordinates/placement.ts @@ -1,5 +1,4 @@ import { action, computed, observable, reaction, makeObservable, runInAction } from 'mobx'; -import _ from 'lodash'; import { Method as HttpMethod } from '~/domain/http'; import { XYWH, XY, dummy as geom } from '~/domain/geometry'; diff --git a/src/ui-layer/service-map/index.ts b/src/ui-layer/service-map/index.ts index 6205fc09b..c3c6078c8 100644 --- a/src/ui-layer/service-map/index.ts +++ b/src/ui-layer/service-map/index.ts @@ -6,11 +6,11 @@ import { Router } from '~/router'; import { EventEmitter } from '~/utils/emitter'; import { ServiceCard } from '~/domain/service-map'; -import { Application, Direction } from '~/domain/common'; +import { Application } from '~/domain/common'; import { FilterEntry } from '~/domain/filtering/filter-entry'; import { RefsCollector } from '~/ui/service-map/collector'; -import { Options, CommonUtils } from '~/ui-layer/common'; +import { Options } from '~/ui-layer/common'; import { StatusCenter } from '~/ui-layer/status-center'; import { ServiceMapPlacementStrategy, ServiceMapArrowStrategy } from './coordinates'; @@ -97,7 +97,7 @@ export class ServiceMap extends EventEmitter { this.router.commit(); } - public cardsMutationsObserved(_muts: MutationRecord[]) { + public cardsMutationsObserved() { this.collector.cardsMutationsObserved(); } @@ -116,7 +116,7 @@ export class ServiceMap extends EventEmitter { return this.store.controls.areSomeFilterEntriesEnabled(card.filterEntries); } - public async appToggled(_prev: Application, next: Application, isChanged: boolean) { + public async appToggled(_prev: Application, next: Application) { // if (!isChanged) return; switch (next) { diff --git a/src/ui-layer/status-center.ts b/src/ui-layer/status-center.ts index 763587845..8ba42b7b6 100644 --- a/src/ui-layer/status-center.ts +++ b/src/ui-layer/status-center.ts @@ -1,4 +1,4 @@ -import { makeAutoObservable, makeObservable } from 'mobx'; +import { makeObservable } from 'mobx'; import { GrpcWrappedError } from '~/api/grpc/error'; import { Notification } from '~/domain/notifications'; @@ -65,7 +65,7 @@ export class StatusCenter extends EventEmitter { // NOTE: We are going to show critical pending entry until it is done, no // NOTE: matter if it is seen or not. - for (const [_, pendingEntry] of this._pendingEntries) { + for (const [, pendingEntry] of this._pendingEntries) { if (pendingEntry.isCritical || pendingEntry.isError) return pendingEntry; } diff --git a/src/ui-layer/ui-layer.ts b/src/ui-layer/ui-layer.ts index 9dacaf741..e065f5164 100644 --- a/src/ui-layer/ui-layer.ts +++ b/src/ui-layer/ui-layer.ts @@ -4,7 +4,6 @@ import { Store } from '~/store'; import * as ui from '~/ui'; import { DataMode, TransferState } from '~/domain/interactions'; -import { FeatureFlags } from '~/domain/features'; import { Application } from '~/domain/common'; import { StatusCenter } from './status-center'; @@ -114,10 +113,10 @@ export class UILayer { return; } - this.setupEverything(this.store.uiSettings.featureFlags); + this.setupEverything(); } - private setupEverything(ff: FeatureFlags) { + private setupEverything() { // NOTE: The only thing `applyLocalParameters` doesnt do is setting current // application inside control store. This allows to decide whether we need // to switch there or not here, on higher level of responsibility. @@ -166,7 +165,7 @@ export class UILayer { private async appToggled(prevApp: Application, nextApp: Application, isChanged: boolean) { console.log(`appToggled`, prevApp, nextApp, isChanged); - await this.serviceMap.appToggled(prevApp, nextApp, isChanged); + await this.serviceMap.appToggled(prevApp, nextApp); } private applyLocalParameters(): void { diff --git a/src/ui/d3/index.ts b/src/ui/d3/index.ts index 601362ce8..755e7e583 100644 --- a/src/ui/d3/index.ts +++ b/src/ui/d3/index.ts @@ -9,7 +9,7 @@ export const setupHovering = >( let isMouseOver = false; self - .on('mouseover', e => { + .on('mouseover', () => { if (isMouseOver) return; isMouseOver = true; diff --git a/src/ui/hooks/useElemCoords.ts b/src/ui/hooks/useElemCoords.ts index 15589cfba..52193baf3 100644 --- a/src/ui/hooks/useElemCoords.ts +++ b/src/ui/hooks/useElemCoords.ts @@ -1,4 +1,4 @@ -import React, { useCallback, useEffect, useLayoutEffect } from 'react'; +import React, { useCallback, useLayoutEffect } from 'react'; import { WH, XY, XYWH } from '~/domain/geometry'; import { tooSmall } from '~/domain/misc'; diff --git a/src/ui/hooks/useIntersectCoords.ts b/src/ui/hooks/useIntersectCoords.ts index 3310c9fc8..da3764bb7 100644 --- a/src/ui/hooks/useIntersectCoords.ts +++ b/src/ui/hooks/useIntersectCoords.ts @@ -1,7 +1,7 @@ import _ from 'lodash'; import * as React from 'react'; -import { XY, WH, XYWH } from '~/domain/geometry'; +import { WH, XYWH } from '~/domain/geometry'; import { ElemCoords } from './useElemCoords'; import { tooSmall } from '~/domain/misc'; diff --git a/src/ui/hooks/useSizeWatcher.ts b/src/ui/hooks/useSizeWatcher.ts index 2aaf02a07..fd757fe7c 100644 --- a/src/ui/hooks/useSizeWatcher.ts +++ b/src/ui/hooks/useSizeWatcher.ts @@ -1,4 +1,4 @@ -import React, { useCallback, useEffect, useLayoutEffect } from 'react'; +import React, { useCallback, useEffect } from 'react'; import { WH } from '~/domain/geometry'; diff --git a/src/ui/service-map/collector.ts b/src/ui/service-map/collector.ts index 6353d1cd5..ee75325ec 100644 --- a/src/ui/service-map/collector.ts +++ b/src/ui/service-map/collector.ts @@ -80,7 +80,7 @@ export class RefsCollector extends EventEmitter { const existing = this.cardRoots.get(cardId); if (existing != null) return existing; - const newRef = reactionRef(null, _elem => { + const newRef = reactionRef(null, () => { this.throttledCardsUpdated?.(); }); @@ -92,7 +92,7 @@ export class RefsCollector extends EventEmitter { const existing = this.accessPoints.get(apId); if (existing != null) return existing; - const newRef = reactionRef(null, _elem => { + const newRef = reactionRef(null, () => { this.throttledCardsUpdated?.(); }); @@ -112,7 +112,7 @@ export class RefsCollector extends EventEmitter { const existing = pathnames?.get(httpMethod); if (existing != null) return existing; - const newRef = reactionRef(null, _elem => { + const newRef = reactionRef(null, () => { this.throttledCardsUpdated?.(); }); From c41f0655a159e03a38453e465ec4192e55aa2cde Mon Sep 17 00:00:00 2001 From: Yannik Messerli Date: Thu, 15 Feb 2024 09:06:29 +0100 Subject: [PATCH 2/4] Fix babel's transpile issue --- src/api/customprotocol-core/oneshot.ts | 2 +- src/api/customprotocol-core/stream.ts | 6 ++++-- src/components/ServiceMapApp/index.tsx | 2 +- src/data-layer/controls.ts | 4 ++-- src/data-layer/service-map.ts | 2 +- src/domain/filtering/filters-diff.ts | 2 +- src/store/frame.ts | 2 +- src/store/stores/main.ts | 4 ++-- 8 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/api/customprotocol-core/oneshot.ts b/src/api/customprotocol-core/oneshot.ts index 7a02d4ebb..2d031cdf7 100644 --- a/src/api/customprotocol-core/oneshot.ts +++ b/src/api/customprotocol-core/oneshot.ts @@ -25,7 +25,7 @@ export class Oneshot extends Stream { // NOTE: IsNotReady set to true means that this is simple Poll request if (!isFirst) msg.setIsNotReady(true); - return this.messageBuilder(msg, isFirst); + return this.messageBuilder(msg); }, req => { this.pendingRequests.add(req); diff --git a/src/api/customprotocol-core/stream.ts b/src/api/customprotocol-core/stream.ts index 0f037477b..358ead1b7 100644 --- a/src/api/customprotocol-core/stream.ts +++ b/src/api/customprotocol-core/stream.ts @@ -124,7 +124,7 @@ export class Stream extends EventEmitter { this.pendingRequests.add(req); @@ -385,7 +385,9 @@ export class Stream extends EventEmitter ui.serviceMap.cardsMutationsObserved(muts)} + onCardMutated={() => ui.serviceMap.cardsMutationsObserved()} /> ) : ( { .controlStream() .onNamespaceChanges(nsChanges => { nsChanges.forEach(nsChange => { - const { namespace: nsDescriptor, change } = nsChange; - this.store.applyNamespaceChange(nsDescriptor, change); + const { namespace: nsDescriptor } = nsChange; + this.store.applyNamespaceChange(nsDescriptor); }); }) .onNotification(notif => { diff --git a/src/data-layer/service-map.ts b/src/data-layer/service-map.ts index 3b6c4b07d..c26dedd00 100644 --- a/src/data-layer/service-map.ts +++ b/src/data-layer/service-map.ts @@ -83,7 +83,7 @@ export class ServiceMap extends EventEmitter { public async appOpened() { const dataMode = this.transferState.isDisabled - ? this.pickDataModeForNamespace(this.store.namespaces.current) + ? this.pickDataModeForNamespace() : this.transferState.dataMode; await this.ensureDataFetch(dataMode); diff --git a/src/domain/filtering/filters-diff.ts b/src/domain/filtering/filters-diff.ts index 5f3578089..94d2a6ba1 100644 --- a/src/domain/filtering/filters-diff.ts +++ b/src/domain/filtering/filters-diff.ts @@ -4,7 +4,7 @@ import { Diff, IDiff } from '~/domain/diff'; import { FilterEntry } from './filter-entry'; import { Filters } from './filters'; -export class FiltersDiff implements IDiff { +export class FiltersDiff implements IDiff { public static fromFilters(f?: Filters | null): FiltersDiff { return new FiltersDiff( Diff.new(f?.namespace), diff --git a/src/store/frame.ts b/src/store/frame.ts index 57e81f7e1..feb5749af 100644 --- a/src/store/frame.ts +++ b/src/store/frame.ts @@ -93,7 +93,7 @@ export class StoreFrame extends EventEmitter { this.interactions.clear(); - this.services.clear(opts); + this.services.clear(); if (!!opts.namespaces) { this.namespaces.clear(); diff --git a/src/store/stores/main.ts b/src/store/stores/main.ts index 2f1e36ef3..e85854853 100644 --- a/src/store/stores/main.ts +++ b/src/store/stores/main.ts @@ -92,8 +92,8 @@ export class Store { this.currentFrame.applyFrame(this.globalFrame, filters); } - public applyNamespaceChange(ns: NamespaceDescriptor, change: StateChange) { - this.namespaces.applyChange(ns, change); + public applyNamespaceChange(ns: NamespaceDescriptor) { + this.namespaces.applyChange(ns); } public setFeatures(features: FeatureFlags) { From d5015cd091428ad8e72f6727c97dd973917ed571 Mon Sep 17 00:00:00 2001 From: Yannik Messerli Date: Fri, 16 Feb 2024 08:22:41 +0100 Subject: [PATCH 3/4] Ignore some usuned variable needed for inheritance --- src/api/customprotocol-core/stream.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/api/customprotocol-core/stream.ts b/src/api/customprotocol-core/stream.ts index 358ead1b7..a6c456058 100644 --- a/src/api/customprotocol-core/stream.ts +++ b/src/api/customprotocol-core/stream.ts @@ -124,7 +124,7 @@ export class Stream extends EventEmitter { this.pendingRequests.add(req); @@ -385,9 +385,9 @@ export class Stream extends EventEmitter Date: Fri, 16 Feb 2024 08:33:05 +0100 Subject: [PATCH 4/4] Fix code --- src/api/customprotocol-core/oneshot.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/customprotocol-core/oneshot.ts b/src/api/customprotocol-core/oneshot.ts index 2d031cdf7..7a02d4ebb 100644 --- a/src/api/customprotocol-core/oneshot.ts +++ b/src/api/customprotocol-core/oneshot.ts @@ -25,7 +25,7 @@ export class Oneshot extends Stream { // NOTE: IsNotReady set to true means that this is simple Poll request if (!isFirst) msg.setIsNotReady(true); - return this.messageBuilder(msg); + return this.messageBuilder(msg, isFirst); }, req => { this.pendingRequests.add(req);