Skip to content

Commit

Permalink
Merge pull request #189 from mrc-ide/mrc-4619
Browse files Browse the repository at this point in the history
mrc-4619 Fix eslint warnings
  • Loading branch information
EmmaLRussell authored Sep 21, 2023
2 parents 160f517 + 878bae7 commit 2e02e29
Show file tree
Hide file tree
Showing 23 changed files with 74 additions and 49 deletions.
2 changes: 2 additions & 0 deletions app/static/src/app/components/WodinPlot.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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<any[]>,
required: true
},
Expand Down Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions app/static/src/app/components/fit/FitTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</template>

<script lang="ts">
import { computed } from "vue";
import { computed, defineComponent } from "vue";
import { useStore } from "vuex";
import VueFeather from "vue-feather";
import FitPlot from "./FitPlot.vue";
Expand All @@ -40,7 +40,7 @@ import { fitRequirementsExplanation, fitUpdateRequiredExplanation } from "./supp
import { allTrue, anyTrue } from "../../utils";
import LoadingButton from "../LoadingButton.vue";
export default {
export default defineComponent({
name: "FitTab",
components: {
LoadingSpinner,
Expand Down Expand Up @@ -123,5 +123,5 @@ export default {
iconClass
};
}
};
});
</script>
10 changes: 8 additions & 2 deletions app/static/src/app/components/mixins/includeConfiguredTabs.ts
Original file line number Diff line number Diff line change
@@ -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<AppState>, fixedTabNames: string[]) => {
export interface IncludeConfiguredTabsMixin {
helpTabName: ComputedRef<string | null>,
multiSensitivityTabName: ComputedRef<string | null>,
rightTabNames: ComputedRef<string[]>
}

export default (store: Store<AppState>, 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
Expand Down
6 changes: 3 additions & 3 deletions app/static/src/app/components/options/OptionsTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</template>

<script lang="ts">
import { computed } from "vue";
import { computed, defineComponent } from "vue";
import { useStore } from "vuex";
import VerticalCollapse from "../VerticalCollapse.vue";
import ParameterValues from "./ParameterValues.vue";
Expand All @@ -43,7 +43,7 @@ import GraphSettings from "./GraphSettings.vue";
import ParameterSets from "./ParameterSets.vue";
import AdvancedSettings from "./AdvancedSettings.vue";
export default {
export default defineComponent({
name: "OptionsTab",
components: {
ParameterSets,
Expand Down Expand Up @@ -75,5 +75,5 @@ export default {
fitTabIsOpen
};
}
};
});
</script>
3 changes: 2 additions & 1 deletion app/static/src/app/components/options/ParameterSetView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ export default defineComponent({
}
};
const saveButton = ref<HTMLButtonElement | null>(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;
Expand Down
4 changes: 2 additions & 2 deletions app/static/src/app/components/run/RunPlot.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion app/static/src/app/components/sensitivity/support.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions app/static/src/app/directives/help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ const getHelpBinding = (binding: DirectiveBinding<string>) => {
};

export default {
mounted(el: HTMLElement, binding: DirectiveBinding<string>) {
mounted(el: HTMLElement, binding: DirectiveBinding<string>): void {
tooltip.mounted(el, getHelpBinding(binding));
},
beforeUpdate(el: HTMLElement, binding: DirectiveBinding<string>) {
beforeUpdate(el: HTMLElement, binding: DirectiveBinding<string>): void {
tooltip.beforeUpdate(el, getHelpBinding(binding));
},
beforeUnmount(el: HTMLElement) {
beforeUnmount(el: HTMLElement): void {
tooltip.beforeUnmount(el);
}
};
13 changes: 8 additions & 5 deletions app/static/src/app/directives/tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export interface ToolTipSettings {
}

export default {
mounted(el: HTMLElement, binding: DirectiveBinding<string | ToolTipSettings>) {
mounted(el: HTMLElement, binding: DirectiveBinding<string | ToolTipSettings>): void {
const { value } = binding;

el.setAttribute("data-bs-toggle", "tooltip");
Expand Down Expand Up @@ -38,7 +38,7 @@ export default {
});
}
},
beforeUpdate(el: HTMLElement, binding: DirectiveBinding<string | ToolTipSettings>) {
beforeUpdate(el: HTMLElement, binding: DirectiveBinding<string | ToolTipSettings>): void {
const { value } = binding;

let tooltip = Tooltip.getInstance(el);
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -78,7 +81,7 @@ export default {
}
}
},
beforeUnmount(el: HTMLElement) {
beforeUnmount(el: HTMLElement): void {
const tooltip = Tooltip.getInstance(el);
if (tooltip) {
tooltip.dispose();
Expand Down
5 changes: 3 additions & 2 deletions app/static/src/app/excel/wodinExcelDownload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion app/static/src/app/plot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<PlotData>, param: string | null, value: number | null,
parameterSetName = "") => {
parameterSetName = ""): void => {
const parenthesisItems = [];
if (param && value) {
parenthesisItems.push(`${param}=${format(".3f")(value)}`);
Expand Down
7 changes: 5 additions & 2 deletions app/static/src/app/router.ts
Original file line number Diff line number Diff line change
@@ -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=")) {
Expand Down
16 changes: 10 additions & 6 deletions app/static/src/app/serialise.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@ import { FitDataState } from "./store/fitData/state";
import { ModelFitState } from "./store/modelFit/state";
import { OdinFitResult, OdinRunResultDiscrete, OdinRunResultOde } from "./types/wrapperTypes";
import {
SerialisedAppState, SerialisedModelState,
SerialisedAppState,
SerialisedModelState,
SerialisedRunState,
SerialisedSensitivityState,
SerialisedRunResult, SerialisedSensitivityResult, SerialisedMultiSensitivityState
SerialisedRunResult,
SerialisedSensitivityResult,
SerialisedModelFitState,
SerialisedMultiSensitivityState
} from "./types/serialisationTypes";
import { GraphSettingsState } from "./store/graphSettings/state";
import { Dict } from "./types/utilTypes";
Expand Down Expand Up @@ -121,7 +125,7 @@ function serialiseFitData(fitData: FitDataState) : FitDataState {
};
}

function serialiseModelFit(modelFit: ModelFitState) {
function serialiseModelFit(modelFit: ModelFitState): SerialisedModelFitState {
return {
fitUpdateRequired: modelFit.fitUpdateRequired,
iterations: modelFit.iterations,
Expand All @@ -132,11 +136,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),
Expand All @@ -156,7 +160,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
Expand Down
2 changes: 1 addition & 1 deletion app/static/src/app/store/model/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export interface ModelGetters {
}

export const getters: ModelGetters & GetterTree<ModelState, AppState> = {
[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;
}
};
4 changes: 2 additions & 2 deletions app/static/src/app/store/sensitivity/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export const runSensitivity = (
endTime: number,
context: ActionContext<BaseSensitivityState, AppState>,
multiSensitivity = false
) => {
): void => {
const {
rootState, commit, dispatch, getters, rootGetters
} = context;
Expand Down Expand Up @@ -143,7 +143,7 @@ export const runSensitivity = (
}
};

export const runSensitivityOnRehydrate = (context: ActionContext<BaseSensitivityState, AppState>) => {
export const runSensitivityOnRehydrate = (context: ActionContext<BaseSensitivityState, AppState>): void => {
const { state, rootState } = context;
const { endTime } = rootState.run;
const { pars } = state.result!.inputs;
Expand Down
7 changes: 4 additions & 3 deletions app/static/src/app/store/sensitivity/sensitivity.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import {
SensitivityParameterSettings,
SensitivityPlotExtreme,
SensitivityPlotType,
SensitivityScaleType,
SensitivityState,
SensitivityState, SensitivityUpdateRequiredReasons,
SensitivityVariationType
} from "./state";
import { mutations } from "./mutations";
import { actions } from "./actions";
import { getters } from "./getters";

export const defaultSensitivityParamSettings = () => ({
export const defaultSensitivityParamSettings = (): SensitivityParameterSettings => ({
parameterToVary: null,
scaleType: SensitivityScaleType.Arithmetic,
variationType: SensitivityVariationType.Percentage,
Expand All @@ -20,7 +21,7 @@ export const defaultSensitivityParamSettings = () => ({
customValues: []
});

export const noSensitivityUpdateRequired = () => ({
export const noSensitivityUpdateRequired = (): SensitivityUpdateRequiredReasons => ({
modelChanged: false,
parameterValueChanged: false,
endTimeChanged: false,
Expand Down
2 changes: 1 addition & 1 deletion app/static/src/app/types/utilTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import { ActionContext } from "vuex";

export type Dict<V> = { [k: string]: V }

/* eslint-disable @typescript-eslint/no-explicit-any */
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type AppCtx = ActionContext<any, any>;
13 changes: 7 additions & 6 deletions app/static/src/app/userMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,28 +79,29 @@ export default {
}
},
multiSensitivity: {
runSummary: (solutionCount: number) => `${sensType(true)} run produced ${solutionCount} solutions.`,
runSummary: (solutionCount: number): string => `${sensType(true)} run produced ${solutionCount} solutions.`,
updateReasons: {
prefix: "Status is out of date:"
}
},
sensitivity: {
compileRequiredForOptions: (multiSens: boolean) => "Please compile a valid model in order to set "
compileRequiredForOptions: (multiSens: boolean): string => "Please compile a valid model in order to set "
+ `${sensType(multiSens)} options.`,
compileRequiredForUpdate: (multiSens: boolean) => "Model code has been updated. "
compileRequiredForUpdate: (multiSens: boolean): string => "Model code has been updated. "
+ `Compile code and Run ${sensType(multiSens)} to update.`,
invalidSettings: "Invalid settings",
notRunYet: (multiSens: boolean) => `${sensType(multiSens)} has not been run.`,
notRunYet: (multiSens: boolean): string => `${sensType(multiSens)} has not been run.`,
updateReasons: {
prefix: "Plot is out of date:",
modelChanged: "model code has been recompiled",
parameterValueChanged: "parameters have been changed",
sensitivityOptionsChanged: (multiSens: boolean) => `${sensType(multiSens)} options have been changed`,
sensitivityOptionsChanged:
(multiSens: boolean): string => `${sensType(multiSens)} options have been changed`,
endTimeChanged: "end time has changed",
numberOfReplicatesChanged: "number of replicates has changed",
advancedSettingsChanged: "advanced settings have been changed",
unknown: "unknown reasons, contact the administrator, as this is unexpected",
suffix: (multiSens: boolean) => `Run ${sensType(multiSens)} to update`
suffix: (multiSens: boolean): string => `Run ${sensType(multiSens)} to update`
}
},
sessions: {
Expand Down
Loading

0 comments on commit 2e02e29

Please sign in to comment.