I'm using this code to validate if some hook is used inside an specific context but I obtain the following error: ESLint: Unnecessary conditional, value is always falsy.(@typescript-eslint/no-unnecessary-condition), what is the correct way to handle this, disabling the rule or is there another way?
import React from 'react'
import {AppStateContext} from '../components/containers'
export function useAppState() {
const context = React.useContext(AppStateContext)
if (!context) { // error comes from here
throw new Error('useAppState must be used within the AppStateProvider')
}
return context
}
I'm using this code to validate if some hook is used inside an specific context but I obtain the following error:
ESLint: Unnecessary conditional, value is always falsy.(@typescript-eslint/no-unnecessary-condition), what is the correct way to handle this, disabling the rule or is there another way?