Skip to content

Commit

Permalink
fix: typescript-eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
MellyGray committed Apr 27, 2023
1 parent fa8a579 commit 8da0a3c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,21 @@ function getFieldsWithIndex(fields: Array<ReactNode>) {
}

function getFieldWithIndex(field: ReactNode, fieldIndex: number) {
return React.Children.map(field, (child) => {
return React.Children.map(field, (child: ReactNode) => {
if (!React.isValidElement(child)) {
return child
}

/* eslint-disable @typescript-eslint/no-unsafe-assignment */
const childProps = getPropsWithFieldIndex(child, fieldIndex)

/* eslint-disable @typescript-eslint/no-unsafe-member-access */
if (child.props.children) {
/* eslint-disable @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-argument */
childProps.children = getFieldWithIndex(child.props.children, fieldIndex)
}

/* eslint-disable @typescript-eslint/no-unsafe-argument */
return React.cloneElement(child, childProps)
})
}
Expand All @@ -26,6 +30,7 @@ function getPropsWithFieldIndex(child: ReactElement, fieldIndex: number) {
return React.isValidElement(child) && child.type === FormGroup
}

/* eslint-disable @typescript-eslint/no-unsafe-return */
return isFormGroup(child)
? { ...child.props, fieldIndex: fieldIndex.toString() }
: { ...child.props }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { render, screen, fireEvent } from '@testing-library/react'
import { render, fireEvent } from '@testing-library/react'
import { DynamicFieldsButtons } from '../../../../../../src/sections/ui/form/form-group-multiple-fields/dynamic-fields-buttons/DynamicFieldsButtons'
import { vi } from 'vitest'

Expand Down

0 comments on commit 8da0a3c

Please sign in to comment.