Skip to content

Commit

Permalink
fix: prettier config trailing comma and vscode (#942)
Browse files Browse the repository at this point in the history
  • Loading branch information
luizstacio authored Oct 20, 2023
1 parent a991b08 commit 103326c
Show file tree
Hide file tree
Showing 191 changed files with 415 additions and 413 deletions.
2 changes: 2 additions & 0 deletions .changeset/new-dolphins-study.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
1 change: 0 additions & 1 deletion .prettierrc

This file was deleted.

9 changes: 9 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const fuelPrettierConfig = require('@fuels/prettier-config');

/** @type {import("prettier").Config} */
module.exports = {
...fuelPrettierConfig,
// trailingComma always adds comma on the end of functions params, that can cause
// issues, when a second param can't be undefined.
trailingComma: 'es5',
};
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"prettier.prettierPath": "./node_modules/prettier",
"prettier.prettierPath": "./node_modules/prettier/index.cjs",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
Expand Down
6 changes: 3 additions & 3 deletions packages/app/load.envs.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const { readFileSync } = require('fs');

function getVersion() {
const packageJson = JSON.parse(
readFileSync(resolve(__dirname, './package.json')).toString(),
readFileSync(resolve(__dirname, './package.json')).toString()
);
return {
version: packageJson.version,
Expand Down Expand Up @@ -33,8 +33,8 @@ function getPublicEnvs() {
const WHITELIST = ['NODE_ENV', 'PUBLIC_URL'];
return Object.fromEntries(
Object.entries(process.env).filter(([key]) =>
WHITELIST.some((k) => k === key || key.match(/^VITE_/)),
),
WHITELIST.some((k) => k === key || key.match(/^VITE_/))
)
);
}

Expand Down
4 changes: 2 additions & 2 deletions packages/app/playwright/commons/seedWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ export async function seedWallet(address: string, amount: BN) {
Address.fromString(address),
amount,
BaseAssetId,
{ gasPrice, gasLimit },
{ gasPrice, gasLimit }
);
await transfETH.wait();
const transfAsset = await genesisWallet.transfer(
Address.fromString(address),
amount,
ALT_ASSET.assetId,
{ gasPrice, gasLimit },
{ gasPrice, gasLimit }
);
await transfAsset.wait();
}
2 changes: 1 addition & 1 deletion packages/app/playwright/commons/text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export async function hasText(
page: Page,
text: string | RegExp,
position: number = 0,
timeout: number = 5000,
timeout: number = 5000
) {
const textFound = page.getByText(text).nth(position);
await expect(textFound).toHaveText(text, {
Expand Down
50 changes: 25 additions & 25 deletions packages/app/playwright/crx/crx.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ test.describe('FuelWallet Extension', () => {

async function createAccountFromPrivateKey(
privateKey: string,
name: string,
name: string
) {
await waitWalletToLoad(popupPage);
await getByAriaLabel(popupPage, 'Accounts').click();
Expand Down Expand Up @@ -315,7 +315,7 @@ test.describe('FuelWallet Extension', () => {
return window.fuel.currentAccount();
});
await expect(currentAccountPromise).rejects.toThrowError(
'address is not authorized for this connection.',
'address is not authorized for this connection.'
);
});
});
Expand All @@ -328,7 +328,7 @@ test.describe('FuelWallet Extension', () => {
async ([address, message]) => {
return window.fuel.signMessage(address, message);
},
[address, message],
[address, message]
);
}

Expand All @@ -346,7 +346,7 @@ test.describe('FuelWallet Extension', () => {
const messageSigned = await signedMessagePromise;
const addressSigner = Signer.recoverAddress(
hashMessage(message),
messageSigned,
messageSigned
);

// Verify signature is from the account selected
Expand All @@ -361,28 +361,28 @@ test.describe('FuelWallet Extension', () => {
await test.step('Signed message using authorized Account 3', async () => {
const authorizedAccount = await getAccountByName(
popupPage,
'Account 3',
'Account 3'
);
await approveMessageSignCheck(authorizedAccount);
});

await test.step('Signed message using authorized Account 4 (from Private Key)', async () => {
const authorizedAccount = await getAccountByName(
popupPage,
'Account 4',
'Account 4'
);
await approveMessageSignCheck(authorizedAccount);
});

await test.step('Throw on not Authorized Account', async () => {
const notAuthorizedAccount = await getAccountByName(
popupPage,
'Account 2',
'Account 2'
);
const signedMessagePromise = signMessage(notAuthorizedAccount.address);

await expect(signedMessagePromise).rejects.toThrowError(
'address is not authorized for this connection.',
'address is not authorized for this connection.'
);
});
});
Expand All @@ -392,15 +392,15 @@ test.describe('FuelWallet Extension', () => {
async function transfer(
senderAddress: string,
receiverAddress: string,
amount: number,
amount: number
) {
return blankPage.evaluate(
async ([senderAddress, receiverAddress, amount]) => {
const receiver = window.fuel.utils.createAddress(
receiverAddress as string,
receiverAddress as string
);
const wallet = await window.fuel!.getWallet(
senderAddress as string,
senderAddress as string
);

// TODO: remove this gas config once SDK fixes and start with correct values
Expand All @@ -412,18 +412,18 @@ test.describe('FuelWallet Extension', () => {
receiver,
Number(amount),
undefined,
{ gasPrice, gasLimit },
{ gasPrice, gasLimit }
);
const result = await response.waitForResult();
return result.status;
},
[senderAddress, receiverAddress, String(amount)],
[senderAddress, receiverAddress, String(amount)]
);
}

async function approveTxCheck(senderAccount: Account) {
const provider = await Provider.create(
process.env.VITE_FUEL_PROVIDER_URL,
process.env.VITE_FUEL_PROVIDER_URL
);
const receiverWallet = Wallet.generate({
provider,
Expand All @@ -437,7 +437,7 @@ test.describe('FuelWallet Extension', () => {
const transferStatus = transfer(
senderAccount.address,
receiverWallet.address.toString(),
AMOUNT_TRANSFER,
AMOUNT_TRANSFER
);

// Wait for approve transaction page to show
Expand All @@ -449,7 +449,7 @@ test.describe('FuelWallet Extension', () => {
await hasText(approveTransactionPage, /0\.0000001.ETH/i);
await waitAriaLabel(
approveTransactionPage,
senderAccount.address.toString(),
senderAccount.address.toString()
);
await hasText(approveTransactionPage, /Confirm before approving/i);
await getButtonByText(approveTransactionPage, /Approve/i).click();
Expand All @@ -467,26 +467,26 @@ test.describe('FuelWallet Extension', () => {
await test.step('Send transfer using authorized Account 3', async () => {
const authorizedAccount = await getAccountByName(
popupPage,
'Account 3',
'Account 3'
);
await approveTxCheck(authorizedAccount);
});

await test.step('Send transfer using authorized Account 4 (from Private Key)', async () => {
const authorizedAccount = await getAccountByName(
popupPage,
'Account 4',
'Account 4'
);
await approveTxCheck(authorizedAccount);
});

await test.step('Send transfer should block unauthorized account', async () => {
const nonAuthorizedAccount = await getAccountByName(
popupPage,
'Account 2',
'Account 2'
);
const provider = await Provider.create(
process.env.VITE_FUEL_PROVIDER_URL,
process.env.VITE_FUEL_PROVIDER_URL
);
const receiverWallet = Wallet.generate({
provider,
Expand All @@ -500,11 +500,11 @@ test.describe('FuelWallet Extension', () => {
const transferStatus = transfer(
nonAuthorizedAccount.address,
receiverWallet.address.toString(),
AMOUNT_TRANSFER,
AMOUNT_TRANSFER
);

await expect(transferStatus).rejects.toThrowError(
'address is not authorized for this connection.',
'address is not authorized for this connection.'
);
});
});
Expand All @@ -522,7 +522,7 @@ test.describe('FuelWallet Extension', () => {
async ([asset]) => {
return window.fuel.addAsset(asset);
},
[asset],
[asset]
);
}

Expand All @@ -542,7 +542,7 @@ test.describe('FuelWallet Extension', () => {
async ([asset]) => {
return window.fuel.addAssets(asset);
},
[assets],
[assets]
);
}

Expand All @@ -562,7 +562,7 @@ test.describe('FuelWallet Extension', () => {
async ([network]) => {
return window.fuel.addNetwork(network);
},
[network],
[network]
);
}

Expand Down
14 changes: 7 additions & 7 deletions packages/app/playwright/e2e/Accounts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ test.describe('Account', () => {
await hasText(page, data.accounts[0].name);
await getByAriaLabel(
page,
`Account Actions ${data.accounts[0].name}`,
`Account Actions ${data.accounts[0].name}`
).click();
await getByAriaLabel(page, `Edit ${data.accounts[0].name}`).click();
await hasText(page, /Edit/i);
Expand All @@ -75,7 +75,7 @@ test.describe('Account', () => {
await hasText(page, data.accounts[0].name);
await getByAriaLabel(
page,
`Account Actions ${data.accounts[0].name}`,
`Account Actions ${data.accounts[0].name}`
).click();
await getByAriaLabel(page, `Export ${data.accounts[0].name}`).click();

Expand All @@ -94,7 +94,7 @@ test.describe('Account', () => {
await hasText(page, data.accounts[1].name);
await getByAriaLabel(
page,
`Account Actions ${data.accounts[1].name}`,
`Account Actions ${data.accounts[1].name}`
).click();
await getByAriaLabel(page, `Hide ${data.accounts[1].name}`).click();
await hasText(page, 'Show hidden accounts');
Expand All @@ -103,7 +103,7 @@ test.describe('Account', () => {
await hasText(page, data.accounts[1].name);
await getByAriaLabel(
page,
`Account Actions ${data.accounts[1].name}`,
`Account Actions ${data.accounts[1].name}`
).click();
await getByAriaLabel(page, `Unhide ${data.accounts[1].name}`).click();
await page.getByText('Show hidden accounts').isHidden();
Expand All @@ -117,14 +117,14 @@ test.describe('Account', () => {
await hasText(page, data.accounts[1].name);
await getByAriaLabel(
page,
`Account Actions ${data.accounts[1].name}`,
`Account Actions ${data.accounts[1].name}`
).click();
await getByAriaLabel(page, `Hide ${data.accounts[1].name}`).click();
await hasText(page, 'Show hidden accounts');
await page.getByText(data.accounts[1].name).isHidden();
await getByAriaLabel(
page,
`Account Actions ${data.accounts[0].name}`,
`Account Actions ${data.accounts[0].name}`
).click();
await getByAriaLabel(page, `Hide ${data.accounts[0].name}`).isHidden();
});
Expand All @@ -136,7 +136,7 @@ test.describe('Account', () => {
await hasText(page, data.accounts[0].name);
await getByAriaLabel(
page,
`Account Actions ${data.accounts[0].name}`,
`Account Actions ${data.accounts[0].name}`
).click();
await getByAriaLabel(page, `Export ${data.accounts[0].name}`).click();

Expand Down
2 changes: 1 addition & 1 deletion packages/app/playwright/e2e/Asset.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ test.describe('Asset', () => {
await getByAriaLabel(page, 'Asset name').type(CUSTOM_ASSET.name);
await getByAriaLabel(page, 'Asset symbol').type(CUSTOM_ASSET.symbol);
await getByAriaLabel(page, 'Asset decimals').type(
String(CUSTOM_ASSET.decimals),
String(CUSTOM_ASSET.decimals)
);
await getByAriaLabel(page, 'Asset image Url').type(CUSTOM_ASSET.imageUrl);
await getByAriaLabel(page, 'Save Asset').click();
Expand Down
2 changes: 1 addition & 1 deletion packages/app/playwright/e2e/RecoverWallet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ test.describe('RecoverWallet', () => {
await getButtonByText(page, /Next: Seed Phrase/i).click();

await getByAriaLabel(page, 'Select format').selectOption(
'I have a 24 words Seed Phrase',
'I have a 24 words Seed Phrase'
);

/** Copy words to clipboard area */
Expand Down
6 changes: 3 additions & 3 deletions packages/app/playwright/e2e/ReportError.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ test.describe('ReportError', () => {

await hasText(page, /Unexpected errors detected/i);
await expect(page.locator(`textarea[name="reports"]`)).toHaveText(
/componentStack/i,
/componentStack/i
);

// get errors from indexedDB
Expand Down Expand Up @@ -64,7 +64,7 @@ test.describe('ReportError', () => {
await reload(page);
await hasText(page, /Unexpected errors detected/i);
await expect(page.locator(`textarea[name="reports"]`)).toHaveText(
/Test Error/i,
/Test Error/i
);

// report error
Expand All @@ -91,7 +91,7 @@ test.describe('ReportError', () => {

await hasText(page, /Unexpected errors detected/i);
await expect(page.locator(`textarea[name="reports"]`)).toHaveText(
/Test Error/i,
/Test Error/i
);

// report error
Expand Down
Loading

0 comments on commit 103326c

Please sign in to comment.