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

fix: biomejs #1150

Merged
merged 22 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
7 changes: 7 additions & 0 deletions .changeset/three-seas-remember.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@fuel-wallet/connections": patch
"@fuel-wallet/types": patch
"fuels-wallet": patch
---

ci: enable biomejs rules (as it was with eslint and prettier)
43 changes: 3 additions & 40 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,48 +15,10 @@
"rules": {
"recommended": true,
"correctness": {
"noUnusedVariables": "off",
"useExhaustiveDependencies": "off",
"noEmptyPattern": "off"
"noUnusedVariables": "error"
},
"style": {
"useImportType": "off",
"useEnumInitializers": "off",
"noUnusedTemplateLiteral": "off",
"noNonNullAssertion": "off",
"noInferrableTypes": "off",
"useNodejsImportProtocol": "off",
"useNumberNamespace": "off",
"useExportType": "off"
},
"suspicious": {
"noArrayIndexKey": "off",
"noConfusingVoidType": "off",
"noExplicitAny": "off",
"noImplicitAnyLet": "off",
"noAssignInExpressions": "off",
"noShadowRestrictedNames": "off",
"noDoubleEquals": "off"
},
"complexity": {
"noThisInStatic": "off",
"noStaticOnlyClass": "off",
"noForEach": "off",
"useOptionalChain": "off",
"noUselessSwitchCase": "off",
"useArrowFunction": "off",
"noUselessEmptyExport": "off",
"useLiteralKeys": "off"
},
"performance": {
"noAccumulatingSpread": "off",
"noDelete": "off"
},
"security": {
"noDangerouslySetInnerHtml": "off"
},
"a11y": {
"useButtonType": "off"
"noNonNullAssertion": "off"
}
}
},
Expand Down Expand Up @@ -85,6 +47,7 @@
"**/build",
"**/dist",
"**/dist-crx",
"**/contracts",
"pnpm-lock.yaml"
]
}
Expand Down
13 changes: 9 additions & 4 deletions examples/cra-dapp/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/* eslint-disable no-console */
import {
useAccounts,
useDisconnect,
useConnectUI,
useDisconnect,
useIsConnected,
} from '@fuels/react';
import './App.css';
Expand All @@ -19,6 +18,7 @@ function App() {
<div className="App" data-theme={theme}>
<div className="Actions">
<button
type="button"
onClick={() => {
console.log('connect');
connect();
Expand All @@ -27,9 +27,14 @@ function App() {
{isConnecting ? 'Connecting' : 'Connect'}
</button>
{isConnected && (
<button onClick={() => disconnect()}>Disconnect</button>
<button type="button" onClick={() => disconnect()}>
Disconnect
</button>
)}
<button onClick={() => setTheme(lightTheme ? 'dark' : 'light')}>
<button
type="button"
onClick={() => setTheme(lightTheme ? 'dark' : 'light')}
>
{lightTheme ? '🌙' : '☀️'}
</button>
</div>
Expand Down
8 changes: 4 additions & 4 deletions packages/app/.storybook/main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import tsconfigpath from 'vite-tsconfig-paths';
import { mergeConfig } from 'vite';
import type { StorybookConfig } from '@storybook/react-vite';
import { join } from 'node:path';
import type { StorybookConfig } from '@storybook/react-vite';
import { mergeConfig } from 'vite';
import tsconfigpath from 'vite-tsconfig-paths';

import { resolveLinkDeps } from '../vite-utils/vite.base.config';

Expand All @@ -28,7 +28,7 @@ const config: StorybookConfig = {
name: '@storybook/react-vite',
options: {},
},
async viteFinal(config: any) {
async viteFinal(config) {
return mergeConfig(config, {
...resolveLinkDeps(),
base: join(process.env.STORYBOOK_BASE_URL || config.base || ''),
Expand Down
7 changes: 4 additions & 3 deletions packages/app/.storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from 'react';
import { darkTheme, lightTheme } from '@fuel-ui/react';
import { themes } from '@storybook/theming';
import { mswDecorator, initialize } from 'msw-storybook-addon';
import { initialize, mswDecorator } from 'msw-storybook-addon';
import React from 'react';
import { withRouter } from 'storybook-addon-react-router-v6';
import { Providers } from '../src/systems/Core/components';

import { MINIMAL_VIEWPORTS } from '@storybook/addon-viewport';
import { WALLET_WIDTH, WALLET_HEIGHT } from '../src/config';
import { WALLET_HEIGHT, WALLET_WIDTH } from '../src/config';

import theme from './theme';

Expand Down Expand Up @@ -58,6 +58,7 @@ export const parameters = {
export const decorators = [
mswDecorator,
withRouter,
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
(Story: any) => (
<Providers>
<Story />
Expand Down
1 change: 0 additions & 1 deletion packages/app/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { defaultsESM as tsjPreset } from 'ts-jest/presets';
import { getPublicEnvs } from './load.envs';
import pkg from './package.json';

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { globals, preset, ...baseConfig } = baseDefaultConfig;

const config: JestConfigWithTsJest = {
Expand Down
10 changes: 8 additions & 2 deletions packages/app/jest.setup.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
// biome-ignore lint/style/useNodejsImportProtocol: <explanation>
import { webcrypto } from 'crypto';
import { TextEncoder, TextDecoder } from 'util';
// biome-ignore lint/style/useNodejsImportProtocol: <explanation>
import { TextDecoder, TextEncoder } from 'util';

import { localStorageMock } from './src/mocks/localStorage';

// biome-ignore lint/suspicious/noExplicitAny: <explanation>
(global as any).TextEncoder = TextEncoder;
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
(global as any).TextDecoder = TextDecoder;
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
(global as any).ArrayBuffer = ArrayBuffer;
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
(global as any).Uint8Array = Uint8Array;
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
(global as any).structuredClone = (val: any) => JSON.parse(JSON.stringify(val));

// https://github.com/jsdom/jsdom/issues/1724#issuecomment-720727999
Expand Down
3 changes: 3 additions & 0 deletions packages/app/load.envs.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const { config } = require('dotenv');
// biome-ignore lint/style/useNodejsImportProtocol: <explanation>
const { resolve } = require('path');
// biome-ignore lint/style/useNodejsImportProtocol: <explanation>
const { readFileSync } = require('fs');

function getVersion() {
Expand All @@ -22,6 +24,7 @@ function getEnvName() {
}

// Load from more specific env file to generic ->
// biome-ignore lint/complexity/noForEach: <explanation>
[getEnvName(), '.env'].forEach((envFile) => {
if (!envFile) return;
config({
Expand Down
3 changes: 2 additions & 1 deletion packages/app/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { defineConfig } from '@playwright/test';
// biome-ignore lint/style/useNodejsImportProtocol: <explanation>
import { join } from 'path';
import { defineConfig } from '@playwright/test';
import './load.envs';

const distDirectory = join(__dirname, './dist');
Expand Down
3 changes: 1 addition & 2 deletions packages/app/playwright/commons/gas.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import type { Provider, BN } from 'fuels';
import type { BN, Provider } from 'fuels';

// TODO: remove this function when SDK make transactions with correct gas configs
export const getGasConfig = async (provider: Provider) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/app/playwright/commons/seedWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { Page } from '@playwright/test';
import type { BN } from 'fuels';
import { Address, BaseAssetId, Provider, Wallet } from 'fuels';

import { getAccount, ALT_ASSET } from '../mocks';
import { ALT_ASSET, getAccount } from '../mocks';

import { getGasConfig } from './gas';

Expand Down
4 changes: 2 additions & 2 deletions packages/app/playwright/commons/text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { expect } from '@playwright/test';
export async function hasText(
page: Page,
text: string | RegExp,
position: number = 0,
timeout: number = 5000
position = 0,
timeout = 5000
) {
const textFound = page.getByText(text).nth(position);
await expect(textFound).toHaveText(text, {
Expand Down
36 changes: 18 additions & 18 deletions packages/app/playwright/crx/crx.test.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import { expect } from '@playwright/test';
import { type Locator, expect } from '@playwright/test';
import {
type Account,
type Asset,
Provider,
Signer,
Wallet,
bn,
hashMessage,
Wallet,
Provider,
type Account,
type Asset,
} from 'fuels';

import {
seedWallet,
getButtonByText,
getByAriaLabel,
getElementByText,
hasText,
waitAriaLabel,
reload,
getElementByText,
seedWallet,
waitAriaLabel,
} from '../commons';
import {
CUSTOM_ASSET_INPUT,
Expand All @@ -26,13 +26,13 @@ import {
} from '../mocks';

import {
test,
waitWalletToLoad,
getAccountByName,
switchAccount,
waitAccountPage,
getWalletAccounts,
hideAccount,
switchAccount,
test,
waitAccountPage,
waitWalletToLoad,
} from './utils';

const WALLET_PASSWORD = 'Qwe123456$';
Expand Down Expand Up @@ -102,7 +102,7 @@ test.describe('FuelWallet Extension', () => {
try {
await window.fuel.ping();
return true;
} catch (err) {
} catch (_err) {
return testConnection();
}
}
Expand Down Expand Up @@ -293,7 +293,7 @@ test.describe('FuelWallet Extension', () => {
await test.step('Current authorized current Account', async () => {
const authorizedAccount = await switchAccount(popupPage, 'Account 1');
await getByAriaLabel(popupPage, 'Accounts').click({ delay: 1000 });
await getByAriaLabel(popupPage, `Close dialog`).click();
await getByAriaLabel(popupPage, 'Close dialog').click();
const currentAccountPromise = await blankPage.evaluate(async () => {
return window.fuel.currentAccount();
});
Expand Down Expand Up @@ -388,7 +388,7 @@ test.describe('FuelWallet Extension', () => {
return blankPage.evaluate(
async ([senderAddress, receiverAddress, amount]) => {
const receiver = window.createAddress(receiverAddress as string);
const wallet = await window.fuel!.getWallet(
const wallet = await window.fuel?.getWallet(
senderAddress as string
);

Expand Down Expand Up @@ -581,7 +581,7 @@ test.describe('FuelWallet Extension', () => {
const networkItemsCount = await items.count();
expect(networkItemsCount).toEqual(2);

let selectedNetworkItem;
let selectedNetworkItem: Locator;
for (let i = 0; i < networkItemsCount; i += 1) {
const isSelected = await items.nth(i).getAttribute('data-active');
if (isSelected === 'true') {
Expand All @@ -606,7 +606,7 @@ test.describe('FuelWallet Extension', () => {
// Switch to account 2
await switchAccount(popupPage, 'Account 2');
await getByAriaLabel(popupPage, 'Accounts').click({ delay: 1000 });
await getByAriaLabel(popupPage, `Close dialog`).click();
await getByAriaLabel(popupPage, 'Close dialog').click();

const onChangeAccountPromise = blankPage.evaluate(() => {
return new Promise((resolve) => {
Expand All @@ -628,7 +628,7 @@ test.describe('FuelWallet Extension', () => {
// Switch to account 2
await switchAccount(popupPage, 'Account 2');
await getByAriaLabel(popupPage, 'Accounts').click({ delay: 1000 });
await getByAriaLabel(popupPage, `Close dialog`).click();
await getByAriaLabel(popupPage, 'Close dialog').click();

const onChangeAccountPromise = blankPage.evaluate(() => {
return new Promise((resolve) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/app/playwright/crx/utils/popup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export async function hideAccount(popupPage: Page, name: string) {
await hasText(popupPage, 'Show hidden accounts');
await popupPage.getByText(name).isHidden();

await getByAriaLabel(popupPage, `Close dialog`).click();
await getByAriaLabel(popupPage, 'Close dialog').click();
}

export async function waitAccountPage(popupPage: Page, name: string) {
Expand Down
5 changes: 3 additions & 2 deletions packages/app/playwright/crx/utils/test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable no-empty-pattern */
// biome-ignore lint/style/useNodejsImportProtocol: <explanation>
import path from 'path';
import type { BrowserContext } from '@playwright/test';
import { test as base, chromium } from '@playwright/test';
import path from 'path';

const pathToExtension = path.join(__dirname, '../../../dist-crx');

Expand Down Expand Up @@ -34,6 +34,7 @@ test.afterAll(({ context }) => {
});

test.use({
// biome-ignore lint/correctness/noEmptyPattern: <explanation>
context: ({}, use) => {
use(context);
},
Expand Down
2 changes: 1 addition & 1 deletion packages/app/playwright/e2e/Accounts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
waitUrl,
} from '../commons';
import type { MockData } from '../mocks';
import { mockData, WALLET_PASSWORD } from '../mocks';
import { WALLET_PASSWORD, mockData } from '../mocks';

test.describe('Account', () => {
let browser: Browser;
Expand Down
2 changes: 1 addition & 1 deletion packages/app/playwright/e2e/ChangePassword.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { Browser, Page } from '@playwright/test';
import test, { chromium } from '@playwright/test';

import { getButtonByText, getByAriaLabel, hasText, visit } from '../commons';
import { mockData, WALLET_PASSWORD } from '../mocks';
import { WALLET_PASSWORD, mockData } from '../mocks';

test.describe('ChangePassword', () => {
let browser: Browser;
Expand Down
2 changes: 1 addition & 1 deletion packages/app/playwright/e2e/HomeWallet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import {
getButtonByText,
getByAriaLabel,
hasText,
visit,
reload,
visit,
} from '../commons';
import { mockData } from '../mocks';

Expand Down
4 changes: 2 additions & 2 deletions packages/app/playwright/e2e/Networks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import type { Browser, Page } from '@playwright/test';
import test, { chromium, expect } from '@playwright/test';

import {
visit,
getButtonByText,
getByAriaLabel,
getInputByName,
getButtonByText,
hasText,
reload,
visit,
} from '../commons';
import { mockData } from '../mocks';

Expand Down
Loading
Loading