Add additional ESLint rules

This commit is contained in:
Marc Rousavy 2021-03-31 15:59:14 +02:00
parent e02c051e19
commit 24a0bcde48
3 changed files with 13 additions and 3 deletions

View File

@ -69,12 +69,23 @@ module.exports = {
'react-native/no-color-literals': 'off', 'react-native/no-color-literals': 'off',
'react-native/no-raw-text': 'off', 'react-native/no-raw-text': 'off',
'react-native/no-single-element-style-arrays': 'warn', 'react-native/no-single-element-style-arrays': 'warn',
'@typescript-eslint/strict-boolean-expressions': [
'error',
{
allowString: false,
allowNullableObject: false,
allowNumber: false,
allowNullableBoolean: true,
},
],
'@typescript-eslint/no-non-null-assertion': 'error',
'@typescript-eslint/no-unnecessary-condition': 'error',
// react hooks // react hooks
'react-hooks/exhaustive-deps': [ 'react-hooks/exhaustive-deps': [
'error', 'error',
{ {
additionalHooks: '(useDerivedValue|useAnimatedStyle|useAnimatedProps|useWorkletCallback)', additionalHooks: '(useDerivedValue|useAnimatedStyle|useAnimatedProps|useWorkletCallback|useFrameProcessor)',
}, },
], ],
}, },

View File

@ -76,6 +76,7 @@ const _CaptureButton: React.FC<Props> = ({
// If we're on Android and flash is disabled, we can use the "snapshot" method. // If we're on Android and flash is disabled, we can use the "snapshot" method.
// this will take a snapshot of the current SurfaceView, which results in faster image // this will take a snapshot of the current SurfaceView, which results in faster image
// capture rate at the cost of greatly reduced quality. // capture rate at the cost of greatly reduced quality.
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
const photoMethod = USE_SNAPSHOT_ON_ANDROID && IS_ANDROID && takePhotoOptions.flash === 'off' ? 'snapshot' : 'photo'; const photoMethod = USE_SNAPSHOT_ON_ANDROID && IS_ANDROID && takePhotoOptions.flash === 'off' ? 'snapshot' : 'photo';
console.log(`Taking ${photoMethod}...`); console.log(`Taking ${photoMethod}...`);
const photo = const photo =

View File

@ -354,8 +354,6 @@ export class Camera extends React.PureComponent<CameraProps, CameraState> {
//#region Events (Wrapped to maintain reference equality) //#region Events (Wrapped to maintain reference equality)
private onError(event: NativeSyntheticEvent<OnErrorEvent>): void { private onError(event: NativeSyntheticEvent<OnErrorEvent>): void {
if (event == null) throw new Error('onError() was invoked but event was null!');
if (this.props.onError != null) { if (this.props.onError != null) {
const error = event.nativeEvent; const error = event.nativeEvent;
const cause = isErrorWithCause(error.cause) ? error.cause : undefined; const cause = isErrorWithCause(error.cause) ? error.cause : undefined;