diff --git a/.github/workflows/prettier.yaml b/.github/workflows/prettier.yaml index db11ce02..2829d560 100644 --- a/.github/workflows/prettier.yaml +++ b/.github/workflows/prettier.yaml @@ -1,13 +1,21 @@ name: Continuous Integration -on: pull_request +on: + push: + branches: [main] + pull_request: + branches: [main] jobs: prettier: + timeout-minutes: 60 runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Prettify code - uses: creyD/prettier_action@v4.3 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: lts/* + - name: Install dependencies + run: npm install -g pnpm && pnpm install + - name: Run ESLint + run: pnpm run lint diff --git a/package.json b/package.json index 17a973a6..5acccfb9 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "dev": "vite --host --port 3001", "build": "tsc && vite build", "build:test": "tsc && vite build --mode test", - "lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0", + "lint": "eslint src --ext ts,tsx --report-unused-disable-directives --quiet", "start": "vite preview --host --port 3002", "tsCheck": "tsc --noEmit", "pq": "pretty-quick", diff --git a/src/@types/parseable/api/dashboards.ts b/src/@types/parseable/api/dashboards.ts index 58b2b249..d3bc89e7 100644 --- a/src/@types/parseable/api/dashboards.ts +++ b/src/@types/parseable/api/dashboards.ts @@ -44,11 +44,11 @@ export type TickConfig = { export type Visualization = { visualization_type: VizType; size: TileSize; - circular_chart_config?: null | { name_key: string; value_key: string } | {}; + circular_chart_config?: null | { name_key: string; value_key: string } | object; graph_config?: | null | { x_key: string; y_keys: string[]; type: CommonGraphBasicType; orientation: CommonGraphOrientationType } - | {}; + | object; color_config: ColorConfig[]; tick_config: TickConfig[]; }; @@ -116,9 +116,9 @@ export type BarChartBasicTypes = 'default' | 'stacked' | 'percent'; export type AreaChartBasicTypes = 'default' | 'stacked' | 'percent'; // orientation -export type BarChartOrientationType = 'horizontal' | 'vertical' -export type AreaChartOrientationType = 'horizontal' | 'vertical' -export type LineChartOrientationType = 'horizontal' | 'vertical' +export type BarChartOrientationType = 'horizontal' | 'vertical'; +export type AreaChartOrientationType = 'horizontal' | 'vertical'; +export type LineChartOrientationType = 'horizontal' | 'vertical'; export type BarChartProps = { data: TileData; @@ -137,7 +137,7 @@ export type LineChartProps = { xUnit: UnitType; yUnit: UnitType; orientation: LineChartOrientationType; -} +}; export type AreaChartProps = { data: TileData; diff --git a/src/@types/parseable/api/stream.ts b/src/@types/parseable/api/stream.ts index 67f261f1..c90116c4 100644 --- a/src/@types/parseable/api/stream.ts +++ b/src/@types/parseable/api/stream.ts @@ -53,7 +53,7 @@ export type HotTierConfig = available_size: string; oldest_date_time_entry: string; } - | {}; + | object; export type UpdateHotTierConfig = { size: string; diff --git a/src/api/auth.ts b/src/api/auth.ts index 1031eb31..03513218 100644 --- a/src/api/auth.ts +++ b/src/api/auth.ts @@ -13,4 +13,4 @@ export const loginIn = (username: string, password: string) => { export const logOut = () => { return Axios().get(LOGOUT_URL); -} +}; diff --git a/src/api/constants.ts b/src/api/constants.ts index 30818ab2..a3022c7f 100644 --- a/src/api/constants.ts +++ b/src/api/constants.ts @@ -2,7 +2,7 @@ import _ from 'lodash'; const API_V1 = 'api/v1'; -export type Params = Record | null | {} | undefined; +export type Params = Record | null | object | undefined; const parseParamsToQueryString = (params: Params) => { if (_.isEmpty(params) || _.isNil(params) || !params) return ''; @@ -20,7 +20,7 @@ const parseParamsToQueryString = (params: Params) => { // Streams Management export const LOG_STREAM_LIST_URL = `${API_V1}/logstream`; export const LOG_STREAMS_SCHEMA_URL = (streamName: string) => `${LOG_STREAM_LIST_URL}/${streamName}/schema`; -export const LOG_QUERY_URL = (params?: Params, resourcePath: string = 'query') => +export const LOG_QUERY_URL = (params?: Params, resourcePath = 'query') => `${API_V1}/${resourcePath}` + parseParamsToQueryString(params); export const LOG_STREAMS_ALERTS_URL = (streamName: string) => `${LOG_STREAM_LIST_URL}/${streamName}/alert`; export const LIST_SAVED_FILTERS_URL = `${API_V1}/filters`; diff --git a/src/api/query.ts b/src/api/query.ts index 6dee5efc..85e4db23 100644 --- a/src/api/query.ts +++ b/src/api/query.ts @@ -1,4 +1,3 @@ -import _ from 'lodash'; import { Axios } from './axios'; import { LOG_QUERY_URL } from './constants'; import { Log, LogsQuery, LogsResponseWithHeaders } from '@/@types/parseable/api/query'; diff --git a/src/assets/customLoader/ParseableAnimate.tsx b/src/assets/customLoader/ParseableAnimate.tsx index 658e97a2..c4dc3d03 100644 --- a/src/assets/customLoader/ParseableAnimate.tsx +++ b/src/assets/customLoader/ParseableAnimate.tsx @@ -57,4 +57,6 @@ const ParseableAnimated: MantineLoaderComponent = forwardRef(() => ( )); +ParseableAnimated.displayName = 'ParsableAnimated'; + export default ParseableAnimated; diff --git a/src/components/Header/RefreshInterval.tsx b/src/components/Header/RefreshInterval.tsx index fbc05103..dd714e59 100644 --- a/src/components/Header/RefreshInterval.tsx +++ b/src/components/Header/RefreshInterval.tsx @@ -12,7 +12,7 @@ import { appStoreReducers, useAppStore } from '@/layouts/MainLayout/providers/Ap const { setRefreshInterval, getCleanStoreForRefetch } = logsStoreReducers; const { syncTimeRange } = appStoreReducers; const RefreshInterval: FC = () => { - const [, setAppStore] = useAppStore((_store) => null); + const [, setAppStore] = useAppStore(() => null); const [refreshInterval, setLogsStore] = useLogsStore((store) => store.refreshInterval); const Icon = useMemo(() => (refreshInterval ? IconRefresh : IconRefreshOff), [refreshInterval]); const timerRef = useRef(null); diff --git a/src/components/Header/RefreshNow.tsx b/src/components/Header/RefreshNow.tsx index 0744be61..2ca234d9 100644 --- a/src/components/Header/RefreshNow.tsx +++ b/src/components/Header/RefreshNow.tsx @@ -11,8 +11,8 @@ const { syncTimeRange } = appStoreReducers; const renderRefreshIcon = () => ; const RefreshNow: FC = () => { - const [, setLogsStore] = useLogsStore((_store) => null); - const [, setAppStore] = useAppStore((_store) => null); + const [, setLogsStore] = useLogsStore(() => null); + const [, setAppStore] = useAppStore(() => null); const onRefresh = useCallback(() => { setAppStore((store) => syncTimeRange(store)); diff --git a/src/components/Header/TimeRange.tsx b/src/components/Header/TimeRange.tsx index b92eb34c..41f86886 100644 --- a/src/components/Header/TimeRange.tsx +++ b/src/components/Header/TimeRange.tsx @@ -43,7 +43,7 @@ const RelativeTimeIntervals = (props: { const TimeRange: FC = () => { const [timeRange, setAppStore] = useAppStore((store) => store.timeRange); - const [, setLogStore] = useLogsStore((_store) => null); + const [, setLogStore] = useLogsStore(() => null); const { label, shiftInterval, interval, startTime, endTime, type } = timeRange; const handleOuterClick = useCallback((event: any) => { const targetClassNames: string[] = event.target?.classList || []; @@ -204,7 +204,7 @@ function isDateInRange(startDate: Date, endDate: Date, currentDate: Date) { } const CustomTimeRange: FC = ({ setOpened, resetToRelative }) => { - const [, setLogStore] = useLogsStore((_store) => null); + const [, setLogStore] = useLogsStore(() => null); const [{ startTime: startTimeFromStore, endTime: endTimeFromStore, type }, setAppStore] = useAppStore( (store) => store.timeRange, ); diff --git a/src/components/Navbar/index.tsx b/src/components/Navbar/index.tsx index 64fbe52c..61186096 100644 --- a/src/components/Navbar/index.tsx +++ b/src/components/Navbar/index.tsx @@ -202,7 +202,9 @@ const Navbar: FC = () => { ? toggleUserModal : navAction.key === 'logout' ? signOutHandler - : () => {}; + : () => { + return; + }; return ( { @@ -121,7 +121,7 @@ const getStreamsSepcificAccess = (rolesWithRoleName: UserRoles | null, stream?: const getUserSepcificStreams = (rolesWithRoleName: object[], streams: any[]) => { let userStreams: any[] = []; let roles: any[] = []; - for (var prop in rolesWithRoleName) { + for (const prop in rolesWithRoleName) { roles = [...roles, ...(rolesWithRoleName[prop] as any)]; } roles.forEach((role: any) => { diff --git a/src/constants/theme.ts b/src/constants/theme.ts index 3a092f42..4b6b0cab 100644 --- a/src/constants/theme.ts +++ b/src/constants/theme.ts @@ -12,4 +12,4 @@ export const DASHBOARDS_SIDEBAR_WIDTH = 200; export const DASHBOARD_TOOLBAR_HEIGHT = 50; export const JSON_VIEW_TOOLBAR_HEIGHT = 50; export const LOGS_CONFIG_SIDEBAR_WIDTH = 200; -export const LOGS_FOOTER_HEIGHT = 50; \ No newline at end of file +export const LOGS_FOOTER_HEIGHT = 50; diff --git a/src/hooks/useAlertsEditor.tsx b/src/hooks/useAlertsEditor.tsx index c2adf9a3..256b7e72 100644 --- a/src/hooks/useAlertsEditor.tsx +++ b/src/hooks/useAlertsEditor.tsx @@ -6,7 +6,7 @@ import { useStreamStore, streamStoreReducers } from '@/pages/Stream/providers/St const { setAlertsConfig } = streamStoreReducers; const useAlertsQuery = (streamName: string, hasAlertsAccess: boolean, isStandAloneMode: boolean | null) => { - const [, setStreamStore] = useStreamStore((_store) => null); + const [, setStreamStore] = useStreamStore(() => null); const { data, isError, isSuccess, isLoading, refetch } = useQuery( ['fetch-log-stream-alert', streamName, hasAlertsAccess], () => getLogStreamAlerts(streamName), diff --git a/src/hooks/useCacheToggle.tsx b/src/hooks/useCacheToggle.tsx index f23ae792..c7e62707 100644 --- a/src/hooks/useCacheToggle.tsx +++ b/src/hooks/useCacheToggle.tsx @@ -6,7 +6,7 @@ import { useStreamStore, streamStoreReducers } from '@/pages/Stream/providers/St const { setCacheEnabled } = streamStoreReducers; export const useCacheToggle = (streamName: string) => { - const [, setStreamStore] = useStreamStore((_store) => null); + const [, setStreamStore] = useStreamStore(() => null); const { data: checkCacheData, refetch: getCacheStatusRefetch, diff --git a/src/hooks/useClusterInfo.ts b/src/hooks/useClusterInfo.ts index d33b4f0e..094072c3 100644 --- a/src/hooks/useClusterInfo.ts +++ b/src/hooks/useClusterInfo.ts @@ -8,7 +8,7 @@ import { useClusterStore, clusterStoreReducers } from '@/pages/Systems/providers const { setIngestorMachines, setCurrentMachineData } = clusterStoreReducers; export const useClusterInfo = () => { - const [, setClusterStore] = useClusterStore((_store) => null); + const [, setClusterStore] = useClusterStore(() => null); const { data: clusterInfoData, isError: getClusterInfoError, diff --git a/src/hooks/useDashboards.tsx b/src/hooks/useDashboards.tsx index b5877bd5..c958a6d6 100644 --- a/src/hooks/useDashboards.tsx +++ b/src/hooks/useDashboards.tsx @@ -154,7 +154,7 @@ export const useTileQuery = (opts: { onSuccess?: (data: TileQueryResponse) => void; enabled?: boolean; }) => { - const [, setDashboardsStore] = useDashboardsStore((_store) => null); + const [, setDashboardsStore] = useDashboardsStore(() => null); const { query, startTime, endTime, tileId, enabled = true } = opts; const { isLoading, isFetching, isError, refetch } = useQuery( [tileId, startTime, endTime], diff --git a/src/hooks/useGetLogStreamSchema.ts b/src/hooks/useGetLogStreamSchema.ts index ea921dd9..ad72865a 100644 --- a/src/hooks/useGetLogStreamSchema.ts +++ b/src/hooks/useGetLogStreamSchema.ts @@ -1,7 +1,6 @@ import { getLogStreamSchema } from '@/api/logStream'; import { useStreamStore, streamStoreReducers } from '@/pages/Stream/providers/StreamProvider'; import { AxiosError, isAxiosError } from 'axios'; -import _ from 'lodash'; import { useQuery } from 'react-query'; import { useState } from 'react'; @@ -9,7 +8,7 @@ const { setStreamSchema } = streamStoreReducers; export const useGetStreamSchema = (opts: { streamName: string }) => { const { streamName } = opts; - const [, setStreamStore] = useStreamStore((_store) => null); + const [, setStreamStore] = useStreamStore(() => null); const [errorMessage, setErrorMesssage] = useState(null); const { isError, isSuccess, isLoading, refetch, isRefetching } = useQuery( diff --git a/src/hooks/useGetStreamInfo.tsx b/src/hooks/useGetStreamInfo.tsx index 628ce0ad..2ebdf72f 100644 --- a/src/hooks/useGetStreamInfo.tsx +++ b/src/hooks/useGetStreamInfo.tsx @@ -7,7 +7,7 @@ import { useQuery } from 'react-query'; const { setStreamInfo } = streamStoreReducers; export const useGetStreamInfo = (currentStream: string, initialFetch: boolean) => { - const [, setStreamStore] = useStreamStore((_store) => null); + const [, setStreamStore] = useStreamStore(() => null); const { data: getStreamInfoData, isError: getStreamInfoError, diff --git a/src/hooks/useGetStreamMetadata.ts b/src/hooks/useGetStreamMetadata.ts index d2ab4cc0..5f780b6f 100644 --- a/src/hooks/useGetStreamMetadata.ts +++ b/src/hooks/useGetStreamMetadata.ts @@ -8,7 +8,7 @@ import { useCallback, useState } from 'react'; export type MetaData = { [key: string]: { - stats: LogStreamStat | {}; + stats: LogStreamStat | object; retention: LogStreamRetention | []; }; }; diff --git a/src/hooks/useLogStreamStats.tsx b/src/hooks/useLogStreamStats.tsx index c1bc3d11..d08135fd 100644 --- a/src/hooks/useLogStreamStats.tsx +++ b/src/hooks/useLogStreamStats.tsx @@ -8,7 +8,7 @@ import { AxiosError, isAxiosError } from 'axios'; const { setStats } = streamStoreReducers; export const useLogStreamStats = (streamName: string, fetchStartTime?: Dayjs) => { - const [, setStreamStore] = useStreamStore((_store) => null); + const [, setStreamStore] = useStreamStore(() => null); const { data: getLogStreamStatsData, isSuccess: getLogStreamStatsDataIsSuccess, diff --git a/src/hooks/useLoginForm.ts b/src/hooks/useLoginForm.ts index a7c38b8b..0cc3b5b2 100644 --- a/src/hooks/useLoginForm.ts +++ b/src/hooks/useLoginForm.ts @@ -9,13 +9,13 @@ import { HOME_ROUTE } from '@/constants/routes'; import { useId } from '@mantine/hooks'; import { useEffect } from 'react'; import Cookies from 'js-cookie'; -import { getQueryParam } from '@/utils'; +import { useGetQueryParam } from '@/utils'; import { isAxiosError } from 'axios'; import _ from 'lodash'; export const useLoginForm = () => { const notificationId = useId(); - const queryParams = getQueryParam(); + const queryParams = useGetQueryParam(); const [loading, setLoading] = useMountedState(false); const [error, setError] = useMountedState(null); const auth = Cookies.get('session'); diff --git a/src/hooks/useQueryResult.tsx b/src/hooks/useQueryResult.tsx index c288305f..a1087bcc 100644 --- a/src/hooks/useQueryResult.tsx +++ b/src/hooks/useQueryResult.tsx @@ -60,10 +60,11 @@ export const useFetchCount = () => { const { setTotalCount } = logsStoreReducers; const [custQuerySearchState] = useLogsStore((store) => store.custQuerySearchState); const [timeRange] = useAppStore((store) => store.timeRange); - const [, setLogsStore] = useLogsStore((_store) => null); + const [, setLogsStore] = useLogsStore(() => null); const { isQuerySearchActive, custSearchQuery, activeMode } = custQuerySearchState; const [appliedQuery] = useFilterStore((store) => store.appliedQuery); + /* eslint-disable no-useless-escape */ const defaultQuery = `select count(*) as count from \"${currentStream}\"`; const query = (() => { if (isQuerySearchActive) { diff --git a/src/hooks/useRetentionEditor.tsx b/src/hooks/useRetentionEditor.tsx index 18ee3451..c34ca1ba 100644 --- a/src/hooks/useRetentionEditor.tsx +++ b/src/hooks/useRetentionEditor.tsx @@ -8,7 +8,7 @@ import _ from 'lodash'; const { setRetention } = streamStoreReducers; export const useRetentionQuery = (streamName: string, hasSettingsAccess: boolean) => { - const [, setStreamStore] = useStreamStore((_store) => null); + const [, setStreamStore] = useStreamStore(() => null); const { data: getLogRetentionData, isError: getLogRetentionIsError, diff --git a/src/hooks/useSavedFilters.tsx b/src/hooks/useSavedFilters.tsx index 45623870..d9071095 100644 --- a/src/hooks/useSavedFilters.tsx +++ b/src/hooks/useSavedFilters.tsx @@ -10,8 +10,8 @@ const { setSavedFilters } = appStoreReducers; const { updateSavedFilterId } = logsStoreReducers; const useSavedFiltersQuery = () => { - const [, setAppStore] = useAppStore((_store) => null); - const [, setLogsStore] = useLogsStore((_store) => null); + const [, setAppStore] = useAppStore(() => null); + const [, setLogsStore] = useLogsStore(() => null); const { isError, isSuccess, isLoading, refetch, isRefetching } = useQuery( ['saved-filters'], () => getSavedFilters(), diff --git a/src/layouts/MainLayout/providers/AppProvider.tsx b/src/layouts/MainLayout/providers/AppProvider.tsx index 01edea2d..6d33bb80 100644 --- a/src/layouts/MainLayout/providers/AppProvider.tsx +++ b/src/layouts/MainLayout/providers/AppProvider.tsx @@ -122,8 +122,7 @@ const generateUserAcccessMap = (accessRoles: string[] | null) => { return Object.keys(accessKeyMap).reduce((acc, accessKey: string) => { return { ...acc, - [accessKey]: - accessRoles !== null && accessKeyMap.hasOwnProperty(accessKey) && accessRoles.includes(accessKeyMap[accessKey]), + [accessKey]: accessRoles !== null && accessKey in accessKeyMap && accessRoles.includes(accessKeyMap[accessKey]), }; }, {}); }; diff --git a/src/pages/Dashboards/CreateDashboardModal.tsx b/src/pages/Dashboards/CreateDashboardModal.tsx index 2283ee4c..07b571de 100644 --- a/src/pages/Dashboards/CreateDashboardModal.tsx +++ b/src/pages/Dashboards/CreateDashboardModal.tsx @@ -29,7 +29,7 @@ const useDashboardForm = (opts: FormOpts) => { initialValues: opts, validate: { name: (val) => (_.isEmpty(val) ? 'Name cannot be empty' : null), - description: (_val) => null, + description: () => null, }, validateInputOnChange: true, validateInputOnBlur: true, diff --git a/src/pages/Dashboards/Dashboard.tsx b/src/pages/Dashboards/Dashboard.tsx index ec614ce6..a15352ab 100644 --- a/src/pages/Dashboards/Dashboard.tsx +++ b/src/pages/Dashboards/Dashboard.tsx @@ -254,7 +254,7 @@ const ImportDashboardModal = () => { }; const NoDashboardsView = () => { - const [, setDashboardsStore] = useDashboardsStore((_store) => null); + const [, setDashboardsStore] = useDashboardsStore(() => null); const openCreateDashboardModal = useCallback(() => { setDashboardsStore((store) => toggleCreateDashboardModal(store, true)); @@ -289,7 +289,7 @@ const NoDashboardsView = () => { }; const NoTilesView = () => { - const [, setDashbaordsStore] = useDashboardsStore((_store) => null); + const [, setDashbaordsStore] = useDashboardsStore(() => null); const openCreateTileModal = useCallback(() => { setDashbaordsStore((store) => toggleCreateTileModal(store, true)); diff --git a/src/pages/Dashboards/SideBar.tsx b/src/pages/Dashboards/SideBar.tsx index f2eb192f..dc435177 100644 --- a/src/pages/Dashboards/SideBar.tsx +++ b/src/pages/Dashboards/SideBar.tsx @@ -68,7 +68,7 @@ const DashboardList = (props: { updateTimeRange: (dashboard: Dashboard) => void const renderShareIcon = () => ; const ImportDashboardButton = () => { - const [_store, setDashbaordsStore] = useDashboardsStore((_store) => null); + const [, setDashbaordsStore] = useDashboardsStore(() => null); const onClick = useCallback(() => { setDashbaordsStore((store) => toggleImportDashboardModal(store, true)); }, []); diff --git a/src/pages/Dashboards/Table.tsx b/src/pages/Dashboards/Table.tsx index 543c9419..3b98857f 100644 --- a/src/pages/Dashboards/Table.tsx +++ b/src/pages/Dashboards/Table.tsx @@ -59,7 +59,7 @@ const TableViz = (props: { data: TileQueryResponse; tick_config: TickConfig[] }) return ( - + {hasNoData ? ( ) : ( diff --git a/src/pages/Dashboards/Tile.tsx b/src/pages/Dashboards/Tile.tsx index dfb5e898..8047ed6b 100644 --- a/src/pages/Dashboards/Tile.tsx +++ b/src/pages/Dashboards/Tile.tsx @@ -165,7 +165,7 @@ function TileControls(props: { tile: TileType; data: TileQueryResponse }) { } = props; const { records = [], fields = [] } = data; const [allowDrag] = useDashboardsStore((store) => store.allowDrag); - const [, setDashboardsStore] = useDashboardsStore((_store) => null); + const [, setDashboardsStore] = useDashboardsStore(() => null); const exportPng = useCallback(() => { handleCapture({ className: makeExportClassName(tile_id), fileName: name }); diff --git a/src/pages/Dashboards/Toolbar.tsx b/src/pages/Dashboards/Toolbar.tsx index f8bffb00..22b9c644 100644 --- a/src/pages/Dashboards/Toolbar.tsx +++ b/src/pages/Dashboards/Toolbar.tsx @@ -77,7 +77,7 @@ const EditLayoutButton = (props: { layoutRef: React.MutableRefObject { - const [, setDashbaordsStore] = useDashboardsStore((_store) => null); + const [, setDashbaordsStore] = useDashboardsStore(() => null); const onClick = useCallback(() => { setDashbaordsStore((store) => toggleCreateTileModal(store, true)); @@ -97,7 +97,7 @@ const AddTileButton = () => { }; const ImportTileButton = () => { - const [, setDashbaordsStore] = useDashboardsStore((_store) => null); + const [, setDashbaordsStore] = useDashboardsStore(() => null); const onClick = useCallback(() => { setDashbaordsStore((store) => toggleImportTileModal(store, true)); @@ -157,7 +157,7 @@ const renderDeleteIcon = () => ; const renderShareIcon = () => ; const DeleteDashboardButton = () => { - const [_store, setDashbaordsStore] = useDashboardsStore((_store) => null); + const [, setDashbaordsStore] = useDashboardsStore(() => null); const onClick = useCallback(() => setDashbaordsStore((store) => toggleDeleteDashboardModal(store, true)), []); return ; }; diff --git a/src/pages/Dashboards/VizEditorModal.tsx b/src/pages/Dashboards/VizEditorModal.tsx index ce9dd94b..c7918242 100644 --- a/src/pages/Dashboards/VizEditorModal.tsx +++ b/src/pages/Dashboards/VizEditorModal.tsx @@ -604,7 +604,7 @@ const Config = (props: { form: TileFormType }) => { const VizEditorModal = (props: { form: TileFormType }) => { const { form } = props; const [vizEditorModalOpen] = useDashboardsStore((store) => store.vizEditorModalOpen); - const [, setDashboardStore] = useDashboardsStore((_store) => null); + const [, setDashboardStore] = useDashboardsStore(() => null); const closeVizModal = useCallback(() => { setDashboardStore((store) => toggleVizEditorModal(store, false)); }, []); diff --git a/src/pages/Dashboards/hooks.ts b/src/pages/Dashboards/hooks.ts index a3848d13..0b986d13 100644 --- a/src/pages/Dashboards/hooks.ts +++ b/src/pages/Dashboards/hooks.ts @@ -11,8 +11,8 @@ const { getCleanStoreForRefetch } = logsStoreReducers; export const useSyncTimeRange = () => { const [dashboards] = useDashboardsStore((store) => store.dashboards); - const [, setLogStore] = useLogsStore((_store) => null); - const [, setAppStore] = useAppStore((_store) => null); + const [, setLogStore] = useLogsStore(() => null); + const [, setAppStore] = useAppStore(() => null); const updateTimeRange = useCallback( (dashboard: Dashboard) => { diff --git a/src/pages/Dashboards/hooks/useParamsController.ts b/src/pages/Dashboards/hooks/useParamsController.ts index 0b68a25c..6a6a2d4b 100644 --- a/src/pages/Dashboards/hooks/useParamsController.ts +++ b/src/pages/Dashboards/hooks/useParamsController.ts @@ -74,7 +74,7 @@ const useParamsController = () => { const [isStoreSynced, setStoreSynced] = useState(false); const [activeDashboard, setDashboardsStore] = useDashboardsStore((store) => store.activeDashboard); const [timeRange, setAppStore] = useAppStore((store) => store.timeRange); - const [, setLogStore] = useLogsStore((_store) => null); + const [, setLogStore] = useLogsStore(() => null); const [searchParams, setSearchParams] = useSearchParams(); const dashboardId = activeDashboard?.dashboard_id || ''; diff --git a/src/pages/Dashboards/index.tsx b/src/pages/Dashboards/index.tsx index 07c497d6..af5f457a 100644 --- a/src/pages/Dashboards/index.tsx +++ b/src/pages/Dashboards/index.tsx @@ -9,7 +9,6 @@ import { useEffect } from 'react'; import { useDashboardsQuery } from '@/hooks/useDashboards'; import CreateTileForm from './CreateTileForm'; import { useSyncTimeRange } from './hooks'; -import _ from 'lodash'; import useParamsController from './hooks/useParamsController'; import { useDocumentTitle } from '@mantine/hooks'; import SavedFiltersModal from '../Stream/components/Querier/SavedFiltersModal'; diff --git a/src/pages/Dashboards/providers/DashboardsProvider.ts b/src/pages/Dashboards/providers/DashboardsProvider.ts index f3a9ea18..072082a3 100644 --- a/src/pages/Dashboards/providers/DashboardsProvider.ts +++ b/src/pages/Dashboards/providers/DashboardsProvider.ts @@ -194,8 +194,7 @@ const setDashboards = (store: DashboardsStore, dashboards: Dashboard[], dashboar const activeDashboard = (() => { if (_.isString(dashboardId) && !_.isEmpty(dashboardId)) { return _.find(dashboards, (dashboard) => dashboard.dashboard_id === dashboardId); - } - else if (activeDashboardFromStore) { + } else if (activeDashboardFromStore) { const id = activeDashboardFromStore.dashboard_id; const dashboard = _.find(dashboards, (dashboard) => dashboard.dashboard_id === id); return dashboard || defaultActiveDashboard; @@ -288,7 +287,7 @@ const dashboardsStoreReducers: DashboardsStoreReducers = { toggleImportTileModal, toggleImportDashboardModal, handlePaging, - toggleDuplicateTileModal + toggleDuplicateTileModal, }; export { DashbaordsProvider, useDashboardsStore, dashboardsStoreReducers }; diff --git a/src/pages/Home/CreateStreamModal.tsx b/src/pages/Home/CreateStreamModal.tsx index f95060ba..1c1539c7 100644 --- a/src/pages/Home/CreateStreamModal.tsx +++ b/src/pages/Home/CreateStreamModal.tsx @@ -34,6 +34,7 @@ const { toggleCreateStreamModal } = appStoreReducers; const allowedSpecialCharacters = ['-', '_']; +/* eslint-disable no-useless-escape */ const isValidStreamName = (val: string) => { if (!/[A-Za-z]/.test(val)) { return 'Name should contain at least one letter'; @@ -100,6 +101,7 @@ const getDataTypeFormValuesFromSchema = (schema: LogStreamSchemaData) => { } else { if (_.get(detectedDataType, 'List')) { const listDatatype = _.get(detectedDataType, 'List', null); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore return listDatatype ? _.get(formValuesListDatatypeMap, listDatatype?.data_type, null) : null; } else if (_.get(detectedDataType, 'Timestamp')) { @@ -344,7 +346,7 @@ const useCreateStreamForm = () => { if (allValues.schemaType === dynamicType) return null; const { fields } = allValues; - const existingNames = _.map(fields, (v, _k) => v.name); + const existingNames = _.map(fields, (v) => v.name); return isValidFieldName(val, existingNames); }, data_type: (val, allValues) => { diff --git a/src/pages/Home/index.tsx b/src/pages/Home/index.tsx index 7631df8d..21cd2fb1 100644 --- a/src/pages/Home/index.tsx +++ b/src/pages/Home/index.tsx @@ -239,7 +239,7 @@ const sanitizeBytes = (str: any) => { type StreamInfoProps = { stream: string; data: { - stats: LogStreamStat | {}; + stats: LogStreamStat | object; retention: LogStreamRetention | []; }; navigateToStream: (stream: string) => void; diff --git a/src/pages/Stream/Views/Explore/LoadingViews.tsx b/src/pages/Stream/Views/Explore/LoadingViews.tsx index 4505af4c..26c2961e 100644 --- a/src/pages/Stream/Views/Explore/LoadingViews.tsx +++ b/src/pages/Stream/Views/Explore/LoadingViews.tsx @@ -9,8 +9,8 @@ const { getCleanStoreForRefetch } = logsStoreReducers; const { syncTimeRange } = appStoreReducers; export const ErrorView = (props: { message: string }) => { - const [, setLogsStore] = useLogsStore((_store) => null); - const [, setAppStore] = useAppStore((_store) => null); + const [, setLogsStore] = useLogsStore(() => null); + const [, setAppStore] = useAppStore(() => null); const { message } = props; const onRetry = useCallback(() => { diff --git a/src/pages/Stream/Views/Explore/LogsView.tsx b/src/pages/Stream/Views/Explore/LogsView.tsx index dd765123..4dbf0d11 100644 --- a/src/pages/Stream/Views/Explore/LogsView.tsx +++ b/src/pages/Stream/Views/Explore/LogsView.tsx @@ -4,7 +4,6 @@ import JsonView from './JSONView'; import LogTable from './StaticLogTable'; import useLogsFetcher from './useLogsFetcher'; import LogsViewConfig from './LogsViewConfig'; -import _ from 'lodash'; const LogsView = (props: { schemaLoading: boolean; infoLoading: boolean }) => { const { schemaLoading, infoLoading } = props; diff --git a/src/pages/Stream/Views/LiveTail/LiveLogTable.tsx b/src/pages/Stream/Views/LiveTail/LiveLogTable.tsx index e251243e..6d8e4c5d 100644 --- a/src/pages/Stream/Views/LiveTail/LiveLogTable.tsx +++ b/src/pages/Stream/Views/LiveTail/LiveLogTable.tsx @@ -1,8 +1,6 @@ import { FC, useEffect, useState } from 'react'; import { ScrollArea, Table, Box } from '@mantine/core'; -import { Tbody, - Thead - } from '@/components/Table'; +import { Tbody, Thead } from '@/components/Table'; import LogRow from './LiveLogRow'; import { useDoGetLiveTail } from '@/hooks/useDoGetLiveTail'; import EmptyBox from '@/components/Empty'; @@ -57,6 +55,7 @@ const LiveLogTable: FC = () => { const headerRows = schema?.map((element) => ( { const classes = styles; - const { container, tableStyle, - liveTheadStyle, - tableContainer, innerContainer } = classes; + const { container, tableStyle, liveTheadStyle, tableContainer, innerContainer } = classes; return ( diff --git a/src/pages/Stream/Views/Manage/Alerts.tsx b/src/pages/Stream/Views/Manage/Alerts.tsx index 503ea51d..2bd7ccbb 100644 --- a/src/pages/Stream/Views/Manage/Alerts.tsx +++ b/src/pages/Stream/Views/Manage/Alerts.tsx @@ -556,7 +556,6 @@ const AlertsModal = (props: { classNames={{ title: classes.modalTitle }}> - {/* @ts-ignore */} diff --git a/src/pages/Stream/Views/Manage/Stats.tsx b/src/pages/Stream/Views/Manage/Stats.tsx index 6700850a..c79401d5 100644 --- a/src/pages/Stream/Views/Manage/Stats.tsx +++ b/src/pages/Stream/Views/Manage/Stats.tsx @@ -50,7 +50,7 @@ const EventsCountRow = () => { const [stats] = useStreamStore((store) => store.stats); const eventsData = _.chain(stats) .get('ingestion', {}) - .thru((e: {}) => ({ ...defaultEventCountData, ...e })) + .thru((e) => ({ ...defaultEventCountData, ...e })) .value(); return ( @@ -87,7 +87,7 @@ const IngestedSizeRow = () => { const [stats] = useStreamStore((store) => store.stats); const ingestionData = _.chain(stats) .get('ingestion', {}) - .thru((e: {}) => ({ ...defaultIngestedSizeData, ...e })) + .thru((e) => ({ ...defaultIngestedSizeData, ...e })) .value(); return ( @@ -124,11 +124,11 @@ const StorageSizeRow = () => { const [stats] = useStreamStore((store) => store.stats); const storageData = _.chain(stats) .get('storage', {}) - .thru((e: {}) => ({ ...defaultStorageData, ...e })) + .thru((e) => ({ ...defaultStorageData, ...e })) .value(); const ingestionData = _.chain(stats) .get('ingestion', {}) - .thru((e: {}) => ({ ...defaultIngestedSizeData, ...e })) + .thru((e) => ({ ...defaultIngestedSizeData, ...e })) .value(); const compressionSize = calcCompressionRate(storageData.size, ingestionData.size); return ( diff --git a/src/pages/Stream/components/ErrorMarker.tsx b/src/pages/Stream/components/ErrorMarker.tsx index fa204774..474a90a5 100644 --- a/src/pages/Stream/components/ErrorMarker.tsx +++ b/src/pages/Stream/components/ErrorMarker.tsx @@ -1,4 +1,4 @@ -export var ErrorMarker: any[] = []; +export let ErrorMarker: any[] = []; // example format to generate error // let err = { @@ -20,10 +20,10 @@ export var ErrorMarker: any[] = []; // }); // } export function errChecker(code: string, streamName: string) { - let arr = code.split('\r\n'); + const arr = code.split('\r\n'); ErrorMarker = []; arr.map((wordsString: string, j: any) => { - let wordsArray = wordsString.split(' '); + const wordsArray = wordsString.split(' '); wordsArray.map((word: string, i: any) => { if (word.toLowerCase() === 'from' && wordsArray[i + 1]) { if (wordsArray[i + 1] !== streamName && wordsArray[i + 1] !== `${streamName};`) { diff --git a/src/pages/Stream/components/EventTimeLineGraph.tsx b/src/pages/Stream/components/EventTimeLineGraph.tsx index 030c6837..27b447ca 100644 --- a/src/pages/Stream/components/EventTimeLineGraph.tsx +++ b/src/pages/Stream/components/EventTimeLineGraph.tsx @@ -92,7 +92,7 @@ const getEndOfTs = (time: Date, compactType: CompactInterval): Date => { }; const incrementDateByCompactType = (date: Date, type: CompactInterval): Date => { - let tempDate = new Date(date); + const tempDate = new Date(date); if (type === 'minute') { tempDate.setMinutes(tempDate.getMinutes() + 1); } else if (type === 'hour') { @@ -151,6 +151,7 @@ const generateCountQuery = ( whereClause: string, ) => { const range = compactTypeIntervalMap[compactType]; + /* eslint-disable no-useless-escape */ return `SELECT DATE_BIN('${range}', p_timestamp, '${startTime.toISOString()}') AS date_bin_timestamp, COUNT(*) AS log_count FROM \"${streamName}\" WHERE p_timestamp BETWEEN '${startTime.toISOString()}' AND '${endTime.toISOString()}' AND ${whereClause} GROUP BY date_bin_timestamp ORDER BY date_bin_timestamp`; }; diff --git a/src/pages/Stream/components/PrimaryToolbar.tsx b/src/pages/Stream/components/PrimaryToolbar.tsx index 16e41568..23a51364 100644 --- a/src/pages/Stream/components/PrimaryToolbar.tsx +++ b/src/pages/Stream/components/PrimaryToolbar.tsx @@ -24,13 +24,13 @@ const renderMaximizeIcon = () => const renderDeleteIcon = () => ; const MaximizeButton = () => { - const [_appStore, setAppStore] = useAppStore((_store) => null); + const [, setAppStore] = useAppStore(() => null); const onClick = useCallback(() => setAppStore(appStoreReducers.toggleMaximize), []); return ; }; const SavedFiltersButton = () => { - const [_store, setLogsStore] = useFilterStore((_store) => null); + const [, setLogsStore] = useFilterStore(() => null); const onClick = useCallback(() => setLogsStore((store) => toggleSavedFiltersModal(store, true)), []); return (