Skip to content

Commit

Permalink
Add additional ESLint rules
Browse files Browse the repository at this point in the history
  • Loading branch information
mrousavy committed Mar 31, 2021
1 parent bb84f7f commit 7676923
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 4 deletions.
13 changes: 12 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,23 @@ module.exports = {
'react-native/no-color-literals': 'off',
'react-native/no-raw-text': 'off',
'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/exhaustive-deps': [
'error',
{
additionalHooks: '(useDerivedValue|useAnimatedStyle|useAnimatedProps|useWorkletCallback)',
additionalHooks: '(useDerivedValue|useAnimatedStyle|useAnimatedProps|useWorkletCallback|useFrameProcessor)',
},
],
},
Expand Down
1 change: 1 addition & 0 deletions example/src/views/CaptureButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ const _CaptureButton: React.FC<Props> = ({
// 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
// 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';
console.log(`Taking ${photoMethod}...`);
const photo =
Expand Down
1 change: 1 addition & 0 deletions ios/CameraView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ public final class CameraView: UIView {
// swiftlint:disable force_cast
return layer as! AVCaptureVideoPreviewLayer
}

override public class var layerClass: AnyClass {
return AVCaptureVideoPreviewLayer.self
}
Expand Down
2 changes: 0 additions & 2 deletions src/Camera.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,6 @@ export class Camera extends React.PureComponent<CameraProps, CameraState> {

//#region Events (Wrapped to maintain reference equality)
private onError(event: NativeSyntheticEvent<OnErrorEvent>): void {
if (event == null) throw new Error('onError() was invoked but event was null!');

if (this.props.onError != null) {
const error = event.nativeEvent;
const cause = isErrorWithCause(error.cause) ? error.cause : undefined;
Expand Down
2 changes: 1 addition & 1 deletion src/CameraError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class CameraError<TCode extends CameraErrorCode> extends Error {
* @internal
*/
constructor(code: TCode, message: string, cause?: ErrorWithCause) {
super(`[${code}]: ${message}${cause ? ` (Cause: ${cause.message})` : ''}`);
super(`[${code}]: ${message}${cause != null ? ` (Cause: ${cause.message})` : ''}`);
this._code = code;
this._message = message;
this._cause = cause;
Expand Down

0 comments on commit 7676923

Please sign in to comment.