An ATproto social media client -- with an independent Appview.

Lints some errors and warnings (#76)

authored by

Aryan Goharzad and committed by
GitHub
06e41167 2fce1637

+62 -38
+2 -1
.gitignore
··· 61 61 /vendor/bundle/ 62 62 63 63 # Testing 64 - coverage/ 64 + coverage/ 65 + junit.xml
+1 -4
__tests__/state/models/navigation.test.ts
··· 1 - import { 2 - NavigationModel, 3 - NavigationTabModel, 4 - } from './../../../src/state/models/navigation' 1 + import {NavigationModel} from './../../../src/state/models/navigation' 5 2 import * as flags from '../../../src/build-flags' 6 3 7 4 describe('NavigationModel', () => {
-2
__tests__/view/com/login/CreateAccount.test.tsx
··· 3 3 import {CreateAccount} from '../../../../src/view/com/login/CreateAccount' 4 4 import {cleanup, fireEvent, render} from '../../../../jest/test-utils' 5 5 import { 6 - mockedLogStore, 7 - mockedRootStore, 8 6 mockedSessionStore, 9 7 mockedShellStore, 10 8 } from '../../../../__mocks__/state-mock'
-2
__tests__/view/com/login/Signin.test.tsx
··· 3 3 import {cleanup, fireEvent, render} from '../../../../jest/test-utils' 4 4 import {SessionServiceClient, sessionClient as AtpApi} from '@atproto/api' 5 5 import { 6 - mockedLogStore, 7 - mockedRootStore, 8 6 mockedSessionStore, 9 7 mockedShellStore, 10 8 } from '../../../../__mocks__/state-mock'
+1 -4
__tests__/view/shell/mobile/Menu.test.tsx
··· 1 1 import React from 'react' 2 2 import {Menu} from '../../../../src/view/shell/mobile/Menu' 3 3 import {cleanup, fireEvent, render} from '../../../../jest/test-utils' 4 - import { 5 - mockedNavigationStore, 6 - mockedShellStore, 7 - } from '../../../../__mocks__/state-mock' 4 + import {mockedNavigationStore} from '../../../../__mocks__/state-mock' 8 5 9 6 describe('Menu', () => { 10 7 const onCloseMock = jest.fn()
+1 -1
__tests__/view/shell/mobile/TabsSelector.test.tsx
··· 1 1 import React from 'react' 2 - import {Animated, Share} from 'react-native' 2 + import {Animated} from 'react-native' 3 3 import {TabsSelector} from '../../../../src/view/shell/mobile/TabsSelector' 4 4 import {cleanup, fireEvent, render} from '../../../../jest/test-utils' 5 5 import {mockedNavigationStore} from '../../../../__mocks__/state-mock'
+2
jest/jestSetup.js
··· 1 + /* global jest */ 2 + 1 3 import 'react-native-gesture-handler/jestSetup' 2 4 jest.mock('@react-native-async-storage/async-storage', () => 3 5 require('@react-native-async-storage/async-storage/jest/async-storage-mock'),
+3 -1
src/lib/strings.ts
··· 199 199 } 200 200 201 201 export function cleanError(str: any): string { 202 - if (!str) return str 202 + if (!str) { 203 + return str 204 + } 203 205 if (typeof str !== 'string') { 204 206 str = str.toString() 205 207 }
+2 -2
src/state/lib/api.ts
··· 84 84 if (!embed && extLink) { 85 85 let thumb 86 86 if (extLink.localThumb) { 87 - onStateChange?.(`Uploading link thumbnail...`) 87 + onStateChange?.('Uploading link thumbnail...') 88 88 let encoding 89 89 if (extLink.localThumb.path.endsWith('.png')) { 90 90 encoding = 'image/png' ··· 140 140 } 141 141 142 142 try { 143 - onStateChange?.(`Posting...`) 143 + onStateChange?.('Posting...') 144 144 return await store.api.app.bsky.feed.post.create( 145 145 {did: store.me.did || ''}, 146 146 {
+1 -1
src/state/models/feed-view.ts
··· 426 426 } 427 427 this._xLoading() 428 428 let numToFetch = this.feed.length 429 - let cursor = undefined 429 + let cursor 430 430 try { 431 431 do { 432 432 const res: GetTimeline.Response = await this._getFeed({
+1 -1
src/state/models/notifications-view.ts
··· 366 366 } 367 367 this._xLoading() 368 368 let numToFetch = this.notifications.length 369 - let cursor = undefined 369 + let cursor 370 370 try { 371 371 do { 372 372 const res: ListNotifications.Response =
+3 -1
src/state/models/onboard.ts
··· 50 50 } 51 51 52 52 next() { 53 - if (!this.isOnboarding) return 53 + if (!this.isOnboarding) { 54 + return 55 + } 54 56 let i = OnboardStageOrder.indexOf(this.stage) 55 57 i++ 56 58 if (i >= OnboardStageOrder.length) {
+6 -2
src/view/com/login/CreateAccount.tsx
··· 48 48 setServiceDescription(undefined) 49 49 store.session.describeService(serviceUrl).then( 50 50 desc => { 51 - if (aborted) return 51 + if (aborted) { 52 + return 53 + } 52 54 setServiceDescription(desc) 53 55 setUserDomain(desc.availableUserDomains[0]) 54 56 }, 55 57 err => { 56 - if (aborted) return 58 + if (aborted) { 59 + return 60 + } 57 61 store.log.warn( 58 62 `Failed to fetch service description for ${serviceUrl}`, 59 63 err,
+6 -2
src/view/com/login/Signin.tsx
··· 47 47 setError('') 48 48 store.session.describeService(serviceUrl).then( 49 49 desc => { 50 - if (aborted) return 50 + if (aborted) { 51 + return 52 + } 51 53 setServiceDescription(desc) 52 54 }, 53 55 err => { 54 - if (aborted) return 56 + if (aborted) { 57 + return 58 + } 55 59 store.log.warn( 56 60 `Failed to fetch service description for ${serviceUrl}`, 57 61 err,
+1 -1
src/view/com/util/LoadingPlaceholder.tsx
··· 76 76 strokeWidth={1.7} 77 77 /> 78 78 </View> 79 - <View style={s.flex1}></View> 79 + <View style={s.flex1} /> 80 80 </View> 81 81 </View> 82 82 </View>
+6 -2
src/view/com/util/UserInfoText.tsx
··· 40 40 let aborted = false 41 41 store.profiles.getProfile(did).then( 42 42 v => { 43 - if (aborted) return 43 + if (aborted) { 44 + return 45 + } 44 46 setProfile(v.data) 45 47 }, 46 48 _err => { 47 - if (aborted) return 49 + if (aborted) { 50 + return 51 + } 48 52 setFailed(true) 49 53 }, 50 54 )
+1 -1
src/view/com/util/ViewHeader.tsx
··· 36 36 store.shell.setMainMenuOpen(true) 37 37 } 38 38 const onPressSearch = () => { 39 - store.nav.navigate(`/search`) 39 + store.nav.navigate('/search') 40 40 } 41 41 const onPressReconnect = () => { 42 42 store.session.connect().catch(e => {
+15 -5
src/view/com/util/gestures/SwipeAndZoom.tsx
··· 88 88 } 89 89 90 90 const canDir = (d: Dir) => { 91 - if (d === Dir.Left) return canSwipeLeft 92 - if (d === Dir.Right) return canSwipeRight 93 - if (d === Dir.Up) return canSwipeUp 94 - if (d === Dir.Down) return canSwipeDown 95 - if (d === Dir.Zoom) return zoomEnabled 91 + if (d === Dir.Left) { 92 + return canSwipeLeft 93 + } 94 + if (d === Dir.Right) { 95 + return canSwipeRight 96 + } 97 + if (d === Dir.Up) { 98 + return canSwipeUp 99 + } 100 + if (d === Dir.Down) { 101 + return canSwipeDown 102 + } 103 + if (d === Dir.Zoom) { 104 + return zoomEnabled 105 + } 96 106 return false 97 107 } 98 108 const isHorz = (d: Dir) => d === Dir.Left || d === Dir.Right
+5 -2
src/view/com/util/text/RichText.tsx
··· 46 46 </Text> 47 47 ) 48 48 } 49 - if (!style) style = [] 50 - else if (!Array.isArray(style)) style = [style] 49 + if (!style) { 50 + style = [] 51 + } else if (!Array.isArray(style)) { 52 + style = [style] 53 + } 51 54 entities.sort(sortByIndex) 52 55 const segments = Array.from(toSegments(text, entities)) 53 56 const els = []
+1 -1
src/view/screens/Contacts.tsx
··· 15 15 16 16 useEffect(() => { 17 17 if (visible) { 18 - store.nav.setTitle(navIdx, `Contacts`) 18 + store.nav.setTitle(navIdx, 'Contacts') 19 19 } 20 20 }, [store, visible]) 21 21
+3 -1
src/view/screens/Profile.tsx
··· 40 40 } else { 41 41 store.nav.setTitle(navIdx, params.name) 42 42 uiState.setup().then(() => { 43 - if (aborted) return 43 + if (aborted) { 44 + return 45 + } 44 46 setHasSetup(true) 45 47 }) 46 48 }
+1 -1
src/view/screens/Search.tsx
··· 33 33 if (visible) { 34 34 store.shell.setMinimalShellMode(false) 35 35 autocompleteView.setup() 36 - store.nav.setTitle(navIdx, `Search`) 36 + store.nav.setTitle(navIdx, 'Search') 37 37 } 38 38 }, [store, visible, name]) 39 39