eslint-plugin-total-functions
eslint-plugin-total-functions copied to clipboard
total-functions/no-unsafe-readonly-mutable-assignment false positive
Error in vscode:
Passing a readonly type to a function that expects a mutable type can lead to unexpected mutation in the readonly value. eslinttotal-functions/no-unsafe-readonly-mutable-assignment
points to children in if statement.
import React, { memo, isValidElement } from 'react'
import type { ReactNode } from 'react'
interface Props {
children: ReactNode
}
function Component({ children }: Props): JSX.Element | null {
if (!isValidElement<ReactNode>(children)) return null
return <div>{children}</div>
}