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

chore: Enable typescript coverage for all the files #10745

Merged
merged 45 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
5c46dde
Enable typescript coverage for all the files
tommasini Aug 22, 2024
765998b
Merge branch 'main' into chore/enable-coverage-typescript
tommasini Aug 26, 2024
b34a230
Merge branch 'main' into chore/enable-coverage-typescript
tommasini Aug 26, 2024
a1596dd
fix last typesscript issues
tommasini Aug 26, 2024
88146ce
rever podfile lock and project pbxproj
tommasini Aug 26, 2024
c7b78e5
update snapshot
tommasini Aug 26, 2024
ba9b491
terms of use content fix on declarations fike
tommasini Aug 26, 2024
d1e848c
convert ToU content to typescript
tommasini Aug 26, 2024
bd5174d
revert converting to ts ToU content
tommasini Aug 26, 2024
366ed34
add file extension for the declarations file
tommasini Aug 26, 2024
d54233d
revert declarations file
tommasini Aug 27, 2024
31550a6
add temsOfUseContent js file empty
tommasini Aug 27, 2024
60a51b9
add git ignore back
tommasini Aug 27, 2024
f17fa6b
terms of use content
tommasini Aug 27, 2024
e6aa37f
update CI to ignore terms of use content when looking for diff and ig…
tommasini Aug 27, 2024
595dc7e
missclick fix _ to :
tommasini Aug 27, 2024
cf5ec16
fix
tommasini Aug 27, 2024
38fc4e0
fix ci setup_node
tommasini Aug 27, 2024
2afbacb
change termsOfUseContent for a ts file
tommasini Aug 27, 2024
b62b65f
change it also on generate file of setup mjs
tommasini Aug 27, 2024
0a41c53
termsOfUseContent.ts commit and remove of ignore temporarily
tommasini Aug 27, 2024
d4edba1
termsOfUseContent.ts added to git ignore
tommasini Aug 27, 2024
cf4cac5
fix import
tommasini Aug 27, 2024
13127c7
merge main and solve conflicts
tommasini Aug 27, 2024
f293761
enforce node version of nvmrc on sonar cloud ci step
tommasini Aug 27, 2024
a817059
fix ci yml cleaner code
tommasini Aug 27, 2024
39723fd
address review from component library replacing AvatarGroupToken to A…
tommasini Aug 27, 2024
af640d5
replace to AvatarTokenProps
tommasini Aug 27, 2024
5b0ea8f
Merge branch 'main' into chore/enable-coverage-typescript
tommasini Aug 27, 2024
ad861fc
more scalable way to exclude file on code clean checker
tommasini Aug 27, 2024
cb9101d
fix SC2086:info:8:11: Double quote to prevent globbing and word split…
tommasini Aug 27, 2024
eaf24e5
remove awk and try it with a while loop on ci yml
tommasini Aug 27, 2024
30d3dad
refactor require clean working directory step
tommasini Aug 27, 2024
4d1104e
refactor excludes
tommasini Aug 27, 2024
1acd9b3
refactor excludes
tommasini Aug 27, 2024
4ff4832
refactor excludes
tommasini Aug 27, 2024
9e1d741
map file exclusions
tommasini Aug 27, 2024
c5d25e1
map file exclusions
tommasini Aug 27, 2024
d747d16
echo for testing
tommasini Aug 27, 2024
b8be018
echo for testing
tommasini Aug 27, 2024
33352b2
add exclusion for testing
tommasini Aug 27, 2024
7be9ed5
revert exclusion and echo on ci for testing purposes
tommasini Aug 27, 2024
24c5912
Merge branch 'main' into chore/enable-coverage-typescript
tommasini Aug 27, 2024
d9503f9
add echo to debug
tommasini Aug 27, 2024
8f2a69b
use git update-index assume unchanged command instead
tommasini Aug 27, 2024
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
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,5 +190,5 @@ module.exports = {
radix: 0,
},

ignorePatterns: ['wdio.conf.js', 'app/util/termsOfUse/termsOfUseContent.js'],
ignorePatterns: ['wdio.conf.js', 'app/util/termsOfUse/termsOfUseContent.ts'],
};
53 changes: 53 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,23 @@ jobs:
env:
PACKAGE_READ_TOKEN: ${{ secrets.PACKAGE_READ_TOKEN }}
- run: yarn setup:node
- name: Ingore changes in specific file
shell: bash
run: |
git update-index --assume-unchanged app/util/termsOfUse/termsOfUseContent.ts
- run: yarn setup:node
- name: Require clean working directory
shell: bash
run: |
if ! git diff --exit-code; then
echo "Working tree dirty at end of job"
exit 1
fi
- run: yarn setup:node
- name: Revert ignore changes in specific file
shell: bash
run: |
git update-index --no-assume-unchanged app/util/termsOfUse/termsOfUseContent.ts
dedupe:
runs-on: ubuntu-20.04
needs: setup
Expand Down Expand Up @@ -70,13 +80,23 @@ jobs:
cache: yarn
- run: yarn setup:node
- run: yarn ${{ matrix['scripts'] }}
- run: yarn setup:node
- name: Ingore changes in specific file
shell: bash
run: |
git update-index --assume-unchanged app/util/termsOfUse/termsOfUseContent.ts
- name: Require clean working directory
shell: bash
run: |
if ! git diff --exit-code; then
echo "Working tree dirty at end of job"
exit 1
fi
- run: yarn setup:node
- name: Revert ignore changes in specific file
shell: bash
run: |
git update-index --no-assume-unchanged app/util/termsOfUse/termsOfUseContent.ts
unit-tests:
runs-on: ubuntu-20.04
needs: setup
Expand Down Expand Up @@ -104,13 +124,23 @@ jobs:
name: coverage-${{ matrix.shard }}
path: ./tests/coverage/coverage-${{ matrix.shard }}.json
if-no-files-found: error
- run: yarn setup:node
- name: Ingore changes in specific file
shell: bash
run: |
git update-index --assume-unchanged app/util/termsOfUse/termsOfUseContent.ts
- name: Require clean working directory
shell: bash
run: |
if ! git diff --exit-code; then
echo "Working tree dirty at end of job"
exit 1
fi
- run: yarn setup:node
- name: Revert ignore changes in specific file
shell: bash
run: |
git update-index --no-assume-unchanged app/util/termsOfUse/termsOfUseContent.ts
merge-unit-tests:
runs-on: ubuntu-20.04
needs: unit-tests
Expand All @@ -135,20 +165,33 @@ jobs:
name: coverage
path: ./tests/merged-coverage/lcov.info
if-no-files-found: error
- run: yarn setup:node
- name: Ingore changes in specific file
shell: bash
run: |
git update-index --assume-unchanged app/util/termsOfUse/termsOfUseContent.ts
- name: Require clean working directory
shell: bash
run: |
if ! git diff --exit-code; then
echo "Working tree dirty at end of job"
exit 1
fi
- run: yarn setup:node
- name: Revert ignore changes in specific file
shell: bash
run: |
git update-index --no-assume-unchanged app/util/termsOfUse/termsOfUseContent.ts
sonar-cloud:
runs-on: ubuntu-20.04
needs: merge-unit-tests
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # SonarCloud needs a full checkout to perform necessary analysis
- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
- uses: actions/download-artifact@v3
with:
name: coverage
Expand All @@ -163,13 +206,23 @@ jobs:
env:
HAVE_SONAR_TOKEN: ${{ secrets.SONAR_TOKEN != '' }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- run: yarn setup:node
- name: Ingore changes in specific file
shell: bash
run: |
git update-index --assume-unchanged app/util/termsOfUse/termsOfUseContent.ts
- name: Require clean working directory
shell: bash
run: |
if ! git diff --exit-code; then
echo "Working tree dirty at end of job"
exit 1
fi
- run: yarn setup:node
- name: Revert ignore changes in specific file
shell: bash
run: |
git update-index --no-assume-unchanged app/util/termsOfUse/termsOfUseContent.ts
check-workflows:
name: Check workflows
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -120,5 +120,5 @@ ccache
html-report/

# terms of use
app/util/termsOfUse/termsOfUseContent.js
app/util/termsOfUse/termsOfUseContent.ts
docs/assets/termsOfUse.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ export interface TokenDetails {

export interface MarketDetails {
marketCap: string | null;
totalVolume: number | null;
totalVolume: string | null;
volumeToMarketCap: string | null;
circulatingSupply: number | null;
circulatingSupply: string | null;
allTimeHigh: string | null;
allTimeLow: string | null;
fullyDiluted: number | null;
fullyDiluted: string | null;
gambinish marked this conversation as resolved.
Show resolved Hide resolved
}

interface TokenDetailsProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('NotificationIcon', () => {
it('matches snapshot when icon is provided', () => {
const { toJSON } = renderWithProvider(
<NotificationIcon
image={{ url: walletNotification.imageUrl }}
image={{ url: walletNotification.imageUrl.name }}
badgeIcon={walletNotification.badgeIcon}
/>,
{ state: mockInitialState },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ exports[`NotificationIcon matches snapshot when icon is provided 1`] = `
}
source={
{
"uri": "SvgMock",
"uri": "MockImage",
}
}
style={
Expand Down
6 changes: 5 additions & 1 deletion app/components/UI/ProfileSyncing/ProfileSyncing.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ const handleSwitchToggle = jest.fn();
describe('ProfileSyncing', () => {
it('should render correctly', () => {
const { toJSON } = renderWithProvider(
<ProfileSyncingComponent handleSwitchToggle={handleSwitchToggle} />,
<ProfileSyncingComponent
handleSwitchToggle={handleSwitchToggle}
isBasicFunctionalityEnabled={false}
isProfileSyncingEnabled={false}
/>,
);
expect(toJSON()).toMatchSnapshot();
});
Expand Down
3 changes: 2 additions & 1 deletion app/components/Views/ImportPrivateKey/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
Text,
View,
ActivityIndicator,
DimensionValue,
} from 'react-native';
import { useNavigation } from '@react-navigation/native';
import StyledButton from '../../UI/StyledButton';
Expand All @@ -26,7 +27,7 @@ import { ImportAccountFromPrivateKeySelectorsIDs } from '../../../../e2e/selecto
const ImportPrivateKey = () => {
const [privateKey, setPrivateKey] = useState('');
const [loading, setLoading] = useState(false);
const [inputWidth, setInputWidth] = useState(
const [inputWidth, setInputWidth] = useState<DimensionValue | undefined>(
Device.isAndroid() ? '99%' : undefined,
);
const navigation = useNavigation();
Expand Down
2 changes: 1 addition & 1 deletion app/components/Views/NetworkSelector/NetworkSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ const NetworkSelector = () => {
networkName: string,
) => {
const searchResult: ExtendedNetwork[] = networks.filter(({ name }) =>
name.toLowerCase().includes(networkName.toLowerCase()),
name?.toLowerCase().includes(networkName.toLowerCase()),
);

return searchResult;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ describe('SDKSessionItem', () => {
icon: 'http://icon-url.com',
platform: 'test',
connected: true,
dappId: '123',
},
},
trigger: 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export interface Network {
}

export interface ExtendedNetwork extends Network {
name: string;
name?: string;
formattedRpcUrl?: string | null;
}

Expand Down
6 changes: 3 additions & 3 deletions app/components/hooks/useAccounts/useAccounts.types.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Third party dependencies.
import { KeyringTypes } from '@metamask/keyring-controller';
import { Hex } from '@metamask/utils';

// External dependencies.
import { AvatarGroupToken } from '../../../component-library/components/Avatars/AvatarGroup/AvatarGroup.types';
import { Hex } from '@metamask/utils';
import { AvatarTokenProps } from '../../../component-library/components/Avatars/Avatar/variants/AvatarToken/AvatarToken.types';

/**
* Asset information associated with the account, which includes both the fiat balance and owned tokens.
Expand All @@ -16,7 +16,7 @@ export interface Assets {
/**
* Tokens owned by this account.
*/
tokens?: AvatarGroupToken[];
tokens?: AvatarTokenProps[];
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/declarations/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ declare module '@metamask/contract-metadata' {
export default content;
}

declare module './util/termsOfUse/termsOfUseContent' {
declare module './util/termsOfUse/termsOfUseContent.ts' {
const content: string;
export default content;
}
Expand Down
1 change: 1 addition & 0 deletions app/util/termsOfUse/termsOfUseContent.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default '';
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"clean-android": "yarn clean:android && yarn clean:node",
"lint": "eslint '**/*.{js,ts,tsx}'",
"lint:fix": "eslint '**/*.{js,ts,tsx}' --fix",
"lint:tsc": "tsc --project ./tsconfig.lint.json",
"lint:tsc": "tsc --project ./tsconfig.json",
"format": "prettier '**/*.{js,ts,tsx,json,feature}' --write",
"setup": "yarn clean && node scripts/setup.mjs",
"setup:node": "yarn clean:node && yarn allow-scripts && yarn patch-package",
Expand Down
2 changes: 1 addition & 1 deletion scripts/setup.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ const generateTermsOfUseContentTask = {
task: async () => {
const termsOfUsePath = path.resolve('./docs/assets/termsOfUse.html');
const outputDir = path.resolve('./app/util/termsOfUse');
const outputPath = path.join(outputDir, 'termsOfUseContent.js');
const outputPath = path.join(outputDir, 'termsOfUseContent.ts');

let termsOfUse = '';
try {
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
},
"include": [
"app/declarations/index.d.ts",
"app/**/*",
"node_modules/expect-webdriverio",
"node_modules/expect-webdriverio/jest",
"app/components/UI/QRHardware/AnimatedQRScanner.tsx"
"node_modules/expect-webdriverio/jest"
],
"exclude": [
"node_modules",
Expand Down
24 changes: 0 additions & 24 deletions tsconfig.lint.json

This file was deleted.

Loading