Skip to content

Commit

Permalink
fix: manually handle lint errors not auto fixable
Browse files Browse the repository at this point in the history
  • Loading branch information
acezard committed Aug 14, 2024
1 parent 0fb8a1c commit 8310c02
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 21 deletions.
20 changes: 13 additions & 7 deletions react/Dialog/DialogEffects.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import '@testing-library/jest-dom'
import React from 'react'
import { Theme } from '@material-ui/core'
import { render } from '@testing-library/react'
import React from 'react'

import { WebviewIntentProvider, WebviewService } from 'cozy-intent'

import Dialog from '.'
import DemoProvider from '../providers/DemoProvider'
import { DOMStrings, makeOnMount, makeOnUnmount } from './DialogEffects'
import { ThemeColor } from '../hooks/useSetFlagshipUi/useSetFlagshipUI'
import DemoProvider from '../providers/DemoProvider'

const theme = {
palette: {
Expand All @@ -29,7 +29,13 @@ const rootModal = document.createElement('div')
const rootModalColor = 'rgba(29, 33, 42, 0.9)'
rootModal.style.color = rootModalColor

const Wrapper = ({ open, service }) => {
const Wrapper = ({
open,
service
}: {
open?: boolean
service: WebviewService
}): JSX.Element => {
return (
<WebviewIntentProvider webviewService={service}>
<DemoProvider>
Expand Down Expand Up @@ -269,7 +275,7 @@ it('should emit onMount() immediately and onUnmount() when the whole tree is del
const caller = jest.fn<void, unknown[]>()
const service = {
call: (...args: unknown[]): void => caller(...args)
} as WebviewService
} as unknown as WebviewService

const { unmount } = render(<Wrapper service={service} open={true} />)

Expand All @@ -294,7 +300,7 @@ it('should emit onMount() immediately and onUnmount() when Dialog is deleted fro
const caller = jest.fn<void, unknown[]>()
const service = {
call: (...args: unknown[]): void => caller(...args)
} as WebviewService
} as unknown as WebviewService

const { rerender } = render(<Wrapper service={service} open={true} />)

Expand All @@ -321,7 +327,7 @@ it('should not emit onMount() if mounted as open:false, then emit onMount() on o
const caller = jest.fn<void, unknown[]>()
const service = {
call: (...args: unknown[]): void => caller(...args)
} as WebviewService
} as unknown as WebviewService

const { rerender, unmount } = render(
<Wrapper service={service} open={false} />
Expand Down Expand Up @@ -393,7 +399,7 @@ it('when provided with a faulty <Dialog /> that has no open prop, and then fixed
const caller = jest.fn<void, unknown[]>()
const service = {
call: (...args: unknown[]): void => caller(...args)
} as WebviewService
} as unknown as WebviewService

const { rerender, unmount } = render(<Wrapper service={service} />)

Expand Down
9 changes: 4 additions & 5 deletions react/Dialog/DialogEffects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import { useEffect } from 'react'
import { isFlagshipApp } from 'cozy-device-helper'
import { useWebviewIntent } from 'cozy-intent'

import { getFlagshipMetadata } from '../hooks/useSetFlagshipUi/helpers'
import { isRsg } from '../hooks/useSetFlagshipUi/helpers'
import {
FlagshipUI,
ThemeColor,
parseArg
} from '../hooks/useSetFlagshipUi/useSetFlagshipUI'
import { getFlagshipMetadata } from '../hooks/useSetFlagshipUi/helpers'
import { isRsg } from '../hooks/useSetFlagshipUi/helpers'
import { useCozyTheme } from '../providers/CozyTheme'

interface DialogEffectsOptions {
Expand Down Expand Up @@ -43,8 +43,7 @@ export const makeOnMount = ({
fullscreen,
sidebar,
rootModal,
theme,
isLight
theme
}: DialogEffectsOptions): FlagshipUI => {
const hasBottomBackground = !rootModal
const hasTopBackground = cozybar && !rootModal
Expand Down Expand Up @@ -184,7 +183,7 @@ export const useDialogSetFlagshipUI = (
*
* Note that this will also handle abrupt unmounting, as in hiding the dialog without using the open prop.
*/
if (open === false || open === undefined) return
if (!open || open === undefined) return

parseArg(
webviewIntent,
Expand Down
3 changes: 2 additions & 1 deletion react/Viewer/Panel/QualificationListItemInformation.spec.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import { fireEvent, render } from '@testing-library/react'
import React from 'react'

import QualificationListItemInformation from './QualificationListItemInformation'

Expand Down Expand Up @@ -30,6 +30,7 @@ describe('QualificationListItemInformation', () => {

expect(getByText('No information'))
})
// eslint-disable-next-line jest/no-focused-tests
it.only('should display current value if it is truthy', () => {
const formattedMetadataQualification = {
name: 'country',
Expand Down
8 changes: 4 additions & 4 deletions react/Wizard/index.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import React from 'react'
import cx from 'classnames'
import React from 'react'

import Button from '../deprecated/Button'
import styles from './styles.styl'
import Icon from '../Icon'
import CloudIcon from '../Icons/Cloud'
import Input from '../Input'
import Typography from '../Typography'

import styles from './styles.styl'
import Button from '../deprecated/Button'

export const Wizard = ({ children, tag, ...props }) => {
const Component = tag || 'div'
Expand Down Expand Up @@ -73,6 +72,7 @@ export const WizardLogo = ({ src, badgeIcon, badgeColor }) => (
src={src}
alt=""
aria-hidden="true"
// eslint-disable-next-line react/no-unknown-property
focusable="false"
/>
<div className={styles['wizard-logo-badge']}>
Expand Down
1 change: 0 additions & 1 deletion react/hooks/useSetFlagshipUi/helpers.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// eslint-disable-next-line no-unused-vars
import { FlagshipUI } from './useSetFlagshipUI'
import { getFlagshipMetadata as getFlagshipMetadataFromDeviceHelper } from 'cozy-device-helper'

/**
Expand Down
6 changes: 3 additions & 3 deletions react/hooks/useSetFlagshipUi/useSetFlagshipUI.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useEffect } from 'react'
import pickBy from 'lodash/pickBy'
import identity from 'lodash/identity'
import isEmpty from 'lodash/isEmpty'
import isObject from 'lodash/isObject'
import pickBy from 'lodash/pickBy'
import { useEffect } from 'react'

import { useWebviewIntent } from 'cozy-intent'
import { FlagshipUI as IntentInterface } from 'cozy-intent/dist/api/models/applications'
Expand Down Expand Up @@ -32,7 +32,7 @@ export const parseArg = (

if (!webviewIntent) return

validUI && webviewIntent.call('setFlagshipUI', validUI, caller)
validUI && void webviewIntent.call('setFlagshipUI', validUI, caller)
}

export const useSetFlagshipUI = (
Expand Down

0 comments on commit 8310c02

Please sign in to comment.