Skip to content

Commit 26aa5fc

Browse files
authored
Merge pull request #288 from EdgeApp/william/typescript
William/typescript
2 parents 62a1fd2 + 5d947ed commit 26aa5fc

143 files changed

Lines changed: 2046 additions & 2089 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
/packages/*/dist/
55
/packages/*/lib/
66
/packages/*/node_modules/
7+
/packages/edge-login-ui-rn/lib/

.eslintrc.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@
33
"standard-kit/prettier",
44
"standard-kit/prettier/jsx",
55
"standard-kit/prettier/flow",
6+
"standard-kit/prettier/typescript",
67
"standard-kit/prettier/node",
78
"standard-kit/prettier/react"
89
],
10+
"parserOptions": {
11+
"project": "tsconfig.json"
12+
},
913
"plugins": [
1014
"simple-import-sort"
1115
],

flow-typed/react-native-material-textfield.js

Lines changed: 0 additions & 90 deletions
This file was deleted.

package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"fix": "npm run lint -- --fix",
88
"flow": "flow",
99
"lint": "eslint .",
10-
"precommit": "node -r sucrase/register localizeLanguage.js && lint-staged && flow",
10+
"precommit": "node -r sucrase/register localizeLanguage.js && lint-staged && flow && tsc",
1111
"prepare": "lerna exec yarn prepare"
1212
},
1313
"husky": {
@@ -16,12 +16,14 @@
1616
}
1717
},
1818
"lint-staged": {
19-
"*.{js,jsx}": "eslint"
19+
"*.{js,jsx,ts,tsx}": "eslint"
2020
},
2121
"resolutions": {
2222
"scrypt.js": "0.3.0"
2323
},
2424
"devDependencies": {
25+
"@typescript-eslint/eslint-plugin": "^4.8.2",
26+
"@typescript-eslint/parser": "^4.8.2",
2527
"babel-eslint": "^10.1.0",
2628
"css-module-flow": "^1.0.0",
2729
"eslint": "^7.14.0",
@@ -39,6 +41,7 @@
3941
"lerna": "^3.16.4",
4042
"lint-staged": "^10.5.3",
4143
"prettier": "^2.2.0",
42-
"sucrase": "^3.19.0"
44+
"sucrase": "^3.19.0",
45+
"typescript": "^4.1.2"
4346
}
4447
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"extends": [
3+
"plugin:react-native/all"
4+
],
5+
"rules": {
6+
"@typescript-eslint/default-param-last": "off",
7+
"@typescript-eslint/explicit-function-return-type": "off",
8+
"@typescript-eslint/no-empty-interface": "off",
9+
"@typescript-eslint/no-floating-promises": "off",
10+
"@typescript-eslint/no-misused-promises": "off",
11+
"@typescript-eslint/no-var-requires": "off",
12+
"@typescript-eslint/prefer-nullish-coalescing": "off",
13+
"@typescript-eslint/prefer-optional-chain": "off",
14+
"@typescript-eslint/restrict-plus-operands": "off",
15+
"@typescript-eslint/restrict-template-expressions": "off",
16+
"@typescript-eslint/strict-boolean-expressions": "off",
17+
"react-native/no-inline-styles": "off",
18+
"react-native/no-raw-text": ["error", { "skip": ["EdgeText"] }]
19+
}
20+
}

packages/edge-login-ui-rn/package.json

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@
1414
"homepage": "https://github.com/EdgeApp/edge-login-ui",
1515
"license": "SEE LICENSE IN LICENSE",
1616
"author": "Airbitz, Inc.",
17-
"main": "src/index.js",
17+
"main": "lib/index.js",
1818
"files": [
19-
"android/**",
20-
"edge-login-ui-rn.podspec",
21-
"ios/**",
22-
"LICENSE",
23-
"src/**",
24-
"README.md"
19+
"/android/*",
20+
"/edge-login-ui-rn.podspec",
21+
"/ios/*",
22+
"/lib/*",
23+
"/LICENSE",
24+
"/README.md"
2525
],
2626
"scripts": {
27-
"prepare": "echo nothing to do"
27+
"prepare": "rm -r lib && tsc && cp src/index.flow.js lib/index.js.flow && cp -r src/assets lib"
2828
},
2929
"resolutions": {
3030
"scrypt.js": "0.3.0"
@@ -52,6 +52,8 @@
5252
},
5353
"devDependencies": {
5454
"@react-native-community/art": "^1.0.2",
55+
"@types/react-native": "^0.64.4",
56+
"@types/sprintf-js": "^1.1.2",
5557
"edge-core-js": "^0.18.2",
5658
"flow-bin": "^0.84.0"
5759
},

packages/edge-login-ui-rn/src/.eslintrc.json

Lines changed: 0 additions & 10 deletions
This file was deleted.

packages/edge-login-ui-rn/src/actions/CreateAccountActions.js renamed to packages/edge-login-ui-rn/src/actions/CreateAccountActions.ts

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
1-
// @flow
2-
31
import { sprintf } from 'sprintf-js'
42
import passwordCheck from 'zxcvbn'
53

6-
import s from '../common/locales/strings.js'
7-
import { Airship } from '../components/services/AirshipInstance.js'
8-
import * as Constants from '../constants/index.js'
9-
import { enableTouchId, isTouchDisabled } from '../keychain.js'
10-
import type { Dispatch, GetState, Imports } from '../types/ReduxTypes.js'
11-
import { logEvent } from '../util/analytics.js'
12-
import { getPreviousUsers, setMostRecentUsers } from './PreviousUsersActions.js'
4+
import s from '../common/locales/strings'
5+
import { Airship } from '../components/services/AirshipInstance'
6+
import * as Constants from '../constants/index'
7+
import { enableTouchId, isTouchDisabled } from '../keychain'
8+
import { Dispatch, GetState, Imports } from '../types/ReduxTypes'
9+
import { logEvent } from '../util/analytics'
10+
import { getPreviousUsers, setMostRecentUsers } from './PreviousUsersActions'
1311

14-
export type CreateUserData = {
15-
username: string,
16-
password: string,
12+
export interface CreateUserData {
13+
username: string
14+
password: string
1715
pin: string
1816
}
1917

@@ -30,8 +28,8 @@ export function validatePin(pin: string) {
3028
}
3129
}
3230
export function checkUsernameForAvailabilty(data: string) {
33-
return (dispatch: Dispatch, getState: GetState, imports: Imports) =>
34-
imports.context
31+
return async (dispatch: Dispatch, getState: GetState, imports: Imports) =>
32+
await imports.context
3533
.usernameAvailable(data)
3634
.then(async response => {
3735
if (response) {

packages/edge-login-ui-rn/src/actions/LoginAction.js renamed to packages/edge-login-ui-rn/src/actions/LoginAction.tsx

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
// @flow
2-
31
import * as React from 'react'
42

5-
import s from '../common/locales/strings.js'
6-
import { TextInputModal } from '../components/modals/TextInputModal.js'
7-
import { Airship, showError } from '../components/services/AirshipInstance.js'
8-
import { getLoginKey } from '../keychain.js'
9-
import type { Dispatch, GetState, Imports } from '../types/ReduxTypes.js'
10-
import { type LoginAttempt, attemptLogin } from '../util/loginAttempt.js'
11-
import { completeLogin } from './LoginCompleteActions.js'
3+
import s from '../common/locales/strings'
4+
import { TextInputModal } from '../components/modals/TextInputModal'
5+
import { Airship, showError } from '../components/services/AirshipInstance'
6+
import { getLoginKey } from '../keychain'
7+
import { Dispatch, GetState, Imports } from '../types/ReduxTypes'
8+
import { attemptLogin, LoginAttempt } from '../util/loginAttempt'
9+
import { completeLogin } from './LoginCompleteActions'
1210

1311
/**
1412
* Logs the user in, using password, PIN, or recovery.

packages/edge-login-ui-rn/src/actions/LoginCompleteActions.js renamed to packages/edge-login-ui-rn/src/actions/LoginCompleteActions.tsx

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,21 @@
1-
// @flow
2-
3-
import { type EdgeAccount } from 'edge-core-js'
1+
import { EdgeAccount } from 'edge-core-js'
42
import * as React from 'react'
53
import { Keyboard } from 'react-native'
64
import { sprintf } from 'sprintf-js'
75

8-
import s from '../common/locales/strings.js'
9-
import { ButtonsModal } from '../components/modals/ButtonsModal.js'
10-
import { Airship } from '../components/services/AirshipInstance.js'
11-
import * as Constants from '../constants/index.js'
6+
import s from '../common/locales/strings'
7+
import { ButtonsModal } from '../components/modals/ButtonsModal'
8+
import { Airship } from '../components/services/AirshipInstance'
9+
import * as Constants from '../constants/index'
1210
import {
1311
enableTouchId,
1412
isTouchDisabled,
1513
isTouchEnabled,
1614
supportsTouchId
17-
} from '../keychain.js'
18-
import {
19-
type Dispatch,
20-
type GetState,
21-
type Imports
22-
} from '../types/ReduxTypes.js'
23-
import { hasSecurityAlerts } from '../util/hasSecurityAlerts.js'
24-
import { setMostRecentUsers } from './PreviousUsersActions.js'
15+
} from '../keychain'
16+
import { Dispatch, GetState, Imports } from '../types/ReduxTypes'
17+
import { hasSecurityAlerts } from '../util/hasSecurityAlerts'
18+
import { setMostRecentUsers } from './PreviousUsersActions'
2519

2620
/**
2721
* The user has just logged in, so figure out what do to next.
@@ -146,7 +140,7 @@ async function twofaReminder(account: EdgeAccount) {
146140

147141
const enableOtp = async account => {
148142
await account.enableOtp()
149-
return Airship.show(bridge => (
143+
return await Airship.show(bridge => (
150144
<ButtonsModal
151145
bridge={bridge}
152146
title={s.strings.otp_authentication_header}
@@ -174,7 +168,7 @@ async function twofaReminder(account: EdgeAccount) {
174168

175169
const createOtpCheckModalDontAsk = async () => {
176170
Keyboard.dismiss()
177-
return Airship.show(bridge => (
171+
return await Airship.show(bridge => (
178172
<ButtonsModal
179173
bridge={bridge}
180174
title={s.strings.otp_reset_modal_header}

0 commit comments

Comments
 (0)