Skip to content

Activate eslint no-extra-boolean-cast #1302

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 @@ -17,7 +17,6 @@ export default [
"indent": "off",
"keyword-spacing": "off",
"max-len": "off",
"no-extra-boolean-cast": "off",
"no-tabs": "off",
"no-unused-expressions": "off",
"object-curly-spacing": "off",
Expand Down
2 changes: 1 addition & 1 deletion src/components/events/partials/EventActionCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const EventActionCell = ({
};

const onClickSeriesDetails = async () => {
if (!!row.series) {
if (row.series) {
await dispatch(fetchSeriesDetailsMetadata(row.series.id));
await dispatch(fetchSeriesDetailsAcls(row.series.id));
await dispatch(fetchSeriesDetailsTheme(row.series.id));
Expand Down
2 changes: 1 addition & 1 deletion src/components/events/partials/EventsDateCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const EventsDateCell = ({
// Filter with value of current cell
const addFilter = async (date: string) => {
let filter = filterMap.find(({ name }) => name === "startDate");
if (!!filter) {
if (filter) {
let startDate = new Date(date);
startDate.setHours(0);
startDate.setMinutes(0);
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 @@ -22,7 +22,7 @@ const EventsLocationCell = ({
// Filter with value of current cell
const addFilter = (location: string) => {
let filter = filterMap.find(({ name }) => name === "location");
if (!!filter) {
if (filter) {
dispatch(editFilterValue({filterName: filter.name, value: location}));
dispatch(fetchEvents());
dispatch(loadEventsIntoTable());
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 @@ -24,7 +24,7 @@ const EventsPresentersCell = ({
let filter = filterMap.find(
({ name }) => name === "presentersBibliographic"
);
if (!!filter) {
if (filter) {
await dispatch(editFilterValue({filterName: filter.name, value: presenter}));
await dispatch(fetchEvents());
dispatch(loadEventsIntoTable());
Expand Down
4 changes: 2 additions & 2 deletions src/components/events/partials/EventsSeriesCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ const EventsSeriesCell = ({
// Filter with value of current cell
const addFilter = async (seriesId: string) => {
let filter = filterMap.find(({ name }) => name === "series");
if (!!filter) {
if (filter) {
await dispatch(editFilterValue({filterName: filter.name, value: seriesId}));
await dispatch(fetchEvents());
dispatch(loadEventsIntoTable());
}
};

return (
!!row.series ? (
row.series ? (
// Link template for series of event
<IconButton
callback={() => row.series
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 @@ -25,7 +25,7 @@ const EventsTechnicalDateCell = ({
// Filter with value of current cell
const addFilter = async (date: string) => {
let filter = filterMap.find(({ name }) => name === "technicalStart");
if (!!filter) {
if (filter) {
await dispatch(editFilterValue({filterName: filter.name, value: date + "/" + date}));
await dispatch(fetchEvents());
dispatch(loadEventsIntoTable());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ const DetailsTobiraTab = ({ kind, id }: DetailsTobiraTabProps) => {
}

const openSubTab = async (tabType: TobiraTabHierarchy, currentPage?: TobiraPage) => {
if (!!currentPage) {
if (currentPage) {
const breadcrumbs = getBreadcrumbs(currentPage);
// Breadcrumbs always include at least the homepage, so the length is at least 1.
const hostPage = breadcrumbs[breadcrumbs.length - 1];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const EventDetailsAssetMediaDetails = () => {
}
</td>
<td>
{!!media.duration
{media.duration
? formatDuration(media.duration)
: null}
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const EventDetailsPublicationTab = ({
<li key={key}>
<div className="v-container">
<span className="icon-container">
{!!publication.icon ? (
{publication.icon ? (
<i
className="custom-icon"
style={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,11 @@ const EventDetailsSchedulingTab = ({
// finds the inputs to be displayed in the formik
const getInputs = (deviceId: Recording["id"]) => {
if (deviceId === source.device.id) {
return !!source.device.inputs ? source.device.inputs : [];
return source.device.inputs ? source.device.inputs : [];
} else {
for (const agent of filterDevicesForAccess(user, captureAgents)) {
if (agent.id === deviceId) {
return !!agent.inputs ? agent.inputs : [];
return agent.inputs ? agent.inputs : [];
}
}
return [];
Expand Down Expand Up @@ -213,7 +213,7 @@ const EventDetailsSchedulingTab = ({
const startDate = new Date(source.start.date);
const endDate = new Date(source.end.date);

const inputs = !!source.device.inputMethods
const inputs = source.device.inputMethods
? Array.from(source.device.inputMethods)
: [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const NewMetadataPage = ({
</td>
{field.readOnly ? (
// non-editable field if readOnly is set or user doesn't have edit access rights
!!field.collection ? (
field.collection ? (
<td>{getMetadataCollectionFieldName(field, field, t)}</td>
) : (
<td>{field.value}</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ const Schedule = <T extends {
const currentLanguage = getCurrentLanguageInformation();

const renderInputDeviceOptions = () => {
if (!!formik.values.location) {
if (formik.values.location) {
let inputDevice = inputDevices.find(
({ name }) => name === formik.values.location
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ const NewTobiraPage = <T extends TobiraFormProps>({
</td>
</Tooltip>
<td>
{!!page.new
{page.new
? <input
placeholder={t('EVENTS.SERIES.NEW.TOBIRA.PAGE_TITLE')}
disabled={checkboxActive(page, key)}
Expand All @@ -295,7 +295,7 @@ const NewTobiraPage = <T extends TobiraFormProps>({
</td>
<td>
<code className="tobira-path">
{!!page.new
{page.new
? <input
placeholder={t('EVENTS.SERIES.NEW.TOBIRA.PATH_SEGMENT')}
value={page.segment ?? ""}
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 @@ -74,11 +74,11 @@ const NewEventSummary = <T extends RequiredFormProps>({
}[] = [];
for (let i = 0; uploadAssetOptions.length > i; i++) {
let fieldValue = formik.values[uploadAssetOptions[i].id];
if (!!fieldValue) {
if (fieldValue) {
const displayOverride = uploadAssetOptions[i].displayOverride as ParseKeys
setUploadAssetsNonTrack(uploadAssetsNonTrack.concat({
name: uploadAssetOptions[i].id,
translate: !!displayOverride
translate: displayOverride
? t(displayOverride)
: translateOverrideFallback(uploadAssetOptions[i], t),
value: fieldValue,
Expand Down Expand Up @@ -157,7 +157,7 @@ const NewEventSummary = <T extends RequiredFormProps>({
{/*Insert row for each upload asset of type track user has provided*/}
{/* @ts-expect-error TS(7006): Parameter 'asset' implicitly has an 'any' type. */}
{formik.values.uploadAssetsTrack.map((asset, key) =>
!!asset.file ? (
asset.file ? (
<tr key={key}>
<td>
{translateOverrideFallback(asset, t, "SHORT")}
Expand Down Expand Up @@ -279,7 +279,7 @@ const NewEventSummary = <T extends RequiredFormProps>({
<tr>
<td>{t("EVENTS.EVENTS.NEW.PROCESSING.WORKFLOW")}</td>
<td>
{!!workflowDefinition ? workflowDefinition.title : ""}
{workflowDefinition ? workflowDefinition.title : ""}
</td>
</tr>
{/* Repeat entry for each configuration key/value pair */}
Expand Down
8 changes: 4 additions & 4 deletions src/components/events/partials/wizards/NewEventWizard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -285,24 +285,24 @@ const getInitialValues = (
}

// Transform additional metadata for source (provided by constant in newEventConfig)
if (!!sourceMetadata.UPLOAD) {
if (sourceMetadata.UPLOAD) {
sourceMetadata.UPLOAD.metadata.forEach((field) => {
initialValues[field.id] = field.value;
});
}
if (!!sourceMetadata.SCHEDULE_SINGLE) {
if (sourceMetadata.SCHEDULE_SINGLE) {
sourceMetadata.SCHEDULE_SINGLE.metadata.forEach((field) => {
initialValues[field.id] = field.value;
});
}
if (!!sourceMetadata.SCHEDULE_MULTIPLE) {
if (sourceMetadata.SCHEDULE_MULTIPLE) {
sourceMetadata.SCHEDULE_MULTIPLE.metadata.forEach((field) => {
initialValues[field.id] = field.value;
});
}

// Add possible files that can be uploaded in source step
if (!!uploadSourceOptions) {
if (uploadSourceOptions) {
initialValues.uploadAssetsTrack = [];
// Sort by displayOrder
uploadSourceOptions = uploadSourceOptions.slice().sort((a, b) => a.displayOrder - b.displayOrder)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ const RenderField = <T extends RequiredFormProps>({
}) => {
// id used for Field and label
const uuid = uuidv4();
const disabled = !!field.disabled ? field.disabled : false;
const disabled = field.disabled ? field.disabled : false;

const renderField = () => {
return(
Expand Down
4 changes: 2 additions & 2 deletions src/components/shared/Stats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const Stats = () => {
}
let filter = filterMap.find(({ name }) => name === f.name);
filterValue = f.value;
if (!!filter) {
if (filter) {
dispatch(editFilterValue({filterName: filter.name, value: filterValue}));
}
});
Expand Down Expand Up @@ -70,7 +70,7 @@ const Stats = () => {
<h1>{st.count}</h1>
{/* Show the description of the status, if defined,
else show name of filter and its value*/}
{!!st.description ? (
{st.description ? (
<span>{t(st.description as ParseKeys)}</span>
) : (
st.filters.map((filter, key) => (
Expand Down
2 changes: 1 addition & 1 deletion src/components/shared/TableFilters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ const TableFilters = ({
// and the filter selections are cleared
if (name === "secondFilter") {
let filter = filterMap.find(({ name }) => name === selectedFilter);
if (!!filter) {
if (filter) {
dispatch(editFilterValue({filterName: filter.name, value: value}));
setFilterSelector(false);
dispatch(removeSelectedFilter());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ export const TemplateSelector = <T extends TemplateSelectorProps>({
aclTemplates,
formik.values.aclTemplate
)}
options={!!aclTemplates ? formatAclTemplatesForDropdown(aclTemplates) : []}
options={aclTemplates ? formatAclTemplatesForDropdown(aclTemplates) : []}
required={true}
handleChange={(element) => {
if (element) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/shared/wizard/WizardNavigationButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const WizardNavigationButtons = <T, >({
isSubmitDisabled={disabled}
nextPage={
isLast
? () => { !!submitPage ? submitPage() : formik.handleSubmit(); }
? () => { submitPage ? submitPage() : formik.handleSubmit(); }
: () => { !!nextPage && nextPage(formik.values); }
}
previousPage={
Expand Down
10 changes: 5 additions & 5 deletions src/slices/eventDetailsSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,7 @@ export const fetchSchedulingInfo = createAppAsyncThunk('eventDetails/fetchSchedu
const agent = captureAgents.find(
(agent) => agent.id === schedulingResponse.agentId
);
if (!!agent) {
if (agent) {
let inputMethods = [];

if (
Expand Down Expand Up @@ -1083,7 +1083,7 @@ export const saveSchedulingInfo = createAppAsyncThunk('eventDetails/saveScheduli
};

const agent = captureAgents.find((agent) => agent.id === values.captureAgent);
if (!!agent) {
if (agent) {
device = {
...agent,
inputMethods: values.inputs,
Expand Down Expand Up @@ -1263,7 +1263,7 @@ export const fetchWorkflows = createAppAsyncThunk('eventDetails/fetchWorkflows',
const workflowsData = await data.data;
let workflows: Workflow;

if (!!workflowsData.results) {
if (workflowsData.results) {
workflows = {
entries: workflowsData.results,
scheduling: false,
Expand Down Expand Up @@ -1381,7 +1381,7 @@ export const deleteWorkflow = createAppAsyncThunk('eventDetails/deleteWorkflow',
const state = getState();
const workflows = getWorkflows(state);

if (!!workflows.entries) {
if (workflows.entries) {
return workflows.entries.filter((wf) => wf.id !== workflowId)
} else {
return workflows.entries;
Expand Down Expand Up @@ -1616,7 +1616,7 @@ export const updateAssets = createAppAsyncThunk('eventDetails/updateAssets', asy
let assetFlavors = "";

uploadAssetOptions.forEach((option) => {
if (!!values[option.id]) {
if (values[option.id]) {
formData.append(option.id + ".0", values[option.id]);
assets.options = assets.options.concat(option);
const uploadAssetFlavor = [option.flavorType, option.flavorSubType].join("/");
Expand Down
8 changes: 4 additions & 4 deletions src/slices/eventSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ export const postNewEvent = createAppAsyncThunk('events/postNewEvent', async (pa
metadata: {
start: startDate,
device: values.location,
inputs: !!values.deviceInputs ? values.deviceInputs.join(",") : "",
inputs: values.deviceInputs ? values.deviceInputs.join(",") : "",
end: endDate,
duration: duration.toString(),
},
Expand Down Expand Up @@ -735,10 +735,10 @@ export const fetchScheduling = createAppAsyncThunk('events/fetchScheduling', asy
eventId: d.eventId,
title: d.agentConfiguration["event.title"],
changedTitle: d.agentConfiguration["event.title"],
series: !!d.agentConfiguration["event.series"]
series: d.agentConfiguration["event.series"]
? d.agentConfiguration["event.series"]
: "",
changedSeries: !!d.agentConfiguration["event.series"]
changedSeries: d.agentConfiguration["event.series"]
? d.agentConfiguration["event.series"]
: "",
location: d.agentConfiguration["event.location"],
Expand Down Expand Up @@ -973,7 +973,7 @@ export const checkForConflicts = async (
device: string,
repeatOn: string[] | undefined = undefined
) => {
let metadata = !!repeatOn
let metadata = repeatOn
? {
start: startDate,
device: device,
Expand Down
6 changes: 3 additions & 3 deletions src/slices/recordingSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ export const fetchRecordings = createAppAsyncThunk('recordings/fetchRecordings',
name: agent.Name,
status: agent.Status,
updated: agent.Update,
inputs: !!agent.inputs ? [...agent.inputs] : [],
roomId: !!agent.roomId ? agent.roomId : "",
inputs: agent.inputs ? [...agent.inputs] : [],
roomId: agent.roomId ? agent.roomId : "",
type: "LOCATION",
url: !!agent.url ? agent.url : "",
url: agent.url ? agent.url : "",
removable:
"AGENTS.STATUS.OFFLINE" === agent.Status ||
"AGENTS.STATUS.UNKNOWN" === agent.Status,
Expand Down
2 changes: 1 addition & 1 deletion src/slices/seriesDetailsSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export const fetchSeriesDetailsAcls = createAppAsyncThunk('seriesDetails/fetchSe
const res = await axios.get(`/admin-ng/series/${id}/access.json`);
const response = res.data;

if (!!response.series_access.locked) {
if (response.series_access.locked) {
dispatch(
addNotification({
type: "warning",
Expand Down
4 changes: 2 additions & 2 deletions src/slices/tableFilterSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export const setSpecificEventFilter = createAppAsyncThunk('tableFilters/setSpeci
await dispatch(fetchFilters("events"));
}

if (!!filterToChange) {
if (filterToChange) {
await dispatch(editFilterValue({
filterName: filterToChange.name,
value: filterValue
Expand All @@ -192,7 +192,7 @@ export const setSpecificServiceFilter = createAppAsyncThunk('tableFilters/setSpe
filterToChange = fetchedFilters.payload.filtersList.find(({ name }: { name: string }) => name === filter);
}

if (!!filterToChange) {
if (filterToChange) {
await dispatch(editFilterValue({
filterName: filterToChange.name,
value: filterValue
Expand Down
2 changes: 1 addition & 1 deletion src/slices/userDetailsSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const userDetailsSlice = createSlice({
state.roles = userDetails.roles;
state.name = userDetails.name;
state.username = userDetails.username;
state.email = !!userDetails.email ? userDetails.email : "";
state.email = userDetails.email ? userDetails.email : "";
state.manageable = userDetails.manageable;
})
.addCase(fetchUserDetails.rejected, (state, action) => {
Expand Down
Loading
Loading