From bccd3117497f23df0601c3f2f379a186c210cdd8 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Thu, 19 Sep 2024 09:27:54 +0200 Subject: [PATCH] front: turn on @typescript-eslint/no-unsafe-call lint Part of https://github.com/OpenRailAssociation/osrd/pull/8772 See https://typescript-eslint.io/rules/no-unsafe-call/ Signed-off-by: Simon Ser --- front/.eslintrc | 1 + .../components/LinearMetadata/FormComponent.tsx | 15 +++++++++++---- .../ChartHelpers/enableInteractivity.tsx | 9 +++++---- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/front/.eslintrc b/front/.eslintrc index 4741908cc51..c2338bce6f5 100644 --- a/front/.eslintrc +++ b/front/.eslintrc @@ -45,6 +45,7 @@ "@typescript-eslint/no-use-before-define": "error", "@typescript-eslint/no-unnecessary-type-assertion": "error", "@typescript-eslint/no-unsafe-return": "error", + "@typescript-eslint/no-unsafe-call": "error", "@typescript-eslint/ban-types": [ "error", diff --git a/front/src/applications/editor/components/LinearMetadata/FormComponent.tsx b/front/src/applications/editor/components/LinearMetadata/FormComponent.tsx index 4c2874faa95..9eca10e8db2 100644 --- a/front/src/applications/editor/components/LinearMetadata/FormComponent.tsx +++ b/front/src/applications/editor/components/LinearMetadata/FormComponent.tsx @@ -41,7 +41,9 @@ export type FormContext = { isCreation: boolean; }; -const IntervalEditorComponent = (props: FieldProps) => { +const IntervalEditorComponent = ( + props: FieldProps +) => { const { name, formContext, formData, schema, onChange, registry } = props; const { openModal, closeModal } = useModal(); const { t } = useTranslation(); @@ -421,7 +423,7 @@ const IntervalEditorComponent = (props: FieldProps) => { +export const FormComponent = (props: FieldProps) => { const { name, formContext, schema, registry } = props; const Fields = getDefaultRegistry().fields; @@ -471,10 +473,15 @@ export const FormComponent = (props: FieldProps)} /> ); - return ; + return ( + )} + schema={jsonSchema} + /> + ); }; export default FormComponent; diff --git a/front/src/modules/simulationResult/components/ChartHelpers/enableInteractivity.tsx b/front/src/modules/simulationResult/components/ChartHelpers/enableInteractivity.tsx index a3a108a1387..bbf8d4bc2ca 100644 --- a/front/src/modules/simulationResult/components/ChartHelpers/enableInteractivity.tsx +++ b/front/src/modules/simulationResult/components/ChartHelpers/enableInteractivity.tsx @@ -1,6 +1,6 @@ import * as d3 from 'd3'; import { pointer } from 'd3-selection'; -import { zoom as d3zoom } from 'd3-zoom'; +import { zoom as d3zoom, type D3ZoomEvent } from 'd3-zoom'; import { mapValues } from 'lodash'; import { @@ -282,8 +282,9 @@ export const enableInteractivity = < ]) .wheelDelta(wheelDelta) // Allows evenements to be triggered on zoom and drag interactions for all graphs - .on('zoom', (event) => { - event.sourceEvent.preventDefault(); + .on('zoom', (event: D3ZoomEvent) => { + const { sourceEvent }: { sourceEvent: Event } = event; + sourceEvent.preventDefault(); const updatedAxis = updateChart(chart, keyValues, additionalValues, rotate, event); // Overide axis with new ones from updated chart const newChart = { @@ -357,7 +358,7 @@ export const enableInteractivity = < chart.svg .on('mouseover', () => displayGuide(chart, 1)) .on('mousemove', mousemove) - .on('wheel', (event) => { + .on('wheel', (event: WheelEvent) => { if (event.ctrlKey || event.shiftKey) { event.preventDefault(); }