Add typescript eslint from metamask (#3088)

* Add typescript eslint from metamask

* address new lints

Co-authored-by: Ricky Miller <ricky.miller@gmail.com>
pull/3062/head
Cal Leung 2 years ago committed by GitHub
parent 456d8536c9
commit 57afe4ca92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 32
      .eslintrc.js
  2. 14
      app/__mocks__/@react-native-community/async-storage.js
  3. 2
      app/__mocks__/react-native-splash-screen.js
  4. 6
      app/__mocks__/rn-fetch-blob.js
  5. 4
      app/actions/alert/index.js
  6. 4
      app/actions/bookmarks/index.js
  7. 16
      app/actions/browser/index.js
  8. 4
      app/actions/collectibles/index.js
  9. 4
      app/actions/infuraAvailability/index.js
  10. 12
      app/actions/modals/index.js
  11. 20
      app/actions/notification/index.js
  12. 4
      app/actions/onboarding/index.js
  13. 8
      app/actions/privacy/index.js
  14. 2
      app/actions/recents/index.js
  15. 14
      app/actions/settings/index.js
  16. 32
      app/actions/transaction/index.js
  17. 22
      app/actions/user/index.js
  18. 2
      app/actions/wizard/index.js
  19. 16
      app/components/Base/Alert.js
  20. 38
      app/components/Base/DetailsModal.js
  21. 58
      app/components/Base/HorizontalSelector/index.js
  22. 20
      app/components/Base/Keypad/components.js
  23. 44
      app/components/Base/Keypad/constants.js
  24. 12
      app/components/Base/Keypad/index.js
  25. 42
      app/components/Base/ListItem.js
  26. 10
      app/components/Base/ModalDragger.js
  27. 38
      app/components/Base/RangeInput.js
  28. 6
      app/components/Base/RemoteImage/index.js
  29. 2
      app/components/Base/RemoteImage/index.test.js
  30. 8
      app/components/Base/SelectorButton.js
  31. 14
      app/components/Base/StatusText.js
  32. 22
      app/components/Base/Summary.js
  33. 8
      app/components/Base/TabBar.js
  34. 48
      app/components/Base/Text.js
  35. 12
      app/components/Base/Title.js
  36. 2
      app/components/Base/hooks/useModalHandler.js
  37. 16
      app/components/Nav/App/index.js
  38. 16
      app/components/Nav/Main/MainNavigator.js
  39. 109
      app/components/Nav/Main/index.js
  40. 34
      app/components/UI/AccountApproval/index.js
  41. 18
      app/components/UI/AccountApproval/index.test.js
  42. 33
      app/components/UI/AccountInfoCard/index.js
  43. 24
      app/components/UI/AccountInfoCard/index.test.js
  44. 60
      app/components/UI/AccountInput/index.js
  45. 34
      app/components/UI/AccountList/AccountElement/index.js
  46. 50
      app/components/UI/AccountList/index.js
  47. 63
      app/components/UI/AccountOverview/index.js
  48. 2
      app/components/UI/AccountOverview/index.test.js
  49. 17
      app/components/UI/AccountRightButton/index.js
  50. 32
      app/components/UI/AccountSelect/index.js
  51. 24
      app/components/UI/ActionModal/ActionContent/index.js
  52. 10
      app/components/UI/ActionModal/index.js
  53. 16
      app/components/UI/ActionView/index.js
  54. 28
      app/components/UI/AddCustomCollectible/index.js
  55. 10
      app/components/UI/AddCustomCollectible/index.test.js
  56. 52
      app/components/UI/AddCustomNetwork/index.js
  57. 24
      app/components/UI/AddCustomToken/index.js
  58. 12
      app/components/UI/AnimatedSpinner/index.js
  59. 60
      app/components/UI/AnimatedTransactionModal/index.js
  60. 46
      app/components/UI/ApproveTransactionReview/EditPermission/index.js
  61. 86
      app/components/UI/ApproveTransactionReview/index.js
  62. 22
      app/components/UI/ApproveTransactionReview/index.test.js
  63. 20
      app/components/UI/AssetActionButton/index.js
  64. 10
      app/components/UI/AssetElement/index.js
  65. 2
      app/components/UI/AssetElement/index.test.js
  66. 8
      app/components/UI/AssetIcon/index.js
  67. 16
      app/components/UI/AssetList/index.js
  68. 53
      app/components/UI/AssetOverview/index.js
  69. 8
      app/components/UI/AssetOverview/index.test.js
  70. 23
      app/components/UI/AssetSearch/index.js
  71. 47
      app/components/UI/BackupAlert/index.js
  72. 6
      app/components/UI/BackupAlert/index.test.js
  73. 12
      app/components/UI/BiometryButton/index.js
  74. 10
      app/components/UI/BlockingActionModal/index.js
  75. 26
      app/components/UI/BrowserBottomBar/index.js
  76. 8
      app/components/UI/Button/index.js
  77. 43
      app/components/UI/CollectibleContractElement/index.js
  78. 48
      app/components/UI/CollectibleContractInformation/index.js
  79. 14
      app/components/UI/CollectibleContractInformation/index.test.js
  80. 33
      app/components/UI/CollectibleContractOverview/index.js
  81. 12
      app/components/UI/CollectibleContractOverview/index.test.js
  82. 30
      app/components/UI/CollectibleContracts/index.js
  83. 26
      app/components/UI/CollectibleContracts/index.test.js
  84. 26
      app/components/UI/CollectibleMedia/index.js
  85. 12
      app/components/UI/CollectibleMediaReproductor/index.js
  86. 25
      app/components/UI/CollectibleModal/index.js
  87. 6
      app/components/UI/CollectibleModal/index.test.js
  88. 76
      app/components/UI/CollectibleOverview/index.js
  89. 18
      app/components/UI/CollectibleOverview/index.test.js
  90. 34
      app/components/UI/Collectibles/index.js
  91. 2
      app/components/UI/ComponentErrorBoundary/index.js
  92. 4
      app/components/UI/Confetti/index.js
  93. 10
      app/components/UI/ConnectHeader/index.js
  94. 16
      app/components/UI/CustomAlert/index.js
  95. 146
      app/components/UI/CustomGas/index.js
  96. 20
      app/components/UI/CustomGas/index.test.js
  97. 8
      app/components/UI/CustomNonce/index.js
  98. 42
      app/components/UI/CustomNonceModal/index.js
  99. 191
      app/components/UI/DrawerView/index.js
  100. 79
      app/components/UI/EditGasFee1559/index.js
  101. Some files were not shown because too many files have changed in this diff Show More

@ -3,6 +3,12 @@ module.exports = {
root: true,
parser: 'babel-eslint',
extends: ['@react-native-community', 'eslint:recommended', 'plugin:import/warnings', 'plugin:react/recommended'],
overrides: [
{
files: ['*.{ts,tsx}'],
extends: ['@metamask/eslint-config-typescript'],
},
],
globals: {
process: true,
beforeAll: true,
@ -18,12 +24,12 @@ module.exports = {
beforeEach: true,
device: true,
waitFor: true,
__DEV__: true
__DEV__: true,
},
settings: {
'import/resolver': {
typescript: {} // this loads <rootdir>/tsconfig.json to eslint
}
typescript: {}, // this loads <rootdir>/tsconfig.json to eslint
},
},
rules: {
'no-catch-shadow': 0,
@ -33,8 +39,8 @@ module.exports = {
'single',
{
avoidEscape: true,
allowTemplateLiterals: true
}
allowTemplateLiterals: true,
},
],
'comma-dangle': 0,
curly: 0,
@ -65,8 +71,8 @@ module.exports = {
'no-constant-condition': [
2,
{
checkLoops: false
}
checkLoops: false,
},
],
'no-duplicate-imports': 2,
'no-empty-function': 2,
@ -89,8 +95,8 @@ module.exports = {
'no-unneeded-ternary': [
2,
{
defaultAssignment: false
}
defaultAssignment: false,
},
],
'no-unsafe-negation': 2,
'no-unused-expressions': 'off',
@ -126,13 +132,13 @@ module.exports = {
'react/no-multi-comp': [
2,
{
ignoreStateless: true
}
ignoreStateless: true,
},
],
'react/no-render-return-value': 2,
'react/no-string-refs': 2,
'react/no-unused-prop-types': 2,
'react/prefer-es6-class': 2,
radix: 0
}
radix: 0,
},
};

@ -1,9 +1,9 @@
const _isObject = obj => typeof obj === 'object' && !Array.isArray(obj);
const _isObject = (obj) => typeof obj === 'object' && !Array.isArray(obj);
const _deepMergeInto = (oldObject, newObject) => {
const newKeys = Object.keys(newObject);
const mergedObject = oldObject;
newKeys.forEach(key => {
newKeys.forEach((key) => {
const oldValue = mergedObject[key];
const newValue = newObject[key];
@ -46,11 +46,11 @@ const asMock = {
multiGet: _multiGet,
multiSet: _multiSet,
multiRemove: _multiRemove,
multiMerge: _multiMerge
multiMerge: _multiMerge,
};
async function _multiSet(keyValuePairs, callback) {
keyValuePairs.forEach(keyValue => {
keyValuePairs.forEach((keyValue) => {
const key = keyValue[0];
asMock.__INTERNAL_MOCK_STORAGE__[key] = keyValue[1];
@ -60,14 +60,14 @@ async function _multiSet(keyValuePairs, callback) {
}
async function _multiGet(keys, callback) {
const values = keys.map(key => [key, asMock.__INTERNAL_MOCK_STORAGE__[key] || null]);
const values = keys.map((key) => [key, asMock.__INTERNAL_MOCK_STORAGE__[key] || null]);
callback && callback(null, values);
return values;
}
async function _multiRemove(keys, callback) {
keys.forEach(key => {
keys.forEach((key) => {
if (asMock.__INTERNAL_MOCK_STORAGE__[key]) {
delete asMock.__INTERNAL_MOCK_STORAGE__[key];
}
@ -90,7 +90,7 @@ async function _getAllKeys() {
}
async function _multiMerge(keyValuePairs, callback) {
keyValuePairs.forEach(keyValue => {
keyValuePairs.forEach((keyValue) => {
const key = keyValue[0];
const value = JSON.parse(keyValue[1]);

@ -6,5 +6,5 @@ export default {
hide: jest.fn().mockImplementation(() => {
// eslint-disable-next-line no-console
console.log('hide splash screen');
})
}),
};

@ -13,8 +13,8 @@ export default {
exists: () => Promise.resolve(),
dirs: {
CacheDir: noop,
DocumentDir: noop
}
DocumentDir: noop,
},
},
wrap: noop
wrap: noop,
};

@ -1,6 +1,6 @@
export function dismissAlert() {
return {
type: 'HIDE_ALERT'
type: 'HIDE_ALERT',
};
}
@ -10,6 +10,6 @@ export function showAlert({ isVisible, autodismiss, content, data }) {
isVisible,
autodismiss,
content,
data
data,
};
}

@ -1,13 +1,13 @@
export function addBookmark(bookmark) {
return {
type: 'ADD_BOOKMARK',
bookmark
bookmark,
};
}
export function removeBookmark(bookmark) {
return {
type: 'REMOVE_BOOKMARK',
bookmark
bookmark,
};
}

@ -9,7 +9,7 @@ export function addToHistory({ url, name }) {
return {
type: 'ADD_TO_BROWSER_HISTORY',
url,
name
name,
};
}
@ -18,7 +18,7 @@ export function addToHistory({ url, name }) {
*/
export function clearHistory() {
return {
type: 'CLEAR_BROWSER_HISTORY'
type: 'CLEAR_BROWSER_HISTORY',
};
}
@ -30,7 +30,7 @@ export function clearHistory() {
export function addToWhitelist(url) {
return {
type: 'ADD_TO_BROWSER_WHITELIST',
url
url,
};
}
@ -39,7 +39,7 @@ export function addToWhitelist(url) {
*/
export function closeAllTabs() {
return {
type: 'CLOSE_ALL_TABS'
type: 'CLOSE_ALL_TABS',
};
}
@ -52,7 +52,7 @@ export function createNewTab(url) {
return {
type: 'CREATE_NEW_TAB',
url,
id: Date.now()
id: Date.now(),
};
}
@ -64,7 +64,7 @@ export function createNewTab(url) {
export function closeTab(id) {
return {
type: 'CLOSE_TAB',
id
id,
};
}
@ -76,7 +76,7 @@ export function closeTab(id) {
export function setActiveTab(id) {
return {
type: 'SET_ACTIVE_TAB',
id
id,
};
}
@ -90,6 +90,6 @@ export function updateTab(id, data) {
return {
type: 'UPDATE_TAB',
id,
data
data,
};
}

@ -4,12 +4,12 @@ export const addFavoriteCollectible = (selectedAddress, chainId, collectible) =>
type: ADD_FAVORITE_COLLECTIBLE,
selectedAddress,
chainId,
collectible
collectible,
});
export const removeFavoriteCollectible = (selectedAddress, chainId, collectible) => ({
type: REMOVE_FAVORITE_COLLECTIBLE,
selectedAddress,
chainId,
collectible
collectible,
});

@ -2,12 +2,12 @@ import { INFURA_AVAILABILITY_BLOCKED, INFURA_AVAILABILITY_NOT_BLOCKED } from '..
export function setInfuraAvailabilityBlocked() {
return {
type: INFURA_AVAILABILITY_BLOCKED
type: INFURA_AVAILABILITY_BLOCKED,
};
}
export function setInfuraAvailabilityNotBlocked() {
return {
type: INFURA_AVAILABILITY_NOT_BLOCKED
type: INFURA_AVAILABILITY_NOT_BLOCKED,
};
}

@ -1,39 +1,39 @@
// eslint-disable-next-line import/prefer-default-export
export function toggleNetworkModal() {
return {
type: 'TOGGLE_NETWORK_MODAL'
type: 'TOGGLE_NETWORK_MODAL',
};
}
export function toggleAccountsModal() {
return {
type: 'TOGGLE_ACCOUNT_MODAL'
type: 'TOGGLE_ACCOUNT_MODAL',
};
}
export function toggleCollectibleContractModal() {
return {
type: 'TOGGLE_COLLECTIBLE_CONTRACT_MODAL'
type: 'TOGGLE_COLLECTIBLE_CONTRACT_MODAL',
};
}
export function toggleReceiveModal(asset) {
return {
type: 'TOGGLE_RECEIVE_MODAL',
asset
asset,
};
}
export function toggleDappTransactionModal(show) {
return {
type: 'TOGGLE_DAPP_TRANSACTION_MODAL',
show
show,
};
}
export function toggleApproveModal(show) {
return {
type: 'TOGGLE_APPROVE_MODAL',
show
show,
};
}

@ -1,13 +1,13 @@
export function hideCurrentNotification() {
return {
type: 'HIDE_CURRENT_NOTIFICATION'
type: 'HIDE_CURRENT_NOTIFICATION',
};
}
export function hideNotificationById(id) {
return {
type: 'HIDE_NOTIFICATION_BY_ID',
id
id,
};
}
@ -16,7 +16,7 @@ export function modifyOrShowTransactionNotificationById({ autodismiss, transacti
type: 'MODIFY_OR_SHOW_TRANSACTION_NOTIFICATION',
autodismiss,
transaction,
status
status,
};
}
@ -26,7 +26,7 @@ export function modifyOrShowSimpleNotificationById({ autodismiss, title, descrip
autodismiss,
title,
description,
status
status,
};
}
@ -34,20 +34,20 @@ export function replaceNotificationById(notification) {
return {
type: 'REPLACE_NOTIFICATION_BY_ID',
notification,
id: notification.id
id: notification.id,
};
}
export function removeNotificationById(id) {
return {
type: 'REMOVE_NOTIFICATION_BY_ID',
id
id,
};
}
export function removeCurrentNotification() {
return {
type: 'REMOVE_CURRENT_NOTIFICATION'
type: 'REMOVE_CURRENT_NOTIFICATION',
};
}
@ -58,7 +58,7 @@ export function showSimpleNotification({ autodismiss, title, description, status
autodismiss,
title,
description,
status
status,
};
}
@ -67,12 +67,12 @@ export function showTransactionNotification({ autodismiss, transaction, status }
type: 'SHOW_TRANSACTION_NOTIFICATION',
autodismiss,
transaction,
status
status,
};
}
export function removeNotVisibleNotifications() {
return {
type: 'REMOVE_NOT_VISIBLE_NOTIFICATIONS'
type: 'REMOVE_NOT_VISIBLE_NOTIFICATIONS',
};
}

@ -6,7 +6,7 @@
export function saveOnboardingEvent(event) {
return {
type: 'SAVE_EVENT',
event
event,
};
}
@ -15,6 +15,6 @@ export function saveOnboardingEvent(event) {
*/
export function clearOnboardingEvents() {
return {
type: 'CLEAR_EVENTS'
type: 'CLEAR_EVENTS',
};
}

@ -1,14 +1,14 @@
export function approveHost(hostname) {
return {
type: 'APPROVE_HOST',
hostname
hostname,
};
}
export function rejectHost(hostname) {
return {
type: 'REJECT_HOST',
hostname
hostname,
};
}
@ -19,13 +19,13 @@ export function clearHosts() {
export function setPrivacyMode(enabled) {
return {
type: 'SET_PRIVACY_MODE',
enabled
enabled,
};
}
export function setThirdPartyApiMode(enabled) {
return {
type: 'SET_THIRD_PARTY_API_MODE',
enabled
enabled,
};
}

@ -1,6 +1,6 @@
export default function addRecent(recent) {
return {
type: 'ADD_RECENT',
recent
recent,
};
}

@ -1,48 +1,48 @@
export function setSearchEngine(searchEngine) {
return {
type: 'SET_SEARCH_ENGINE',
searchEngine
searchEngine,
};
}
export function setShowHexData(showHexData) {
return {
type: 'SET_SHOW_HEX_DATA',
showHexData
showHexData,
};
}
export function setShowCustomNonce(showCustomNonce) {
return {
type: 'SET_SHOW_CUSTOM_NONCE',
showCustomNonce
showCustomNonce,
};
}
export function setHideZeroBalanceTokens(hideZeroBalanceTokens) {
return {
type: 'SET_HIDE_ZERO_BALANCE_TOKENS',
hideZeroBalanceTokens
hideZeroBalanceTokens,
};
}
export function setLockTime(lockTime) {
return {
type: 'SET_LOCK_TIME',
lockTime
lockTime,
};
}
export function setPrimaryCurrency(primaryCurrency) {
return {
type: 'SET_PRIMARY_CURRENCY',
primaryCurrency
primaryCurrency,
};
}
export function setUseBlockieIcon(useBlockieIcon) {
return {
type: 'SET_USE_BLOCKIE_ICON',
useBlockieIcon
useBlockieIcon,
};
}

@ -1,7 +1,7 @@
import TransactionTypes from '../../core/TransactionTypes';
const {
ASSET: { ETH, ERC20, ERC721 }
ASSET: { ETH, ERC20, ERC721 },
} = TransactionTypes;
/**
@ -9,7 +9,7 @@ const {
*/
export function resetTransaction() {
return {
type: 'RESET_TRANSACTION'
type: 'RESET_TRANSACTION',
};
}
@ -22,7 +22,7 @@ export function newAssetTransaction(selectedAsset) {
return {
type: 'NEW_ASSET_TRANSACTION',
selectedAsset,
assetType: selectedAsset.isETH ? ETH : selectedAsset.tokenId ? ERC721 : ERC20
assetType: selectedAsset.isETH ? ETH : selectedAsset.tokenId ? ERC721 : ERC20,
};
}
@ -42,7 +42,7 @@ export function setRecipient(from, to, ensRecipient, transactionToName, transact
to,
ensRecipient,
transactionToName,
transactionFromName
transactionFromName,
};
}
@ -55,7 +55,7 @@ export function setSelectedAsset(selectedAsset) {
return {
type: 'SET_SELECTED_ASSET',
selectedAsset,
assetType: selectedAsset.isETH ? ETH : selectedAsset.tokenId ? ERC721 : ERC20
assetType: selectedAsset.isETH ? ETH : selectedAsset.tokenId ? ERC721 : ERC20,
};
}
@ -67,7 +67,7 @@ export function setSelectedAsset(selectedAsset) {
export function prepareTransaction(transaction) {
return {
type: 'PREPARE_TRANSACTION',
transaction
transaction,
};
}
@ -88,7 +88,7 @@ export function prepareFullTransaction({
transactionToName,
transactionFromName,
selectedAsset,
assetType
assetType,
}) {
return {
type: 'PREPARE_FULL_TRANSACTION',
@ -97,7 +97,7 @@ export function prepareFullTransaction({
transactionToName,
transactionFromName,
selectedAsset,
assetType
assetType,
};
}
@ -109,7 +109,7 @@ export function prepareFullTransaction({
export function setTransactionObject(transaction) {
return {
type: 'SET_TRANSACTION_OBJECT',
transaction
transaction,
};
}
@ -121,7 +121,7 @@ export function setTransactionObject(transaction) {
export function setTokensTransaction(asset) {
return {
type: 'SET_TOKENS_TRANSACTION',
asset
asset,
};
}
@ -133,7 +133,7 @@ export function setTokensTransaction(asset) {
export function setEtherTransaction(transaction) {
return {
type: 'SET_ETHER_TRANSACTION',
transaction
transaction,
};
}
@ -145,7 +145,7 @@ export function setEtherTransaction(transaction) {
export function setIndividualTokenTransaction(token) {
return {
type: 'SET_INDIVIDUAL_TOKEN_TRANSACTION',
token
token,
};
}
@ -157,7 +157,7 @@ export function setIndividualTokenTransaction(token) {
export function setIndividualCollectibleTransaction(collectible) {
return {
type: 'SET_INDIVIDUAL_COLLECTIBLE_TRANSACTION',
collectible
collectible,
};
}
@ -169,20 +169,20 @@ export function setIndividualCollectibleTransaction(collectible) {
export function setCollectibleContractTransaction(collectible) {
return {
type: 'SET_COLLECTIBLE_CONTRACT_TRANSACTION',
collectible
collectible,
};
}
export function setNonce(nonce) {
return {
type: 'SET_NONCE',
nonce
nonce,
};
}
export function setProposedNonce(proposedNonce) {
return {
type: 'SET_PROPOSED_NONCE',
proposedNonce
proposedNonce,
};
}

@ -1,66 +1,66 @@
export function passwordSet() {
return {
type: 'PASSWORD_SET'
type: 'PASSWORD_SET',
};
}
export function passwordUnset() {
return {
type: 'PASSWORD_UNSET'
type: 'PASSWORD_UNSET',
};
}
export function seedphraseBackedUp() {
return {
type: 'SEEDPHRASE_BACKED_UP'
type: 'SEEDPHRASE_BACKED_UP',
};
}
export function seedphraseNotBackedUp() {
return {
type: 'SEEDPHRASE_NOT_BACKED_UP'
type: 'SEEDPHRASE_NOT_BACKED_UP',
};
}
export function backUpSeedphraseAlertVisible() {
return {
type: 'BACK_UP_SEEDPHRASE_VISIBLE'
type: 'BACK_UP_SEEDPHRASE_VISIBLE',
};
}
export function backUpSeedphraseAlertNotVisible() {
return {
type: 'BACK_UP_SEEDPHRASE_NOT_VISIBLE'
type: 'BACK_UP_SEEDPHRASE_NOT_VISIBLE',
};
}
export function protectWalletModalVisible() {
return {
type: 'PROTECT_MODAL_VISIBLE'
type: 'PROTECT_MODAL_VISIBLE',
};
}
export function protectWalletModalNotVisible() {
return {
type: 'PROTECT_MODAL_NOT_VISIBLE'
type: 'PROTECT_MODAL_NOT_VISIBLE',
};
}
export function loadingSet(loadingMsg) {
return {
type: 'LOADING_SET',
loadingMsg
loadingMsg,
};
}
export function loadingUnset() {
return {
type: 'LOADING_UNSET'
type: 'LOADING_UNSET',
};
}
export function setGasEducationCarouselSeen() {
return {
type: 'SET_GAS_EDUCATION_CAROUSEL_SEEN'
type: 'SET_GAS_EDUCATION_CAROUSEL_SEEN',
};
}

@ -4,6 +4,6 @@
export default function setOnboardingWizardStep(step) {
return {
type: 'SET_ONBOARDING_WIZARD_STEP',
step
step,
};
}

@ -10,30 +10,30 @@ const styles = StyleSheet.create({
paddingVertical: 12,
borderWidth: 1,
borderRadius: 4,
flexDirection: 'row'
flexDirection: 'row',
},
baseSmall: {
paddingVertical: 8
paddingVertical: 8,
},
info: {
backgroundColor: colors.blue100,
borderColor: colors.blue
borderColor: colors.blue,
},
warning: {
backgroundColor: colors.yellow100,
borderColor: colors.yellow
borderColor: colors.yellow,
},
error: {
backgroundColor: colors.red000,
borderColor: colors.red
borderColor: colors.red,
},
textInfo: { color: colors.blue, flexShrink: 1, lineHeight: 16.8 },
textWarning: { color: colors.yellow700, flexShrink: 1, lineHeight: 16.8 },
textError: { color: colors.red, flexShrink: 1, lineHeight: 16.8 },
textIconStyle: { marginRight: 12 },
iconWrapper: {
alignItems: 'center'
}
alignItems: 'center',
},
});
function getStyles(type) {
@ -75,7 +75,7 @@ Alert.propTypes = {
small: PropTypes.bool,
renderIcon: PropTypes.func,
onPress: PropTypes.func,
children: PropTypes.oneOfType([PropTypes.node, PropTypes.func])
children: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
};
export default Alert;

@ -10,18 +10,18 @@ const styles = StyleSheet.create({
modalContainer: {
width: '100%',
backgroundColor: colors.white,
borderRadius: 10
borderRadius: 10,
},
modalView: {
flexDirection: 'column',
justifyContent: 'center',
alignItems: 'center'
alignItems: 'center',
},
header: {
borderBottomWidth: StyleSheet.hairlineWidth,
borderColor: colors.grey100,
flexDirection: 'row',
paddingHorizontal: 16
paddingHorizontal: 16,
},
title: {
flex: 1,
@ -30,32 +30,32 @@ const styles = StyleSheet.create({
marginVertical: 12,
marginHorizontal: 24,
color: colors.fontPrimary,
...fontStyles.bold
...fontStyles.bold,
},
closeIcon: { paddingTop: 4, position: 'absolute', right: 16 },
body: {
paddingHorizontal: 15
paddingHorizontal: 15,
},
section: {
paddingVertical: 16,
flexDirection: 'row'
flexDirection: 'row',
},
sectionBorderBottom: {
borderBottomColor: colors.grey100,
borderBottomWidth: 1
borderBottomWidth: 1,
},
column: {
flex: 1
flex: 1,
},
columnEnd: {
alignItems: 'flex-end'
alignItems: 'flex-end',
},
sectionTitle: {
...fontStyles.normal,
fontSize: 10,
color: colors.grey500,
marginBottom: 8
}
marginBottom: 8,
},
});
const DetailsModal = ({ children }) => (
<View style={styles.modalView}>
@ -93,36 +93,36 @@ DetailsModal.Column = DetailsModalColumn;
const stylePropType = PropTypes.oneOfType([PropTypes.object, PropTypes.array]);
DetailsModal.propTypes = {
children: PropTypes.node
children: PropTypes.node,
};
DetailsModalHeader.propTypes = {
style: stylePropType
style: stylePropType,
};
DetailsModalTitle.propTypes = {
style: stylePropType
style: stylePropType,
};
DetailsModalCloseIcon.propTypes = {
style: stylePropType
style: stylePropType,
};
DetailsModalBody.propTypes = {
style: stylePropType
style: stylePropType,
};
DetailsModalSection.propTypes = {
style: stylePropType,
/**
* Adds a border to the bottom of the section
*/
borderBottom: PropTypes.bool
borderBottom: PropTypes.bool,
};
DetailsModalSectionTitle.propTypes = {
style: stylePropType
style: stylePropType,
};
DetailsModalColumn.propTypes = {
style: stylePropType,
/**
* Aligns column content to flex-end
*/
end: PropTypes.bool
end: PropTypes.bool,
};
export default DetailsModal;

@ -11,22 +11,22 @@ const styles = StyleSheet.create({
display: 'flex',
flexDirection: 'row',
justifyContent: 'space-around',
alignItems: 'center'
alignItems: 'center',
},
labels: {
display: 'flex',
flexDirection: 'row',
justifyContent: 'space-around',
alignItems: 'flex-start'
alignItems: 'flex-start',
},
option: {
width: OPTION_WIDTH,
display: 'flex',
alignItems: 'center',
flex: 0,
flexDirection: 'column'
flexDirection: 'column',
},
circle: size => ({
circle: (size) => ({
width: size,
height: size,
flexShrink: 0,
@ -36,27 +36,27 @@ const styles = StyleSheet.create({
justifyContent: 'center',
borderWidth: 2,
borderRadius: 9999,
borderColor: colors.grey200
borderColor: colors.grey200,
}),
circleSelected: {
borderColor: colors.blue
borderColor: colors.blue,
},
circleError: {
borderColor: colors.red
borderColor: colors.red,
},
circleDisabled: {
opacity: 0.4
opacity: 0.4,
},
innerCircle: size => ({
innerCircle: (size) => ({
width: size * INNER_CIRCLE_SCALE,
height: size * INNER_CIRCLE_SCALE,
flexShrink: 0,
flexGrow: 0,
backgroundColor: colors.blue,
borderRadius: 999
borderRadius: 999,
}),
innerCircleError: {
backgroundColor: colors.red
backgroundColor: colors.red,
},
verticalLine: {
marginTop: 2,
@ -64,7 +64,7 @@ const styles = StyleSheet.create({
width: 0,
height: 4,
borderLeftWidth: 1,
borderColor: colors.grey200
borderColor: colors.grey200,
},
topVerticalLine: {
marginTop: 0,
@ -72,33 +72,33 @@ const styles = StyleSheet.create({
width: 0,
height: 4,
borderLeftWidth: 1,
borderColor: colors.blue
borderColor: colors.blue,
},
line: {
alignItems: 'center',
flexDirection: 'row',
justifyContent: 'space-around',
width: '100%',
marginBottom: 2
marginBottom: 2,
},
lineHolder: {
flexDirection: 'row',
alignItems: 'center',
borderWidth: 0
borderWidth: 0,
},
lineFill: {
flex: 1
flex: 1,
},
lineVisible: {
borderTopWidth: 1,
borderColor: colors.grey200
borderColor: colors.grey200,
},
circleHitSlop: {
top: 0,
bottom: 20,
left: 0,
right: 0
}
right: 0,
},
});
function Circle({ size = 22, selected, disabled, error }) {
@ -108,7 +108,7 @@ function Circle({ size = 22, selected, disabled, error }) {
styles.circle(size),
selected && styles.circleSelected,
selected && error && styles.circleError,
disabled && styles.circleDisabled
disabled && styles.circleDisabled,
]}
>
{selected && (
@ -116,7 +116,7 @@ function Circle({ size = 22, selected, disabled, error }) {
style={[
styles.innerCircle(size),
selected && error && styles.innerCircleError,
{ width: size * INNER_CIRCLE_SCALE, height: size * INNER_CIRCLE_SCALE }
{ width: size * INNER_CIRCLE_SCALE, height: size * INNER_CIRCLE_SCALE },
]}
/>
)}
@ -127,7 +127,7 @@ Circle.propTypes = {
size: PropTypes.number,
selected: PropTypes.bool,
disabled: PropTypes.bool,
error: PropTypes.bool
error: PropTypes.bool,
};
function Option({ onPress, name, ...props }) {
@ -137,16 +137,16 @@ function Option({ onPress, name, ...props }) {
Option.propTypes = {
onPress: PropTypes.func,
name: PropTypes.string
name: PropTypes.string,
};
function HorizontalSelector({ options = [], selected, circleSize, onPress, disabled, ...props }) {
const hasTopLabels = useMemo(() => options.some(option => option.topLabel), [options]);
const hasTopLabels = useMemo(() => options.some((option) => option.topLabel), [options]);
return (
<View {...props}>
{hasTopLabels && (
<View style={styles.selector}>
{options.map(option =>
{options.map((option) =>
option.topLabel ? (
<View key={option.name} style={styles.option}>
{typeof option.topLabel === 'string' ? (
@ -167,7 +167,7 @@ function HorizontalSelector({ options = [], selected, circleSize, onPress, disab
</View>
)}
<View style={styles.selector}>
{options.map(option => (
{options.map((option) => (
<Option
key={option.name}
onPress={onPress}
@ -199,7 +199,7 @@ function HorizontalSelector({ options = [], selected, circleSize, onPress, disab
))}
</View>
<View style={styles.labels}>
{options.map(option => (
{options.map((option) => (
<Option
key={option.name}
onPress={onPress}
@ -247,7 +247,7 @@ HorizontalSelector.propTypes = {
/**
* Boolean value to determine if the option should represent an error
*/
error: PropTypes.bool
error: PropTypes.bool,
})
),
/**
@ -265,7 +265,7 @@ HorizontalSelector.propTypes = {
/**
* Current option name selected
*/
selected: PropTypes.string
selected: PropTypes.string,
};
export default HorizontalSelector;

@ -9,32 +9,32 @@ import { colors } from '../../../styles/common';
const styles = StyleSheet.create({
keypad: {
paddingHorizontal: 25
paddingHorizontal: 25,
},
keypadRow: {
flexDirection: 'row',
justifyContent: 'space-around'
justifyContent: 'space-around',
},
keypadButton: {
paddingHorizontal: 20,
paddingVertical: Device.isMediumDevice() ? (Device.isIphone5() ? 4 : 8) : 12,
flex: 1,
justifyContent: 'center',
alignItems: 'center'
alignItems: 'center',
},
keypadButtonText: {
color: colors.black,
textAlign: 'center',
fontSize: 30
fontSize: 30,
},
deleteIcon: {
fontSize: 25,
marginTop: 5
}
marginTop: 5,
},
});
const KeypadContainer = props => <View style={styles.keypad} {...props} />;
const KeypadRow = props => <View style={styles.keypadRow} {...props} />;
const KeypadContainer = (props) => <View style={styles.keypad} {...props} />;
const KeypadRow = (props) => <View style={styles.keypadRow} {...props} />;
const KeypadButton = ({ children, ...props }) => (
<TouchableOpacity style={styles.keypadButton} {...props}>
<Text style={styles.keypadButtonText}>{children}</Text>
@ -42,10 +42,10 @@ const KeypadButton = ({ children, ...props }) => (
);
KeypadButton.propTypes = {
children: PropTypes.node
children: PropTypes.node,
};
const KeypadDeleteButton = props => (
const KeypadDeleteButton = (props) => (
<TouchableOpacity style={styles.keypadButton} {...props}>
<IonicIcon style={[styles.keypadButtonText, styles.deleteIcon]} name="md-arrow-back" />
</TouchableOpacity>

@ -13,108 +13,108 @@ export const KEYS = {
DIGIT_0: '0',
PERIOD: 'PERIOD',
BACK: 'BACK',
INITIAL: 'INITIAL'
INITIAL: 'INITIAL',
};
export const CURRENCIES = {
AUD: {
decimalSeparator: '.',
handler: createKeypadRule({ decimalSeparator: '.', decimals: 2 }),
symbol: '$'
symbol: '$',
},
BRL: {
decimalSeparator: '.',
handler: createKeypadRule({ decimalSeparator: '.', decimals: 2 }),
symbol: 'R$'
symbol: 'R$',
},
CAD: {
decimalSeparator: '.',
handler: createKeypadRule({ decimalSeparator: '.', decimals: 2 }),
symbol: '$'
symbol: '$',
},
CLP: {
decimalSeparator: null,
handler: createKeypadRule({ decimalSeparator: null }),
symbol: '$'
symbol: '$',
},
CZK: {
decimalSeparator: '.',
handler: createKeypadRule({ decimalSeparator: '.', decimals: 2 }),
symbol: 'Kč'
symbol: 'Kč',
},
default: {
decimalSeparator: '.',
handler: createKeypadRule({ decimalSeparator: '.' }),
symbol: null
symbol: null,
},
DKK: {
decimalSeparator: '.',
handler: createKeypadRule({ decimalSeparator: '.', decimals: 2 }),