Skip to content

chore(all): fix eslint and lint-staged setup #117

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

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ const currentEpoch = {
}
};
const lovelaceSupply = {
// eslint-disable-next-line @typescript-eslint/no-loss-of-precision
circulating: BigInt(42_064_399_450_423_723),
total: BigInt(40_267_211_394_073_980)
};
const stake = {
active: BigInt(1_060_378_314_781_343),
// eslint-disable-next-line @typescript-eslint/no-loss-of-precision
live: BigInt(15_001_884_895_856_815)
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const convertVersionFormat = (version: string) => version.replace(/\./g, '_');
// eslint-disable-next-line unicorn/prefer-string-replace-all
const convertVersionFormat = (version: string) => version.replace('.', '_');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now only the first occurrence of . will be replaced and I thing it is an incorrect behaviour. Consider reverting this change.


export const fetchNotes = async (version: string): Promise<string> => {
const notes = await import(/* webpackMode: "eager" */ `../../release-notes/${convertVersionFormat(version)}.tsx`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,24 @@ export const MainFooter = (): React.ReactElement => {

const handleNavigation = (path: string) => {
switch (path) {
case walletRoutePaths.assets:
case walletRoutePaths.assets: {
sendAnalytics(AnalyticsEventCategories.VIEW_TOKENS, AnalyticsEventNames.ViewTokens.VIEW_TOKEN_LIST_POPUP);
break;
case walletRoutePaths.earn:
}
case walletRoutePaths.earn: {
sendAnalytics(AnalyticsEventCategories.STAKING, AnalyticsEventNames.Staking.VIEW_STAKING_POPUP);
break;
case walletRoutePaths.activity:
}
case walletRoutePaths.activity: {
sendAnalytics(
AnalyticsEventCategories.VIEW_TRANSACTIONS,
AnalyticsEventNames.ViewTransactions.VIEW_TX_LIST_POPUP
);
break;
case walletRoutePaths.nfts:
}
case walletRoutePaths.nfts: {
sendAnalytics(AnalyticsEventCategories.VIEW_NFT, AnalyticsEventNames.ViewNFTs.VIEW_NFT_LIST_POPUP);
}
}
history.push(path);
};
Expand Down
24 changes: 12 additions & 12 deletions apps/browser-extension-wallet/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ export const config = (): Config => {
CHAIN: chosenChain,
AVAILABLE_CHAINS: process.env.AVAILABLE_CHAINS.split(',') as Wallet.ChainName[],
MNEMONIC_LENGTH: 24,
WALLET_SYNC_TIMEOUT: !Number.isNaN(Number(process.env.WALLET_SYNC_TIMEOUT_IN_SEC))
? Number(process.env.WALLET_SYNC_TIMEOUT_IN_SEC) * 1000
: 60 * 1000,
WALLET_INTERVAL: !Number.isNaN(Number(process.env.WALLET_INTERVAL_IN_SEC))
? Number(process.env.WALLET_INTERVAL_IN_SEC) * 1000
: 30 * 1000,
ADA_PRICE_CHECK_INTERVAL: !Number.isNaN(Number(process.env.ADA_PRICE_POLLING_IN_SEC))
? Number(process.env.ADA_PRICE_POLLING_IN_SEC) * 1000
: 30 * 1000,
WALLET_SYNC_TIMEOUT: Number.isNaN(Number(process.env.WALLET_SYNC_TIMEOUT_IN_SEC))
? 60 * 1000
: Number(process.env.WALLET_SYNC_TIMEOUT_IN_SEC) * 1000,
WALLET_INTERVAL: Number.isNaN(Number(process.env.WALLET_INTERVAL_IN_SEC))
? 30 * 1000
: Number(process.env.WALLET_INTERVAL_IN_SEC) * 1000,
ADA_PRICE_CHECK_INTERVAL: Number.isNaN(Number(process.env.ADA_PRICE_POLLING_IN_SEC))
? 30 * 1000
: Number(process.env.ADA_PRICE_POLLING_IN_SEC) * 1000,
CARDANO_SERVICES_URLS: {
Mainnet: process.env.CARDANO_SERVICES_URL_MAINNET,
Preprod: process.env.CARDANO_SERVICES_URL_PREPROD,
Expand All @@ -82,8 +82,8 @@ export const config = (): Config => {
Preprod: `${process.env.CEXPLORER_URL_PREPROD}/tx`,
Preview: `${process.env.CEXPLORER_URL_PREVIEW}/tx`
},
SAVED_PRICE_DURATION: !Number.isNaN(Number(process.env.SAVED_PRICE_DURATION_IN_MINUTES))
? Number(process.env.SAVED_PRICE_DURATION_IN_MINUTES)
: 720
SAVED_PRICE_DURATION: Number.isNaN(Number(process.env.SAVED_PRICE_DURATION_IN_MINUTES))
? 720
: Number(process.env.SAVED_PRICE_DURATION_IN_MINUTES)
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ export const AddressDetailDrawer = ({
};

const onClose = () => {
if (!popupView) {
setStepsConfig(config[AddressDetailsSteps.DETAIL]);
if (popupView) {
onCancelClick();
} else {
setStepsConfig(config[AddressDetailsSteps.DETAIL]);
onCancelClick();
}
};
Expand Down Expand Up @@ -136,7 +136,7 @@ export const AddressDetailDrawer = ({
navigation={
<DrawerNavigation
title={t('browserView.addressBook.title')}
onCloseIconClick={!popupView ? onClose : undefined}
onCloseIconClick={popupView ? undefined : onClose}
onArrowIconClick={showArrowIcon ? onArrowIconClick : undefined}
/>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const DappConfirmData = (): React.ReactElement => {
{
api$: of({
async allowSignData(): Promise<boolean> {
return Promise.resolve(false);
return false;
}
}),
baseChannel: DAPP_CHANNELS.userPrompt,
Expand Down Expand Up @@ -107,7 +107,7 @@ export const DappConfirmData = (): React.ReactElement => {
{
api$: of({
async allowSignTx(): Promise<boolean> {
return Promise.resolve(true);
return true;
}
}),
baseChannel: DAPP_CHANNELS.userPrompt,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export const ConfirmTransaction = withAddressBookContext((): React.ReactElement
{
api$: of({
async allowSignTx(): Promise<boolean> {
return Promise.resolve(false);
return false;
}
}),
baseChannel: DAPP_CHANNELS.userPrompt,
Expand All @@ -113,7 +113,7 @@ export const ConfirmTransaction = withAddressBookContext((): React.ReactElement
{
api$: of({
async allowSignTx(): Promise<boolean> {
return Promise.resolve(true);
return true;
}
}),
baseChannel: DAPP_CHANNELS.userPrompt,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ export const availableCoinsTransformer = (
const assetList = [...tokens.entries()].map(([assetId, balance]) => ({
id: assetId.toString(),
balance: balance.toString(),
symbol: !isEmpty(tokensInfo)
? tokensInfo.get(assetId)?.tokenMetadata?.ticker ??
symbol: isEmpty(tokensInfo)
? addEllipsis(assetId.toString(), 8, 6)
: tokensInfo.get(assetId)?.tokenMetadata?.ticker ??
tokensInfo.get(assetId)?.tokenMetadata?.name ??
addEllipsis(tokensInfo.get(assetId)?.fingerprint.toString() ?? assetId.toString(), 8, 6)
: addEllipsis(assetId.toString(), 8, 6)
}));

return [adaCoin, ...assetList];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ const setStorageHelper = async ({
withAppSettings?: boolean;
withKeyAgentsByChain?: boolean;
}) => {
if (withLock) saveValueInLocalStorage({ key: 'lock', value: !isHardwareWallet ? Buffer.from('test') : null });
if (withLock) saveValueInLocalStorage({ key: 'lock', value: isHardwareWallet ? null : Buffer.from('test') });
if (withKeyAgentData) {
saveValueInLocalStorage({
key: 'keyAgentData',
value: !isHardwareWallet
? mockKeyAgentDataTestnet
: {
value: isHardwareWallet
? {
...mockKeyAgentDataTestnet,
__typename: Wallet.KeyManagement.KeyAgentType.Ledger,
communicationType: Wallet.KeyManagement.CommunicationType.Web
}
: mockKeyAgentDataTestnet
});
}
if (withWalletStorage) saveValueInLocalStorage({ key: 'wallet', value: { name: 'test wallet' } });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const useActionExecution = (
duration: params?.toastDuration || TOAST_DEFAULT_DURATION,
icon: ErrorIcon
});
// eslint-disable-next-line unicorn/no-useless-promise-resolve-reject
return Promise.reject(errorMessage);
}
};
Expand Down
15 changes: 10 additions & 5 deletions apps/browser-extension-wallet/src/hooks/useDataCheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,21 @@ export type UseDataCheck = [DataCheckState, () => Promise<void>];

const dataCheckReducer = (state: DataCheckState, action: DataCheckAction): DataCheckState => {
switch (action.type) {
case 'not-checked':
case 'not-checked': {
return { checkState: 'not-checked' };
case 'checking':
}
case 'checking': {
return { checkState: 'checking' };
case 'valid':
}
case 'valid': {
return { checkState: 'checked', result: { valid: true } };
case 'error':
}
case 'error': {
return { checkState: 'checked', result: { valid: false, error: action.error } };
default:
}
default: {
return state;
}
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ export const useDelegationDetails = (): Wallet.Cardano.StakePool => {
const rewardAccounts = useObservable(inMemoryWallet.delegation.rewardAccounts$);

return useMemo(() => {
const rewardAccount = !isEmpty(rewardAccounts) ? rewardAccounts[0] : undefined;
const rewardAccount = isEmpty(rewardAccounts) ? undefined : rewardAccounts[0];

return !rewardAccounts
? undefined
: rewardAccount?.delegatee?.nextNextEpoch ||
return rewardAccounts
? rewardAccount?.delegatee?.nextNextEpoch ||
rewardAccount?.delegatee?.nextEpoch ||
rewardAccount?.delegatee?.currentEpoch ||
// eslint-disable-next-line unicorn/no-null
null;
null
: undefined;
}, [rewardAccounts]);
};
21 changes: 14 additions & 7 deletions apps/browser-extension-wallet/src/hooks/useEnterKeyPress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,26 +97,33 @@ const handleEnterKeyPress = (event: KeyboardEvent) => {
const hash = window.location.hash;
if (event.code === 'Enter') {
switch (true) {
case new RegExp('send').test(hash):
case new RegExp('send').test(hash): {
handleSendBtn();
break;
case new RegExp('nft').test(hash):
}
case new RegExp('nft').test(hash): {
handleClick(buttonIds.nftDetailsBtnId);
break;
case new RegExp(walletRoutePaths.assets).test(hash):
}
case new RegExp(walletRoutePaths.assets).test(hash): {
handleAssetBtn();
break;
case new RegExp(walletRoutePaths.earn).test(hash) || new RegExp(walletRoutePaths.staking).test(hash):
}
case new RegExp(walletRoutePaths.earn).test(hash) || new RegExp(walletRoutePaths.staking).test(hash): {
handleStakingBtn();
break;
case new RegExp(walletRoutePaths.addressBook).test(hash):
}
case new RegExp(walletRoutePaths.addressBook).test(hash): {
handleAddressBtn();
break;
case new RegExp(walletRoutePaths.settings).test(hash):
}
case new RegExp(walletRoutePaths.settings).test(hash): {
handleSetting();
break;
default:
}
default: {
break;
}
}
}
};
Expand Down
4 changes: 2 additions & 2 deletions apps/browser-extension-wallet/src/hooks/useMaxAda.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { useObservable } from './useObservable';

const { getTotalMinimumCoins, setMissingCoins } = Wallet;

export const useMaxAda = (): BigInt => {
const [maxADA, setMaxADA] = useState<BigInt>();
export const useMaxAda = (): bigint => {
const [maxADA, setMaxADA] = useState<bigint>();
const { walletInfo, inMemoryWallet } = useWalletStore();
const balance = useObservable(inMemoryWallet.balance.utxo.available$);
const availableRewards = useObservable(inMemoryWallet.balance.rewardAccounts.rewards$);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { combineLatest, map } from 'rxjs';
import { useObservable } from './useObservable';

interface UseStakingRewardsReturns {
totalRewards: BigInt | number;
lastReward: BigInt | number;
totalRewards: bigint | number;
lastReward: bigint | number;
}

const LAST_STABLE_EPOCH = 2;
Expand All @@ -28,6 +28,7 @@ export const useStakingRewards = (): UseStakingRewardsReturns => {
? // eslint-disable-next-line unicorn/no-null
BigNumber.sum.apply(null, confirmedRewardHistory.map(({ rewards }) => rewards.toString()) ?? [])
: 0,
// eslint-disable-next-line unicorn/prefer-at
lastReward: confirmedRewardHistory[confirmedRewardHistory.length - 1]?.rewards || 0
};
})
Expand Down
Empty file.
2 changes: 1 addition & 1 deletion apps/browser-extension-wallet/src/lib/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ i18n.use(initReactI18next).init({
}
});

export default i18n;
export { default } from 'i18next';
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const confirmationCallback: walletCip30.CallbackConfirmation = async (
// Remove this method once it is dropped from the SDK in future build
// Also transactions can be submitted by the dApps externally
// once they've got the witnesss keys if they construct their own transactions
return Promise.resolve(true);
return true;
}
case walletCip30.Cip30ConfirmationCallbackType.SignTx: {
try {
Expand Down Expand Up @@ -63,8 +63,10 @@ export const confirmationCallback: walletCip30.CallbackConfirmation = async (
return false;
}
}
default:
return Promise.reject();
default: {
// eslint-disable-next-line no-throw-literal
throw undefined;
}
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ const checkMigrationsOnUpdate = async (details: Runtime.OnInstalledDetailsType)
// Initialize migration state with not-loaded
await initMigrationState();
// Set migration state to up-to-date on install or check migrations on update
!details.previousVersion
? await storage.local.set({ MIGRATION_STATE: { state: 'up-to-date' } as MigrationState })
: await checkMigrations(details.previousVersion);
details.previousVersion
? await checkMigrations(details.previousVersion)
: await storage.local.set({ MIGRATION_STATE: { state: 'up-to-date' } as MigrationState });
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const requestAccess: RequestAccess = async (origin: Origin) => {
const dappUrl = `#/dapp/connect?url=${url}&name=${name}&logo=${logo}`;
await ensureUiIsOpenAndLoaded(dappUrl);
const isAllowed = await userPromptService.allowOrigin(origin);
if (isAllowed === 'deny') return Promise.resolve(false);
if (isAllowed === 'deny') return false;
if (isAllowed === 'allow') {
const { authorizedDapps }: AuthorizedDappStorage = await webStorage.local.get(AUTHORIZED_DAPPS_KEY);
if (authorizedDapps) {
Expand All @@ -34,7 +34,7 @@ export const requestAccess: RequestAccess = async (origin: Origin) => {
}
});
}
return Promise.resolve(true);
return true;
};

export const requestAccessDebounced = pDebounce(requestAccess, DEBOUNCE_THROTTLE);
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ try {
.then((dapps) => {
authorizedDappsList.next(dapps);
})
// eslint-disable-next-line unicorn/prefer-top-level-await
.catch((error) => {
throw new Error(error);
});
Expand Down
Loading