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: update prettier to v3 #28638

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion app/scripts/controllers/account-tracker-controller.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ async function withController<ReturnValue>(
({
id: 'accountId',
address: SELECTED_ADDRESS,
} as InternalAccount);
}) as InternalAccount;
controllerMessenger.registerActionHandler(
'AccountsController:getSelectedAccount',
getSelectedAccount || getSelectedAccountStub,
Expand Down
19 changes: 8 additions & 11 deletions app/scripts/controllers/decrypt-message.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const createMessengerMock = () =>
call: jest.fn(),
// TODO: Replace `any` with type
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any as jest.Mocked<DecryptMessageControllerMessenger>);
}) as any as jest.Mocked<DecryptMessageControllerMessenger>;

const createDecryptMessageManagerMock = <T>() =>
({
Expand All @@ -61,7 +61,7 @@ const createDecryptMessageManagerMock = <T>() =>
},
// TODO: Replace `any` with type
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any as jest.Mocked<T>);
}) as any as jest.Mocked<T>;

describe('DecryptMessageController', () => {
class MockDecryptMessageController extends DecryptMessageController {
Expand Down Expand Up @@ -178,9 +178,8 @@ describe('DecryptMessageController', () => {
);
getStateMock.mockReturnValue(mockExtState);

const result = await decryptMessageController.decryptMessage(
messageToDecrypt,
);
const result =
await decryptMessageController.decryptMessage(messageToDecrypt);

expect(decryptMessageManagerMock.approveMessage).toBeCalledTimes(1);
expect(decryptMessageManagerMock.approveMessage).toBeCalledWith(
Expand Down Expand Up @@ -248,9 +247,8 @@ describe('DecryptMessageController', () => {
);
getStateMock.mockReturnValue(mockExtState);

const result = await decryptMessageController.decryptMessageInline(
messageToDecrypt,
);
const result =
await decryptMessageController.decryptMessageInline(messageToDecrypt);

expect(decryptMessageManagerMock.setResult).toBeCalledTimes(1);
expect(decryptMessageManagerMock.setResult).toBeCalledWith(
Expand All @@ -277,9 +275,8 @@ describe('DecryptMessageController', () => {
);
getStateMock.mockReturnValue(mockExtState);

const result = await decryptMessageController.cancelDecryptMessage(
messageIdMock,
);
const result =
await decryptMessageController.cancelDecryptMessage(messageIdMock);

expect(decryptMessageManagerMock.rejectMessage).toBeCalledTimes(1);
expect(decryptMessageManagerMock.rejectMessage).toBeCalledWith(
Expand Down
4 changes: 2 additions & 2 deletions app/scripts/controllers/encryption-public-key.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const createMessengerMock = () =>
registerInitialEventPayload: jest.fn(),
// TODO: Replace `any` with type
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any as jest.Mocked<EncryptionPublicKeyControllerMessenger>);
}) as any as jest.Mocked<EncryptionPublicKeyControllerMessenger>;

const createEncryptionPublicKeyManagerMock = <T>() =>
({
Expand All @@ -78,7 +78,7 @@ const createEncryptionPublicKeyManagerMock = <T>() =>
},
// TODO: Replace `any` with type
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any as jest.Mocked<T>);
}) as any as jest.Mocked<T>;

describe('EncryptionPublicKeyController', () => {
let encryptionPublicKeyController: EncryptionPublicKeyController;
Expand Down
14 changes: 8 additions & 6 deletions app/scripts/controllers/permissions/background-api.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,10 @@ describe('permission background API methods', () => {
}),
};

const id = await getPermissionBackgroundApiMethods(
permissionController,
).requestAccountsPermissionWithId('foo.com');
const id =
await getPermissionBackgroundApiMethods(
permissionController,
).requestAccountsPermissionWithId('foo.com');

expect(permissionController.requestPermissions).toHaveBeenCalledTimes(1);
expect(permissionController.requestPermissions).toHaveBeenCalledWith(
Expand All @@ -211,9 +212,10 @@ describe('permission background API methods', () => {
}),
};

const id = await getPermissionBackgroundApiMethods(
permissionController,
).requestAccountsAndChainPermissionsWithId('foo.com');
const id =
await getPermissionBackgroundApiMethods(
permissionController,
).requestAccountsAndChainPermissionsWithId('foo.com');

expect(permissionController.requestPermissions).toHaveBeenCalledTimes(1);
expect(permissionController.requestPermissions).toHaveBeenCalledWith(
Expand Down
11 changes: 7 additions & 4 deletions app/scripts/lib/state-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,13 @@ function sanitizeSnapData(state: FlattenedUIState) {
return;
}

state.snaps = Object.values(snapsData).reduce((acc, snap) => {
acc[snap.id] = stripLargeSnapData(snap) as Snap;
return acc;
}, {} as SnapControllerState['snaps']);
state.snaps = Object.values(snapsData).reduce(
(acc, snap) => {
acc[snap.id] = stripLargeSnapData(snap) as Snap;
return acc;
},
{} as SnapControllerState['snaps'],
);
}

function stripLargeSnapData(snapData: Snap): Partial<Snap> {
Expand Down
5 changes: 2 additions & 3 deletions app/scripts/lib/transaction/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,8 @@ export async function addTransaction(
): Promise<TransactionMeta> {
await validateSecurity(request);

const { transactionMeta, waitForHash } = await addTransactionOrUserOperation(
request,
);
const { transactionMeta, waitForHash } =
await addTransactionOrUserOperation(request);

if (!request.waitForSubmit) {
waitForHash().catch(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
} from './tx-verification-middleware';

const getMockNetworkController = (chainId: `0x${string}` = '0x1') =>
({ state: mockNetworkState({ chainId }) } as NetworkController);
({ state: mockNetworkState({ chainId }) }) as NetworkController;

const mockTrustedSigners: Partial<Record<EXPERIENCES_TYPE, Hex>> = {
[EXPERIENCES_TYPE.METAMASK_BRIDGE]:
Expand Down
10 changes: 4 additions & 6 deletions app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -4838,9 +4838,8 @@ export default class MetamaskController extends EventEmitter {
* @returns {'hardware' | 'imported' | 'snap' | 'MetaMask'}
*/
async getAccountType(address) {
const keyringType = await this.keyringController.getAccountKeyringType(
address,
);
const keyringType =
await this.keyringController.getAccountKeyringType(address);
switch (keyringType) {
case KeyringType.trezor:
case KeyringType.lattice:
Expand Down Expand Up @@ -4951,9 +4950,8 @@ export default class MetamaskController extends EventEmitter {
async addNewAccount(accountCount) {
const oldAccounts = await this.keyringController.getAccounts();

const addedAccountAddress = await this.keyringController.addNewAccount(
accountCount,
);
const addedAccountAddress =
await this.keyringController.addNewAccount(accountCount);

if (!oldAccounts.includes(addedAccountAddress)) {
this.preferencesController.setSelectedAddress(addedAccountAddress);
Expand Down
25 changes: 10 additions & 15 deletions app/scripts/metamask-controller.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -639,12 +639,10 @@ describe('MetaMaskController', () => {
it('can only create new vault on keyringController once', async () => {
const password = 'a-fake-password';

const vault1 = await metamaskController.createNewVaultAndKeychain(
password,
);
const vault2 = await metamaskController.createNewVaultAndKeychain(
password,
);
const vault1 =
await metamaskController.createNewVaultAndKeychain(password);
const vault2 =
await metamaskController.createNewVaultAndKeychain(password);

expect(vault1).toStrictEqual(vault2);
});
Expand Down Expand Up @@ -885,9 +883,8 @@ describe('MetaMaskController', () => {
it('should be unlocked by default', async () => {
await metamaskController.connectHardware(device, 0);

const status = await metamaskController.checkHardwareStatus(
device,
);
const status =
await metamaskController.checkHardwareStatus(device);

expect(status).toStrictEqual(true);
});
Expand Down Expand Up @@ -2192,9 +2189,8 @@ describe('MetaMaskController', () => {
)
.mockReturnValue(tokenData);

const tokenSymbol = await metamaskController.getTokenSymbol(
'0xNotInTokenList',
);
const tokenSymbol =
await metamaskController.getTokenSymbol('0xNotInTokenList');

expect(tokenSymbol).toStrictEqual(tokenData.symbol);
});
Expand Down Expand Up @@ -2230,9 +2226,8 @@ describe('MetaMaskController', () => {
throw new Error('error');
});

const tokenSymbol = await metamaskController.getTokenSymbol(
'0xNotInTokenList',
);
const tokenSymbol =
await metamaskController.getTokenSymbol('0xNotInTokenList');

expect(tokenSymbol).toStrictEqual(null);
});
Expand Down
10 changes: 4 additions & 6 deletions app/scripts/services/data-deletion-service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -575,9 +575,8 @@ describe('DataDeletionService', () => {
mockDataDeletionStatusInterceptor(mockTaskId).reply(200, mockResponse);
const dataDeletionService = new DataDeletionService(getDefaultOptions());

const response = await dataDeletionService.fetchDeletionRegulationStatus(
mockTaskId,
);
const response =
await dataDeletionService.fetchDeletionRegulationStatus(mockTaskId);

expect(response).toStrictEqual(mockOverAllStatus);
});
Expand Down Expand Up @@ -623,9 +622,8 @@ describe('DataDeletionService', () => {
mockDataDeletionStatusInterceptor(mockTaskId).reply(200, mockResponse);
const dataDeletionService = new DataDeletionService(getDefaultOptions());

const response = await dataDeletionService.fetchDeletionRegulationStatus(
mockTaskId,
);
const response =
await dataDeletionService.fetchDeletionRegulationStatus(mockTaskId);

expect(response).toStrictEqual(mockOverAllStatus);
});
Expand Down
6 changes: 3 additions & 3 deletions app/scripts/services/data-deletion-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ const fallbackDataDeletionEndpoint = 'https://metametrics.metamask.test';

const DEFAULT_ANALYTICS_DATA_DELETION_SOURCE_ID = inTest
? fallbackSourceId
: process.env.ANALYTICS_DATA_DELETION_SOURCE_ID ?? fallbackSourceId;
: (process.env.ANALYTICS_DATA_DELETION_SOURCE_ID ?? fallbackSourceId);
const DEFAULT_ANALYTICS_DATA_DELETION_ENDPOINT = inTest
? fallbackDataDeletionEndpoint
: process.env.ANALYTICS_DATA_DELETION_ENDPOINT ??
fallbackDataDeletionEndpoint;
: (process.env.ANALYTICS_DATA_DELETION_ENDPOINT ??
fallbackDataDeletionEndpoint);

/**
* The number of times we retry a specific failed request to the data deletion API.
Expand Down
33 changes: 18 additions & 15 deletions development/webpack/test/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,24 @@ export function mockWebpack(
maps: (string | null)[],
devtool: 'source-map' | 'hidden-source-map' | false = 'source-map',
) {
const assets = files.reduce((acc, name, i) => {
const source = contents[i];
const map = maps?.[i];
const webpackSource = map
? new SourceMapSource(source, name, map)
: new RawSource(source);
acc[name] = {
name,
info: {
size: webpackSource.size(),
},
source: webpackSource,
};
return acc;
}, {} as Record<string, Asset>);
const assets = files.reduce(
(acc, name, i) => {
const source = contents[i];
const map = maps?.[i];
const webpackSource = map
? new SourceMapSource(source, name, map)
: new RawSource(source);
acc[name] = {
name,
info: {
size: webpackSource.size(),
},
source: webpackSource,
};
return acc;
},
{} as Record<string, Asset>,
);
let done: () => void;
const promise = new Promise<void>((resolve) => {
done = resolve;
Expand Down
8 changes: 3 additions & 5 deletions development/webpack/test/plugins.ManifestPlugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,9 @@ describe('ManifestPlugin', () => {
zip,
} = testCase;
const context = join(__dirname, `fixtures/ManifestPlugin/${fixture}`);
const baseManifest = require(join(
context,
`manifest/v${manifestVersion}`,
'_base.json',
));
const baseManifest = require(
join(context, `manifest/v${manifestVersion}`, '_base.json'),
);
const expectedAssets = getExpectedAssets(zip, browsers, files);
const validateManifest = getValidateManifest(testCase, baseManifest);

Expand Down
2 changes: 2 additions & 0 deletions lavamoat/browserify/beta/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -3553,6 +3553,8 @@
},
"@swc/helpers>tslib": {
"globals": {
"AsyncIterator": true,
"Iterator": true,
"SuppressedError": true,
"define": true
}
Expand Down
2 changes: 2 additions & 0 deletions lavamoat/browserify/flask/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -3553,6 +3553,8 @@
},
"@swc/helpers>tslib": {
"globals": {
"AsyncIterator": true,
"Iterator": true,
"SuppressedError": true,
"define": true
}
Expand Down
2 changes: 2 additions & 0 deletions lavamoat/browserify/main/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -3553,6 +3553,8 @@
},
"@swc/helpers>tslib": {
"globals": {
"AsyncIterator": true,
"Iterator": true,
"SuppressedError": true,
"define": true
}
Expand Down
2 changes: 2 additions & 0 deletions lavamoat/browserify/mmi/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -3645,6 +3645,8 @@
},
"@swc/helpers>tslib": {
"globals": {
"AsyncIterator": true,
"Iterator": true,
"SuppressedError": true,
"define": true
}
Expand Down
Loading
Loading