Lints some errors and warnings (#76)

zio/stable
Aryan Goharzad 2023-01-20 14:43:28 -05:00 committed by GitHub
parent 2fce1637b4
commit 06e41167d0
22 changed files with 62 additions and 38 deletions

1
.gitignore vendored
View File

@ -62,3 +62,4 @@ buck-out/
# Testing # Testing
coverage/ coverage/
junit.xml

View File

@ -1,7 +1,4 @@
import { import {NavigationModel} from './../../../src/state/models/navigation'
NavigationModel,
NavigationTabModel,
} from './../../../src/state/models/navigation'
import * as flags from '../../../src/build-flags' import * as flags from '../../../src/build-flags'
describe('NavigationModel', () => { describe('NavigationModel', () => {

View File

@ -3,8 +3,6 @@ import {Keyboard} from 'react-native'
import {CreateAccount} from '../../../../src/view/com/login/CreateAccount' import {CreateAccount} from '../../../../src/view/com/login/CreateAccount'
import {cleanup, fireEvent, render} from '../../../../jest/test-utils' import {cleanup, fireEvent, render} from '../../../../jest/test-utils'
import { import {
mockedLogStore,
mockedRootStore,
mockedSessionStore, mockedSessionStore,
mockedShellStore, mockedShellStore,
} from '../../../../__mocks__/state-mock' } from '../../../../__mocks__/state-mock'

View File

@ -3,8 +3,6 @@ import {Signin} from '../../../../src/view/com/login/Signin'
import {cleanup, fireEvent, render} from '../../../../jest/test-utils' import {cleanup, fireEvent, render} from '../../../../jest/test-utils'
import {SessionServiceClient, sessionClient as AtpApi} from '@atproto/api' import {SessionServiceClient, sessionClient as AtpApi} from '@atproto/api'
import { import {
mockedLogStore,
mockedRootStore,
mockedSessionStore, mockedSessionStore,
mockedShellStore, mockedShellStore,
} from '../../../../__mocks__/state-mock' } from '../../../../__mocks__/state-mock'

View File

@ -1,10 +1,7 @@
import React from 'react' import React from 'react'
import {Menu} from '../../../../src/view/shell/mobile/Menu' import {Menu} from '../../../../src/view/shell/mobile/Menu'
import {cleanup, fireEvent, render} from '../../../../jest/test-utils' import {cleanup, fireEvent, render} from '../../../../jest/test-utils'
import { import {mockedNavigationStore} from '../../../../__mocks__/state-mock'
mockedNavigationStore,
mockedShellStore,
} from '../../../../__mocks__/state-mock'
describe('Menu', () => { describe('Menu', () => {
const onCloseMock = jest.fn() const onCloseMock = jest.fn()

View File

@ -1,5 +1,5 @@
import React from 'react' import React from 'react'
import {Animated, Share} from 'react-native' import {Animated} from 'react-native'
import {TabsSelector} from '../../../../src/view/shell/mobile/TabsSelector' import {TabsSelector} from '../../../../src/view/shell/mobile/TabsSelector'
import {cleanup, fireEvent, render} from '../../../../jest/test-utils' import {cleanup, fireEvent, render} from '../../../../jest/test-utils'
import {mockedNavigationStore} from '../../../../__mocks__/state-mock' import {mockedNavigationStore} from '../../../../__mocks__/state-mock'

View File

@ -1,3 +1,5 @@
/* global jest */
import 'react-native-gesture-handler/jestSetup' import 'react-native-gesture-handler/jestSetup'
jest.mock('@react-native-async-storage/async-storage', () => jest.mock('@react-native-async-storage/async-storage', () =>
require('@react-native-async-storage/async-storage/jest/async-storage-mock'), require('@react-native-async-storage/async-storage/jest/async-storage-mock'),

View File

@ -199,7 +199,9 @@ export function enforceLen(str: string, len: number): string {
} }
export function cleanError(str: any): string { export function cleanError(str: any): string {
if (!str) return str if (!str) {
return str
}
if (typeof str !== 'string') { if (typeof str !== 'string') {
str = str.toString() str = str.toString()
} }

View File

@ -84,7 +84,7 @@ export async function post(
if (!embed && extLink) { if (!embed && extLink) {
let thumb let thumb
if (extLink.localThumb) { if (extLink.localThumb) {
onStateChange?.(`Uploading link thumbnail...`) onStateChange?.('Uploading link thumbnail...')
let encoding let encoding
if (extLink.localThumb.path.endsWith('.png')) { if (extLink.localThumb.path.endsWith('.png')) {
encoding = 'image/png' encoding = 'image/png'
@ -140,7 +140,7 @@ export async function post(
} }
try { try {
onStateChange?.(`Posting...`) onStateChange?.('Posting...')
return await store.api.app.bsky.feed.post.create( return await store.api.app.bsky.feed.post.create(
{did: store.me.did || ''}, {did: store.me.did || ''},
{ {

View File

@ -426,7 +426,7 @@ export class FeedModel {
} }
this._xLoading() this._xLoading()
let numToFetch = this.feed.length let numToFetch = this.feed.length
let cursor = undefined let cursor
try { try {
do { do {
const res: GetTimeline.Response = await this._getFeed({ const res: GetTimeline.Response = await this._getFeed({

View File

@ -366,7 +366,7 @@ export class NotificationsViewModel {
} }
this._xLoading() this._xLoading()
let numToFetch = this.notifications.length let numToFetch = this.notifications.length
let cursor = undefined let cursor
try { try {
do { do {
const res: ListNotifications.Response = const res: ListNotifications.Response =

View File

@ -50,7 +50,9 @@ export class OnboardModel {
} }
next() { next() {
if (!this.isOnboarding) return if (!this.isOnboarding) {
return
}
let i = OnboardStageOrder.indexOf(this.stage) let i = OnboardStageOrder.indexOf(this.stage)
i++ i++
if (i >= OnboardStageOrder.length) { if (i >= OnboardStageOrder.length) {

View File

@ -48,12 +48,16 @@ export const CreateAccount = ({onPressBack}: {onPressBack: () => void}) => {
setServiceDescription(undefined) setServiceDescription(undefined)
store.session.describeService(serviceUrl).then( store.session.describeService(serviceUrl).then(
desc => { desc => {
if (aborted) return if (aborted) {
return
}
setServiceDescription(desc) setServiceDescription(desc)
setUserDomain(desc.availableUserDomains[0]) setUserDomain(desc.availableUserDomains[0])
}, },
err => { err => {
if (aborted) return if (aborted) {
return
}
store.log.warn( store.log.warn(
`Failed to fetch service description for ${serviceUrl}`, `Failed to fetch service description for ${serviceUrl}`,
err, err,

View File

@ -47,11 +47,15 @@ export const Signin = ({onPressBack}: {onPressBack: () => void}) => {
setError('') setError('')
store.session.describeService(serviceUrl).then( store.session.describeService(serviceUrl).then(
desc => { desc => {
if (aborted) return if (aborted) {
return
}
setServiceDescription(desc) setServiceDescription(desc)
}, },
err => { err => {
if (aborted) return if (aborted) {
return
}
store.log.warn( store.log.warn(
`Failed to fetch service description for ${serviceUrl}`, `Failed to fetch service description for ${serviceUrl}`,
err, err,

View File

@ -76,7 +76,7 @@ export function PostLoadingPlaceholder({
strokeWidth={1.7} strokeWidth={1.7}
/> />
</View> </View>
<View style={s.flex1}></View> <View style={s.flex1} />
</View> </View>
</View> </View>
</View> </View>

View File

@ -40,11 +40,15 @@ export function UserInfoText({
let aborted = false let aborted = false
store.profiles.getProfile(did).then( store.profiles.getProfile(did).then(
v => { v => {
if (aborted) return if (aborted) {
return
}
setProfile(v.data) setProfile(v.data)
}, },
_err => { _err => {
if (aborted) return if (aborted) {
return
}
setFailed(true) setFailed(true)
}, },
) )

View File

@ -36,7 +36,7 @@ export const ViewHeader = observer(function ViewHeader({
store.shell.setMainMenuOpen(true) store.shell.setMainMenuOpen(true)
} }
const onPressSearch = () => { const onPressSearch = () => {
store.nav.navigate(`/search`) store.nav.navigate('/search')
} }
const onPressReconnect = () => { const onPressReconnect = () => {
store.session.connect().catch(e => { store.session.connect().catch(e => {

View File

@ -88,11 +88,21 @@ export function SwipeAndZoom({
} }
const canDir = (d: Dir) => { const canDir = (d: Dir) => {
if (d === Dir.Left) return canSwipeLeft if (d === Dir.Left) {
if (d === Dir.Right) return canSwipeRight return canSwipeLeft
if (d === Dir.Up) return canSwipeUp }
if (d === Dir.Down) return canSwipeDown if (d === Dir.Right) {
if (d === Dir.Zoom) return zoomEnabled return canSwipeRight
}
if (d === Dir.Up) {
return canSwipeUp
}
if (d === Dir.Down) {
return canSwipeDown
}
if (d === Dir.Zoom) {
return zoomEnabled
}
return false return false
} }
const isHorz = (d: Dir) => d === Dir.Left || d === Dir.Right const isHorz = (d: Dir) => d === Dir.Left || d === Dir.Right

View File

@ -46,8 +46,11 @@ export function RichText({
</Text> </Text>
) )
} }
if (!style) style = [] if (!style) {
else if (!Array.isArray(style)) style = [style] style = []
} else if (!Array.isArray(style)) {
style = [style]
}
entities.sort(sortByIndex) entities.sort(sortByIndex)
const segments = Array.from(toSegments(text, entities)) const segments = Array.from(toSegments(text, entities))
const els = [] const els = []

View File

@ -15,7 +15,7 @@ export const Contacts = ({navIdx, visible, params}: ScreenParams) => {
useEffect(() => { useEffect(() => {
if (visible) { if (visible) {
store.nav.setTitle(navIdx, `Contacts`) store.nav.setTitle(navIdx, 'Contacts')
} }
}, [store, visible]) }, [store, visible])

View File

@ -40,7 +40,9 @@ export const Profile = observer(({navIdx, visible, params}: ScreenParams) => {
} else { } else {
store.nav.setTitle(navIdx, params.name) store.nav.setTitle(navIdx, params.name)
uiState.setup().then(() => { uiState.setup().then(() => {
if (aborted) return if (aborted) {
return
}
setHasSetup(true) setHasSetup(true)
}) })
} }

View File

@ -33,7 +33,7 @@ export const Search = ({navIdx, visible, params}: ScreenParams) => {
if (visible) { if (visible) {
store.shell.setMinimalShellMode(false) store.shell.setMinimalShellMode(false)
autocompleteView.setup() autocompleteView.setup()
store.nav.setTitle(navIdx, `Search`) store.nav.setTitle(navIdx, 'Search')
} }
}, [store, visible, name]) }, [store, visible, name])