Skip to content

Commit

Permalink
Get rid of ESLint warnings in the build
Browse files Browse the repository at this point in the history
Either by fixing them or by adding them to the long list of locally
disabled ones, when fixing them is too complicated for now.

May contain traces of formatting related nitpicks.
  • Loading branch information
JulianKniephoff committed May 23, 2024
1 parent e6d61ff commit 5ee5694
Show file tree
Hide file tree
Showing 17 changed files with 88 additions and 99 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { initialFormValuesNewThemes } from "../../../../configs/modalConfig";
import { usePageFunctions } from "../../../../hooks/wizardHooks";
import { NewThemeSchema } from "../../../../utils/validate";
import { useAppDispatch } from "../../../../store";
import { Details, postNewTheme } from "../../../../slices/themeSlice";
import { postNewTheme } from "../../../../slices/themeSlice";

/**
* This component manages the pages of the new theme wizard and the submission of values
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import RenderDate from "../../../shared/RenderDate";
import RenderMultiField from "../../../shared/wizard/RenderMultiField";
import RenderField from "../../../shared/wizard/RenderField";
import { getUserInformation } from "../../../../selectors/userInfoSelectors";
import { getCurrentLanguageInformation, hasAccess, isJson } from "../../../../utils/utils";
import { hasAccess, isJson } from "../../../../utils/utils";
import { getMetadataCollectionFieldName } from "../../../../utils/resourceUtils";
import { useAppSelector } from "../../../../store";

Expand All @@ -31,8 +31,6 @@ const DetailsMetadataTab: React.FC<{
const { t } = useTranslation();

const user = useAppSelector(state => getUserInformation(state));
// Get info about the current language and its date locale
const currentLanguage = getCurrentLanguageInformation();

// @ts-expect-error TS(7006): Parameter 'values' implicitly has an 'any' type.
const handleSubmit = (values) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ const EventDetailsAssetAttachmentDetails = ({
}
</td>
<td>
{/* eslint-disable-next-line jsx-a11y/anchor-has-content */}
<a
className="fa fa-external-link"
href={attachment.url}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ const EventDetailsAssetCatalogDetails = ({
}
</td>
<td>
{/* eslint-disable-next-line jsx-a11y/anchor-has-content */}
<a className="fa fa-external-link" href={catalog.url} />
</td>
</tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ const EventDetailsAssetPublicationDetails = ({
}
</td>
<td>
{/* eslint-disable-next-line jsx-a11y/anchor-has-content */}
<a
className="fa fa-external-link"
href={publication.url}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ const EventDetailsAssetsAddAsset = ({
{" "}
{translateOverrideFallback(asset, t)}
<span className="ui-helper-hidden">
{ // eslint-disable-next-line react/jsx-no-comment-textnodes
} ({asset.type} "{asset.flavorType}//
{/* eslint-disable-next-line react/jsx-no-comment-textnodes */}
({asset.type} "{asset.flavorType}//
{asset.flavorSubType}")
</span>
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ const EventDetailsPublicationTab = ({
</div>

{publication.enabled ? (
// eslint-disable-next-line jsx-a11y/anchor-has-content
<a className="play" href={publication.url} />
) : (
<span style={styleSpan}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ const NewAssetUploadPage = <T extends RequiredFormProps>({
{" "}
{translateOverrideFallback(asset, t)}
<span className="ui-helper-hidden">
{ // eslint-disable-next-line react/jsx-no-comment-textnodes
} ({asset.type} "{asset.flavorType}//
{/* eslint-disable-next-line react/jsx-no-comment-textnodes */}
({asset.type} "{asset.flavorType}//
{asset.flavorSubType}")
</span>
</td>
Expand Down
1 change: 1 addition & 0 deletions src/components/events/partials/modals/StartTaskModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ const StartTaskModal = ({
// eslint-disable-next-line react-hooks/rules-of-hooks
useEffect(() => {
formik.validateForm().then();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [page]);

return (
Expand Down
8 changes: 4 additions & 4 deletions src/components/events/partials/wizards/NewEventSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ const NewEventSummary = <T extends RequiredFormProps>({
<td>
{asset.translate}
<span className="ui-helper-hidden">
{ // eslint-disable-next-line react/jsx-no-comment-textnodes
} ({asset.type} "{asset.flavorType}//
{/* eslint-disable-next-line react/jsx-no-comment-textnodes */}
({asset.type} "{asset.flavorType}//
{asset.flavorSubType}")
</span>
</td>
Expand Down Expand Up @@ -165,8 +165,8 @@ const NewEventSummary = <T extends RequiredFormProps>({
<td>
{translateOverrideFallback(asset, t, "SHORT")}
<span className="ui-helper-hidden">
{ // eslint-disable-next-line react/jsx-no-comment-textnodes
} ({asset.type} "{asset.flavorType}//
{/* eslint-disable-next-line react/jsx-no-comment-textnodes */}
({asset.type} "{asset.flavorType}//
{asset.flavorSubType}")
</span>
</td>
Expand Down
3 changes: 1 addition & 2 deletions src/components/shared/TableFilterProfiles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { getFilterProfiles } from "../../selectors/tableFilterProfilesSelectors"
import {
cancelEditFilterProfile,
createFilterProfile,
editFilterProfile,
removeFilterProfile,
} from "../../slices/tableFilterProfilesSlice";
import { getFilters } from "../../selectors/tableFilterSelectors";
Expand Down Expand Up @@ -43,7 +42,7 @@ const TableFiltersProfiles = ({
// State for helping saving and editing profiles
const [profileName, setProfileName] = useState("");
const [profileDescription, setProfileDescription] = useState("");
const [currentlyEditing, setCurrentlyEditing] = useState("");
const [, setCurrentlyEditing] = useState("");
const [validName, setValidName] = useState(false);

const { t } = useTranslation();
Expand Down
65 changes: 31 additions & 34 deletions src/components/shared/TableFilters.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { createRef, useRef, useState } from "react";
import React, { useRef, useState } from "react";
import { useTranslation } from "react-i18next";
import { connect } from "react-redux";
import { DatePicker } from "@mui/x-date-pickers/DatePicker";
Expand Down Expand Up @@ -307,41 +307,39 @@ const TableFilters = ({
{/* Show for each selected filter a blue label containing its name and option */}
{/* @ts-expect-error TS(7006): Parameter 'filter' implicitly has an 'any' type. */}
{filterMap.map((filter, key) => {
if (!!filter.value) {
return (
<span className="ng-multi-value" key={key}>
<span>
{
// Use different representation of name and value depending on type of filter
filter.type === "select" ? (
renderBlueBox(filter)
) : filter.type === "period" ? (
return filter.value && (
<span className="ng-multi-value" key={key}>
<span>
{
// Use different representation of name and value depending on type of filter
filter.type === "select" ? (
renderBlueBox(filter)
) : filter.type === "period" ? (
<span>
<span>
<span>
{t(filter.label).substr(0, 40)}:
{t("dateFormats.date.short", {
date: new Date(filter.value.split("/")[0]),
})}
-
{t("dateFormats.date.short", {
date: new Date(filter.value.split("/")[1]),
})}
</span>
{t(filter.label).substr(0, 40)}:
{t("dateFormats.date.short", {
date: new Date(filter.value.split("/")[0]),
})}
-
{t("dateFormats.date.short", {
date: new Date(filter.value.split("/")[1]),
})}
</span>
) : null
}
</span>
{/* Remove icon in blue area around filter */}
<button
title={t("TABLE_FILTERS.REMOVE")}
onClick={() => removeFilter(filter)}
className="button-like-anchor"
>
<i className="fa fa-times" />
</button>
</span>
) : null
}
</span>
);
}
{/* Remove icon in blue area around filter */}
<button
title={t("TABLE_FILTERS.REMOVE")}
onClick={() => removeFilter(filter)}
className="button-like-anchor"
>
<i className="fa fa-times" />
</button>
</span>
);
})}
</div>

Expand Down Expand Up @@ -525,7 +523,6 @@ const FilterSwitch = ({
// This should never happen
default:
return null;

}
};

Expand Down
11 changes: 3 additions & 8 deletions src/components/shared/TimeSeriesStatistics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,6 @@ const TimeSeriesStatistics = ({
// @ts-expect-error TS(7031): Binding element 'chartOptions' implicitly has an '... Remove this comment to see the full error message
chartOptions,
}) => {
// Style for date picker
const datePickerStyle = {
border: "1px solid #dedddd",
borderRadius: "4px",
marginLeft: "3px",
marginRight: "5px",
};

// Style for radio buttons
const radioButtonStyle = {
backgroundColor: "whitesmoke",
Expand Down Expand Up @@ -212,6 +204,7 @@ const TimeSeriesStatistics = ({
<div className="statistics-graph">
{/* download link for a statistic file */}
<div className="download">
{/* eslint-disable-next-line jsx-a11y/anchor-has-content */}
<a
className="download-icon"
href={exportUrl}
Expand Down Expand Up @@ -265,6 +258,7 @@ const TimeSeriesStatistics = ({
formik.values.timeMode === "month") && (
/* year/month selection for statistic via previous and next buttons */
<span className="preset">
{/* eslint-disable-next-line jsx-a11y/anchor-has-content, jsx-a11y/anchor-is-valid */}
<a
className="navigation prev"
onClick={() =>
Expand All @@ -282,6 +276,7 @@ const TimeSeriesStatistics = ({
formik.values.timeMode
)}
</div>
{/* eslint-disable-next-line jsx-a11y/anchor-has-content, jsx-a11y/anchor-is-valid */}
<a
className="navigation next"
onClick={() =>
Expand Down
76 changes: 36 additions & 40 deletions src/components/shared/wizard/RenderField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,49 +183,45 @@ const EditableDateValue = ({
showCheck,
// @ts-expect-error TS(7031):
handleKeyDown
}) => {
const { t } = useTranslation();

return editMode ? (
<div>
<DateTimePicker
name={field.name}
value={typeof field.value === "string" ? parseISO(field.value) : field.value}
onChange={(value) => setFieldValue(field.name, value)}
onClose={() => setEditMode(false)}
slotProps={{
textField: {
fullWidth: true,
onKeyDown: (event) => {
if (event.key === "Enter") {
handleKeyDown(event, "date")
}
},
onBlur: (event) => {
setEditMode(false)
}) => editMode ? (
<div>
<DateTimePicker
name={field.name}
value={typeof field.value === "string" ? parseISO(field.value) : field.value}
onChange={(value) => setFieldValue(field.name, value)}
onClose={() => setEditMode(false)}
slotProps={{
textField: {
fullWidth: true,
onKeyDown: (event) => {
if (event.key === "Enter") {
handleKeyDown(event, "date")
}
},
onBlur: (event) => {
setEditMode(false)
}
}}
/>
</div>
) : (
<div onClick={() => setEditMode(true)} className="show-edit">
<span className="editable preserve-newlines">
<RenderDate date={text} />
</span>
<div>
<i className="edit fa fa-pencil-square" />
{showCheck && (
<i
className={cn("saved fa fa-check", {
active: initialValues[field.name] !== field.value,
})}
/>
)}
</div>
}
}}
/>
</div>
) : (
<div onClick={() => setEditMode(true)} className="show-edit">
<span className="editable preserve-newlines">
<RenderDate date={text} />
</span>
<div>
<i className="edit fa fa-pencil-square" />
{showCheck && (
<i
className={cn("saved fa fa-check", {
active: initialValues[field.name] !== field.value,
})}
/>
)}
</div>
);
};
</div>
);

// renders editable field for selecting value via dropdown
const EditableSingleSelect = ({
Expand Down
3 changes: 1 addition & 2 deletions src/components/shared/wizard/SelectContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ const SelectContainer = ({

// Formik hook for getting data of specific form field
// DON'T delete field and meta, hook works with indices not variable names
// eslint-disable-next-line no-unused-vars
const [field, meta, helpers] = useField(formikField);
const [field, , helpers] = useField(formikField);

// Search field for filter options/items
const [searchField, setSearchField] = useState("");
Expand Down
1 change: 1 addition & 0 deletions src/components/users/partials/wizard/NewUserWizard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ const NewUserWizard = ({
// eslint-disable-next-line react-hooks/rules-of-hooks
useEffect(() => {
formik.validateForm();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [tab]);

return (
Expand Down
1 change: 0 additions & 1 deletion src/utils/bulkActionUtils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Check if an event is scheduled and therefore editable
import { hasDeviceAccess } from "./resourceUtils";
import { NOTIFICATION_CONTEXT } from "../configs/modalConfig";
import { useAppDispatch } from "../store";
import { addNotification } from "../slices/notificationSlice";

// Check if event is scheduled and therefore the schedule is editable
Expand Down

0 comments on commit 5ee5694

Please sign in to comment.