Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: TypeScript ~4.8.4 and ESLint deps upgrades and initial type fixes #6080

Merged
merged 26 commits into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
0e2ecbc
TypeScript 5 ESLint upgrade and initial type fixes
leotm Mar 30, 2023
4219cc7
Add back test and rename both
leotm Apr 3, 2023
21e94ae
Update ESLint config comment
leotm Apr 3, 2023
daad80e
Downgrade TypeScript from ^5.0.2 to ~4.8.4
leotm Apr 3, 2023
833dea8
Merge remote-tracking branch 'upstream/main' into typescript-5-eslint…
leotm Apr 6, 2023
9111a68
Update Yarn.lock after conflict resolution
leotm Apr 6, 2023
4354a9e
Bump CocoaPods from 1.11.3 to 1.12.0
leotm Apr 6, 2023
249b1fa
Revert "Bump CocoaPods from 1.11.3 to 1.12.0"
leotm Apr 6, 2023
a0cacdd
Revert ButtonLink.types.ts TextStyle addition
leotm Apr 11, 2023
98e893f
Remove Button style from ContractBoxBase
leotm Apr 11, 2023
f380d20
Merge remote-tracking branch 'upstream/main' into typescript-5-eslint…
leotm May 2, 2023
9aa5c8b
Update Yarn lockfile (from prev conflict res)
leotm May 2, 2023
bdbe467
Merge branch 'main' into typescript-5-eslint-upgrade-initial-fixes
sethkfman May 8, 2023
8038bb4
Merge remote-tracking branch 'upstream/main' into typescript-5-eslint…
leotm May 16, 2023
4497275
Merge branch 'main' into typescript-5-eslint-upgrade-initial-fixes
leotm May 23, 2023
28b7c75
Merge remote-tracking branch 'upstream/main' into typescript-5-eslint…
leotm Jun 5, 2023
2dd1f73
Fix lint error @typescript-eslint/no-loss-of-precision
leotm Jun 5, 2023
7b51fe0
Merge remote-tracking branch 'upstream/main' into typescript-5-eslint…
leotm Jun 22, 2023
fe62cac
Merge branch 'main' into typescript-5-eslint-upgrade-initial-fixes
leotm Jun 26, 2023
effe4ec
Merge branch 'main' into typescript-5-eslint-upgrade-initial-fixes
leotm Jul 5, 2023
6bba7a1
Merge branch 'main' into typescript-5-eslint-upgrade-initial-fixes
leotm Jul 20, 2023
810bdc7
Merge branch 'main' into typescript-5-eslint-upgrade-initial-fixes
leotm Jul 20, 2023
b95454b
Merge branch 'main' into typescript-5-eslint-upgrade-initial-fixes
leotm Jul 25, 2023
dccfb95
Downgrade ESLint config to v9 and fix peer dependency warnings
Gudahtt Jul 25, 2023
8c746e7
Bump eslint-plugin-react-native 4.0.0 to ^4.0.0
leotm Jul 25, 2023
4240c98
Merge branch 'main' into typescript-5-eslint-upgrade-initial-fixes
Cal-L Jul 25, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ module.exports = {
root: true,
parser: 'babel-eslint',
extends: [
// @react-native-community
// - Depends on babel-eslint parser
// - Migrated to @react-native/eslint-config after v3.2.0
'@react-native-community',
'eslint:recommended',
'plugin:import/warnings',
Expand All @@ -13,6 +16,10 @@ module.exports = {
{
files: ['*.{ts,tsx}'],
extends: ['@metamask/eslint-config-typescript'],
rules: {
// TODO: re-enable
'jsdoc/no-types': 'off',
},
},
{
files: ['scripts/**/*.js'],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// @flow
leotm marked this conversation as resolved.
Show resolved Hide resolved

// eslint-disable-next-line import/no-extraneous-dependencies
import I18nJs from 'i18n-js';

Expand Down
10 changes: 5 additions & 5 deletions app/actions/security/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable import/prefer-default-export */
import type { Action } from 'redux';
import type { Action as ReduxAction } from 'redux';

export enum ActionType {
SET_ALLOW_LOGIN_WITH_REMEMBER_ME = 'SET_ALLOW_LOGIN_WITH_REMEMBER_ME',
Expand All @@ -9,22 +9,22 @@ export enum ActionType {
}

export interface AllowLoginWithRememberMeUpdated
extends Action<ActionType.SET_ALLOW_LOGIN_WITH_REMEMBER_ME> {
extends ReduxAction<ActionType.SET_ALLOW_LOGIN_WITH_REMEMBER_ME> {
enabled: boolean;
}

export interface AutomaticSecurityChecks
extends Action<ActionType.SET_AUTOMATIC_SECURITY_CHECKS> {
extends ReduxAction<ActionType.SET_AUTOMATIC_SECURITY_CHECKS> {
enabled: boolean;
}

export interface UserSelectedAutomaticSecurityChecksOptions
extends Action<ActionType.USER_SELECTED_AUTOMATIC_SECURITY_CHECKS_OPTION> {
extends ReduxAction<ActionType.USER_SELECTED_AUTOMATIC_SECURITY_CHECKS_OPTION> {
selected: boolean;
}

export interface SetAutomaticSecurityChecksModalOpen
extends Action<ActionType.SET_AUTOMATIC_SECURITY_CHECKS_MODAL_OPEN> {
extends ReduxAction<ActionType.SET_AUTOMATIC_SECURITY_CHECKS_MODAL_OPEN> {
open: boolean;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import TEST_ADDRESS from '../../../../constants/address';
import {
CONTRACT_PET_NAME,
CONTRACT_LOCAL_IMAGE,
CONTRACT_COPY_ADDRESS,
CONTRACT_ON_PRESS,
} from '../ContractBox/ContractBox.constants';
import { CONTRACT_BOX_NO_PET_NAME_TEST_ID } from './ContractBoxBase.constants';
import { ContractBoxBaseProps } from './ContractBoxBase.types';
Expand All @@ -17,6 +19,8 @@ describe('Component ContractBoxBase', () => {
contractAddress: TEST_ADDRESS,
contractPetName: CONTRACT_PET_NAME,
contractLocalImage: CONTRACT_LOCAL_IMAGE,
onCopyAddress: CONTRACT_COPY_ADDRESS,
onContractPress: CONTRACT_ON_PRESS,
};
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ const ContractBoxBase = ({
variant={ButtonVariants.Link}
textVariant={TextVariant.HeadingMD}
label={formattedAddress}
style={styles.header}
onPress={onContractPress}
/>
</View>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ exports[`Component ContractBoxBase should render correctly 1`] = `
variant="Token"
/>
</View>
<Component>
<Component
onPress={[Function]}
>
<Text
style={
Object {
Expand Down Expand Up @@ -65,6 +67,7 @@ exports[`Component ContractBoxBase should render correctly 1`] = `
>
<IconView
name="Copy"
onPress={[Function]}
size="24"
testID="copy-icon"
/>
Expand Down
5 changes: 5 additions & 0 deletions app/components/UI/Identicon/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ interface IdenticonProps {
useBlockieIcon?: boolean;
}

/**
* UI component that renders an Identicon
* for now it's just a blockie
* but we could add more types in the future
*/
const Identicon: React.FC<IdenticonProps> = ({
diameter = 46,
address,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const mockInitialState = {
AccountTrackerController: {
accounts: {
'0x0': {
balance: 0x4a7036655fab2ca3,
balance: '0x4a7036655fab2ca3',
},
'0x1': {
balance: '0x5',
Expand Down
4 changes: 2 additions & 2 deletions app/core/Authentication/Authentication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ class AuthenticationService {
* This method is used for password memory obfuscation
* It simply returns an empty string so we can reset all the sensitive params like passwords and SRPs.
* Since we cannot control memory in JS the best we can do is remove the pointer to sensitive information in memory
* - see this thread for more details: https://security.stackexchange.com/questions/192387/how-to-securely-erase-javascript-parameters-after-use
* - see this thread for more details: https://security.stackexchange.com/questions/192387/how-to-securely-erase-javascript-parameters-after-use
* [Future improvement] to fully remove these values from memory we can convert these params to Buffers or UInt8Array as is done in extension
* - see: https://github.com/MetaMask/metamask-extension/commit/98f187c301176152a7f697e62e2ba6d78b018b68
* - see: https://github.com/MetaMask/metamask-extension/commit/98f187c301176152a7f697e62e2ba6d78b018b68
*/
private wipeSensitiveData = () => '';

Expand Down
2 changes: 1 addition & 1 deletion app/core/EngineService/EngineService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class EngineService {
* Initialize the engine with a backup vault from the Secure KeyChain
*
* @returns Promise<InitializeEngineResult>
* InitializeEngineResult {
* InitializeEngineResult {
success: boolean;
error?: string;
}
Expand Down
7 changes: 7 additions & 0 deletions app/declarations.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
// This file contains type declarations for asset types.
// Ex. This makes it so that when you import CloseIcon from './close-icon.svg, CloseIcon, will be detected as a React.FC component.
declare module '*.mp4';

declare module '@exodus/react-native-payments/lib/js/__mocks__';

declare module 'react-native-fade-in-image';

declare module 'react-native-minimizer';

declare module '*.svg' {
import { SvgProps } from 'react-native-svg';
const content: React.FC<SvgProps & { name: string }>;
Expand Down
28 changes: 15 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,8 @@
"@ethersproject/contracts": "^5.7.0",
"@ethersproject/providers": "^5.7.2",
"@lavamoat/allow-scripts": "^1.0.6",
"@metamask/eslint-config": "^7.0.0",
"@metamask/eslint-config-typescript": "^7.0.0",
"@metamask/eslint-config": "^9.0.0",
"@metamask/eslint-config-typescript": "^9.0.0",
"@metamask/mobile-provider": "^2.1.0",
"@metamask/test-dapp": "^6.1.0",
"@react-native-community/eslint-config": "^2.0.0",
Expand All @@ -357,7 +357,8 @@
"@testing-library/react": "14.0.0",
"@testing-library/react-hooks": "^8.0.1",
"@testing-library/react-native": "12.1.2",
"@types/enzyme": "^3.10.9",
"@types/i18n-js": "^3.8.4",
"@types/enzyme": "^3.10.12",
"@types/is-url": "^1.2.30",
"@types/jest": "^28.1.8",
"@types/node": "^17.0.21",
Expand All @@ -367,12 +368,12 @@
"@types/react-native-background-timer": "^2.0.0",
"@types/react-native-material-textfield": "^0.16.5",
"@types/react-native-svg-charts": "^5.0.12",
"@types/react-native-vector-icons": "^6.4.8",
"@types/react-native-video": "^5.0.13",
"@types/react-native-vector-icons": "^6.4.13",
"@types/react-native-video": "^5.0.14",
"@types/redux-mock-store": "^1.0.3",
"@types/url-parse": "^1.4.8",
"@typescript-eslint/eslint-plugin": "^4.20.0",
"@typescript-eslint/parser": "^4.20.0",
"@typescript-eslint/eslint-plugin": "^5.57.0",
"@typescript-eslint/parser": "^5.57.0",
"@walletconnect/types": "^2.9.0",
"@wdio/appium-service": "^7.19.1",
"@wdio/browserstack-service": "^7.26.0",
Expand All @@ -396,13 +397,14 @@
"enzyme": "3.9.0",
"enzyme-adapter-react-16": "1.10.0",
"enzyme-to-json": "3.3.5",
"eslint": "7.14.0",
"eslint-config-react-native": "4.0.0",
leotm marked this conversation as resolved.
Show resolved Hide resolved
"eslint-import-resolver-typescript": "^2.4.0",
"eslint-plugin-import": "^2.22.1",
"eslint": "^7.23.0",
"eslint-config-prettier": "^8.1.0",
"eslint-import-resolver-typescript": "^3.5.3",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jsdoc": "^36.1.0",
"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-react": "7.16.0",
"eslint-plugin-react-native": "3.7.0",
"eslint-plugin-react-native": "^4.0.0",
"execa": "^5.0.0",
"fbjs-scripts": "^3.0.1",
"fs-extra": "^10.1.0",
Expand Down Expand Up @@ -434,7 +436,7 @@
"rn-nodeify": "10.3.0",
"stack-beautifier": "1.0.2",
"ts-node": "^10.5.0",
"typescript": "^4.4.2",
"typescript": "~4.8.4",
"wdio-cucumberjs-json-reporter": "^4.4.3",
"xml2js": "^0.5.0"
},
Expand Down
Loading