Skip to content

Activate eslint prefer-const #1304

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export default [
"no-tabs": "off",
"no-unused-expressions": "off",
"object-curly-spacing": "off",
"prefer-const": "off",
"quotes": "off",
"semi": "off",
"spaced-comment": "off",
Expand Down
2 changes: 1 addition & 1 deletion src/components/configuration/Themes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const Themes = () => {
loadThemes();

// Fetch themes every minute
let fetchThemesInterval = setInterval(loadThemes, 5000);
const fetchThemesInterval = setInterval(loadThemes, 5000);

return () => {
allowLoadIntoTable = false;
Expand Down
4 changes: 2 additions & 2 deletions src/components/events/Events.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const Events = () => {
const events = useAppSelector(state => getTotalEvents(state));
const isFetchingAssetUploadOptions = useAppSelector(state => getIsFetchingAssetUploadOptions(state));

let location = useLocation();
const location = useLocation();

useEffect(() => {
// State variable for interrupting the load function
Expand Down Expand Up @@ -92,7 +92,7 @@ const Events = () => {
loadEvents();

// Fetch events every five seconds
let fetchEventsInterval = setInterval(() => loadEvents(), 5000);
const fetchEventsInterval = setInterval(() => loadEvents(), 5000);

return () => {
allowLoadIntoTable = false;
Expand Down
4 changes: 2 additions & 2 deletions src/components/events/Series.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const Series = () => {
const newSeriesModalRef = useRef<ModalHandle>(null);
const deleteModalRef = useRef<ModalHandle>(null);

let location = useLocation();
const location = useLocation();

const series = useAppSelector(state => getTotalSeries(state));
const showActions = useAppSelector(state => isShowActions(state));
Expand Down Expand Up @@ -72,7 +72,7 @@ const Series = () => {
loadSeries();

// Fetch series every minute
let fetchSeriesInterval = setInterval(() => loadSeries(), 5000);
const fetchSeriesInterval = setInterval(() => loadSeries(), 5000);

return () => {
allowLoadIntoTable = false;
Expand Down
6 changes: 3 additions & 3 deletions src/components/events/partials/EventsDateCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ const EventsDateCell = ({

// Filter with value of current cell
const addFilter = async (date: string) => {
let filter = filterMap.find(({ name }) => name === "startDate");
const filter = filterMap.find(({ name }) => name === "startDate");
if (!!filter) {
let startDate = new Date(date);
const startDate = new Date(date);
startDate.setHours(0);
startDate.setMinutes(0);
startDate.setSeconds(0);
let endDate = new Date(date);
const endDate = new Date(date);
endDate.setHours(23);
endDate.setMinutes(59);
endDate.setSeconds(59);
Expand Down
2 changes: 1 addition & 1 deletion src/components/events/partials/EventsLocationCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const EventsLocationCell = ({

// Filter with value of current cell
const addFilter = (location: string) => {
let filter = filterMap.find(({ name }) => name === "location");
const filter = filterMap.find(({ name }) => name === "location");
if (!!filter) {
dispatch(editFilterValue({filterName: filter.name, value: location}));
dispatch(fetchEvents());
Expand Down
2 changes: 1 addition & 1 deletion src/components/events/partials/EventsPresentersCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const EventsPresentersCell = ({

// Filter with value of current cell
const addFilter = async (presenter: string) => {
let filter = filterMap.find(
const filter = filterMap.find(
({ name }) => name === "presentersBibliographic"
);
if (!!filter) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/events/partials/EventsSeriesCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const EventsSeriesCell = ({

// Filter with value of current cell
const addFilter = async (seriesId: string) => {
let filter = filterMap.find(({ name }) => name === "series");
const filter = filterMap.find(({ name }) => name === "series");
if (!!filter) {
await dispatch(editFilterValue({filterName: filter.name, value: seriesId}));
await dispatch(fetchEvents());
Expand Down
2 changes: 1 addition & 1 deletion src/components/events/partials/EventsTechnicalDateCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const EventsTechnicalDateCell = ({

// Filter with value of current cell
const addFilter = async (date: string) => {
let filter = filterMap.find(({ name }) => name === "technicalStart");
const filter = filterMap.find(({ name }) => name === "technicalStart");
if (!!filter) {
await dispatch(editFilterValue({filterName: filter.name, value: date + "/" + date}));
await dispatch(fetchEvents());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const DetailsMetadataTab = ({

// set current values of metadata fields as initial values
const getInitialValues = (metadataCatalog: MetadataCatalog) => {
let initialValues: { [key: string]: any } = {};
const initialValues: { [key: string]: any } = {};

// Transform metadata fields and their values provided by backend (saved in redux)
if (!!metadataCatalog.fields && metadataCatalog.fields.length > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ const EditScheduledEventsSummaryPage = <T extends RequiredFormProps>({
}, []);

const checkForChanges = () => {
let changed: Change[] = [];
const changed: Change[] = [];

// Loop through each event selected for editing and compare original values and changed values
for (const event of formik.values.editedEvents) {
let eventChanges: Change = {
const eventChanges: Change = {
eventId: event.eventId,
title: event.title,
changes: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const EventDetailsWorkflowOperations = ({
loadWorkflowOperations().then();

// Fetch workflow operations every 5 seconds
let fetchWorkflowOperationsInterval = setInterval(loadWorkflowOperations, 5000);
const fetchWorkflowOperationsInterval = setInterval(loadWorkflowOperations, 5000);

// Unmount interval
return () => clearInterval(fetchWorkflowOperationsInterval);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const EventDetailsWorkflowTab = ({
}, []);

const isCurrentWorkflow = (workflowId: string) => {
let currentWorkflow = workflows.entries[workflows.entries.length - 1];
const currentWorkflow = workflows.entries[workflows.entries.length - 1];
return currentWorkflow.id === workflowId;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ const NewProcessingPage = <T extends RequiredFormProps>({
};

const setDefaultValues = (value: string) => {
let workflowId = value;
const workflowId = value;
// fill values with default configuration of chosen workflow
let defaultConfiguration = setDefaultConfig(workflowDef, workflowId);
const defaultConfiguration = setDefaultConfig(workflowDef, workflowId);

// set default configuration in formik
formik.setFieldValue("configuration", defaultConfiguration);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ const Schedule = <T extends {

const renderInputDeviceOptions = () => {
if (!!formik.values.location) {
let inputDevice = inputDevices.find(
const inputDevice = inputDevices.find(
({ name }) => name === formik.values.location
);
if (!inputDevice) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ const StartTaskWorkflowPage = <T extends RequiredFormProps>({
}, [workflowDef]);

const setDefaultValues = (value: string) => {
let workflowId = value;
const workflowId = value;
// fill values with default configuration of chosen workflow
let defaultConfiguration = setDefaultConfig(workflowDef, workflowId);
const defaultConfiguration = setDefaultConfig(workflowDef, workflowId);

// set default configuration in formik
formik.setFieldValue("configuration", defaultConfiguration);
Expand Down
4 changes: 2 additions & 2 deletions src/components/events/partials/modals/DeleteEventsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const DeleteEventsModal = ({
const onChangeAllSelected = (e: React.ChangeEvent<HTMLInputElement>) => {
const selected = e.target.checked;
setAllChecked(selected);
let changedSelection = selectedEvents.map((event) => {
const changedSelection = selectedEvents.map((event) => {
return {
...event,
selected: selected,
Expand All @@ -46,7 +46,7 @@ const DeleteEventsModal = ({
// Handle change of checkboxes indicating which events to consider further
const onChangeSelected = (e: React.ChangeEvent<HTMLInputElement>, id: string) => {
const selected = e.target.checked;
let changedEvents = selectedEvents.map((event) => {
const changedEvents = selectedEvents.map((event) => {
if (isEvent(event) && event.id === id) {
return {
...event,
Expand Down
8 changes: 4 additions & 4 deletions src/components/events/partials/modals/DeleteSeriesModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ const DeleteSeriesModal = ({
useEffect(() => {
async function fetchData() {
// Query from backend if deletion of series with events allowed
let response = await getSeriesConfig();
const response = await getSeriesConfig();
setDeleteWithSeriesAllowed(response);

// Check for each selected series if it has events
let series = [];
const series = [];
for (let i = 0; i < selectedSeries.length; i++) {
const selectedSeriesInThisLoop = selectedSeries[i];
const events = isSeries(selectedSeriesInThisLoop) ? await hasEvents(selectedSeriesInThisLoop.id.toString()) : false;
Expand All @@ -74,7 +74,7 @@ const DeleteSeriesModal = ({
const onChangeAllSelected = (e: React.ChangeEvent<HTMLInputElement>) => {
const selected = e.target.checked;
setAllChecked(selected);
let changedSelection = selectedSeries.map((series) => {
const changedSelection = selectedSeries.map((series) => {
return {
...series,
selected: selected,
Expand All @@ -86,7 +86,7 @@ const DeleteSeriesModal = ({
// Handle change of checkboxes indicating which series to consider further
const onChangeSelected = (e: React.ChangeEvent<HTMLInputElement>, id: string) => {
const selected = e.target.checked;
let changedSeries = selectedSeries.map((series) => {
const changedSeries = selectedSeries.map((series) => {
if (isSeries(series) && series.id === id) {
return {
...series,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const EditMetadataEventsModal = ({
async function fetchData() {
setLoading(true);

let eventIds: string[] = [];
const eventIds: string[] = [];
selectedEvents.forEach((event) => isEvent(event) && eventIds.push(event.id));

// Get merged metadata from backend
Expand All @@ -64,7 +64,7 @@ const EditMetadataEventsModal = ({
.then(unwrapResult)
.then((result) => {
// Set initial values and save metadata field infos in state
let initialValues = getInitialValues(result.mergedMetadata);
const initialValues = getInitialValues(result.mergedMetadata);
setFetchedValues(initialValues);
setMetadataFields({
merged: result.merged,
Expand All @@ -90,8 +90,8 @@ const EditMetadataEventsModal = ({
};

const onChangeSelected = (e: React.ChangeEvent<HTMLInputElement>, fieldId: string) => {
let selected = e.target.checked;
let fields = metadataFields;
const selected = e.target.checked;
const fields = metadataFields;
fields.mergedMetadata = metadataFields.mergedMetadata.map((field) => {
if (field.id === fieldId) {
return {
Expand All @@ -112,16 +112,16 @@ const EditMetadataEventsModal = ({
return true;
}

let fetched = fetchedValues[field.id];
let inForm = formikValues[field.id];
const fetched = fetchedValues[field.id];
const inForm = formikValues[field.id];
let same = false;
if (fetched === inForm) {
same = true;
} else if (Array.isArray(fetched) && Array.isArray(inForm)) {
same = fetched.length === inForm.length && fetched.every((e, i) => e === inForm[i]);
}
if (!same) {
let fields = metadataFields;
const fields = metadataFields;
fields.mergedMetadata = metadataFields.mergedMetadata.map((f) => {
if (f.id === field.id) {
return {
Expand Down Expand Up @@ -299,7 +299,7 @@ const EditMetadataEventsModal = ({

const getInitialValues = (metadataFields: MetadataFieldSelected[]) => {
// Transform metadata fields provided by backend (saved in redux)
let initialValues: { [key: string]: string | string[] } = {};
const initialValues: { [key: string]: string | string[] } = {};
metadataFields.forEach((field) => {
initialValues[field.id] = field.value;
});
Expand Down
14 changes: 7 additions & 7 deletions src/components/events/partials/modals/EmbeddingCodeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ const EmbeddingCodeModal = ({
useEffect(() => {
const fetchData = async () => {
// get source url
let sourceURL = await getSourceURL();
const sourceURL = await getSourceURL();

setSourceURL(sourceURL);
};
fetchData();
}, []);

const copy = () => {
let copyText = document.getElementById("social_embed-textarea") as HTMLTextAreaElement;
const copyText = document.getElementById("social_embed-textarea") as HTMLTextAreaElement;
if (copyText) {
copyText.select();
document.execCommand("copy");
Expand All @@ -42,14 +42,14 @@ const EmbeddingCodeModal = ({

const updateTextArea = (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {
// chosen frame size
let frameSize = e.currentTarget.textContent;
const frameSize = e.currentTarget.textContent;

if (!frameSize) {
return;
}

// buttons containing possible frame sizes
let embedSizeButtons = document.getElementsByClassName("embedSizeButton");
const embedSizeButtons = document.getElementsByClassName("embedSizeButton");

// iterate through embedSizeButtons and mark the chosen size
if (frameSize) {
Expand All @@ -62,12 +62,12 @@ const EmbeddingCodeModal = ({
}
}
// split frameSize to be used in iFrameString
let size = frameSize.split("x");
const size = frameSize.split("x");

// build whole url
let url = sourceURL + "/play/" + eventId;
const url = sourceURL + "/play/" + eventId;
// code displayed in text area containing the iFrame to copy
let iFrameString = `<iframe allowfullscreen src="${url}"
const iFrameString = `<iframe allowfullscreen src="${url}"
style="border: 0; margin 0;" name="Player" scrolling="no"
width="${size[0]}" height="${size[1]}"></iframe>`
.replace(/\s\s+/g, ' ');
Expand Down
4 changes: 2 additions & 2 deletions src/components/events/partials/wizards/NewEventSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ const NewEventSummary = <T extends RequiredFormProps>({

// upload asset that user has provided
useEffect(() => {
let uploadAssetsNonTrack: {
const uploadAssetsNonTrack: {
name: string,
translate?: string,
value: any,
}[] = [];
for (let i = 0; uploadAssetOptions.length > i; i++) {
let fieldValue = formik.values[uploadAssetOptions[i].id];
const fieldValue = formik.values[uploadAssetOptions[i].id];
if (!!fieldValue) {
const displayOverride = uploadAssetOptions[i].displayOverride as ParseKeys
setUploadAssetsNonTrack(uploadAssetsNonTrack.concat({
Expand Down
2 changes: 1 addition & 1 deletion src/components/events/partials/wizards/NewEventWizard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ const NewEventWizard = ({
setSnapshot(values);

// set page as completely filled out
let updatedPageCompleted = pageCompleted;
const updatedPageCompleted = pageCompleted;
updatedPageCompleted[page] = true;
setPageCompleted(updatedPageCompleted);

Expand Down
2 changes: 1 addition & 1 deletion src/components/events/partials/wizards/NewSeriesWizard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ const NewSeriesWizard = ({
setSnapshot(values);

// set page as completely filled out
let updatedPageCompleted = pageCompleted;
const updatedPageCompleted = pageCompleted;
updatedPageCompleted[page] = true;
setPageCompleted(updatedPageCompleted);

Expand Down
2 changes: 1 addition & 1 deletion src/components/shared/DropDown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ const DropDown = <T, >({
};


let commonProps: Props = {
const commonProps: Props = {
tabIndex: tabIndex,
theme: (theme) => (dropDownSpacingTheme(theme)),
styles: style,
Expand Down
2 changes: 1 addition & 1 deletion src/components/shared/MainNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const MainNav = ({
toggleMenu: () => void,
}) => {
const { t } = useTranslation();
let navigate = useNavigate();
const navigate = useNavigate();

const orgProperties = useAppSelector(state => getOrgProperties(state));

Expand Down
2 changes: 1 addition & 1 deletion src/components/shared/RegistrationModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const RegistrationModalContent = () => {
};

const fetchRegistrationInfos = async () => {
let registrationInfo = await fetchAdopterRegistration();
const registrationInfo = await fetchAdopterRegistration();

// merge response into initial values for formik
setInitialValues({...initialValues, ...registrationInfo});
Expand Down
Loading
Loading