Skip to content

Commit

Permalink
Merge pull request #6245 from espoon-voltti/eslint-eqeqeq-rule
Browse files Browse the repository at this point in the history
Eslint-sääntö: vaaditaan triple equals käyttö
  • Loading branch information
Joosakur authored Jan 15, 2025
2 parents 706c146 + 7e74add commit 27a20e8
Show file tree
Hide file tree
Showing 56 changed files with 78 additions and 79 deletions.
3 changes: 2 additions & 1 deletion frontend/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ export default [
'no-console': ['error', { allow: ['warn', 'error'] }],
'prefer-arrow-callback': ['error', { allowNamedFunctions: true }],
'arrow-body-style': ['error', 'as-needed'],
'no-constant-binary-expression': ['error']
'no-constant-binary-expression': ['error'],
eqeqeq: ['error', 'smart']
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/citizen-frontend/api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ if (isAutomatedTest) {
}

client.interceptors.response.use(undefined, async (err: AxiosError) => {
if (err.response && err.response.status == 401) {
if (err.response && err.response.status === 401) {
window.location.replace('/')
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ export default React.memo(function ChildApplicationsBlock({
)}
</FixedSpaceFlexWrap>

{index != applicationSummaries.length - 1 && <LineBreak />}
{index !== applicationSummaries.length - 1 && <LineBreak />}
</React.Fragment>
)
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default React.memo(function ApplicationReadViewContents({
const { user } = useContext(AuthContext)

const userIsApplicationGuardian = user
.map((u) => u && u.id == application.guardianId)
.map((u) => u && u.id === application.guardianId)
.getOrElse(false)

return (
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/citizen-frontend/calendar/AbsenceModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function initialFormState(
maxDate: LocalDate
): StateOf<typeof absenceForm> {
const selectedChildren =
availableChildren.length == 1 ? [availableChildren[0].id] : []
availableChildren.length === 1 ? [availableChildren[0].id] : []
const range =
initialDate !== undefined
? { startDate: initialDate, endDate: initialDate }
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/citizen-frontend/calendar/AttendanceInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function AttendanceInfoWithServiceUsage({
const usageFromMonthlyAverage = usedService.usedServiceRanges.length === 0
const attendanceWarning = usageFromMonthlyAverage
? i18n.calendar.calculatedUsedServiceTime
: simpleExceedWarning != ''
: simpleExceedWarning !== ''
? simpleExceedWarning
: i18n.calendar.exceedGeneric
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const HoursMinutes = ({ minutes }: { minutes: number }) => {
return '-'
}
return `${hours > 0 ? `${hours} ${i18n.calendar.monthSummary.hours}` : ''}${
extraMinutes != 0
extraMinutes !== 0
? ` ${extraMinutes} ${i18n.calendar.monthSummary.minutes}`
: ''
}`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export default React.memo(function AssistanceDecision({
{sortBy(assistanceLevels)
.map((level, i) => {
const text = t.decisions.assistanceDecisions.level[level]
return i == 0 ? text : text.toLocaleLowerCase()
return i === 0 ? text : text.toLocaleLowerCase()
})
.join(', ')}
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export function fromBody(

if (
gross === invalid ||
entrepreneur == invalid ||
entrepreneur === invalid ||
(!gross && !entrepreneur)
) {
return null
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/citizen-frontend/map/MapView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,13 @@ const filterAndSortUnits = (
)
.filter(
(u) =>
languages.length == 0 ||
languages.length === 0 ||
(!(u.language === 'fi' && !languages.includes('fi')) &&
!(u.language === 'sv' && !languages.includes('sv')))
)
.filter(
(u) =>
providerTypes.length == 0 ||
providerTypes.length === 0 ||
(!(
(u.providerType === 'MUNICIPAL' ||
u.providerType === 'MUNICIPAL_SCHOOL') &&
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/e2e-test/dev-api/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ const uniqueLabel = (l = 7): string =>
export const uuidv4 = (): string =>
'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
const r = (Math.random() * 16) | 0,
v = c == 'x' ? r : (r & 0x3) | 0x8
v = c === 'x' ? r : (r & 0x3) | 0x8
return v.toString(16)
})

Expand Down
4 changes: 2 additions & 2 deletions frontend/src/e2e-test/pages/citizen/citizen-header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export default class CitizenHeader {

async assertUnreadChildrenCount(expectedCount: number) {
await this.#childrenNav.waitUntilVisible()
if (expectedCount != 0) {
if (expectedCount !== 0) {
await this.#unreadChildrenCount.assertTextEquals(expectedCount.toString())
} else {
await waitUntilFalse(() => this.#unreadChildrenCount.visible)
Expand All @@ -153,7 +153,7 @@ export default class CitizenHeader {
const notification = this.page.findByDataQa(
`children-menu-${childId}-notification-count`
)
if (expectedCount != 0) {
if (expectedCount !== 0) {
await notification.assertText(
(text) => text === expectedCount.toString()
)
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/employee-frontend/api/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ if (isAutomatedTest) {
}

client.interceptors.response.use(undefined, async (err: AxiosError) => {
if (err.response && err.response.status == 401) {
if (err.response && err.response.status === 401) {
const event = new LoginStatusChangeEvent(false)
window.dispatchEvent(event)

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/employee-frontend/components/UnitPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ const UnitPage = React.memo(function UnitPage({ id }: { id: DaycareId }) {
Object.keys(openGroups)
.reduce(
(prev: string[], cur: string) =>
openGroups[cur] == true ? prev.concat(cur) : prev,
openGroups[cur] ? prev.concat(cur) : prev,
[]
)
.join(',')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@ export default React.memo(function ApplicationEditView({
)
)
}
disabled={i == 0}
disabled={i === 0}
data-qa="button-move-up-preferred-unit"
/>
<Button
Expand All @@ -755,7 +755,7 @@ export default React.memo(function ApplicationEditView({
)
)
}
disabled={i == preferredUnits.length - 1}
disabled={i === preferredUnits.length - 1}
data-qa="button-move-down-preferred-unit"
/>
<Button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export default React.memo(function ApplicationFilters() {
setApplicationSearchFilters({
...applicationSearchFilters,
basis: applicationSearchFilters.basis.includes(toggledBasis)
? applicationSearchFilters.basis.filter((v) => v != toggledBasis)
? applicationSearchFilters.basis.filter((v) => v !== toggledBasis)
: [...applicationSearchFilters.basis, toggledBasis]
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ export default React.memo(function PedagogicalDocuments({
modifiedAt={pedagogicalDocument.modifiedAt}
modifiedBy={pedagogicalDocument.modifiedBy}
initInEditMode={
uiMode ==
uiMode ===
`edit-pedagogical-document-${pedagogicalDocument.id}`
}
onReload={loadData}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ const DecisionEditor = React.memo(function DecisionEditor({
<Radio
key={opt.domValue}
label={opt.label}
checked={type.value() == opt.value}
checked={type.value() === opt.value}
onChange={() =>
type.update((prev) => ({
...prev,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ const noErrors: AssistanceActionFormErrors = {
const getExistingAssistanceActionRanges = (props: Props): DateRange[] =>
props.assistanceActions
.filter(
({ action }) => isCreate(props) || action.id != props.assistanceAction.id
({ action }) => isCreate(props) || action.id !== props.assistanceAction.id
)
.map(({ action: { startDate, endDate } }) => ({ startDate, endDate }))

Expand Down Expand Up @@ -199,7 +199,7 @@ export default React.memo(function AssistanceActionForm(props: Props) {
if (res.isSuccess) {
clearUiMode()
} else if (res.isFailure) {
if (res.statusCode == 409) {
if (res.statusCode === 409) {
setFormErrors({
...formErrors,
dateRange: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default React.memo(function AssistanceActionSection({
!!uiMode && uiMode.startsWith('duplicate-assistance-action')
? assistanceActions
.map((actions) =>
actions.find((an) => an.action.id == uiMode.split('_').pop())
actions.find((an) => an.action.id === uiMode.split('_').pop())
)
.getOrElse(undefined)
: undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export default function BackupCareForm({ childId, backupCare }: Props) {
bcs
.filter(
(it) =>
backupCare == undefined || it.backupCare.id !== backupCare.id
backupCare === undefined || it.backupCare.id !== backupCare.id
)
.map(({ backupCare: { period } }) => ({
startDate: period.start,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export default React.memo(function AdditionalInformation({ childId }: Props) {
mealTexture: null
})

const editing = uiMode == 'child-additional-details-editing'
const editing = uiMode === 'child-additional-details-editing'

const startEdit = useCallback(() => {
if (additionalInformation.isSuccess) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default React.memo(function CreatePersonInput({

return (
<>
{personType == 'NEW_NO_SSN' && (
{personType === 'NEW_NO_SSN' && (
<ListGrid labelWidth="min-content">
<Label>{i18n.personSearch.createNewPerson.form.firstName}*</Label>
<InputField
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ export function ApplicationTypeFilter({
<Gap size="xs" />
<FixedSpaceColumn spacing="xs">
{types.map((id) =>
id != 'PRESCHOOL' ? (
id !== 'PRESCHOOL' ? (
<Radio
key={id}
label={i18n.applications.types[id]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default React.memo(function EmployeePreferredFirstNamePage() {
const disableConfirm = () =>
preferredFirstName.isSuccess
? preferredFirstName.value.preferredFirstName != null &&
preferredFirstName.value.preferredFirstName ==
preferredFirstName.value.preferredFirstName ===
selectedPreferredFirstName
: false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default React.memo(function PlacementTypeItem({
{serviceNeedsList
.filter(
(value) =>
value.validPlacementType == placementType && value.defaultOption
value.validPlacementType === placementType && value.defaultOption
)
.map((serviceNeed) => (
<ServiceNeedItem
Expand All @@ -62,7 +62,7 @@ export default React.memo(function PlacementTypeItem({
{serviceNeedsList
.filter(
(value) =>
value.validPlacementType == placementType && !value.defaultOption
value.validPlacementType === placementType && !value.defaultOption
)
.map((serviceNeed, i) => (
<ServiceNeedItem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export default React.memo(function ServiceNeedItem({
</Tr>
</Thead>
<Tbody>
{editorState.editing == 'new' ? (
{editorState.editing === 'new' ? (
<VoucherValueEditor
i18n={i18n}
id={undefined}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default React.memo(function VoucherValueEditor({
const validationResult = validateForm(
i18n,
editorState,
existingVoucherValues.filter((voucherValue) => voucherValue.id != id),
existingVoucherValues.filter((voucherValue) => voucherValue.id !== id),
latestVoucherValue
)

Expand Down Expand Up @@ -118,7 +118,7 @@ export default React.memo(function VoucherValueEditor({
...previousState,
baseValue,
value:
baseValue == ''
baseValue === ''
? '0.00'
: (
parseFloat(baseValue) *
Expand All @@ -143,7 +143,7 @@ export default React.memo(function VoucherValueEditor({
...previousState,
coefficient,
value:
coefficient == ''
coefficient === ''
? '0.00'
: (
parseFloat(previousState.baseValue) *
Expand Down Expand Up @@ -186,7 +186,7 @@ export default React.memo(function VoucherValueEditor({
...previousState,
baseValueUnder3y,
valueUnder3y:
baseValueUnder3y == ''
baseValueUnder3y === ''
? '0.00'
: (
parseFloat(baseValueUnder3y) *
Expand All @@ -211,7 +211,7 @@ export default React.memo(function VoucherValueEditor({
...previousState,
coefficientUnder3y,
valueUnder3y:
coefficientUnder3y == ''
coefficientUnder3y === ''
? '0.00'
: (
parseFloat(previousState.baseValueUnder3y) *
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ export default React.memo(function InvoiceRowsSection({
)
})}
</CollapsibleSection>
{uiMode == 'invoices-absence-modal' && child !== undefined && (
{uiMode === 'invoices-absence-modal' && child !== undefined && (
<AbsencesModal child={child} date={absenceModalDate} />
)}
</Fragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ export default function MessageBox({
}: MessageBoxProps) {
const { i18n } = useTranslation()
const { unreadCountsByAccount } = useContext(MessageContext)
const active = view == activeView?.view && account.id == activeView.account.id
const active =
view === activeView?.view && account.id === activeView.account.id
const unreadCount = unreadCountsByAccount
.map((unreadCounts) => {
if (view === 'received') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ const shouldSensitiveCheckboxBeEnabled = (
senderAccountType: string | undefined
) => {
const recipientValid =
selectedReceivers.length == 1 &&
selectedReceivers.length === 1 &&
selectedReceivers[0].messageRecipient.type === 'CHILD'
if (!recipientValid) {
return false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export default React.memo(function ThreadListContainer({
? thread.messages[0].recipientNames || getUniqueParticipants(thread)
: getUniqueParticipants(thread),
unread: thread.messages.some(
(m) => !m.readAt && m.sender.id != account.id
(m) => !m.readAt && m.sender.id !== account.id
),
onClick: () => selectThread(thread),
type: thread.type,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export async function uploadPlacementFile(
headers: { 'Content-Type': 'multipart/form-data' },
onUploadProgress: ({ loaded, total }) =>
onUploadProgress(
total !== undefined && total != 0
total !== undefined && total !== 0
? Math.round((loaded / total) * 100)
: 0
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ const getTableBody = (
const components: React.ReactNode[] = []
rowsByTime.forEach((rows, time) => {
components.push(
<Tr key={time} ref={time == '05:30' ? autoScrollRef : undefined}>
<Tr key={time} ref={time === '05:30' ? autoScrollRef : undefined}>
<Td sticky>{time}</Td>
{rows.map((row) => {
const isToday = row.dateTime.toLocalDate().isToday()
Expand Down
Loading

0 comments on commit 27a20e8

Please sign in to comment.