From d4bbeb6e27738d0ced34857ba6ef27ca8a19d5a7 Mon Sep 17 00:00:00 2001 From: EmmaLRussell Date: Fri, 15 Sep 2023 10:37:10 +0100 Subject: [PATCH] more lint warnings eliminated --- app/static/src/app/components/WodinPlot.vue | 2 ++ app/static/src/app/components/fit/FitTab.vue | 6 +++--- .../app/components/mixins/includeConfiguredTabs.ts | 10 ++++++++-- .../src/app/components/options/OptionsTab.vue | 6 +++--- .../src/app/components/options/ParameterSetView.vue | 3 ++- app/static/src/app/components/run/RunPlot.vue | 4 ++-- .../src/app/components/sensitivity/support.ts | 2 +- app/static/src/app/directives/help.ts | 6 +++--- app/static/src/app/directives/tooltip.ts | 13 ++++++++----- app/static/src/app/excel/wodinExcelDownload.ts | 5 +++-- app/static/src/app/plot.ts | 2 +- app/static/src/app/router.ts | 7 +++++-- app/static/src/app/serialise.ts | 10 +++++----- app/static/src/app/store/model/getters.ts | 2 +- app/static/src/app/types/utilTypes.ts | 2 +- 15 files changed, 48 insertions(+), 32 deletions(-) diff --git a/app/static/src/app/components/WodinPlot.vue b/app/static/src/app/components/WodinPlot.vue index cd05e94ec..81b4f0429 100644 --- a/app/static/src/app/components/WodinPlot.vue +++ b/app/static/src/app/components/WodinPlot.vue @@ -43,6 +43,7 @@ export default defineComponent({ // Only used as an indicator that redraw is required when this changes - the data to display is calculated by // plotData function using these solutions redrawWatches: { + // eslint-disable-next-line @typescript-eslint/no-explicit-any type: Array as PropType, required: true }, @@ -70,6 +71,7 @@ export default defineComponent({ const yAxisRange = computed(() => store.state.graphSettings.yAxisRange as YAxisRange); const updateAxesRange = () => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any const plotLayout = (plot.value as any).layout; const yRange = plotLayout.yaxis?.range; if (plotLayout) { diff --git a/app/static/src/app/components/fit/FitTab.vue b/app/static/src/app/components/fit/FitTab.vue index e2bfa9d77..e0577c0f7 100644 --- a/app/static/src/app/components/fit/FitTab.vue +++ b/app/static/src/app/components/fit/FitTab.vue @@ -26,7 +26,7 @@ diff --git a/app/static/src/app/components/mixins/includeConfiguredTabs.ts b/app/static/src/app/components/mixins/includeConfiguredTabs.ts index 6c17f70ca..ebe070308 100644 --- a/app/static/src/app/components/mixins/includeConfiguredTabs.ts +++ b/app/static/src/app/components/mixins/includeConfiguredTabs.ts @@ -1,8 +1,14 @@ import { Store } from "vuex"; -import { computed } from "vue"; +import { computed, ComputedRef } from "vue"; import { AppState, VisualisationTab } from "../../store/appState/state"; -export default (store: Store, fixedTabNames: string[]) => { +export interface IncludeConfiguredTabsMixin { + helpTabName: ComputedRef, + multiSensitivityTabName: ComputedRef, + rightTabNames: ComputedRef +} + +export default (store: Store, fixedTabNames: string[]): IncludeConfiguredTabsMixin => { const helpTabName = computed(() => { if (store.state.config?.help?.markdown?.length) { return store.state.config.help.tabName || "Explanation"; // default if markdown but no tab name diff --git a/app/static/src/app/components/options/OptionsTab.vue b/app/static/src/app/components/options/OptionsTab.vue index e5b413d0f..b708e3fc5 100644 --- a/app/static/src/app/components/options/OptionsTab.vue +++ b/app/static/src/app/components/options/OptionsTab.vue @@ -30,7 +30,7 @@ diff --git a/app/static/src/app/components/options/ParameterSetView.vue b/app/static/src/app/components/options/ParameterSetView.vue index 617422552..32b6fd209 100644 --- a/app/static/src/app/components/options/ParameterSetView.vue +++ b/app/static/src/app/components/options/ParameterSetView.vue @@ -159,7 +159,8 @@ export default defineComponent({ } }; const saveButton = ref(null); - const cancelEditDisplayName = (event: any) => { + const cancelEditDisplayName = (event: FocusEvent) => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any if (event.relatedTarget && event.relatedTarget === (saveButton.value as any).$el) return; store.commit(`run/${RunMutation.TurnOffDisplayNameError}`, props.parameterSet.name); newDisplayName.value = props.parameterSet.displayName; diff --git a/app/static/src/app/components/run/RunPlot.vue b/app/static/src/app/components/run/RunPlot.vue index 28d39b419..c86f466ec 100644 --- a/app/static/src/app/components/run/RunPlot.vue +++ b/app/static/src/app/components/run/RunPlot.vue @@ -19,7 +19,7 @@ import { } from "../../plot"; import WodinPlot from "../WodinPlot.vue"; import { RunGetter } from "../../store/run/getters"; -import { OdinSolution } from "../../types/responseTypes"; +import { OdinSolution, Times } from "../../types/responseTypes"; import { Dict } from "../../types/utilTypes"; import { runPlaceholderMessage } from "../../utils"; import { ParameterSet } from "../../store/run/state"; @@ -88,7 +88,7 @@ export default defineComponent({ Object.keys(parameterSetSolutions.value).forEach((name) => { const paramSetSln = parameterSetSolutions.value[name]; - const paramSetResult = paramSetSln!(options as any); + const paramSetResult = paramSetSln!(options as Times); const dash = lineStylesForParamSets.value[name]; if (paramSetResult) { diff --git a/app/static/src/app/components/sensitivity/support.ts b/app/static/src/app/components/sensitivity/support.ts index e4fcde5bb..46b38d0b0 100644 --- a/app/static/src/app/components/sensitivity/support.ts +++ b/app/static/src/app/components/sensitivity/support.ts @@ -22,7 +22,7 @@ export const sensitivityUpdateRequiredExplanation = (reasons: SensitivityUpdateR return `${prefix} ${joinStringsSentence(explanation)}. ${help.suffix(multiSens)}.`; }; -export const verifyValidPlotSettingsTime = (state: AppState, commit: Commit) => { +export const verifyValidPlotSettingsTime = (state: AppState, commit: Commit): void => { // update plot settings' end time to be valid before we use it const { plotSettings } = state.sensitivity; let endTime = plotSettings.time; diff --git a/app/static/src/app/directives/help.ts b/app/static/src/app/directives/help.ts index a16fa8559..8bdbaf389 100644 --- a/app/static/src/app/directives/help.ts +++ b/app/static/src/app/directives/help.ts @@ -11,13 +11,13 @@ const getHelpBinding = (binding: DirectiveBinding) => { }; export default { - mounted(el: HTMLElement, binding: DirectiveBinding) { + mounted(el: HTMLElement, binding: DirectiveBinding): void { tooltip.mounted(el, getHelpBinding(binding)); }, - beforeUpdate(el: HTMLElement, binding: DirectiveBinding) { + beforeUpdate(el: HTMLElement, binding: DirectiveBinding): void { tooltip.beforeUpdate(el, getHelpBinding(binding)); }, - beforeUnmount(el: HTMLElement) { + beforeUnmount(el: HTMLElement): void { tooltip.beforeUnmount(el); } }; diff --git a/app/static/src/app/directives/tooltip.ts b/app/static/src/app/directives/tooltip.ts index c6e737f60..cce8089b8 100644 --- a/app/static/src/app/directives/tooltip.ts +++ b/app/static/src/app/directives/tooltip.ts @@ -10,7 +10,7 @@ export interface ToolTipSettings { } export default { - mounted(el: HTMLElement, binding: DirectiveBinding) { + mounted(el: HTMLElement, binding: DirectiveBinding): void { const { value } = binding; el.setAttribute("data-bs-toggle", "tooltip"); @@ -38,7 +38,7 @@ export default { }); } }, - beforeUpdate(el: HTMLElement, binding: DirectiveBinding) { + beforeUpdate(el: HTMLElement, binding: DirectiveBinding): void { const { value } = binding; let tooltip = Tooltip.getInstance(el); @@ -47,6 +47,7 @@ export default { const variant = value?.variant || "text"; const oldCustomClass = (variant === "text") ? "" : `tooltip-${variant}`; + // eslint-disable-next-line @typescript-eslint/no-explicit-any const isVariantSame = (tooltip as any)._config.customClass === oldCustomClass; if (!isVariantSame) { tooltip.dispose(); @@ -67,8 +68,10 @@ export default { : value?.content || ""; if (tooltip) { - (tooltip as any)._config.title = content; - const { trigger } = (tooltip as any)._config; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const configuredTooltip = tooltip as any; + configuredTooltip._config.title = content; + const { trigger } = configuredTooltip._config; if (trigger === "manual") { if (!content) { tooltip.hide(); @@ -78,7 +81,7 @@ export default { } } }, - beforeUnmount(el: HTMLElement) { + beforeUnmount(el: HTMLElement): void { const tooltip = Tooltip.getInstance(el); if (tooltip) { tooltip.dispose(); diff --git a/app/static/src/app/excel/wodinExcelDownload.ts b/app/static/src/app/excel/wodinExcelDownload.ts index 44c915a75..3e289bef9 100644 --- a/app/static/src/app/excel/wodinExcelDownload.ts +++ b/app/static/src/app/excel/wodinExcelDownload.ts @@ -9,6 +9,7 @@ export abstract class WodinExcelDownload { protected readonly _state: AppState; + // eslint-disable-next-line @typescript-eslint/no-explicit-any protected readonly _rootGetters: any; protected readonly _commit: Commit; @@ -23,7 +24,7 @@ export abstract class WodinExcelDownload { this._workbook = XLSX.utils.book_new(); } - protected _addParameters(excludeParams: string[] = []) { + protected _addParameters(excludeParams: string[] = []): void { const paramVals = this._state.run.parameterValues; if (paramVals) { const paramData = Object.keys(paramVals) @@ -36,7 +37,7 @@ export abstract class WodinExcelDownload { } } - protected _writeFile(buildWorkbook: () => void) { + protected _writeFile(buildWorkbook: () => void): void { try { buildWorkbook(); XLSX.writeFile(this._workbook, this._fileName); diff --git a/app/static/src/app/plot.ts b/app/static/src/app/plot.ts index 5423cb93c..efe8b25a2 100644 --- a/app/static/src/app/plot.ts +++ b/app/static/src/app/plot.ts @@ -164,7 +164,7 @@ const lineStyles = ["dot", "dash", "longdash", "dashdot", "longdashdot"]; export const paramSetLineStyle = (index: number): string => (lineStyles[index % lineStyles.length]); export const updatePlotTraceName = (plotTrace: Partial, param: string | null, value: number | null, - parameterSetName = "") => { + parameterSetName = ""): void => { const parenthesisItems = []; if (param && value) { parenthesisItems.push(`${param}=${format(".3f")(value)}`); diff --git a/app/static/src/app/router.ts b/app/static/src/app/router.ts index 5250931fb..7799a2cce 100644 --- a/app/static/src/app/router.ts +++ b/app/static/src/app/router.ts @@ -1,7 +1,10 @@ -import { createRouter, createWebHistory, RouteComponent } from "vue-router"; +import { + createRouter, createWebHistory, RouteComponent, Router +} from "vue-router"; import SessionsPage from "./components/sessions/SessionsPage.vue"; -export function initialiseRouter(appComponent: RouteComponent, appName: string, baseUrl: string, appsPath: string) { +export function initialiseRouter(appComponent: RouteComponent, appName: string, baseUrl: string, + appsPath: string): Router { // Remove any sessionId parameter from url const url = window.location.href; if (url.includes("sessionId=")) { diff --git a/app/static/src/app/serialise.ts b/app/static/src/app/serialise.ts index 6413448dd..d3ef18cc6 100644 --- a/app/static/src/app/serialise.ts +++ b/app/static/src/app/serialise.ts @@ -11,7 +11,7 @@ import { SerialisedAppState, SerialisedModelState, SerialisedRunState, SerialisedSensitivityState, - SerialisedRunResult, SerialisedSensitivityResult + SerialisedRunResult, SerialisedSensitivityResult, SerialisedModelFitState } from "./types/serialisationTypes"; import { GraphSettingsState } from "./store/graphSettings/state"; import { Dict } from "./types/utilTypes"; @@ -107,7 +107,7 @@ function serialiseFitData(fitData: FitDataState) : FitDataState { }; } -function serialiseModelFit(modelFit: ModelFitState) { +function serialiseModelFit(modelFit: ModelFitState): SerialisedModelFitState { return { fitUpdateRequired: modelFit.fitUpdateRequired, iterations: modelFit.iterations, @@ -118,11 +118,11 @@ function serialiseModelFit(modelFit: ModelFitState) { }; } -export const serialiseGraphSettings = (state: GraphSettingsState) => { +export const serialiseGraphSettings = (state: GraphSettingsState): GraphSettingsState => { return { ...state }; }; -export const serialiseState = (state: AppState) => { +export const serialiseState = (state: AppState): string => { const result: SerialisedAppState = { openVisualisationTab: state.openVisualisationTab, code: serialiseCode(state.code), @@ -141,7 +141,7 @@ export const serialiseState = (state: AppState) => { return JSON.stringify(result); }; -export const deserialiseState = (targetState: AppState, serialised: SerialisedAppState) => { +export const deserialiseState = (targetState: AppState, serialised: SerialisedAppState): void => { Object.assign(targetState, { ...targetState, ...serialised diff --git a/app/static/src/app/store/model/getters.ts b/app/static/src/app/store/model/getters.ts index 96357b49a..0ad9c20c3 100644 --- a/app/static/src/app/store/model/getters.ts +++ b/app/static/src/app/store/model/getters.ts @@ -11,7 +11,7 @@ export interface ModelGetters { } export const getters: ModelGetters & GetterTree = { - [ModelGetter.hasRunner]: (state: ModelState, _: any, rootState: AppState): boolean => { + [ModelGetter.hasRunner]: (state: ModelState, _: ModelGetters, rootState: AppState): boolean => { return (rootState.appType === AppType.Stochastic) ? !!state.odinRunnerDiscrete : !!state.odinRunnerOde; } }; diff --git a/app/static/src/app/types/utilTypes.ts b/app/static/src/app/types/utilTypes.ts index 4d5d84ad9..a749966a5 100644 --- a/app/static/src/app/types/utilTypes.ts +++ b/app/static/src/app/types/utilTypes.ts @@ -2,5 +2,5 @@ import { ActionContext } from "vuex"; export type Dict = { [k: string]: V } -/* eslint-disable @typescript-eslint/no-explicit-any */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any export type AppCtx = ActionContext;