diff --git a/Common/Types/GenericFunction.ts b/Common/Types/GenericFunction.ts index fcf5b6937c..dd154c4ca4 100644 --- a/Common/Types/GenericFunction.ts +++ b/Common/Types/GenericFunction.ts @@ -1,4 +1,4 @@ -// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type +// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type, @typescript-eslint/no-restricted-types type GenericFunction = Function; export default GenericFunction; diff --git a/Common/UI/Components/CategoryCheckbox/CheckboxList.tsx b/Common/UI/Components/CategoryCheckbox/CheckboxList.tsx index a37744ddd0..51314b09bb 100644 --- a/Common/UI/Components/CategoryCheckbox/CheckboxList.tsx +++ b/Common/UI/Components/CategoryCheckbox/CheckboxList.tsx @@ -57,7 +57,9 @@ const CheckBoxList: FunctionComponent = ( )} onChange={(changedValue: boolean) => { if (changedValue) { - props.onChecked && props.onChecked(option.value); + if (props.onChecked) { + props.onChecked(option.value); + } // add the option.value to the currentValues array const newValues: Array = [ @@ -72,7 +74,9 @@ const CheckBoxList: FunctionComponent = ( setCurrentValues(newValues); props.onChange(newValues); } else { - props.onUnchecked && props.onUnchecked(option.value); + if (props.onUnchecked) { + props.onUnchecked(option.value); + } // remove the option.value from the currentValues array diff --git a/Common/UI/Components/CodeEditor/CodeEditor.tsx b/Common/UI/Components/CodeEditor/CodeEditor.tsx index b6e4dd68e2..5cabaa6cda 100644 --- a/Common/UI/Components/CodeEditor/CodeEditor.tsx +++ b/Common/UI/Components/CodeEditor/CodeEditor.tsx @@ -101,8 +101,12 @@ const CodeEditor: FunctionComponent = (
{ - props.onClick && props.onClick(); - props.onFocus && props.onFocus(); + if (props.onClick) { + props.onClick(); + } + if (props.onFocus) { + props.onFocus(); + } }} > {helpText && ( @@ -122,8 +126,12 @@ const CodeEditor: FunctionComponent = ( } setValue(code); - props.onBlur && props.onBlur(); - props.onChange && props.onChange(code); + if (props.onBlur) { + props.onBlur(); + } + if (props.onChange) { + props.onChange(code); + } }} defaultValue={value || placeholder || ""} className={className} diff --git a/Common/UI/Components/Radio/Radio.tsx b/Common/UI/Components/Radio/Radio.tsx index d838634d0d..7f2b3593a2 100644 --- a/Common/UI/Components/Radio/Radio.tsx +++ b/Common/UI/Components/Radio/Radio.tsx @@ -7,7 +7,7 @@ import React, { useState, } from "react"; -export interface RadioOption extends DropdownOption {} +export type RadioOption = DropdownOption; export type RadioValue = DropdownValue; @@ -50,9 +50,15 @@ const Radio: FunctionComponent = ( checked={value === option.value} onClick={() => { setValue(option.value); - props.onChange && props.onChange(option.value); - props.onBlur && props.onBlur(); - props.onFocus && props.onFocus(); + if (props.onChange) { + props.onChange(option.value); + } + if (props.onBlur) { + props.onBlur(); + } + if (props.onFocus) { + props.onFocus(); + } }} name={groupName} type="radio" diff --git a/Common/UI/Components/Tabs/Tabs.tsx b/Common/UI/Components/Tabs/Tabs.tsx index 84d756443a..32382b4704 100644 --- a/Common/UI/Components/Tabs/Tabs.tsx +++ b/Common/UI/Components/Tabs/Tabs.tsx @@ -21,8 +21,8 @@ const Tabs: FunctionComponent = ( }, [props.tabs]); useEffect(() => { - if (currentTab) { - props.onTabChange && props.onTabChange(currentTab); + if (currentTab && props.onTabChange) { + props.onTabChange(currentTab); } }, [currentTab]); diff --git a/Common/UI/Components/TextArea/TextArea.tsx b/Common/UI/Components/TextArea/TextArea.tsx index da72aa4ab5..4f76cd37d6 100644 --- a/Common/UI/Components/TextArea/TextArea.tsx +++ b/Common/UI/Components/TextArea/TextArea.tsx @@ -50,7 +50,9 @@ const TextArea: FunctionComponent = ( const handleChange: HandleChangeFunction = (content: string): void => { setText(content); - props.onChange && props.onChange(content); + if (props.onChange) { + props.onChange(content); + } }; return ( diff --git a/Common/UI/Utils/AnalyticsModelAPI/AnalyticsModelAPI.ts b/Common/UI/Utils/AnalyticsModelAPI/AnalyticsModelAPI.ts index fc602e1a73..1b360f73e8 100644 --- a/Common/UI/Utils/AnalyticsModelAPI/AnalyticsModelAPI.ts +++ b/Common/UI/Utils/AnalyticsModelAPI/AnalyticsModelAPI.ts @@ -24,8 +24,8 @@ import AggregateBy from "../../../Types/BaseDatabase/AggregateBy"; import AggregatedResult from "../../../Types/BaseDatabase/AggregatedResult"; import Query from "../../../Types/BaseDatabase/Query"; -export interface ListResult - extends BaseListResult {} +export type ListResult = + BaseListResult; export default class ModelAPI { public static async create< diff --git a/Common/UI/Utils/ModelAPI/ModelAPI.ts b/Common/UI/Utils/ModelAPI/ModelAPI.ts index 9483bc4651..2295626388 100644 --- a/Common/UI/Utils/ModelAPI/ModelAPI.ts +++ b/Common/UI/Utils/ModelAPI/ModelAPI.ts @@ -28,8 +28,8 @@ export class ModelAPIHttpResponse< public miscData?: JSONObject | undefined; } -export interface ListResult - extends BaseListResult {} +export type ListResult = + BaseListResult; export interface RequestOptions extends BaseRequestOptions { isMultiTenantRequest?: boolean | undefined; diff --git a/Dashboard/src/Components/Form/Monitor/MonitorStep.tsx b/Dashboard/src/Components/Form/Monitor/MonitorStep.tsx index 69a0777cb7..b1cefb5401 100644 --- a/Dashboard/src/Components/Form/Monitor/MonitorStep.tsx +++ b/Dashboard/src/Components/Form/Monitor/MonitorStep.tsx @@ -555,7 +555,7 @@ return { ...errors, requestBody: "", }); - } catch (err) { + } catch { setErrors({ ...errors, requestBody: "Invalid JSON", diff --git a/Dashboard/src/Components/Header/Header.tsx b/Dashboard/src/Components/Header/Header.tsx index b284c5a2da..44e044603a 100644 --- a/Dashboard/src/Components/Header/Header.tsx +++ b/Dashboard/src/Components/Header/Header.tsx @@ -318,7 +318,7 @@ const DashboardHeader: FunctionComponent = ( setCurrentOnCallPolicies(currentOnCallPolicies); } - } catch (err) { + } catch { setOnCallDutyPolicyFetchError( "Something isnt right, we are unable to fetch on-call policies that you are on duty for. Reload the page to try again.", ); diff --git a/Dashboard/src/Components/Header/Logo.tsx b/Dashboard/src/Components/Header/Logo.tsx index 1254999f1e..0519d525e2 100644 --- a/Dashboard/src/Components/Header/Logo.tsx +++ b/Dashboard/src/Components/Header/Logo.tsx @@ -17,7 +17,9 @@ const Logo: FunctionComponent = ( { - props.onClick && props.onClick(); + if (props.onClick) { + props.onClick(); + } }} imageUrl={Route.fromString(`${OneUptimeLogo}`)} alt={"OneUptime"} diff --git a/Dashboard/src/Components/Monitor/MonitorMetrics.tsx b/Dashboard/src/Components/Monitor/MonitorMetrics.tsx index 8128116223..8bac884c62 100644 --- a/Dashboard/src/Components/Monitor/MonitorMetrics.tsx +++ b/Dashboard/src/Components/Monitor/MonitorMetrics.tsx @@ -169,7 +169,7 @@ const MonitorMetricsElement: FunctionComponent = ( if (typeof attributes === "string") { try { attributes = JSONFunctions.parseJSONObject(attributes); - } catch (err) { + } catch { return { title: MonitorMetricTypeUtil.getTitleByMonitorMetricType( @@ -231,7 +231,7 @@ const MonitorMetricsElement: FunctionComponent = ( if (typeof attributes === "string") { try { attributes = JSONFunctions.parseJSONObject(attributes); - } catch (err) { + } catch { return { title: MonitorMetricTypeUtil.getTitleByMonitorMetricType( diff --git a/Dashboard/src/Pages/Home/SideMenu.tsx b/Dashboard/src/Pages/Home/SideMenu.tsx index 06f9a62832..353914e913 100644 --- a/Dashboard/src/Pages/Home/SideMenu.tsx +++ b/Dashboard/src/Pages/Home/SideMenu.tsx @@ -48,7 +48,7 @@ const DashboardSideMenu: FunctionComponent = ( ); setUnresolvedIncidentStates(unresolvedIncidentStates); } - } catch (err) { + } catch { // maybe show an error message } }; @@ -60,7 +60,7 @@ const DashboardSideMenu: FunctionComponent = ( await AlertStateUtil.getUnresolvedAlertStates(props.project?.id); setUnresolvedAlertStates(unresolvedAlertStates); } - } catch (err) { + } catch { // maybe show an error message } }; diff --git a/Dashboard/src/Pages/Settings/Billing.tsx b/Dashboard/src/Pages/Settings/Billing.tsx index 2b3206f4a0..fb6a23d55b 100644 --- a/Dashboard/src/Pages/Settings/Billing.tsx +++ b/Dashboard/src/Pages/Settings/Billing.tsx @@ -49,7 +49,7 @@ import React, { } from "react"; import useAsyncEffect from "use-async-effect"; -export interface ComponentProps extends PageComponentProps {} +export type ComponentProps = PageComponentProps; const Settings: FunctionComponent = ( _props: ComponentProps, diff --git a/Dashboard/src/Pages/Settings/Invoices.tsx b/Dashboard/src/Pages/Settings/Invoices.tsx index 4398b50512..f29f978c28 100644 --- a/Dashboard/src/Pages/Settings/Invoices.tsx +++ b/Dashboard/src/Pages/Settings/Invoices.tsx @@ -39,7 +39,7 @@ import BillingPaymentMethod from "Common/Models/DatabaseModels/BillingPaymentMet import { LIMIT_PER_PROJECT } from "Common/Types/Database/LimitMax"; import ListResult from "Common/Types/BaseDatabase/ListResult"; -export interface ComponentProps extends PageComponentProps {} +export type ComponentProps = PageComponentProps; const Settings: FunctionComponent = ( _props: ComponentProps, diff --git a/Dashboard/src/Pages/Settings/MonitorSecrets.tsx b/Dashboard/src/Pages/Settings/MonitorSecrets.tsx index 6ce8032085..3cdbb62d28 100644 --- a/Dashboard/src/Pages/Settings/MonitorSecrets.tsx +++ b/Dashboard/src/Pages/Settings/MonitorSecrets.tsx @@ -212,7 +212,7 @@ const MonitorSecrets: FunctionComponent< }); setCurrentlyEditingItem(null); - } catch (err) { + } catch { // do nothing } diff --git a/Dashboard/src/Pages/Settings/UsageHistory.tsx b/Dashboard/src/Pages/Settings/UsageHistory.tsx index bf7c233f62..13253dc80f 100644 --- a/Dashboard/src/Pages/Settings/UsageHistory.tsx +++ b/Dashboard/src/Pages/Settings/UsageHistory.tsx @@ -13,7 +13,7 @@ import TelemetryService from "Common/Models/DatabaseModels/TelemetryService"; import TelemetryUsageBilling from "Common/Models/DatabaseModels/TelemetryUsageBilling"; import React, { Fragment, FunctionComponent, ReactElement } from "react"; -export interface ComponentProps extends PageComponentProps {} +export type ComponentProps = PageComponentProps; const Settings: FunctionComponent = ( _props: ComponentProps, diff --git a/E2E/Tests/Accounts/Register.spec.ts b/E2E/Tests/Accounts/Register.spec.ts index 9415024fb1..6f912f656f 100644 --- a/E2E/Tests/Accounts/Register.spec.ts +++ b/E2E/Tests/Accounts/Register.spec.ts @@ -22,7 +22,7 @@ test.describe("Account Registration", () => { try { // reload page if it fails to load dashboardPageResult = await page.reload(); - } catch (e) { + } catch { // reload page if it fails to load dashboardPageResult = await page.goto( URL.fromString(BASE_URL.toString()).addRoute("/dashboard").toString(), @@ -40,7 +40,7 @@ test.describe("Account Registration", () => { try { // reload page if it fails to load pageResult = await page.reload(); - } catch (e) { + } catch { // reload page if it fails to load pageResult = await page.goto( URL.fromString(BASE_URL.toString()) diff --git a/FluentIngest/API/FluentIngest.ts b/FluentIngest/API/FluentIngest.ts index 82c61316a2..08d490c832 100644 --- a/FluentIngest/API/FluentIngest.ts +++ b/FluentIngest/API/FluentIngest.ts @@ -99,7 +99,7 @@ router.post( // check if its parseable to json try { logItem = JSON.parse(logItem); - } catch (err) { + } catch { // do nothing } } diff --git a/MCP/Service/ModelAPI.ts b/MCP/Service/ModelAPI.ts index f3e6ccce38..f80398a098 100644 --- a/MCP/Service/ModelAPI.ts +++ b/MCP/Service/ModelAPI.ts @@ -23,8 +23,8 @@ export class ModelAPIHttpResponse< public miscData?: JSONObject | undefined; } -export interface ListResult - extends BaseListResult {} +export type ListResult = + BaseListResult; export default interface RequestOptions { requestHeaders?: Dictionary | undefined; diff --git a/Probe/Utils/Monitors/MonitorTypes/SslMonitor.ts b/Probe/Utils/Monitors/MonitorTypes/SslMonitor.ts index 927c7cec4e..db708f2b53 100644 --- a/Probe/Utils/Monitors/MonitorTypes/SslMonitor.ts +++ b/Probe/Utils/Monitors/MonitorTypes/SslMonitor.ts @@ -130,7 +130,7 @@ export default class SSLMonitor { port, rejectUnauthorized: true, }); - } catch (err) { + } catch { try { certificate = await this.getCertificate({ host, diff --git a/Scripts/TerraformProvider/GenerateProvider.ts b/Scripts/TerraformProvider/GenerateProvider.ts index 9c670824dd..1438bf4bf8 100644 --- a/Scripts/TerraformProvider/GenerateProvider.ts +++ b/Scripts/TerraformProvider/GenerateProvider.ts @@ -107,7 +107,7 @@ settings: try { execSync(generateCommand, { stdio: "inherit" }); Logger.info("✅ Terraform provider generated successfully"); - } catch (error: any) { + } catch { Logger.error("❌ Provider generation failed with tfplugingen-openapi"); Logger.info( "🔄 Trying alternative approach with direct Go generation...", diff --git a/StatusPage/Serve.ts b/StatusPage/Serve.ts index 364e289b44..d3a0bde4fc 100644 --- a/StatusPage/Serve.ts +++ b/StatusPage/Serve.ts @@ -99,7 +99,7 @@ const init: PromiseVoidFunction = async (): Promise => { "Status Page lets you see real-time information about the status of our services.", faviconUrl: `/status-page-api/favicon/${statusPageIdOrDomain}`, }; - } catch (err) { + } catch { return { title: "Status Page", description: diff --git a/StatusPage/src/Components/Banner/Banner.tsx b/StatusPage/src/Components/Banner/Banner.tsx index 845e741cfe..b289af160e 100644 --- a/StatusPage/src/Components/Banner/Banner.tsx +++ b/StatusPage/src/Components/Banner/Banner.tsx @@ -18,7 +18,9 @@ const Banner: FunctionComponent = (
{ - props.onClick && props.onClick(); + if (props.onClick) { + props.onClick(); + } }} className="rounded-xl w-full mt-5 mb-5" file={props.file} diff --git a/StatusPage/src/Pages/Subscribe/SlackSubscribe.tsx b/StatusPage/src/Pages/Subscribe/SlackSubscribe.tsx index c8728d474e..311e74e611 100644 --- a/StatusPage/src/Pages/Subscribe/SlackSubscribe.tsx +++ b/StatusPage/src/Pages/Subscribe/SlackSubscribe.tsx @@ -33,7 +33,7 @@ import { GetReactElementFunction } from "Common/UI/Types/FunctionTypes"; import SubscriberUtil from "Common/UI/Utils/StatusPage"; import FormValues from "Common/UI/Components/Forms/Types/FormValues"; -export interface ComponentProps extends SubscribePageProps {} +export type ComponentProps = SubscribePageProps; const SubscribePage: FunctionComponent = ( props: ComponentProps, diff --git a/Worker/DataMigrations/AddTelemetryServiceColor.ts b/Worker/DataMigrations/AddTelemetryServiceColor.ts index 10e80b72ba..e304e68604 100644 --- a/Worker/DataMigrations/AddTelemetryServiceColor.ts +++ b/Worker/DataMigrations/AddTelemetryServiceColor.ts @@ -29,16 +29,16 @@ export default class AddTelemetryServiceColor extends DataMigrationBase { for (const service of services) { if (!service.serviceColor) { - (service.serviceColor = ArrayUtil.selectItemByRandom(BrightColors)), - await TelemetryServiceService.updateOneById({ - id: service.id!, - data: { - serviceColor: service.serviceColor, - }, - props: { - isRoot: true, - }, - }); + service.serviceColor = ArrayUtil.selectItemByRandom(BrightColors); + await TelemetryServiceService.updateOneById({ + id: service.id!, + data: { + serviceColor: service.serviceColor, + }, + props: { + isRoot: true, + }, + }); } } }