Skip to content

Commit

Permalink
Apply a bunch of eslint suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
mthh committed Jan 6, 2025
1 parent dc93d5c commit 860da3a
Show file tree
Hide file tree
Showing 13 changed files with 79 additions and 88 deletions.
2 changes: 1 addition & 1 deletion src/components/LeftMenu/LayerManagerItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ export function LayerManagerLayerItem(props: LayerDescription): JSX.Element {
<button
aria-label={LL().LayerManager.Settings()}
class="unstyled"
onClick={(e) => {
onClick={() => {
onClickSettings(props.id, LL);
}}
title={LL().LayerManager.Settings()}
Expand Down
17 changes: 10 additions & 7 deletions src/components/MapZone.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -459,18 +459,18 @@ export default function MapZone(): JSX.Element {
clearTimeout(resetTimeout);
// Clone the clicked SVG element and add it on top of the others
// with a slightly modified style
svgElem.getElementById('cloned-feature')?.remove();
svgElem!.getElementById('cloned-feature')?.remove();
const clone = element.cloneNode(true) as SVGElement & ID3Element;
clone.id = 'cloned-feature';
clone.style.stroke = 'red';
clone.style.strokeWidth = '3px';
clone.style.fill = 'none';
svgElem.appendChild(clone);
svgElem!.appendChild(clone);
// Get the layer name for the clicked feature
let targetGroup = element as SVGElement;
let i = 0;
while (targetGroup.parentElement && i < 7) {
targetGroup = targetGroup.parentElement! as SVGElement;
targetGroup = targetGroup.parentElement;
if (targetGroup.classList.contains('layer')) break;
i += 1;
}
Expand Down Expand Up @@ -504,7 +504,7 @@ export default function MapZone(): JSX.Element {
}, delay);
};

const onMouseMoveInfo = (e) => {
const onMouseMoveInfo = (e: MouseEvent) => {
const element = document.elementFromPoint(e.clientX, e.clientY);
if (!element) return;
let it = 0;
Expand All @@ -516,7 +516,7 @@ export default function MapZone(): JSX.Element {
resetInfoFeature();
return;
}
targetElement = targetElement.parentElement;
targetElement = targetElement.parentElement as never;
it += 1;
}
// eslint-disable-next-line no-underscore-dangle
Expand Down Expand Up @@ -558,7 +558,10 @@ export default function MapZone(): JSX.Element {
// the values used in the transform attribute up to now
// and remove the transform attribute from the elements on
// which it was defined).
const applyZoomPan = (e: MouseEvent & d3.D3ZoomEvent<any, any>, redraw: boolean) => {
const applyZoomPan = (
e: MouseEvent & d3.D3ZoomEvent<SVGSVGElement, unknown>,
redraw: boolean,
) => {
if (!redraw) {
const t = e.transform.toString();
// We just change the transform attribute of the layers
Expand Down Expand Up @@ -611,7 +614,7 @@ export default function MapZone(): JSX.Element {
// is set to the identity transform, so that the zoom/pan
// does not change the map.
// eslint-disable-next-line no-underscore-dangle, no-param-reassign
svgElem.__zoom = d3.zoomIdentity;
svgElem!.__zoom = d3.zoomIdentity;
} else {
// Otherwise we apply the zoom/pan
applyZoomPan(e, false);
Expand Down
24 changes: 12 additions & 12 deletions src/components/Modals/ClassificationPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,12 @@ function ManualBreaks(
breaks: newBreaks,
});
}}
onChange={function (e) {
onChange={(e) => {
// We don't want to update the breaks if the user is typing
// a number that is not a valid number or if the value is superior
// to the next break or inferior to the previous break.
const value = +e.target.value;
const self = e.currentTarget;
if (
!isFiniteNumber(value)
|| (i() < props.currentBreaksInfo.breaks.length - 1
Expand All @@ -158,7 +159,7 @@ function ManualBreaks(
&& value <= props.currentBreaksInfo.breaks[i() - 1])
) {
// eslint-disable-next-line no-param-reassign
this.value = round(b, props.statSummary.precision);
self.value = `${round(b, props.statSummary.precision)}`;
return;
}
// If this is the first break value, we accept values inferior to the minimum
Expand All @@ -176,7 +177,7 @@ function ManualBreaks(
breaks: newBreaks,
});
// eslint-disable-next-line no-param-reassign
this.value = round(props.statSummary.minimum, props.statSummary.precision);
self.value = `${round(props.statSummary.minimum, props.statSummary.precision)}`;
} else if (
isGreaterThan(value, props.statSummary.minimum, props.statSummary.precision)
) {
Expand All @@ -190,7 +191,7 @@ function ManualBreaks(
breaks: newBreaks,
});
// eslint-disable-next-line no-param-reassign
this.value = round(props.statSummary.minimum, props.statSummary.precision);
self.value = `${round(props.statSummary.minimum, props.statSummary.precision)}`;
// Inform the user that the series should be covered
// and that we adjusted the breaks
displayWarningDontCoverSeries();
Expand All @@ -212,7 +213,7 @@ function ManualBreaks(
breaks: newBreaks,
});
// eslint-disable-next-line no-param-reassign
this.value = round(props.statSummary.maximum, props.statSummary.precision);
self.value = `${round(props.statSummary.maximum, props.statSummary.precision)}`;
} else if (
isLessThan(value, props.statSummary.maximum, props.statSummary.precision)
) {
Expand All @@ -226,7 +227,7 @@ function ManualBreaks(
breaks: newBreaks,
});
// eslint-disable-next-line no-param-reassign
this.value = round(props.statSummary.maximum, props.statSummary.precision);
self.value = `${round(props.statSummary.maximum, props.statSummary.precision)}`;
// Inform the user that the series should be covered
// and that we adjusted the breaks
displayWarningDontCoverSeries();
Expand Down Expand Up @@ -316,13 +317,13 @@ function CustomPaletteCreation(
'font-size': '0.7rem',
}}
value={c}
onChange={function (e) {
onChange={(e) => {
if (!/^#[0-9a-f]{6}$/i.test(e.target.value)) {
// Display an error to the user, we need only colors
toast.error(LL().ClassificationPanel.inputColorInvalid());
// Rollback to the previous value
// eslint-disable-next-line no-param-reassign
this.value = c;
e.currentTarget.value = c;
return;
}
// If the color is valid, we update the colors to take it
Expand Down Expand Up @@ -551,14 +552,14 @@ export default function ClassificationPanel(): JSX.Element {
.map((d) => ({
name: `${d.name} (${d.provider})`,
value: d.name,
prefixImage: PaletteThumbnails[`img${d.provider}${d.name}`] as string,
prefixImage: PaletteThumbnails[`img${d.provider}${d.name}` as never] as string,
}));

const availableDivergingPalettes = getPalettes({ type: 'diverging', number: 8 })
.map((d) => ({
name: `${d.name} (${d.provider})`,
value: d.name,
prefixImage: PaletteThumbnails[`img${d.provider}${d.name}`] as string,
prefixImage: PaletteThumbnails[`img${d.provider}${d.name}` as never] as string,
}));

// Signals for the current component:
Expand Down Expand Up @@ -664,7 +665,6 @@ export default function ClassificationPanel(): JSX.Element {
});

let refParentNode: HTMLDivElement;
let refTextArea: HTMLTextAreaElement;

const entriesClassificationMethod = [
{
Expand Down Expand Up @@ -727,7 +727,7 @@ export default function ClassificationPanel(): JSX.Element {
? (event.key === 'Escape' || event.key === 'Esc')
: (event.keyCode === 27);
if (isEscape) {
(refParentNode.querySelector(
(refParentNode!.querySelector(
'.classification-panel__cancel-button',
) as HTMLElement).click();
}
Expand Down
10 changes: 6 additions & 4 deletions src/components/Modals/JoinModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const checkJoin = async (
};

// For each table field value
tableFieldValues.forEach((v, i) => {
tableFieldValues.forEach((v) => {
// If the value is null
if (v === null) {
result.nNoDataTable += 1;
Expand All @@ -103,7 +103,7 @@ const checkJoin = async (
});

// For each layer field value
layerFieldValues.forEach((v, i) => {
layerFieldValues.forEach((v) => {
// If the value is null
if (v === null) {
result.nNoDataLayer += 1;
Expand Down Expand Up @@ -323,7 +323,7 @@ export default function JoinPanel(
const [selectedFields, setSelectedFields] = createSignal<string[]>([]);

onMount(() => {
refSuccessButton = refJoinPanel.parentElement!.parentElement!.parentElement!
refSuccessButton = refJoinPanel!.parentElement!.parentElement!.parentElement!
.querySelector('.button.is-success')! as HTMLButtonElement;

refSuccessButton.disabled = true;
Expand Down Expand Up @@ -498,7 +498,9 @@ export default function JoinPanel(
<div class="has-text-centered">
<MultipleSelect
onChange={(e) => {
setSelectedFields(Array.from(e.target.selectedOptions).map((d: any) => d.value));
setSelectedFields(
Array.from(e.target.selectedOptions).map((d: HTMLOptionElement) => d.value),
);
}}
size={tableDescription.fields.length}
values={selectedFields()}
Expand Down
26 changes: 13 additions & 13 deletions src/components/Modals/LayerSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ function makeSettingsLabels(
<InputFieldSelect
disabled={true}
label={LL().LayerSettings.PortrayedVariable()}
onChange={(v) => {}}
onChange={() => {}}
value={props.rendererParameters.variable}
>
<option value={props.rendererParameters.variable}>{props.rendererParameters.variable}</option>
Expand Down Expand Up @@ -409,7 +409,7 @@ function makeSettingsLabels(
<InputFieldSelect
disabled={true}
label={LL().LayerSettings.VariableForProportionality()}
onChange={(v) => {}}
onChange={() => {}}
value={props.rendererParameters.proportional!.variable}
>
<option value={props.rendererParameters.proportional!.variable}>
Expand Down Expand Up @@ -806,7 +806,7 @@ function makeSettingsDefaultPoint(
<InputFieldSelect
disabled={true}
label={LL().FunctionalitiesSection.ProportionalSymbolsOptions.SymbolType()}
onChange={(v) => {}}
onChange={() => {}}
value={(props.rendererParameters as ProportionalSymbolsParameters).symbolType}
>
<option value={ProportionalSymbolsSymbolType.circle}>
Expand Down Expand Up @@ -1148,7 +1148,7 @@ function makeSettingsDefaultPoint(
disabled={
layerLinkedToHistogramOrBarChart(props, layersDescriptionStore.layoutFeaturesAndLegends)
}
onChange={(v) => {
onChange={() => {
const legendPosition = getPossibleLegendPosition(300, 250);

setLayersDescriptionStoreBase(
Expand Down Expand Up @@ -1201,7 +1201,7 @@ function makeSettingsDefaultPoint(
disabled={
layerLinkedToHistogramOrBarChart(props, layersDescriptionStore.layoutFeaturesAndLegends)
}
onChange={(v) => {
onChange={() => {
const legendPosition = getPossibleLegendPosition(300, 250);

setLayersDescriptionStoreBase(
Expand Down Expand Up @@ -1256,7 +1256,7 @@ function makeSettingsDefaultPoint(
disabled={
layerLinkedToHistogramOrBarChart(props, layersDescriptionStore.layoutFeaturesAndLegends)
}
onChange={(v) => {
onChange={() => {
const legendPosition = getPossibleLegendPosition(300, 250);

setLayersDescriptionStoreBase(
Expand Down Expand Up @@ -1310,7 +1310,7 @@ function makeSettingsDefaultPoint(
disabled={
layerLinkedToHistogramOrBarChart(props, layersDescriptionStore.layoutFeaturesAndLegends)
}
onChange={(v) => {
onChange={() => {
const legendPosition = getPossibleLegendPosition(300, 250);

setLayersDescriptionStoreBase(
Expand Down Expand Up @@ -1797,7 +1797,7 @@ function makeSettingsDefaultLine(
disabled={
layerLinkedToHistogramOrBarChart(props, layersDescriptionStore.layoutFeaturesAndLegends)
}
onChange={(v) => {
onChange={() => {
const legendPosition = getPossibleLegendPosition(300, 250);

setLayersDescriptionStoreBase(
Expand Down Expand Up @@ -1850,7 +1850,7 @@ function makeSettingsDefaultLine(
disabled={
layerLinkedToHistogramOrBarChart(props, layersDescriptionStore.layoutFeaturesAndLegends)
}
onChange={(v) => {
onChange={() => {
const legendPosition = getPossibleLegendPosition(300, 250);

setLayersDescriptionStoreBase(
Expand Down Expand Up @@ -1903,7 +1903,7 @@ function makeSettingsDefaultLine(
disabled={
layerLinkedToHistogramOrBarChart(props, layersDescriptionStore.layoutFeaturesAndLegends)
}
onChange={(v) => {
onChange={() => {
const legendPosition = getPossibleLegendPosition(300, 250);

setLayersDescriptionStoreBase(
Expand Down Expand Up @@ -1959,7 +1959,7 @@ function makeSettingsDefaultLine(
disabled={
layerLinkedToHistogramOrBarChart(props, layersDescriptionStore.layoutFeaturesAndLegends)
}
onChange={(v) => {
onChange={() => {
const legendPosition = getPossibleLegendPosition(300, 250);

setLayersDescriptionStoreBase(
Expand Down Expand Up @@ -2167,7 +2167,7 @@ function makeSettingsDefaultPolygon(
disabled={
layerLinkedToHistogramOrBarChart(props, layersDescriptionStore.layoutFeaturesAndLegends)
}
onChange={(v) => {
onChange={() => {
const legendPosition = getPossibleLegendPosition(300, 250);

setLayersDescriptionStoreBase(
Expand Down Expand Up @@ -2217,7 +2217,7 @@ function makeSettingsDefaultPolygon(
disabled={
layerLinkedToHistogramOrBarChart(props, layersDescriptionStore.layoutFeaturesAndLegends)
}
onChange={(v) => {
onChange={() => {
const legendPosition = getPossibleLegendPosition(300, 250);

setLayersDescriptionStoreBase(
Expand Down
Loading

0 comments on commit 860da3a

Please sign in to comment.