From 03bf9afe037e573d0789371ecac81b87b0462fde Mon Sep 17 00:00:00 2001 From: pal-sig <88981777+pal-sig@users.noreply.github.com> Date: Thu, 2 Dec 2021 20:32:08 +0530 Subject: [PATCH] feat(UI): Eslint fixes (#418) * chore(UI): port finder is removed * chore(UI): webpack config is updated * fix(UI): eslint error and fixes are updated --- frontend/package.json | 1 - frontend/src/api/alerts/getGroup.ts | 3 +-- frontend/src/components/Editor/index.tsx | 4 ++-- frontend/src/container/FormAlertChannels/index.tsx | 6 +++--- frontend/src/container/MapAlertChannels/index.tsx | 7 ------- .../src/container/TraceCustomVisualization/index.tsx | 3 ++- frontend/src/modules/Traces/SelectedSpanDetails.tsx | 2 +- frontend/src/modules/Usage/UsageExplorer.tsx | 2 +- frontend/src/pages/CreateAlert/index.tsx | 4 ++-- frontend/src/store/actions/traces.ts | 3 +-- frontend/src/store/index.ts | 2 +- frontend/src/typings/environment.ts | 1 + frontend/src/typings/window.ts | 3 ++- frontend/webpack.config.js | 2 +- frontend/yarn.lock | 10 +--------- 15 files changed, 19 insertions(+), 34 deletions(-) delete mode 100644 frontend/src/container/MapAlertChannels/index.tsx diff --git a/frontend/package.json b/frontend/package.json index 4c14f2928b..b82fe2f9e1 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -173,7 +173,6 @@ "less-plugin-npm-import": "^2.1.0", "lint-staged": "10.5.3", "lodash-es": "^4.17.21", - "portfinder-sync": "^0.0.2", "prettier": "2.2.1", "react-hot-loader": "^4.13.0", "react-is": "^17.0.1", diff --git a/frontend/src/api/alerts/getGroup.ts b/frontend/src/api/alerts/getGroup.ts index 9fd69bc49c..f1cb2c6d77 100644 --- a/frontend/src/api/alerts/getGroup.ts +++ b/frontend/src/api/alerts/getGroup.ts @@ -1,5 +1,4 @@ -import { apiV1, AxiosAlertManagerInstance } from 'api'; -import { apiV2 } from 'api/apiV1'; +import { AxiosAlertManagerInstance } from 'api'; import { ErrorResponseHandler } from 'api/ErrorResponseHandler'; import { AxiosError } from 'axios'; import { ErrorResponse, SuccessResponse } from 'types/api'; diff --git a/frontend/src/components/Editor/index.tsx b/frontend/src/components/Editor/index.tsx index ae928d0084..3d9ce44ee6 100644 --- a/frontend/src/components/Editor/index.tsx +++ b/frontend/src/components/Editor/index.tsx @@ -3,7 +3,7 @@ import React, { useEffect, useRef } from 'react'; import { Container } from './styles'; -const Editor = ({ value }: EditorProps) => { +const Editor = ({ value }: EditorProps): JSX.Element => { const divEl = useRef(null); const editorRef = useRef(); @@ -28,7 +28,7 @@ const Editor = ({ value }: EditorProps) => { value.current = editor?.getValue() || ''; }); - return () => { + return (): void => { if (editor) { editor.dispose(); } diff --git a/frontend/src/container/FormAlertChannels/index.tsx b/frontend/src/container/FormAlertChannels/index.tsx index b7ded23285..a4f71e8e7e 100644 --- a/frontend/src/container/FormAlertChannels/index.tsx +++ b/frontend/src/container/FormAlertChannels/index.tsx @@ -19,7 +19,7 @@ const FormAlertChannels = ({ type, setSelectedConfig, onTypeChangeHandler, - onTestHandler, + // onTestHandler, onSaveHandler, savingState, NotificationElement, @@ -92,8 +92,8 @@ interface FormAlertChannelsProps { onSaveHandler: (props: ChannelType) => void; savingState: boolean; NotificationElement: React.ReactElement< - any, - string | React.JSXElementConstructor + unknown, + string | React.JSXElementConstructor >; title: string; initialValue: Store; diff --git a/frontend/src/container/MapAlertChannels/index.tsx b/frontend/src/container/MapAlertChannels/index.tsx deleted file mode 100644 index ffdebf9c59..0000000000 --- a/frontend/src/container/MapAlertChannels/index.tsx +++ /dev/null @@ -1,7 +0,0 @@ -import React from 'react'; - -const MapAlertChannels = () => { - return
MapAlertChannels
; -}; - -export default MapAlertChannels; diff --git a/frontend/src/container/TraceCustomVisualization/index.tsx b/frontend/src/container/TraceCustomVisualization/index.tsx index 3f9f0a050b..dbc4c46ed0 100644 --- a/frontend/src/container/TraceCustomVisualization/index.tsx +++ b/frontend/src/container/TraceCustomVisualization/index.tsx @@ -4,6 +4,7 @@ import React from 'react'; import { connect, useSelector } from 'react-redux'; import { AppState } from 'store/reducers'; const { Option } = Select; +import { Store } from 'rc-field-form/lib/interface'; import { bindActionCreators } from 'redux'; import { ThunkDispatch } from 'redux-thunk'; import { @@ -33,7 +34,7 @@ const TraceCustomVisualisation = ({ return ; } - const handleFormValuesChange = (changedValues: any): void => { + const handleFormValuesChange = (changedValues: Store): void => { const formFieldName = Object.keys(changedValues)[0]; if (formFieldName === 'entity') { const temp_entity = aggregation_options.filter( diff --git a/frontend/src/modules/Traces/SelectedSpanDetails.tsx b/frontend/src/modules/Traces/SelectedSpanDetails.tsx index 0d42ed4f94..427066081e 100644 --- a/frontend/src/modules/Traces/SelectedSpanDetails.tsx +++ b/frontend/src/modules/Traces/SelectedSpanDetails.tsx @@ -75,7 +75,7 @@ const SelectedSpanDetails = (props: SelectedSpanDetailsProps): JSX.Element => { {spanTags && - spanTags.map((tags, index) => { + spanTags.map((tags) => { return ( <> {tags.value && ( diff --git a/frontend/src/modules/Usage/UsageExplorer.tsx b/frontend/src/modules/Usage/UsageExplorer.tsx index 6114f3084c..f6bbe06c7b 100644 --- a/frontend/src/modules/Usage/UsageExplorer.tsx +++ b/frontend/src/modules/Usage/UsageExplorer.tsx @@ -18,7 +18,7 @@ interface UsageExplorerProps { getUsageData: ( minTime: number, maxTime: number, - selectedInterval: any, + selectedInterval: number, selectedService: string, ) => void; getServicesList: ({ diff --git a/frontend/src/pages/CreateAlert/index.tsx b/frontend/src/pages/CreateAlert/index.tsx index 6a89e61c47..1c2b9474d8 100644 --- a/frontend/src/pages/CreateAlert/index.tsx +++ b/frontend/src/pages/CreateAlert/index.tsx @@ -12,7 +12,7 @@ import { ButtonContainer, Title } from './styles'; const CreateAlert = (): JSX.Element => { const value = useRef( - `\n alert: \n expr: system_cpu_load_average_1m > 0.01\n for: 0m\n labels:\n severity: warning\n annotations:\n summary: High CPU load\n description: \"CPU load is > 0.01\n VALUE = {{ $value }}\n LABELS = {{ $labels }}\"\n `, + `\n alert: \n expr: system_cpu_load_average_1m > 0.01\n for: 0m\n labels:\n severity: warning\n annotations:\n summary: High CPU load\n description: "CPU load is > 0.01\n VALUE = {{ $value }}\n LABELS = {{ $labels }}"\n `, ); const [newAlertState, setNewAlertState] = useState< @@ -85,7 +85,7 @@ const CreateAlert = (): JSX.Element => { 'Oops! Some issue occured in saving the alert please try again or contact support@signoz.io', }); } - }, []); + }, [notifications]); return ( <> diff --git a/frontend/src/store/actions/traces.ts b/frontend/src/store/actions/traces.ts index f7771346fb..72200fb5eb 100644 --- a/frontend/src/store/actions/traces.ts +++ b/frontend/src/store/actions/traces.ts @@ -1,5 +1,4 @@ import api from 'api'; -import ROUTES from 'constants/routes'; import { Dispatch } from 'redux'; import { GlobalTime } from 'types/actions/globalTime'; import { toUTCEpoch } from 'utils/timeUtils'; @@ -120,7 +119,7 @@ export interface FetchTraceItemAction { } export const fetchTraces = (globalTime: GlobalTime, filter_params: string) => { - return async (dispatch: Dispatch): void => { + return async (dispatch: Dispatch): Promise => { if (globalTime) { const request_string = '/spans?limit=100&lookback=2d&start=' + diff --git a/frontend/src/store/index.ts b/frontend/src/store/index.ts index ee3ab8b134..4b725b7218 100644 --- a/frontend/src/store/index.ts +++ b/frontend/src/store/index.ts @@ -4,7 +4,7 @@ import thunk, { ThunkMiddleware } from 'redux-thunk'; import reducers, { AppState } from './reducers'; const composeEnhancers = - (window && (window as any).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__) || compose; + (window && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__) || compose; const store = createStore( reducers, diff --git a/frontend/src/typings/environment.ts b/frontend/src/typings/environment.ts index e2b058af48..c77832ce43 100644 --- a/frontend/src/typings/environment.ts +++ b/frontend/src/typings/environment.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-namespace */ declare global { namespace NodeJS { interface ProcessEnv { diff --git a/frontend/src/typings/window.ts b/frontend/src/typings/window.ts index d8b4316586..d0155f99c8 100644 --- a/frontend/src/typings/window.ts +++ b/frontend/src/typings/window.ts @@ -1,10 +1,11 @@ import Cypress from 'cypress'; -import { Store } from 'redux'; +import { compose, Store } from 'redux'; declare global { interface Window { store: Store; Cypress: typeof Cypress; + __REDUX_DEVTOOLS_EXTENSION_COMPOSE__: typeof compose; } } diff --git a/frontend/webpack.config.js b/frontend/webpack.config.js index 42be93b725..c7d335b8a7 100644 --- a/frontend/webpack.config.js +++ b/frontend/webpack.config.js @@ -19,7 +19,7 @@ const config = { open: true, hot: true, liveReload: true, - port: portFinderSync.getPort(3000), + port: 3000, static: { directory: resolve(__dirname, 'public'), publicPath: '/', diff --git a/frontend/yarn.lock b/frontend/yarn.lock index 0f467d6f47..5a10d9ea26 100644 --- a/frontend/yarn.lock +++ b/frontend/yarn.lock @@ -11251,15 +11251,7 @@ polished@4: dependencies: "@babel/runtime" "^7.14.0" -portfinder-sync@^0.0.2: - version "0.0.2" - resolved "https://registry.yarnpkg.com/portfinder-sync/-/portfinder-sync-0.0.2.tgz#6e3409a73a718436de053ac949385350caabd8a2" - integrity sha1-bjQJpzpxhDbeBTrJSThTUMqr2KI= - dependencies: - minimist "^1.2.0" - portfinder "^1.0.10" - -portfinder@^1.0.10, portfinder@^1.0.28: +portfinder@^1.0.28: version "1.0.28" resolved "https://registry.yarnpkg.com/portfinder/-/portfinder-1.0.28.tgz#67c4622852bd5374dd1dd900f779f53462fac778" integrity sha512-Se+2isanIcEqf2XMHjyUKskczxbPH7dQnlMjXX6+dybayyHvAf/TCgyMRlzf/B6QDhAEFOGes0pzRo3by4AbMA==