Skip to content

Commit

Permalink
ESLintのエラーを修正
Browse files Browse the repository at this point in the history
  • Loading branch information
s-yoshiii committed Jul 8, 2022
1 parent 64bcacc commit 107f5ab
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 33 deletions.
12 changes: 3 additions & 9 deletions .eslintrc.json
Expand Up @@ -17,15 +17,9 @@
"linebreak-style": 0,
"import/no-extraneous-dependencies": ["error", { "devDependencies": true }],
"react/prop-types": ["error", { "ignore": ["navigation"] }],
"import/prefer-default-export": "off",
"object-curly-newline": [
"error",
{
"ObjectExpression": "always",
"ObjectPattern": { "multiline": true },
"ImportDeclaration": "never",
"ExportDeclaration": { "multiline": true, "minProperties": 3 }
}
"import/prefer-default-export": 0,
"react/function-component-definition": [
2, { "namedComponents": "function-declaration" }
]
}
}
15 changes: 8 additions & 7 deletions src/components/KeyboardSafeView.jsx
@@ -1,5 +1,7 @@
import React, { useRef, useState, useEffect } from 'react';
import { Keyboard, Dimensions, Animated, ViewPropTypes } from 'react-native';
import {
Keyboard, Dimensions, Animated, ViewPropTypes,
} from 'react-native';

import { node } from 'prop-types';

Expand All @@ -20,7 +22,7 @@ export default function KeyboardSafeView({ children, style }) {
useEffect(() => {
if (
[initialViewHeight, animatedViewHeight, viewHeight].some(
(val) => val === null
(val) => val === null,
)
) {
return;
Expand All @@ -44,8 +46,7 @@ export default function KeyboardSafeView({ children, style }) {

const handleShow = ({ endCoordinates }) => {
if (endCoordinates.height && initialViewHeight.current) {
const keyboardHeight =
Dimensions.get('window').height - endCoordinates.screenY;
const keyboardHeight = Dimensions.get('window').height - endCoordinates.screenY;
setViewHeight(initialViewHeight.current - keyboardHeight);
}
};
Expand All @@ -66,9 +67,9 @@ export default function KeyboardSafeView({ children, style }) {

const animatedStyle = viewHeight
? {
height: animatedViewHeight.current,
flex: 0,
}
height: animatedViewHeight.current,
flex: 0,
}
: {};
return (
<Animated.View style={[style, animatedStyle]} onLayout={handleLayout}>
Expand Down
7 changes: 6 additions & 1 deletion src/components/LogOutButton.jsx
@@ -1,5 +1,10 @@
import React from 'react';
import { Alert, StyleSheet, Text, TouchableOpacity } from 'react-native';
import {
Alert,
StyleSheet,
Text,
TouchableOpacity,
} from 'react-native';
import firebase from 'firebase';
import { useNavigation } from '@react-navigation/native';

Expand Down
6 changes: 4 additions & 2 deletions src/components/MemoList.jsx
Expand Up @@ -8,7 +8,9 @@ import {
FlatList,
} from 'react-native';
import { useNavigation } from '@react-navigation/native';
import { shape, string, instanceOf, arrayOf } from 'prop-types';
import {
shape, string, instanceOf, arrayOf,
} from 'prop-types';
import firebase from 'firebase';
import Icon from './Icon';
import { dateToString } from '../utils';
Expand Down Expand Up @@ -84,7 +86,7 @@ MemoList.propsTypes = {
id: string,
bodyText: string,
updatedAt: instanceOf(Date),
})
}),
).isRequired,
};
const styles = StyleSheet.create({
Expand Down
19 changes: 15 additions & 4 deletions src/screens/LoginScreen.jsx
Expand Up @@ -24,7 +24,11 @@ function LoginScreen(props) {
if (user) {
navigation.reset({
index: 0,
routes: [{ name: 'MemoList' }],
routes: [
{
name: 'MemoList',
},
],
});
} else {
setIsLoading(false);
Expand All @@ -40,9 +44,12 @@ function LoginScreen(props) {
const { user } = userCredential;
navigation.reset({
index: 0,
routes: [{ name: 'MemoList' }],
routes: [
{
name: 'MemoList',
},
],
});
console.log(user.uid);
})
.catch((error) => {
const errorMsg = translateErrors(error.code);
Expand Down Expand Up @@ -90,7 +97,11 @@ function LoginScreen(props) {
onPress={() => {
navigation.reset({
index: 0,
routes: [{ name: 'SignUp' }],
routes: [
{
name: 'SignUp',
},
],
});
}}
>
Expand Down
12 changes: 8 additions & 4 deletions src/screens/MemoCreateScreen.jsx
@@ -1,10 +1,13 @@
import React, { useState } from 'react';
import { View, StyleSheet, TextInput, Keyboard } from 'react-native';
import {
View, StyleSheet, TextInput, Keyboard, Alert,
} from 'react-native';

import firebase from 'firebase';

import CircleButton from '../components/CircleButton';
import KeyboardSafeView from '../components/KeyboardSafeView';
import { translateErrors } from '../utils';

function MemoCreateScreen(props) {
const { navigation } = props;
Expand All @@ -18,11 +21,12 @@ function MemoCreateScreen(props) {
bodyText,
updatedAt: new Date(),
})
.then((docRef) => {
console.log('Created!', docRef.id);
.then(() => {
navigation.goBack();
})
.catch((error) => {
console.log('error', error);
const errorMsg = translateErrors(error.code);
Alert.alert(errorMsg.title, errorMsg.description);
});
navigation.goBack();
};
Expand Down
4 changes: 3 additions & 1 deletion src/screens/MemoDetailScreen.jsx
@@ -1,6 +1,8 @@
import React, { useEffect, useState } from 'react';
import { shape, string } from 'prop-types';
import { View, Text, ScrollView, StyleSheet } from 'react-native';
import {
View, Text, ScrollView, StyleSheet,
} from 'react-native';
import firebase from 'firebase';

import CircleButton from '../components/CircleButton';
Expand Down
4 changes: 3 additions & 1 deletion src/screens/MemoEditScreen.jsx
@@ -1,6 +1,8 @@
import { shape, string } from 'prop-types';
import React, { useState } from 'react';
import { View, StyleSheet, TextInput, Keyboard, Alert } from 'react-native';
import {
View, StyleSheet, TextInput, Keyboard, Alert,
} from 'react-native';
import firebase from 'firebase';
import { translateErrors } from '../utils';

Expand Down
7 changes: 4 additions & 3 deletions src/screens/MemoListScreen.jsx
@@ -1,5 +1,7 @@
import React, { useEffect, useState } from 'react';
import { View, StyleSheet, Alert, Text } from 'react-native';
import {
View, StyleSheet, Alert, Text,
} from 'react-native';
import firebase from 'firebase';
import CircleButton from '../components/CircleButton';
import LogOutButton from '../components/LogOutButton';
Expand Down Expand Up @@ -41,10 +43,9 @@ function MemoListScreen(props) {
setIsLoading(false);
},
(error) => {
console.log(error);
setIsLoading(false);
Alert.alert('データの読み込みに失敗しました');
}
},
);
}
return unscribe;
Expand Down
1 change: 0 additions & 1 deletion src/screens/SignUpScreen.jsx
Expand Up @@ -26,7 +26,6 @@ function SingUpScreen(props) {
index: 0,
routes: [{ name: 'MemoList' }],
});
console.log(user.uid);
})
.catch((error) => {
const errorMsg = translateErrors(error.code);
Expand Down

0 comments on commit 107f5ab

Please sign in to comment.