Skip to content

Commit

Permalink
Merge pull request #106 from funnyzak/refactor/escode
Browse files Browse the repository at this point in the history
  • Loading branch information
funnyzak authored Oct 15, 2022
2 parents 2f6d10b + 9922c78 commit f587003
Show file tree
Hide file tree
Showing 17 changed files with 26 additions and 25 deletions.
8 changes: 5 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module.exports = {
'comma-dangle': ['error', 'never'],
'import/no-unresolved': 'off',
'import/no-extraneous-dependencies': 'off',
'no-console': 'warn',
'no-console': 'off',
'no-debugger': 'error',
'no-plusplus': 'off',
'camelcase': 'off',
Expand Down Expand Up @@ -88,14 +88,16 @@ module.exports = {
endOfLine: 'auto'
}
],
'eslint-comments/no-unused-disable': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'react-hooks/exhaustive-deps': 'warn',
'react-hooks/exhaustive-deps': 'off',
'react-native/no-unused-styles': 2,
'react-native/split-platform-components': 2,
'react-native/no-inline-styles': 'off',
'react-native/no-color-literals': 2,
'react-native/no-raw-text': 0,
'react-native/no-single-element-style-arrays': 2
'react-native/no-single-element-style-arrays': 2,
'react/no-unstable-nested-components': 'off'
}
}
]
Expand Down
2 changes: 1 addition & 1 deletion src/components/avatar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const AvatarComponent = ({ username, size = 24, source, onPress, style }: IProps
NavigationService.navigate(ROUTES.Profile, { username })
}
onPress && onPress()
}, [username])
}, [username, onPress])

const onAvatarImageLoadEnd = () => {
Animated.timing(avatarImageScaleValue, {
Expand Down
4 changes: 2 additions & 2 deletions src/helper/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const memberFromCache = (
list?: { pullTime: number; info: V2exObject.Member }[],
cacheExpireTime: number = CACHE_EXPIRE_TIME
) => {
if (!list || list.length == 0) {
if (!list || list.length === 0) {
return undefined
}
return (
Expand All @@ -23,7 +23,7 @@ export const memberFromCache = (
}

export const nodeFromCache = (nodeid: number | string, list?: { pullTime: number; info: V2exObject.Node }[]) => {
if (!list || list.length == 0) {
if (!list || list.length === 0) {
return undefined
}
return (
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useMember.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const useMember = ({ userid: id, forcePull = true }: { userid: string | n
} else {
dispatch(cacheMember(id) as any)
}
}, [id, info, members])
}, [id, info, members]) // eslint-disable-line react-hooks/exhaustive-deps

return {
member: info
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const useNode = ({ nodeid: id }: { nodeid: number | string }) => {
} else {
dispatch(cacheNode(id) as any)
}
}, [id, info, nodes])
}, [id, info, nodes]) // eslint-disable-line react-hooks/exhaustive-deps

return {
node: info
Expand Down
4 changes: 2 additions & 2 deletions src/navigation/Navigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ const HotDrawerContent = (props: DrawerContentComponentProps) => {
(route_index: number) => {
return props.state.index === route_index
},
[theme, props]
[props]
)

const textStyle = useCallback(
Expand All @@ -167,7 +167,7 @@ const HotDrawerContent = (props: DrawerContentComponentProps) => {
color: isFocus(route_index) ? theme.colors.secondary : theme.colors.captionText
}
},
[theme, props]
[theme, isFocus]
)
return (
<View style={[drawContentStyles.drawerContent(theme), { paddingTop: insets.top }]}>
Expand Down
4 changes: 2 additions & 2 deletions src/screens/common/WebLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const WebLink = ({ route, navigation }: ScreenProps) => {
if (loading) {
navigation.setOptions({ title: translate('placeholder.loading') })
}
}, [])
})

useLayoutEffect(() => {
navigation.setOptions({
Expand All @@ -44,7 +44,7 @@ const WebLink = ({ route, navigation }: ScreenProps) => {
</>
)
})
}, [navigation])
}, [navigation]) // eslint-disable-line react-hooks/exhaustive-deps

return (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const FollowPeopleHeaderButton = ({
const dispatch = useAppDispatch()
const isInterest = useMemo(
() => (logined ? followPeoples && followPeoples.findIndex((v) => v.id === member.id) >= 0 : false),
[followPeoples]
[followPeoples, logined, member]
)

const buttonPress = () => {
Expand Down
2 changes: 1 addition & 1 deletion src/screens/components/common/RenderHTML.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const renderersProps = {
return
}

const regexp = /about\:\/{3}([\w]+)\/(\w+)/
const regexp = /about:\/{3}([\w]+)\/(\w+)/
const match = href.match(regexp)
const type = match && match.length > 1 ? match[1] : ''

Expand Down
2 changes: 1 addition & 1 deletion src/screens/components/profile/ProfileTopics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const ProfileTopics: React.FC<ProfileTopicsProps> = ({ containerStyle, username
const renderContent = () => {
return (
<>
{list == undefined || list.length > 0 ? (
{list === undefined || list.length > 0 ? (
<TabCardContainer
containerStyle={[styles.container(theme), containerStyle]}
icon={theme.assets.images.icons.tabbar.title.latest}
Expand Down
2 changes: 1 addition & 1 deletion src/screens/components/topic/FetchTopicCardList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const FetchTopicCardList: React.FC<FetchTopicCardListProps> = ({
showMessage(err.message)
})
},
[nodeName, showMessage, page, v2API, logined]
[nodeName, showMessage, page, v2API, logined] // eslint-disable-line react-hooks/exhaustive-deps
)

const onRefresh = () => {
Expand Down
4 changes: 2 additions & 2 deletions src/screens/components/topic/TopicReplayList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ const TopicReplayList: React.FC<TopicReplayListProps> = ({
setRefreshing(false)
refreshCallBack && refreshCallBack(res)
},
(err) => {
(_err) => {
showMessage(translate('error.network'))
setRefreshing(false)
refreshCallBack && refreshCallBack([])
}
)
}, [topicId, v2exLib])
}, [topicId, v2exLib]) // eslint-disable-line react-hooks/exhaustive-deps

useEffect(() => {
onRefresh()
Expand Down
4 changes: 2 additions & 2 deletions src/screens/login/SignIn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ const Screen = ({
showMessage({ type: 'success', text2: success })
goNextRoute()
}
}, [success])
}, [success]) // eslint-disable-line react-hooks/exhaustive-deps

useEffect(() => {
if (error) {
showMessage({ type: 'error', text2: error })
}
}, [error])
}, [error]) // eslint-disable-line react-hooks/exhaustive-deps

const onLoginPress = () => {
_auth(token)
Expand Down
2 changes: 1 addition & 1 deletion src/screens/my/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const My = ({
/>
)
})
}, [])
}, [profile]) // eslint-disable-line react-hooks/exhaustive-deps

return (
<ScrollView
Expand Down
3 changes: 1 addition & 2 deletions src/screens/my/Topics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const MyTopics = ({
profile?: V2exObject.Member
setTopics: (topics: V2exObject.Topic[]) => void
}) => {
const { theme } = useTheme()
const [refreshing, setRefreshing] = useState<boolean>(false)
const [list, setList] = useState<V2exObject.Topic[] | undefined>(topics)
const { showMessage } = useToast()
Expand All @@ -38,7 +37,7 @@ const MyTopics = ({
.catch((err) => {
showMessage(err.message)
})
}, [])
}, [profile]) // eslint-disable-line react-hooks/exhaustive-deps

return (
<View style={SylCommon.Layout.fill}>
Expand Down
2 changes: 1 addition & 1 deletion src/screens/node/InterestNodes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const InterestNodes = ({
return (
<View style={SylCommon.Layout.fill}>
<NeedLogin>
{!likeNodes || likeNodes.length == 0 ? (
{!likeNodes || likeNodes.length === 0 ? (
<Placeholder displayType="text" placeholderText={translate('placeholder.noInterestNodes')} />
) : (
<Tab.Navigator
Expand Down
2 changes: 1 addition & 1 deletion src/screens/node/NodeDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const NodeDetail = ({
headerRight: () => <LikeNodeHeaderButton node={info} />
})
}
}, [interestNodes, info])
}, [interestNodes, info]) // eslint-disable-line react-hooks/exhaustive-deps

return (
<View style={SylCommon.Layout.fill}>
Expand Down

0 comments on commit f587003

Please sign in to comment.