diff --git a/eslint-warning-thresholds.json b/eslint-warning-thresholds.json index 878c1974e90..52125a19d86 100644 --- a/eslint-warning-thresholds.json +++ b/eslint-warning-thresholds.json @@ -6,12 +6,8 @@ "@typescript-eslint/no-unsafe-enum-comparison": 8 }, "packages/approval-controller/src/ApprovalController.test.ts": { - "import-x/order": 1, "jest/no-conditional-in-test": 16 }, - "packages/approval-controller/src/ApprovalController.ts": { - "@typescript-eslint/prefer-readonly": 4 - }, "packages/assets-controllers/jest.environment.js": { "n/prefer-global/text-encoder": 1, "n/prefer-global/text-decoder": 1, @@ -46,24 +42,10 @@ "@typescript-eslint/no-misused-promises": 2 }, "packages/assets-controllers/src/NftDetectionController.test.ts": { - "import-x/namespace": 6, - "import-x/order": 3 + "import-x/namespace": 6 }, "packages/assets-controllers/src/NftDetectionController.ts": { - "jsdoc/check-tag-names": 34, - "jsdoc/tag-lines": 1 - }, - "packages/assets-controllers/src/RatesController/RatesController.test.ts": { - "import-x/order": 1, - "jsdoc/tag-lines": 2 - }, - "packages/assets-controllers/src/RatesController/RatesController.ts": { - "@typescript-eslint/prefer-readonly": 1, - "import-x/order": 1, - "jsdoc/tag-lines": 3 - }, - "packages/assets-controllers/src/RatesController/types.ts": { - "import-x/order": 1 + "jsdoc/check-tag-names": 34 }, "packages/assets-controllers/src/Standards/ERC20Standard.test.ts": { "jest/no-commented-out-tests": 1 @@ -71,9 +53,6 @@ "packages/assets-controllers/src/Standards/NftStandards/ERC1155/ERC1155Standard.test.ts": { "import-x/no-named-as-default-member": 1 }, - "packages/assets-controllers/src/Standards/NftStandards/ERC721/ERC721Standard.ts": { - "prettier/prettier": 1 - }, "packages/assets-controllers/src/TokenBalancesController.ts": { "@typescript-eslint/no-misused-promises": 1 }, @@ -82,45 +61,31 @@ }, "packages/assets-controllers/src/TokenListController.test.ts": { "import-x/namespace": 7, - "import-x/order": 2, "jest/no-conditional-in-test": 2 }, "packages/assets-controllers/src/TokenRatesController.ts": { - "@typescript-eslint/prefer-readonly": 1, "jsdoc/check-tag-names": 11 }, "packages/assets-controllers/src/TokensController.test.ts": { "import-x/namespace": 1, - "import-x/order": 3, "jest/no-conditional-in-test": 2 }, "packages/assets-controllers/src/TokensController.ts": { "@typescript-eslint/no-unused-vars": 1, - "@typescript-eslint/prefer-readonly": 1, - "jsdoc/check-tag-names": 10, - "jsdoc/tag-lines": 2 + "jsdoc/check-tag-names": 10 }, "packages/assets-controllers/src/assetsUtil.test.ts": { "jest/no-conditional-in-test": 2 }, - "packages/assets-controllers/src/assetsUtil.ts": { - "jsdoc/tag-lines": 2 - }, "packages/assets-controllers/src/multicall.test.ts": { "@typescript-eslint/prefer-promise-reject-errors": 2 }, - "packages/assets-controllers/src/token-prices-service/codefi-v2.ts": { - "jsdoc/tag-lines": 2 - }, "packages/base-controller/src/BaseController.test.ts": { "import-x/namespace": 13 }, "packages/bridge-status-controller/src/utils/transaction.ts": { "@typescript-eslint/no-unsafe-enum-comparison": 2 }, - "packages/build-utils/src/transforms/remove-fenced-code.test.ts": { - "import-x/order": 1 - }, "packages/build-utils/src/transforms/remove-fenced-code.ts": { "@typescript-eslint/no-unsafe-enum-comparison": 1 }, @@ -136,9 +101,6 @@ "@typescript-eslint/no-unused-vars": 1, "jsdoc/check-tag-names": 5 }, - "packages/controller-utils/src/types.ts": { - "jsdoc/tag-lines": 1 - }, "packages/controller-utils/src/util.test.ts": { "import-x/no-named-as-default": 1, "jest/no-conditional-in-test": 1, @@ -153,9 +115,6 @@ "packages/eip-5792-middleware/src/hooks/processSendCalls.ts": { "@typescript-eslint/no-misused-promises": 1 }, - "packages/ens-controller/src/EnsController.test.ts": { - "import-x/order": 1 - }, "packages/ens-controller/src/EnsController.ts": { "jsdoc/check-tag-names": 6 }, @@ -260,15 +219,10 @@ "jsdoc/match-description": 11 }, "packages/gas-fee-controller/src/GasFeeController.test.ts": { - "import-x/namespace": 2, - "import-x/order": 1 + "import-x/namespace": 2 }, "packages/gas-fee-controller/src/GasFeeController.ts": { - "@typescript-eslint/prefer-readonly": 1, - "jsdoc/check-tag-names": 21 - }, - "packages/gas-fee-controller/src/determineGasFeeCalculations.ts": { - "jsdoc/tag-lines": 4 + "jsdoc/check-tag-names": 20 }, "packages/json-rpc-middleware-stream/src/index.test.ts": { "@typescript-eslint/prefer-promise-reject-errors": 1, @@ -285,24 +239,17 @@ "@typescript-eslint/no-unsafe-enum-comparison": 2, "@typescript-eslint/no-unused-vars": 1 }, - "packages/keyring-controller/tests/mocks/mockKeyring.ts": { - "@typescript-eslint/prefer-readonly": 1 - }, "packages/logging-controller/src/LoggingController.test.ts": { "import-x/namespace": 1 }, "packages/logging-controller/src/LoggingController.ts": { "jsdoc/check-tag-names": 1 }, - "packages/logging-controller/src/logTypes/index.ts": { - "@typescript-eslint/consistent-type-exports": 1 - }, "packages/message-manager/src/AbstractMessageManager.test.ts": { "jest/no-conditional-in-test": 7 }, "packages/message-manager/src/AbstractMessageManager.ts": { - "jsdoc/check-tag-names": 25, - "jsdoc/tag-lines": 2 + "jsdoc/check-tag-names": 25 }, "packages/message-manager/src/DecryptMessageManager.test.ts": { "jest/no-conditional-in-test": 3 @@ -316,9 +263,6 @@ "packages/message-manager/src/EncryptionPublicKeyManager.ts": { "jsdoc/check-tag-names": 13 }, - "packages/message-manager/src/index.ts": { - "@typescript-eslint/consistent-type-exports": 1 - }, "packages/message-manager/src/utils.ts": { "@typescript-eslint/no-unused-vars": 1 }, @@ -329,32 +273,7 @@ "@typescript-eslint/no-misused-promises": 2 }, "packages/name-controller/src/NameController.ts": { - "@typescript-eslint/no-unsafe-enum-comparison": 1, - "@typescript-eslint/prefer-readonly": 2 - }, - "packages/name-controller/src/providers/ens.test.ts": { - "import-x/order": 1 - }, - "packages/name-controller/src/providers/ens.ts": { - "@typescript-eslint/prefer-readonly": 2 - }, - "packages/name-controller/src/providers/etherscan.test.ts": { - "import-x/order": 1 - }, - "packages/name-controller/src/providers/etherscan.ts": { - "@typescript-eslint/prefer-readonly": 2 - }, - "packages/name-controller/src/providers/lens.test.ts": { - "import-x/order": 1 - }, - "packages/name-controller/src/providers/lens.ts": { - "@typescript-eslint/prefer-readonly": 1 - }, - "packages/name-controller/src/providers/token.test.ts": { - "import-x/order": 1 - }, - "packages/name-controller/src/providers/token.ts": { - "@typescript-eslint/prefer-readonly": 1 + "@typescript-eslint/no-unsafe-enum-comparison": 1 }, "packages/name-controller/src/util.ts": { "jsdoc/require-returns": 1 @@ -368,16 +287,8 @@ "packages/permission-controller/src/PermissionController.test.ts": { "jest/no-conditional-in-test": 4 }, - "packages/permission-controller/src/rpc-methods/getPermissions.test.ts": { - "import-x/order": 1 - }, - "packages/permission-controller/src/rpc-methods/requestPermissions.ts": { - "prettier/prettier": 1 - }, "packages/permission-log-controller/src/PermissionLogController.ts": { - "@typescript-eslint/prefer-readonly": 1, - "jsdoc/check-tag-names": 2, - "jsdoc/tag-lines": 1 + "jsdoc/check-tag-names": 2 }, "packages/phishing-controller/src/PhishingController.ts": { "jsdoc/check-tag-names": 32 @@ -388,28 +299,12 @@ "packages/phishing-controller/src/utils.ts": { "@typescript-eslint/no-unsafe-enum-comparison": 1 }, - "packages/polling-controller/src/AbstractPollingController.ts": { - "@typescript-eslint/prefer-readonly": 1 - }, "packages/rate-limit-controller/src/RateLimitController.ts": { "jsdoc/check-tag-names": 4 }, "packages/remote-feature-flag-controller/src/client-config-api-service/client-config-api-service.test.ts": { - "import-x/order": 1, - "jsdoc/tag-lines": 1, "promise/param-names": 1 }, - "packages/remote-feature-flag-controller/src/client-config-api-service/client-config-api-service.ts": { - "@typescript-eslint/prefer-readonly": 4, - "jsdoc/tag-lines": 2 - }, - "packages/remote-feature-flag-controller/src/remote-feature-flag-controller.ts": { - "@typescript-eslint/prefer-readonly": 1, - "jsdoc/check-tag-names": 2 - }, - "packages/remote-feature-flag-controller/src/utils/user-segmentation-utils.ts": { - "jsdoc/tag-lines": 2 - }, "packages/sample-controllers/src/sample-gas-prices-controller.ts": { "@typescript-eslint/no-misused-promises": 1 }, @@ -441,64 +336,12 @@ "@typescript-eslint/no-base-to-string": 1, "@typescript-eslint/no-unused-vars": 2 }, - "packages/user-operation-controller/src/UserOperationController.test.ts": { - "jsdoc/tag-lines": 4 - }, "packages/user-operation-controller/src/UserOperationController.ts": { "@typescript-eslint/prefer-promise-reject-errors": 1, - "@typescript-eslint/prefer-readonly": 3, "jsdoc/require-returns": 2 }, "packages/user-operation-controller/src/helpers/Bundler.test.ts": { - "import-x/order": 1, - "jsdoc/require-returns": 1, - "jsdoc/tag-lines": 1 - }, - "packages/user-operation-controller/src/helpers/Bundler.ts": { - "@typescript-eslint/prefer-readonly": 1, - "jsdoc/tag-lines": 2 - }, - "packages/user-operation-controller/src/helpers/PendingUserOperationTracker.test.ts": { - "import-x/order": 2, - "jsdoc/tag-lines": 4, - "prettier/prettier": 1 - }, - "packages/user-operation-controller/src/helpers/PendingUserOperationTracker.ts": { - "@typescript-eslint/prefer-readonly": 2, - "import-x/order": 1 - }, - "packages/user-operation-controller/src/helpers/SnapSmartContractAccount.test.ts": { - "import-x/order": 1, - "jsdoc/tag-lines": 1 - }, - "packages/user-operation-controller/src/helpers/SnapSmartContractAccount.ts": { - "@typescript-eslint/prefer-readonly": 1 - }, - "packages/user-operation-controller/src/types.ts": { - "jsdoc/tag-lines": 3 - }, - "packages/user-operation-controller/src/utils/gas-fees.ts": { - "jsdoc/tag-lines": 7 - }, - "packages/user-operation-controller/src/utils/gas.test.ts": { - "import-x/order": 1, - "jsdoc/tag-lines": 1 - }, - "packages/user-operation-controller/src/utils/gas.ts": { - "jsdoc/tag-lines": 2 - }, - "packages/user-operation-controller/src/utils/transaction.test.ts": { - "import-x/order": 1 - }, - "packages/user-operation-controller/src/utils/transaction.ts": { - "jsdoc/tag-lines": 2 - }, - "packages/user-operation-controller/src/utils/validation.test.ts": { - "import-x/order": 1, - "jsdoc/tag-lines": 2 - }, - "packages/user-operation-controller/src/utils/validation.ts": { - "jsdoc/tag-lines": 8 + "jsdoc/require-returns": 1 }, "scripts/create-package/utils.test.ts": { "@typescript-eslint/no-unsafe-enum-comparison": 3, @@ -506,20 +349,17 @@ "jest/no-conditional-in-test": 1 }, "scripts/create-package/utils.ts": { - "@typescript-eslint/no-unsafe-enum-comparison": 5, - "prettier/prettier": 1 + "@typescript-eslint/no-unsafe-enum-comparison": 5 }, "tests/fake-block-tracker.ts": { "no-empty-function": 1 }, "tests/fake-provider.ts": { "@typescript-eslint/prefer-promise-reject-errors": 1, - "@typescript-eslint/prefer-readonly": 2, "jsdoc/check-tag-names": 12 }, "tests/mock-network.ts": { "@typescript-eslint/no-unsafe-enum-comparison": 1, - "@typescript-eslint/prefer-readonly": 3, "jsdoc/check-tag-names": 10 }, "tests/setupAfterEnv/nock.ts": { diff --git a/packages/approval-controller/src/ApprovalController.test.ts b/packages/approval-controller/src/ApprovalController.test.ts index 318bd0a967c..a84b05b218f 100644 --- a/packages/approval-controller/src/ApprovalController.test.ts +++ b/packages/approval-controller/src/ApprovalController.test.ts @@ -11,7 +11,6 @@ import { import { errorCodes, JsonRpcError } from '@metamask/rpc-errors'; import { nanoid } from 'nanoid'; -import { flushPromises } from '../../../tests/helpers'; import type { AddApprovalOptions, ApprovalControllerActions, @@ -33,6 +32,7 @@ import { MissingApprovalFlowError, NoApprovalFlowsError, } from './errors'; +import { flushPromises } from '../../../tests/helpers'; jest.mock('nanoid'); diff --git a/packages/approval-controller/src/ApprovalController.ts b/packages/approval-controller/src/ApprovalController.ts index 1c5254f8e45..582382cd9b7 100644 --- a/packages/approval-controller/src/ApprovalController.ts +++ b/packages/approval-controller/src/ApprovalController.ts @@ -369,13 +369,13 @@ export class ApprovalController extends BaseController< ApprovalControllerState, ApprovalControllerMessenger > { - #approvals: Map; + readonly #approvals: Map; - #origins: Map>; + readonly #origins: Map>; - #showApprovalRequest: () => void; + readonly #showApprovalRequest: () => void; - #typesExcludedFromRateLimiting: string[]; + readonly #typesExcludedFromRateLimiting: string[]; /** * Construct an Approval controller. @@ -615,8 +615,6 @@ export class ApprovalController extends BaseController< if (origin) { return Array.from( (this.#origins.get(origin) || new Map()).values(), - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/restrict-plus-operands ).reduce((total, value) => total + value, 0); } diff --git a/packages/assets-controllers/src/NftController.test.ts b/packages/assets-controllers/src/NftController.test.ts index 3f61016b34b..09b37101869 100644 --- a/packages/assets-controllers/src/NftController.test.ts +++ b/packages/assets-controllers/src/NftController.test.ts @@ -583,8 +583,6 @@ describe('NftController', () => { 'mainnet', ); await expect(erc721Result).rejects.toThrow( - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions `Suggested NFT of type ${ERC721} does not match received type ${ERC1155}`, ); }); @@ -2485,12 +2483,8 @@ describe('NftController', () => { .reply(200, { name: 'name (directly from tokenURI)', description: 'description (directly from tokenURI)', - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention external_link: null, image: 'image (directly from tokenURI)', - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention animation_url: null, }); diff --git a/packages/assets-controllers/src/NftController.ts b/packages/assets-controllers/src/NftController.ts index fc26e7945c7..15113baa394 100644 --- a/packages/assets-controllers/src/NftController.ts +++ b/packages/assets-controllers/src/NftController.ts @@ -525,8 +525,6 @@ export class NftController extends BaseController< } #getNftCollectionApi(): string { - // False negative. - return `${NFT_API_BASE_URL}/collections`; } diff --git a/packages/assets-controllers/src/NftDetectionController.test.ts b/packages/assets-controllers/src/NftDetectionController.test.ts index 5cb89d7549e..d485a77361f 100644 --- a/packages/assets-controllers/src/NftDetectionController.test.ts +++ b/packages/assets-controllers/src/NftDetectionController.test.ts @@ -29,6 +29,13 @@ import { import nock from 'nock'; import * as sinon from 'sinon'; +import { Source } from './constants'; +import { getDefaultNftControllerState } from './NftController'; +import { + NftDetectionController, + BlockaidResultType, + type NftDetectionControllerMessenger, +} from './NftDetectionController'; import { FakeBlockTracker } from '../../../tests/fake-block-tracker'; import { FakeProvider } from '../../../tests/fake-provider'; import { advanceTime } from '../../../tests/helpers'; @@ -37,13 +44,6 @@ import { buildMockFindNetworkClientIdByChainId, buildMockGetNetworkClientById, } from '../../network-controller/tests/helpers'; -import { Source } from './constants'; -import { getDefaultNftControllerState } from './NftController'; -import { - NftDetectionController, - BlockaidResultType, - type NftDetectionControllerMessenger, -} from './NftDetectionController'; type AllActions = MessengerActions; @@ -222,8 +222,6 @@ describe('NftDetectionController', () => { }, }, blockaidResult: { - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention result_type: BlockaidResultType.Benign, }, }, @@ -247,8 +245,6 @@ describe('NftDetectionController', () => { }, }, blockaidResult: { - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention result_type: BlockaidResultType.Benign, }, }, @@ -279,8 +275,6 @@ describe('NftDetectionController', () => { }, }, blockaidResult: { - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention result_type: BlockaidResultType.Benign, }, }, @@ -321,8 +315,6 @@ describe('NftDetectionController', () => { isSpam: false, }, blockaidResult: { - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention result_type: BlockaidResultType.Malicious, }, }, @@ -343,8 +335,6 @@ describe('NftDetectionController', () => { isSpam: true, }, blockaidResult: { - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention result_type: BlockaidResultType.Benign, }, }, @@ -365,8 +355,6 @@ describe('NftDetectionController', () => { isSpam: true, }, blockaidResult: { - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention result_type: BlockaidResultType.Malicious, }, }, @@ -845,8 +833,6 @@ describe('NftDetectionController', () => { it('should not call addNFt when the request to Nft API call throws', async () => { const selectedAccount = createMockInternalAccount({ address: '0x3' }); nock(NFT_API_BASE_URL) - // ESLint is confused; this is a string. - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions .get(`/users/${selectedAccount.address}/tokens`) .query({ continuation: '', diff --git a/packages/assets-controllers/src/NftDetectionController.ts b/packages/assets-controllers/src/NftDetectionController.ts index 30275447086..cff23beeb25 100644 --- a/packages/assets-controllers/src/NftDetectionController.ts +++ b/packages/assets-controllers/src/NftDetectionController.ts @@ -78,10 +78,12 @@ const supportedNftDetectionNetworks: Set = new Set([ * @type ApiNft * * NFT object coming from OpenSea api + * * @property token_id - The NFT identifier * @property num_sales - Number of sales * @property background_color - The background color to be displayed with the item * @property image_url - URI of an image associated with this NFT + * * @property image_preview_url - URI of a smaller image associated with this NFT * @property image_thumbnail_url - URI of a thumbnail image associated with this NFT * @property image_original_url - URI of the original image associated with this NFT @@ -95,44 +97,20 @@ const supportedNftDetectionNetworks: Set = new Set([ * @property lastSale - When this item was last sold */ export type ApiNft = { - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention token_id: string; - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention num_sales: number | null; - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention background_color: string | null; - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention image_url: string | null; - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention image_preview_url: string | null; - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention image_thumbnail_url: string | null; - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention image_original_url: string | null; - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention animation_url: string | null; - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention animation_original_url: string | null; name: string | null; description: string | null; - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention external_link: string | null; - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention asset_contract: ApiNftContract; creator: ApiNftCreator; - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention last_sale: ApiNftLastSale | null; }; @@ -140,6 +118,7 @@ export type ApiNft = { * @type ApiNftContract * * NFT contract object coming from OpenSea api + * * @property address - Address of the NFT contract * @property asset_contract_type - The NFT type, it could be `semi-fungible` or `non-fungible` * @property created_date - Creation date @@ -152,27 +131,15 @@ export type ApiNft = { */ export type ApiNftContract = { address: string; - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention asset_contract_type: string | null; - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention created_date: string | null; - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention schema_name: string | null; symbol: string | null; - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention total_supply: string | null; description: string | null; - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention external_link: string | null; collection: { name: string | null; - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention image_url?: string | null; tokenCount?: string | null; }; @@ -182,19 +149,14 @@ export type ApiNftContract = { * @type ApiNftLastSale * * NFT sale object coming from OpenSea api + * * @property event_timestamp - Object containing a `username` * @property total_price - URI of NFT image associated with this owner * @property transaction - Object containing transaction_hash and block_hash */ export type ApiNftLastSale = { - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention event_timestamp: string; - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention total_price: string; - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention transaction: { transaction_hash: string; block_hash: string }; }; @@ -202,14 +164,13 @@ export type ApiNftLastSale = { * @type ApiNftCreator * * NFT creator object coming from OpenSea api + * * @property user - Object containing a `username` * @property profile_img_url - URI of NFT image associated with this owner * @property address - The owner address */ export type ApiNftCreator = { user: { username: string }; - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention profile_img_url: string; address: string; }; @@ -236,14 +197,8 @@ export enum BlockaidResultType { export type Blockaid = { contract: string; chainId: number; - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention result_type: BlockaidResultType; - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention malicious_score: string; - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention attack_types: object; }; @@ -535,6 +490,7 @@ export class NftDetectionController extends BaseController< /** * Handles the state change of the preference controller. + * * @param preferencesState - The new state of the preference controller. * @param preferencesState.useNftDetection - Boolean indicating user preference on NFT detection. */ diff --git a/packages/assets-controllers/src/RatesController/RatesController.test.ts b/packages/assets-controllers/src/RatesController/RatesController.test.ts index 175dc9258f7..ecb36af1e6c 100644 --- a/packages/assets-controllers/src/RatesController/RatesController.test.ts +++ b/packages/assets-controllers/src/RatesController/RatesController.test.ts @@ -8,14 +8,14 @@ import { } from '@metamask/messenger'; import { useFakeTimers } from 'sinon'; -import type { RatesControllerMessenger, RatesControllerState } from './types'; -import { advanceTime } from '../../../../tests/helpers'; -import type { fetchMultiExchangeRate as defaultFetchExchangeRate } from '../crypto-compare-service'; import { Cryptocurrency, RatesController, name as ratesControllerName, } from './RatesController'; +import type { RatesControllerMessenger, RatesControllerState } from './types'; +import { advanceTime } from '../../../../tests/helpers'; +import type { fetchMultiExchangeRate as defaultFetchExchangeRate } from '../crypto-compare-service'; type AllActions = MessengerActions; @@ -27,6 +27,7 @@ const MOCK_TIMESTAMP = 1709983353; /** * Returns a stubbed date based on a predefined timestamp. + * * @returns The stubbed date in milliseconds. */ function getStubbedDate(): number { @@ -59,6 +60,7 @@ function buildRatesControllerMessenger( /** * Sets up and returns a new instance of RatesController with the provided configuration. + * * @param config - The configuration object for the RatesController. * @param config.interval - Polling interval. * @param config.initialState - Initial state of the controller. diff --git a/packages/assets-controllers/src/RatesController/RatesController.ts b/packages/assets-controllers/src/RatesController/RatesController.ts index 92c81c49215..c7056cbe37a 100644 --- a/packages/assets-controllers/src/RatesController/RatesController.ts +++ b/packages/assets-controllers/src/RatesController/RatesController.ts @@ -2,13 +2,13 @@ import { BaseController, type StateMetadata } from '@metamask/base-controller'; import { Mutex } from 'async-mutex'; import type { Draft } from 'immer'; -import { fetchMultiExchangeRate as defaultFetchExchangeRate } from '../crypto-compare-service'; import type { ConversionRates, RatesControllerState, RatesControllerOptions, RatesControllerMessenger, } from './types'; +import { fetchMultiExchangeRate as defaultFetchExchangeRate } from '../crypto-compare-service'; export const name = 'RatesController'; @@ -72,7 +72,7 @@ export class RatesController extends BaseController< readonly #includeUsdRate; - #intervalLength: number; + readonly #intervalLength: number; #intervalId: NodeJS.Timeout | undefined; @@ -119,8 +119,6 @@ export class RatesController extends BaseController< * // Execute criticalLogic within a lock. * const result = await this.#withLock(criticalLogic); */ - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention async #withLock(callback: () => R) { const releaseLock = await this.#mutex.acquire(); try { @@ -204,6 +202,7 @@ export class RatesController extends BaseController< /** * Returns the current list of cryptocurrency. + * * @returns The cryptocurrency list. */ getCryptocurrencyList(): Cryptocurrency[] { @@ -213,6 +212,7 @@ export class RatesController extends BaseController< /** * Sets the list of supported cryptocurrencies. + * * @param cryptocurrencies - The list of supported cryptocurrencies. */ async setCryptocurrencyList( @@ -232,6 +232,7 @@ export class RatesController extends BaseController< /** * Sets the internal fiat currency and update rates accordingly. + * * @param fiatCurrency - The fiat currency. */ async setFiatCurrency(fiatCurrency: string): Promise { diff --git a/packages/assets-controllers/src/RatesController/types.ts b/packages/assets-controllers/src/RatesController/types.ts index 49c5515391b..a78124b0197 100644 --- a/packages/assets-controllers/src/RatesController/types.ts +++ b/packages/assets-controllers/src/RatesController/types.ts @@ -4,11 +4,11 @@ import type { } from '@metamask/base-controller'; import type { Messenger } from '@metamask/messenger'; -import type { fetchMultiExchangeRate as defaultFetchExchangeRate } from '../crypto-compare-service'; import type { name as ratesControllerName, Cryptocurrency, } from './RatesController'; +import type { fetchMultiExchangeRate as defaultFetchExchangeRate } from '../crypto-compare-service'; /** * Represents the conversion rates from one currency to others, including the conversion date. diff --git a/packages/assets-controllers/src/Standards/NftStandards/ERC721/ERC721Standard.ts b/packages/assets-controllers/src/Standards/NftStandards/ERC721/ERC721Standard.ts index 431598f26e0..055da1e47d6 100644 --- a/packages/assets-controllers/src/Standards/NftStandards/ERC721/ERC721Standard.ts +++ b/packages/assets-controllers/src/Standards/NftStandards/ERC721/ERC721Standard.ts @@ -87,9 +87,8 @@ export class ERC721Standard { */ getTokenURI = async (address: string, tokenId: string): Promise => { const contract = new Contract(address, abiERC721, this.provider); - const supportsMetadata = await this.contractSupportsMetadataInterface( - address, - ); + const supportsMetadata = + await this.contractSupportsMetadataInterface(address); if (!supportsMetadata) { // Do not throw error here, supporting Metadata interface is optional even though majority of ERC721 nfts do support it. // This change is made because of instances of NFTs that are ERC404( mixed ERC20 / ERC721 implementation). diff --git a/packages/assets-controllers/src/TokenDetectionController.test.ts b/packages/assets-controllers/src/TokenDetectionController.test.ts index 1db2d4e6e37..4ea7ed05065 100644 --- a/packages/assets-controllers/src/TokenDetectionController.test.ts +++ b/packages/assets-controllers/src/TokenDetectionController.test.ts @@ -2628,11 +2628,7 @@ describe('TokenDetectionController', () => { category: 'Wallet', properties: { tokens: [`${sampleTokenA.symbol} - ${sampleTokenA.address}`], - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - token_standard: 'ERC20', - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - asset_type: 'TOKEN', }, }); diff --git a/packages/assets-controllers/src/TokenListController.test.ts b/packages/assets-controllers/src/TokenListController.test.ts index 7f1342a683f..9d0f5cecae0 100644 --- a/packages/assets-controllers/src/TokenListController.test.ts +++ b/packages/assets-controllers/src/TokenListController.test.ts @@ -18,12 +18,6 @@ import type { Hex } from '@metamask/utils'; import nock from 'nock'; import * as sinon from 'sinon'; -import { advanceTime } from '../../../tests/helpers'; -import { - buildCustomNetworkClientConfiguration, - buildInfuraNetworkClientConfiguration, - buildMockGetNetworkClientById, -} from '../../network-controller/tests/helpers'; import * as tokenService from './token-service'; import type { TokenListMap, @@ -31,6 +25,12 @@ import type { TokenListControllerMessenger, } from './TokenListController'; import { TokenListController } from './TokenListController'; +import { advanceTime } from '../../../tests/helpers'; +import { + buildCustomNetworkClientConfiguration, + buildInfuraNetworkClientConfiguration, + buildMockGetNetworkClientById, +} from '../../network-controller/tests/helpers'; const namespace = 'TokenListController'; const timestamp = Date.now(); @@ -1371,8 +1371,6 @@ describe('TokenListController', () => { * @returns The constructed path. */ function getTokensPath(chainId: Hex) { - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions return `/tokens/${convertHexToDecimal( chainId, )}?occurrenceFloor=3&includeNativeAssets=false&includeTokenFees=false&includeAssetType=false&includeERC20Permit=false&includeStorage=false`; diff --git a/packages/assets-controllers/src/TokenRatesController.ts b/packages/assets-controllers/src/TokenRatesController.ts index e4791e4ee63..8163ab3be20 100644 --- a/packages/assets-controllers/src/TokenRatesController.ts +++ b/packages/assets-controllers/src/TokenRatesController.ts @@ -37,6 +37,7 @@ import type { * @type Token * * Token representation + * * @property address - Hex address of the token contract * @property decimals - Number of decimals the token uses * @property symbol - Symbol of the token @@ -123,6 +124,7 @@ export const controllerName = 'TokenRatesController'; * @type TokenRatesState * * Token rates controller state + * * @property marketData - Market data for tokens, keyed by chain ID and then token contract address. */ export type TokenRatesControllerState = { @@ -246,7 +248,7 @@ export class TokenRatesController extends StaticIntervalPollingController ({ @@ -1620,8 +1620,6 @@ describe('TokensController', () => { const fullErrorMessage = `TokenService Error: ${error}`; nock(TOKEN_END_POINT_API) .get( - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions `/token/${convertHexToDecimal( chainId, )}?address=${dummyTokenAddress}`, diff --git a/packages/assets-controllers/src/TokensController.ts b/packages/assets-controllers/src/TokensController.ts index 62cac130a75..cafd25dc26b 100644 --- a/packages/assets-controllers/src/TokensController.ts +++ b/packages/assets-controllers/src/TokensController.ts @@ -61,6 +61,7 @@ import type { Token } from './TokenRatesController'; * @type SuggestedAssetMeta * * Suggested asset by EIP747 meta data + * * @property id - Generated UUID associated with this suggested asset * @property time - Timestamp associated with this this suggested asset * @property type - Type type this suggested asset @@ -79,6 +80,7 @@ type SuggestedAssetMeta = { * @type TokensControllerState * * Assets controller state + * * @property allTokens - Object containing tokens by network and account * @property allIgnoredTokens - Object containing hidden/ignored tokens by network and account * @property allDetectedTokens - Object containing tokens detected with non-zero balances @@ -185,12 +187,13 @@ export class TokensController extends BaseController< #selectedAccountId: string; - #provider: Provider; + readonly #provider: Provider; readonly #abortController: AbortController; /** * Tokens controller options + * * @param options - Constructor options. * @param options.chainId - The chain ID of the current network. * @param options.provider - Network provider. @@ -326,6 +329,7 @@ export class TokensController extends BaseController< /** * Handles the event when the network state changes. + * * @param _ - The network state. * @param patches - An array of patch operations performed on the network state. */ @@ -862,8 +866,6 @@ export class TokensController extends BaseController< if (await this.#detectIsERC721(asset.address, networkClientId)) { throw rpcErrors.invalidParams( - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions `Contract ${asset.address} must match type ${type}, but was detected as ${ERC721}`, ); } @@ -876,8 +878,6 @@ export class TokensController extends BaseController< ); if (isErc1155) { throw rpcErrors.invalidParams( - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions `Contract ${asset.address} must match type ${type}, but was detected as ${ERC1155}`, ); } @@ -905,8 +905,6 @@ export class TokensController extends BaseController< asset.symbol.toUpperCase() !== contractSymbol.toUpperCase() ) { throw rpcErrors.invalidParams( - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions `The symbol in the request (${asset.symbol}) does not match the symbol in the contract (${contractSymbol})`, ); } @@ -936,8 +934,6 @@ export class TokensController extends BaseController< String(asset.decimals) !== contractDecimals ) { throw rpcErrors.invalidParams( - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions `The decimals in the request (${asset.decimals}) do not match the decimals in the contract (${contractDecimals})`, ); } @@ -946,8 +942,6 @@ export class TokensController extends BaseController< const decimalsNum = parseInt(decimalsStr as unknown as string, 10); if (!Number.isInteger(decimalsNum) || decimalsNum > 36 || decimalsNum < 0) { throw rpcErrors.invalidParams( - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions `Invalid decimals "${decimalsStr}": must be an integer 0 <= 36`, ); } diff --git a/packages/assets-controllers/src/assetsUtil.test.ts b/packages/assets-controllers/src/assetsUtil.test.ts index f93298b44cb..e67bbb89280 100644 --- a/packages/assets-controllers/src/assetsUtil.test.ts +++ b/packages/assets-controllers/src/assetsUtil.test.ts @@ -152,8 +152,6 @@ describe('assetsUtil', () => { chainId: ChainId.mainnet, tokenAddress: linkTokenAddress, }); - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions const expectedValue = `https://static.cx.metamask.io/api/v1/tokenIcons/${convertHexToDecimal( ChainId.mainnet, )}/${linkTokenAddress}.png`; diff --git a/packages/assets-controllers/src/assetsUtil.ts b/packages/assets-controllers/src/assetsUtil.ts index 46f9ae22739..6827486f631 100644 --- a/packages/assets-controllers/src/assetsUtil.ts +++ b/packages/assets-controllers/src/assetsUtil.ts @@ -56,6 +56,7 @@ export function compareNftMetadata(newNftMetadata: NftMetadata, nft: Nft) { /** * Checks whether the existing nft object has all the keys of the new incoming nft metadata object + * * @param newNftMetadata - New nft metadata object * @param nft - Existing nft object to compare with * @returns Whether the existing nft object has all the new keys from the new Nft metadata object @@ -129,8 +130,6 @@ export const formatIconUrlWithProxy = ({ tokenAddress: string; }) => { const chainIdDecimal = convertHexToDecimal(chainId).toString(); - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions return `https://static.cx.metamask.io/api/v1/tokenIcons/${chainIdDecimal}/${tokenAddress.toLowerCase()}.png`; }; @@ -138,65 +137,25 @@ export const formatIconUrlWithProxy = ({ * Networks where token detection is supported - Values are in hex format */ export enum SupportedTokenDetectionNetworks { - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention mainnet = '0x1', // decimal: 1 - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention bsc = '0x38', // decimal: 56 - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention polygon = '0x89', // decimal: 137 - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention avax = '0xa86a', // decimal: 43114 - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention aurora = '0x4e454152', // decimal: 1313161554 - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention linea_goerli = '0xe704', // decimal: 59140 - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention linea_mainnet = '0xe708', // decimal: 59144 - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention arbitrum = '0xa4b1', // decimal: 42161 - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention optimism = '0xa', // decimal: 10 - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention base = '0x2105', // decimal: 8453 - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention zksync = '0x144', // decimal: 324 - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention cronos = '0x19', // decimal: 25 - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention celo = '0xa4ec', // decimal: 42220 - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention gnosis = '0x64', // decimal: 100 - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention fantom = '0xfa', // decimal: 250 - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention polygon_zkevm = '0x44d', // decimal: 1101 - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention moonbeam = '0x504', // decimal: 1284 - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention moonriver = '0x505', // decimal: 1285 - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention sei = '0x531', // decimal: 1329 - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention monad_mainnet = '0x8f', // decimal: 143 } @@ -204,11 +163,7 @@ export enum SupportedTokenDetectionNetworks { * Networks where staked balance is supported - Values are in hex format */ export enum SupportedStakedBalanceNetworks { - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention mainnet = '0x1', // decimal: 1 - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention hoodi = '0x88bb0', // decimal: 560048 } @@ -448,6 +403,7 @@ export async function fetchTokenContractExchangeRates({ /** * Function to search for a specific value in a given map and return the key + * * @param map - map input to search value * @param value - the value to search for * @returns returns key that corresponds to the value diff --git a/packages/assets-controllers/src/crypto-compare-service/crypto-compare.ts b/packages/assets-controllers/src/crypto-compare-service/crypto-compare.ts index 0d303713543..b204d1fd31b 100644 --- a/packages/assets-controllers/src/crypto-compare-service/crypto-compare.ts +++ b/packages/assets-controllers/src/crypto-compare-service/crypto-compare.ts @@ -74,8 +74,6 @@ function getMultiPricingURL( * @param json.Response - The response status. * @param json.Message - The error message. */ -// TODO: Either fix this lint violation or explain why it's necessary to ignore. -// eslint-disable-next-line @typescript-eslint/naming-convention function handleErrorResponse(json: { Response?: string; Message?: string }) { if (json.Response === 'Error') { throw new Error(json.Message); @@ -114,16 +112,12 @@ export async function fetchExchangeRate( if (!Number.isFinite(conversionRate)) { throw new Error( `Invalid response for ${currency.toUpperCase()}: ${ - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions json[currency.toUpperCase()] }`, ); } if (includeUSDRate && !Number.isFinite(usdConversionRate)) { - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions throw new Error(`Invalid response for usdConversionRate: ${json.USD}`); } diff --git a/packages/assets-controllers/src/multicall.test.ts b/packages/assets-controllers/src/multicall.test.ts index a06f0f510ea..92f6199c9c9 100644 --- a/packages/assets-controllers/src/multicall.test.ts +++ b/packages/assets-controllers/src/multicall.test.ts @@ -71,12 +71,10 @@ describe('multicall', () => { expect(results).toMatchObject([ { success: true, - // eslint-disable-next-line @typescript-eslint/naming-convention value: { _hex: '0x01' }, }, { success: true, - // eslint-disable-next-line @typescript-eslint/naming-convention value: { _hex: '0x02' }, }, ]); @@ -126,12 +124,10 @@ describe('multicall', () => { expect(results).toMatchObject([ { success: true, - // eslint-disable-next-line @typescript-eslint/naming-convention value: { _hex: '0x01' }, }, { success: true, - // eslint-disable-next-line @typescript-eslint/naming-convention value: { _hex: '0x02' }, }, ]); @@ -166,7 +162,6 @@ describe('multicall', () => { expect(results).toMatchObject([ { success: true, - // eslint-disable-next-line @typescript-eslint/naming-convention value: { _hex: '0x01' }, }, ]); diff --git a/packages/assets-controllers/src/token-prices-service/codefi-v2.ts b/packages/assets-controllers/src/token-prices-service/codefi-v2.ts index 1b96e9e1aac..5ec2ddcee3c 100644 --- a/packages/assets-controllers/src/token-prices-service/codefi-v2.ts +++ b/packages/assets-controllers/src/token-prices-service/codefi-v2.ts @@ -167,6 +167,7 @@ const chainIdToNativeTokenAddress: Record = { * Returns the address that should be used to query the price api for the * chain's native token. On most chains, this is signified by the zero address. * But on some chains, the native token has a specific address. + * * @param chainId - The hexadecimal chain id. * @returns The address of the chain's native token. */ @@ -185,6 +186,7 @@ type SupportedCurrency = * The list of chain IDs that can be supplied in the URL for the `/spot-prices` * endpoint, but in hexadecimal form (for consistency with how we represent * chain IDs in other places). + * * @see Used by {@link CodefiTokenPricesServiceV2} to validate that a given chain ID is supported by V2 of the Codefi Price API. */ export const SUPPORTED_CHAIN_IDS = [ diff --git a/packages/base-controller/src/BaseController.ts b/packages/base-controller/src/BaseController.ts index 304e1886264..80370ba0292 100644 --- a/packages/base-controller/src/BaseController.ts +++ b/packages/base-controller/src/BaseController.ts @@ -40,8 +40,6 @@ export type StateChangeListener = (state: T, patches: Patch[]) => void; * @param value - A piece of controller state. * @returns Something derived from controller state. */ -// TODO: Either fix this lint violation or explain why it's necessary to ignore. -// eslint-disable-next-line @typescript-eslint/naming-convention export type StateDeriver = (value: T) => Json; /** @@ -50,8 +48,6 @@ export type StateDeriver = (value: T) => Json; * This metadata describes which parts of state should be persisted, and how to * get an anonymized representation of the state. */ -// TODO: Either fix this lint violation or explain why it's necessary to ignore. -// eslint-disable-next-line @typescript-eslint/naming-convention export type StateMetadata = { [P in keyof T]-?: StatePropertyMetadata; }; diff --git a/packages/bridge-controller/src/types.ts b/packages/bridge-controller/src/types.ts index cc30e8b50e5..728090aa7ab 100644 --- a/packages/bridge-controller/src/types.ts +++ b/packages/bridge-controller/src/types.ts @@ -235,7 +235,6 @@ export enum StatusTypes { export type GenericQuoteRequest = QuoteRequest< Hex | CaipChainId | string | number, // chainIds Hex | CaipAssetId | string, // assetIds/addresses - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-arguments Hex | CaipAccountId | string // accountIds/addresses >; diff --git a/packages/build-utils/src/transforms/remove-fenced-code.test.ts b/packages/build-utils/src/transforms/remove-fenced-code.test.ts index 9c6e55d0290..b75d6de8ddb 100644 --- a/packages/build-utils/src/transforms/remove-fenced-code.test.ts +++ b/packages/build-utils/src/transforms/remove-fenced-code.test.ts @@ -1,10 +1,10 @@ -import { removeFencedCode } from '..'; -import type { FeatureLabels } from '..'; import { DirectiveCommand, multiSplice, validateCommand, } from './remove-fenced-code'; +import { removeFencedCode } from '..'; +import type { FeatureLabels } from '..'; const FEATURE_A = 'feature-a'; const FEATURE_B = 'feature-b'; diff --git a/packages/build-utils/src/transforms/remove-fenced-code.ts b/packages/build-utils/src/transforms/remove-fenced-code.ts index b0732155b47..b872989a324 100644 --- a/packages/build-utils/src/transforms/remove-fenced-code.ts +++ b/packages/build-utils/src/transforms/remove-fenced-code.ts @@ -20,7 +20,6 @@ enum DirectiveTerminus { } export enum DirectiveCommand { - // eslint-disable-next-line @typescript-eslint/naming-convention ONLY_INCLUDE_IF = 'ONLY_INCLUDE_IF', } diff --git a/packages/composable-controller/src/ComposableController.ts b/packages/composable-controller/src/ComposableController.ts index e926683eb8e..594e10e41f3 100644 --- a/packages/composable-controller/src/ComposableController.ts +++ b/packages/composable-controller/src/ComposableController.ts @@ -195,8 +195,6 @@ export class ComposableController< }); }); } catch (error: unknown) { - // False negative. `name` is a string type. - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions console.error(`${name} - ${String(error)}`); } } diff --git a/packages/controller-utils/src/siwe.ts b/packages/controller-utils/src/siwe.ts index cc924809429..f2e4898ba04 100644 --- a/packages/controller-utils/src/siwe.ts +++ b/packages/controller-utils/src/siwe.ts @@ -40,9 +40,10 @@ function msgHexToText(hex: string): string { * @type WrappedSIWERequest * * Sign-In With Ethereum (SIWE)(EIP-4361) message with request metadata - * @property {string} from - Subject account address - * @property {string} origin - The RFC 3986 originating authority of the signing request, including scheme - * @property {ParsedMessage} siwe - The data parsed from the message + * + * @property from - Subject account address + * @property origin - The RFC 3986 originating authority of the signing request, including scheme + * @property siwe - The data parsed from the message */ // This interface was created before this ESLint rule was added. // Convert to a `type` in a future major version. diff --git a/packages/controller-utils/src/types.ts b/packages/controller-utils/src/types.ts index bb7c2e3d1bf..649c36e9e60 100644 --- a/packages/controller-utils/src/types.ts +++ b/packages/controller-utils/src/types.ts @@ -219,6 +219,7 @@ export type TraceCallback = ( /** * Callback to trace. * Thrown errors will not be caught, but the trace will still be recorded. + * * @param context - The context in which the operation is running. */ fn?: (context?: TraceContext) => ReturnType, diff --git a/packages/controller-utils/src/util.test.ts b/packages/controller-utils/src/util.test.ts index 74bfee0ebd5..db7ad0cf971 100644 --- a/packages/controller-utils/src/util.test.ts +++ b/packages/controller-utils/src/util.test.ts @@ -666,8 +666,6 @@ describe('util', () => { if (method === 'eth_getBlockByHash') { return cb(null, { id: params[0] }); } - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions throw new Error(`Unsupported method ${method}`); } } diff --git a/packages/controller-utils/src/util.ts b/packages/controller-utils/src/util.ts index 5fb889cd5ce..65164aa1756 100644 --- a/packages/controller-utils/src/util.ts +++ b/packages/controller-utils/src/util.ts @@ -69,8 +69,6 @@ export function isSafeChainId(chainId: Hex): boolean { * @param inputBn - BN|BigNumber instance to convert to a hex string. * @returns A '0x'-prefixed hex string. */ -// TODO: Either fix this lint violation or explain why it's necessary to ignore. -// eslint-disable-next-line @typescript-eslint/naming-convention export function BNToHex(inputBn: BN | BigNumber) { return add0x(inputBn.toString(16)); } @@ -155,8 +153,6 @@ export function getBuyURL( ): string | undefined { switch (networkCode) { case '1': - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions return `https://buy.coinbase.com/?code=9ec56d01-7e81-5017-930c-513daa27bb6a&amount=${amount}&address=${address}&crypto_currency=ETH`; case '5': return 'https://goerli-faucet.slock.it/'; @@ -299,8 +295,6 @@ function toChecksumHexAddressUnmemoized(address: string): string; * and is only present for backward compatibility. It may be removed in a future * major version. Please pass a string to `toChecksumHexAddress` instead. */ -// TODO: Either fix this lint violation or explain why it's necessary to ignore. -// eslint-disable-next-line @typescript-eslint/naming-convention function toChecksumHexAddressUnmemoized(address: T): T; // Tools only see JSDocs for overloads and ignore them for the implementation. @@ -620,8 +614,6 @@ export function isPlainObject(value: unknown): value is PlainObject { * * @template T - The non-empty array member type. */ -// TODO: Either fix this lint violation or explain why it's necessary to ignore. -// eslint-disable-next-line @typescript-eslint/naming-convention export type NonEmptyArray = [T, ...T[]]; /** @@ -631,8 +623,6 @@ export type NonEmptyArray = [T, ...T[]]; * @param value - The value to check. * @returns Whether the value is a non-empty array. */ -// TODO: Either fix this lint violation or explain why it's necessary to ignore. -// eslint-disable-next-line @typescript-eslint/naming-convention export function isNonEmptyArray(value: T[]): value is NonEmptyArray { return Array.isArray(value) && value.length > 0; } diff --git a/packages/ens-controller/src/EnsController.test.ts b/packages/ens-controller/src/EnsController.test.ts index 8085cd6cebb..1a28a326733 100644 --- a/packages/ens-controller/src/EnsController.test.ts +++ b/packages/ens-controller/src/EnsController.test.ts @@ -18,15 +18,15 @@ import { getDefaultNetworkControllerState, } from '@metamask/network-controller'; -import { - buildMockGetNetworkClientById, - buildCustomNetworkClientConfiguration, -} from '../../network-controller/tests/helpers'; import { EnsController, DEFAULT_ENS_NETWORK_MAP } from './EnsController'; import type { EnsControllerState, EnsControllerMessenger, } from './EnsController'; +import { + buildMockGetNetworkClientById, + buildCustomNetworkClientConfiguration, +} from '../../network-controller/tests/helpers'; const defaultState: EnsControllerState = { ensEntries: {}, @@ -49,8 +49,6 @@ jest.mock('@ethersproject/providers', () => { const originalModule = jest.requireActual('@ethersproject/providers'); return { - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention __esModule: true, ...originalModule, }; diff --git a/packages/ens-controller/src/EnsController.ts b/packages/ens-controller/src/EnsController.ts index 649a0fcb55c..0f9a1da71c8 100644 --- a/packages/ens-controller/src/EnsController.ts +++ b/packages/ens-controller/src/EnsController.ts @@ -49,6 +49,7 @@ export const DEFAULT_ENS_NETWORK_MAP: Record = { * @type EnsEntry * * ENS entry representation + * * @property chainId - Id of the associated chain * @property ensName - The ENS name * @property address - Hex address with the ENS name, or null @@ -63,6 +64,7 @@ export type EnsEntry = { * @type EnsControllerState * * ENS controller state + * * @property ensEntries - Object of ENS entry objects */ export type EnsControllerState = { @@ -263,8 +265,6 @@ export class EnsController extends BaseController< (address && !isValidHexAddress(address)) ) { throw new Error( - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions `Invalid ENS entry: { chainId:${chainId}, ensName:${ensName}, address:${address}}`, ); } diff --git a/packages/gas-fee-controller/src/GasFeeController.test.ts b/packages/gas-fee-controller/src/GasFeeController.test.ts index 562589f8064..aa69131f30b 100644 --- a/packages/gas-fee-controller/src/GasFeeController.test.ts +++ b/packages/gas-fee-controller/src/GasFeeController.test.ts @@ -21,10 +21,6 @@ import type { Hex } from '@metamask/utils'; import nock from 'nock'; import * as sinon from 'sinon'; -import { - buildCustomNetworkConfiguration, - buildCustomRpcEndpoint, -} from '../../network-controller/tests/helpers'; import determineGasFeeCalculations from './determineGasFeeCalculations'; import { fetchGasEstimates, @@ -40,6 +36,10 @@ import type { GasFeeStateFeeMarket, GasFeeStateLegacy, } from './GasFeeController'; +import { + buildCustomNetworkConfiguration, + buildCustomRpcEndpoint, +} from '../../network-controller/tests/helpers'; jest.mock('./determineGasFeeCalculations'); @@ -307,7 +307,6 @@ describe('GasFeeController', () => { getIsEIP1559Compatible?: jest.Mock>; getCurrentNetworkLegacyGasAPICompatibility?: jest.Mock; legacyAPIEndpoint?: string; - // eslint-disable-next-line @typescript-eslint/naming-convention EIP1559APIEndpoint?: string; clientId?: string; networkControllerState?: Partial; @@ -1099,14 +1098,10 @@ describe('GasFeeController', () => { isEIP1559Compatible: true, isLegacyGasAPICompatible: false, fetchGasEstimates, - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions fetchGasEstimatesUrl: `https://some-eip-1559-endpoint/${convertHexToDecimal( ChainId.sepolia, )}`, fetchLegacyGasPriceEstimates, - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions fetchLegacyGasPriceEstimatesUrl: `https://some-legacy-endpoint/${convertHexToDecimal( ChainId.sepolia, )}`, @@ -1210,8 +1205,6 @@ describe('GasFeeController', () => { expect(mockedDetermineGasFeeCalculations).toHaveBeenCalledWith( expect.objectContaining({ - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions fetchGasEstimatesUrl: `http://eip-1559.endpoint/${convertHexToDecimal( ChainId.sepolia, )}`, @@ -1258,8 +1251,6 @@ describe('GasFeeController', () => { expect(mockedDetermineGasFeeCalculations).toHaveBeenNthCalledWith( 1, expect.objectContaining({ - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions fetchGasEstimatesUrl: `https://some-eip-1559-endpoint/${convertHexToDecimal( ChainId['linea-sepolia'], )}`, @@ -1271,8 +1262,6 @@ describe('GasFeeController', () => { expect(mockedDetermineGasFeeCalculations).toHaveBeenNthCalledWith( 2, expect.objectContaining({ - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions fetchGasEstimatesUrl: `https://some-eip-1559-endpoint/${convertHexToDecimal( ChainId['linea-sepolia'], )}`, @@ -1290,8 +1279,6 @@ describe('GasFeeController', () => { await clock.tickAsync(pollingInterval); expect(mockedDetermineGasFeeCalculations).toHaveBeenCalledWith( expect.objectContaining({ - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions fetchGasEstimatesUrl: `https://some-eip-1559-endpoint/${convertHexToDecimal( ChainId.sepolia, )}`, diff --git a/packages/gas-fee-controller/src/GasFeeController.ts b/packages/gas-fee-controller/src/GasFeeController.ts index 30b0822667e..f68a381ac24 100644 --- a/packages/gas-fee-controller/src/GasFeeController.ts +++ b/packages/gas-fee-controller/src/GasFeeController.ts @@ -33,8 +33,6 @@ import { export const LEGACY_GAS_PRICES_API_URL = `https://api.metaswap.codefi.network/gasPrices`; -// TODO: Either fix this lint violation or explain why it's necessary to ignore. -// eslint-disable-next-line @typescript-eslint/naming-convention export type unknownString = 'unknown'; // Fee Market describes the way gas is set after the london hardfork, and was @@ -83,6 +81,7 @@ export type EstimatedGasFeeTimeBounds = { * A single gas price estimate for networks and accounts that don't support EIP-1559 * This estimate comes from eth_gasPrice but is converted to dec gwei to match other * return values + * * @property gasPrice - A GWEI dec string */ @@ -96,6 +95,7 @@ export type EthGasPriceEstimate = { * A set of gas price estimates for networks and accounts that don't support EIP-1559 * These estimates include low, medium and high all as strings representing gwei in * decimal format. + * * @property high - gasPrice, in decimal gwei string format, suggested for fast inclusion * @property medium - gasPrice, in decimal gwei string format, suggested for avg inclusion * @property low - gasPrice, in decimal gwei string format, suggested for slow inclusion @@ -110,6 +110,7 @@ export type LegacyGasPriceEstimate = { * @type Eip1559GasFee * * Data necessary to provide an estimate of a gas fee with a specific tip + * * @property minWaitTimeEstimate - The fastest the transaction will take, in milliseconds * @property maxWaitTimeEstimate - The slowest the transaction will take, in milliseconds * @property suggestedMaxPriorityFeePerGas - A suggested "tip", a GWEI hex number @@ -126,6 +127,7 @@ export type Eip1559GasFee = { * @type GasFeeEstimates * * Data necessary to provide multiple GasFee estimates, and supporting information, to the user + * * @property low - A GasFee for a minimum necessary combination of tip and maxFee * @property medium - A GasFee for a recommended combination of tip and maxFee * @property high - A GasFee for a high combination of tip and maxFee @@ -227,6 +229,7 @@ export type FetchGasFeeEstimateOptions = { * @type GasFeeState * * Gas Fee controller state + * * @property gasFeeEstimates - Gas fee estimate data based on new EIP-1559 properties * @property estimatedGasFeeTimeBounds - Estimates representing the minimum and maximum */ @@ -298,8 +301,6 @@ export class GasFeeController extends StaticIntervalPollingController ProviderProxy; + readonly #getProvider: () => ProviderProxy; /** * Creates a GasFeeController instance. @@ -363,7 +364,6 @@ export class GasFeeController extends StaticIntervalPollingController ProviderProxy; onNetworkDidChange?: (listener: (state: NetworkState) => void) => void; legacyAPIEndpoint?: string; - // eslint-disable-next-line @typescript-eslint/naming-convention EIP1559APIEndpoint: string; clientId?: string; }) { @@ -585,7 +585,6 @@ export class GasFeeController extends StaticIntervalPollingController new Promise((resolve) => setTimeout(resolve, time)); // TODO: Replace `any` with type -// eslint-disable-next-line @typescript-eslint/no-empty-function,@typescript-eslint/no-explicit-any +// eslint-disable-next-line @typescript-eslint/no-explicit-any const noop = function (_a: any) {}; const jsonrpc = '2.0' as const; diff --git a/packages/keyring-controller/tests/mocks/mockKeyring.ts b/packages/keyring-controller/tests/mocks/mockKeyring.ts index 7d8b9ab1265..e1d59417610 100644 --- a/packages/keyring-controller/tests/mocks/mockKeyring.ts +++ b/packages/keyring-controller/tests/mocks/mockKeyring.ts @@ -6,10 +6,10 @@ export class MockKeyring implements EthKeyring { public type = 'Mock Keyring'; - #accounts: Hex[] = []; + readonly #accounts: Hex[] = []; constructor(options: Record | undefined = {}) { - // eslint-disable-next-line @typescript-eslint/no-floating-promises, @typescript-eslint/promise-function-async + // eslint-disable-next-line @typescript-eslint/no-floating-promises this.deserialize(options); } diff --git a/packages/logging-controller/src/LoggingController.test.ts b/packages/logging-controller/src/LoggingController.test.ts index ccf0938cdf4..0a65f2b57da 100644 --- a/packages/logging-controller/src/LoggingController.test.ts +++ b/packages/logging-controller/src/LoggingController.test.ts @@ -15,8 +15,6 @@ import { SigningMethod, SigningStage } from './logTypes/EthSignLog'; jest.mock('uuid', () => { return { - // We need to use this name as this is what Jest recognizes. - // eslint-disable-next-line @typescript-eslint/naming-convention __esModule: true, ...jest.requireActual('uuid'), }; diff --git a/packages/logging-controller/src/logTypes/index.ts b/packages/logging-controller/src/logTypes/index.ts index 48239f262c5..e34adbc63a8 100644 --- a/packages/logging-controller/src/logTypes/index.ts +++ b/packages/logging-controller/src/logTypes/index.ts @@ -10,5 +10,5 @@ export type Log = EthSignLog | GenericLog; * Export all other types from these files for usage by clients */ export * from './EthSignLog'; -export * from './GenericLog'; +export type * from './GenericLog'; export * from './LogType'; diff --git a/packages/message-manager/src/AbstractMessageManager.ts b/packages/message-manager/src/AbstractMessageManager.ts index d820246136e..14054ed42a7 100644 --- a/packages/message-manager/src/AbstractMessageManager.ts +++ b/packages/message-manager/src/AbstractMessageManager.ts @@ -40,6 +40,7 @@ const getDefaultState = () => ({ * @type OriginalRequest * * Represents the original request object for adding a message. + * * @property origin? - Is it is specified, represents the origin */ export type OriginalRequest = { @@ -52,6 +53,7 @@ export type OriginalRequest = { * @type AbstractMessage * * Represents and contains data about a signing type signature request. + * * @property id - An id to track and identify the message object * @property type - The json-prc signing method for which a signature request has been made. * A 'Message' which always has a signing type @@ -92,6 +94,7 @@ export type AbstractMessageParams = { * * Represents the parameters to pass to the signing method once the signature request is approved * plus data added by MetaMask. + * * @property metamaskId - Added for tracking and identification within MetaMask * @property from - Address from which the message is processed * @property origin? - Added for request origin identification @@ -104,6 +107,7 @@ export type AbstractMessageParamsMetamask = AbstractMessageParams & { * @type MessageManagerState * * Message Manager state + * * @property unapprovedMessages - A collection of all Messages in the 'unapproved' state * @property unapprovedMessagesCount - The count of all Messages in this.unapprovedMessages */ @@ -205,6 +209,7 @@ export abstract class AbstractMessageManager< /** * Adds request props to the message params and returns a new messageParams object. + * * @param messageParams - The messageParams to add the request props to. * @param req - The original request object. * @returns The messageParams with the request props added. @@ -226,6 +231,7 @@ export abstract class AbstractMessageManager< /** * Creates a new Message with a random id and an 'unapproved' status. + * * @param messageParams - The messageParams to add the request props to. * @param type - The approval type of the message. * @param req - The original request object. diff --git a/packages/message-manager/src/DecryptMessageManager.ts b/packages/message-manager/src/DecryptMessageManager.ts index 0ae8d1d80bd..81f6c66934e 100644 --- a/packages/message-manager/src/DecryptMessageManager.ts +++ b/packages/message-manager/src/DecryptMessageManager.ts @@ -59,6 +59,7 @@ type DecryptMessageManagerOptions = { * * Represents and contains data about a 'eth_decrypt' type signature request. * These are created when a signature for an eth_decrypt call is requested. + * * @property id - An id to track and identify the message object * @property messageParams - The parameters to pass to the eth_decrypt method once the request is approved * @property type - The json-prc signing method for which a signature request has been made. @@ -83,6 +84,7 @@ export type DecryptMessageParams = AbstractMessageParams & { * * Represents the parameters to pass to the eth_decrypt method once the request is approved * plus data added by MetaMask. + * * @property metamaskId - Added for tracking and identification within MetaMask * @property data - A hex string conversion of the raw buffer data of the signature request * @property from - Address to sign this message from diff --git a/packages/message-manager/src/EncryptionPublicKeyManager.ts b/packages/message-manager/src/EncryptionPublicKeyManager.ts index eff493ee3fb..9b3fec821dc 100644 --- a/packages/message-manager/src/EncryptionPublicKeyManager.ts +++ b/packages/message-manager/src/EncryptionPublicKeyManager.ts @@ -62,6 +62,7 @@ type EncryptionPublicKeyManagerOptions = { * * Represents and contains data about a 'eth_getEncryptionPublicKey' type request. * These are created when an encryption public key is requested. + * * @property id - An id to track and identify the message object * @property messageParams - The parameters to pass to the eth_getEncryptionPublicKey method once the request is approved * @property type - The json-prc method for which an encryption public key request has been made. @@ -86,6 +87,7 @@ export type EncryptionPublicKeyParams = AbstractMessageParams; * * Represents the parameters to pass to the eth_getEncryptionPublicKey method once the request is approved * plus data added by MetaMask. + * * @property metamaskId - Added for tracking and identification within MetaMask * @property data - Encryption public key * @property from - Address from which to extract the encryption public key diff --git a/packages/message-manager/src/index.ts b/packages/message-manager/src/index.ts index 27723685451..bdcd9e46a88 100644 --- a/packages/message-manager/src/index.ts +++ b/packages/message-manager/src/index.ts @@ -1,4 +1,4 @@ export * from './AbstractMessageManager'; export * from './EncryptionPublicKeyManager'; export * from './DecryptMessageManager'; -export * from './types'; +export type * from './types'; diff --git a/packages/multichain-api-middleware/src/middlewares/multichainMethodCallValidatorMiddleware.test.ts b/packages/multichain-api-middleware/src/middlewares/multichainMethodCallValidatorMiddleware.test.ts index 832b61bf082..baaf1daf6b3 100644 --- a/packages/multichain-api-middleware/src/middlewares/multichainMethodCallValidatorMiddleware.test.ts +++ b/packages/multichain-api-middleware/src/middlewares/multichainMethodCallValidatorMiddleware.test.ts @@ -34,8 +34,6 @@ describe('multichainMethodCallValidatorMiddleware', () => { response, mockNext, (error) => { - // This is okay; we'll get what we get. - // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors reject(error); }, ); @@ -45,8 +43,6 @@ describe('multichainMethodCallValidatorMiddleware', () => { expect(mockNext).toHaveBeenCalled(); resolve(); } catch (error) { - // This is okay; we'll get what we get. - // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors reject(error); } }); @@ -92,8 +88,6 @@ describe('multichainMethodCallValidatorMiddleware', () => { ); resolve(); } catch (e) { - // This is okay; we'll get what we get. - // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors reject(e); } }, @@ -104,8 +98,6 @@ describe('multichainMethodCallValidatorMiddleware', () => { expect(mockNext).not.toHaveBeenCalled(); resolve(); } catch (error) { - // This is okay; we'll get what we get. - // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors reject(error); } }); @@ -151,8 +143,6 @@ describe('multichainMethodCallValidatorMiddleware', () => { ); resolve(); } catch (e) { - // This is okay; we'll get what we get. - // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors reject(e); } }, @@ -163,8 +153,6 @@ describe('multichainMethodCallValidatorMiddleware', () => { expect(mockNext).not.toHaveBeenCalled(); resolve(); } catch (error) { - // This is okay; we'll get what we get. - // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors reject(error); } }); @@ -215,8 +203,6 @@ describe('multichainMethodCallValidatorMiddleware', () => { ); resolve(); } catch (e) { - // This is okay; we'll get what we get. - // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors reject(e); } }, @@ -227,8 +213,6 @@ describe('multichainMethodCallValidatorMiddleware', () => { expect(mockNext).not.toHaveBeenCalled(); resolve(); } catch (error) { - // This is okay; we'll get what we get. - // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors reject(error); } }); @@ -262,8 +246,6 @@ describe('multichainMethodCallValidatorMiddleware', () => { response, mockNext, (error) => { - // This is okay; we'll get what we get. - // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors reject(error); }, ); @@ -273,8 +255,6 @@ describe('multichainMethodCallValidatorMiddleware', () => { expect(mockNext).toHaveBeenCalled(); resolve(); } catch (error) { - // This is okay; we'll get what we get. - // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors reject(error); } }); @@ -324,8 +304,6 @@ describe('multichainMethodCallValidatorMiddleware', () => { ); resolve(); } catch (e) { - // This is okay; we'll get what we get. - // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors reject(e); } }, @@ -336,8 +314,6 @@ describe('multichainMethodCallValidatorMiddleware', () => { expect(mockNext).not.toHaveBeenCalled(); resolve(); } catch (error) { - // This is okay; we'll get what we get. - // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors reject(error); } }); @@ -360,8 +336,6 @@ describe('multichainMethodCallValidatorMiddleware', () => { response, mockNext, (error) => { - // This is okay; we'll get what we get. - // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors reject(error); }, ); @@ -371,8 +345,6 @@ describe('multichainMethodCallValidatorMiddleware', () => { expect(mockNext).toHaveBeenCalled(); resolve(); } catch (error) { - // This is okay; we'll get what we get. - // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors reject(error); } }); @@ -396,8 +368,6 @@ describe('multichainMethodCallValidatorMiddleware', () => { response, mockNext, (error) => { - // This is okay; we'll get what we get. - // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors reject(error); }, ); @@ -407,8 +377,6 @@ describe('multichainMethodCallValidatorMiddleware', () => { expect(mockNext).toHaveBeenCalled(); resolve(); } catch (error) { - // This is okay; we'll get what we get. - // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors reject(error); } }); @@ -439,8 +407,6 @@ describe('multichainMethodCallValidatorMiddleware', () => { ); resolve(); } catch (e) { - // This is okay; we'll get what we get. - // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors reject(e); } }, @@ -451,8 +417,6 @@ describe('multichainMethodCallValidatorMiddleware', () => { expect(mockNext).not.toHaveBeenCalled(); resolve(); } catch (error) { - // This is okay; we'll get what we get. - // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors reject(error); } }); @@ -493,8 +457,6 @@ describe('multichainMethodCallValidatorMiddleware', () => { ); resolve(); } catch (e) { - // This is okay; we'll get what we get. - // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors reject(e); } }, @@ -505,8 +467,6 @@ describe('multichainMethodCallValidatorMiddleware', () => { expect(mockNext).not.toHaveBeenCalled(); resolve(); } catch (error) { - // This is okay; we'll get what we get. - // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors reject(error); } }); diff --git a/packages/name-controller/src/NameController.ts b/packages/name-controller/src/NameController.ts index 1c1385bb4b8..36d55321efe 100644 --- a/packages/name-controller/src/NameController.ts +++ b/packages/name-controller/src/NameController.ts @@ -22,12 +22,8 @@ export const PROPOSED_NAME_EXPIRE_DURATION = 60 * 60 * 24; // 24 hours */ export enum NameOrigin { // Originated from an account identity. - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention ACCOUNT_IDENTITY = 'account-identity', // Originated from an address book entry. - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention ADDRESS_BOOK = 'address-book', // Originated from the API (NameController.setName). This is the default. API = 'api', @@ -141,9 +137,9 @@ export class NameController extends BaseController< NameControllerState, NameControllerMessenger > { - #providers: NameProvider[]; + readonly #providers: NameProvider[]; - #updateDelay: number; + readonly #updateDelay: number; /** * Construct a Name controller. diff --git a/packages/name-controller/src/providers/ens.test.ts b/packages/name-controller/src/providers/ens.test.ts index 126fb0cdcd7..2bc6b042bdb 100644 --- a/packages/name-controller/src/providers/ens.test.ts +++ b/packages/name-controller/src/providers/ens.test.ts @@ -1,5 +1,5 @@ -import { NameType } from '../types'; import { ENSNameProvider } from './ens'; +import { NameType } from '../types'; jest.mock('../util'); diff --git a/packages/name-controller/src/providers/ens.ts b/packages/name-controller/src/providers/ens.ts index 20dfa8eadc6..84f7df329df 100644 --- a/packages/name-controller/src/providers/ens.ts +++ b/packages/name-controller/src/providers/ens.ts @@ -18,9 +18,9 @@ const LABEL = 'Ethereum Name Service (ENS)'; const log = createModuleLogger(projectLogger, 'ens'); export class ENSNameProvider implements NameProvider { - #isEnabled: () => boolean; + readonly #isEnabled: () => boolean; - #reverseLookup: ReverseLookupCallback; + readonly #reverseLookup: ReverseLookupCallback; constructor({ isEnabled, diff --git a/packages/name-controller/src/providers/etherscan.test.ts b/packages/name-controller/src/providers/etherscan.test.ts index 78ae2d42e41..da6cbca600f 100644 --- a/packages/name-controller/src/providers/etherscan.test.ts +++ b/packages/name-controller/src/providers/etherscan.test.ts @@ -1,7 +1,7 @@ +import { EtherscanNameProvider } from './etherscan'; import { CHAIN_IDS } from '../constants'; import { NameType } from '../types'; import { handleFetch } from '../util'; -import { EtherscanNameProvider } from './etherscan'; jest.mock('../util'); diff --git a/packages/name-controller/src/providers/etherscan.ts b/packages/name-controller/src/providers/etherscan.ts index 377bcb01719..9d26e5db03b 100644 --- a/packages/name-controller/src/providers/etherscan.ts +++ b/packages/name-controller/src/providers/etherscan.ts @@ -23,52 +23,28 @@ type EtherscanGetSourceCodeResponse = { message: string; result: [ { - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention SourceCode: string; - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention ABI: string; - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention ContractName: string; - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention CompilerVersion: string; - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention OptimizationUsed: string; - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention Runs: string; - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention ConstructorArguments: string; - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention Library: string; - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention LicenseType: string; - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention Proxy: string; - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention Implementation: string; - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention SwarmSource: string; }, ]; }; export class EtherscanNameProvider implements NameProvider { - #isEnabled: () => boolean; + readonly #isEnabled: () => boolean; #lastRequestTime = 0; - #mutex = new Mutex(); + readonly #mutex = new Mutex(); constructor({ isEnabled }: { isEnabled?: () => boolean } = {}) { this.#isEnabled = isEnabled || (() => true); @@ -192,8 +168,6 @@ export class EtherscanNameProvider implements NameProvider { Object.keys(params).forEach((key, index) => { const value = params[key]; - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions url += `${index === 0 ? '?' : '&'}${key}=${value}`; }); diff --git a/packages/name-controller/src/providers/lens.test.ts b/packages/name-controller/src/providers/lens.test.ts index dc22770dbf3..4af8e5829fe 100644 --- a/packages/name-controller/src/providers/lens.test.ts +++ b/packages/name-controller/src/providers/lens.test.ts @@ -1,6 +1,6 @@ +import { LensNameProvider } from './lens'; import { NameType } from '../types'; import { graphQL } from '../util'; -import { LensNameProvider } from './lens'; jest.mock('../util'); diff --git a/packages/name-controller/src/providers/lens.ts b/packages/name-controller/src/providers/lens.ts index 36e05744806..b3560c1e7f5 100644 --- a/packages/name-controller/src/providers/lens.ts +++ b/packages/name-controller/src/providers/lens.ts @@ -34,7 +34,7 @@ type LensResponse = { }; export class LensNameProvider implements NameProvider { - #isEnabled: () => boolean; + readonly #isEnabled: () => boolean; constructor({ isEnabled }: { isEnabled?: () => boolean } = {}) { this.#isEnabled = isEnabled || (() => true); diff --git a/packages/name-controller/src/providers/token.test.ts b/packages/name-controller/src/providers/token.test.ts index 4215e2dfe51..3094459fdab 100644 --- a/packages/name-controller/src/providers/token.test.ts +++ b/packages/name-controller/src/providers/token.test.ts @@ -1,6 +1,6 @@ +import { TokenNameProvider } from './token'; import { NameType } from '../types'; import { handleFetch } from '../util'; -import { TokenNameProvider } from './token'; jest.mock('../util'); diff --git a/packages/name-controller/src/providers/token.ts b/packages/name-controller/src/providers/token.ts index c9a47b355b7..b082439caba 100644 --- a/packages/name-controller/src/providers/token.ts +++ b/packages/name-controller/src/providers/token.ts @@ -14,7 +14,7 @@ const LABEL = 'Blockchain (Token Name)'; const log = createModuleLogger(projectLogger, 'token'); export class TokenNameProvider implements NameProvider { - #isEnabled: () => boolean; + readonly #isEnabled: () => boolean; constructor({ isEnabled }: { isEnabled?: () => boolean } = {}) { this.#isEnabled = isEnabled || (() => true); diff --git a/packages/name-controller/src/types.ts b/packages/name-controller/src/types.ts index 1bcb952b82d..c1da882409d 100644 --- a/packages/name-controller/src/types.ts +++ b/packages/name-controller/src/types.ts @@ -1,8 +1,6 @@ /** The name types supported by the NameController. */ export enum NameType { /** The address of an Ethereum account. */ - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention ETHEREUM_ADDRESS = 'ethereumAddress', } diff --git a/packages/name-controller/src/util.ts b/packages/name-controller/src/util.ts index a4ce342c056..dac27892b6d 100644 --- a/packages/name-controller/src/util.ts +++ b/packages/name-controller/src/util.ts @@ -5,8 +5,6 @@ * @param query - GraphQL query. * @param variables - GraphQL variables. */ -// TODO: Either fix this lint violation or explain why it's necessary to ignore. -// eslint-disable-next-line @typescript-eslint/naming-convention export async function graphQL( url: string, query: string, diff --git a/packages/network-controller/src/NetworkController.ts b/packages/network-controller/src/NetworkController.ts index e8204301abc..5863aa1de35 100644 --- a/packages/network-controller/src/NetworkController.ts +++ b/packages/network-controller/src/NetworkController.ts @@ -705,8 +705,6 @@ function getDefaultInfuraNetworkConfigurationsByChainId(): Record< } const rpcEndpointUrl = - // False positive - this is a string. - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions `https://${infuraNetworkType}.infura.io/v3/{infuraProjectId}` as const; const networkConfiguration: NetworkConfiguration = { diff --git a/packages/network-controller/tests/network-client/helpers.ts b/packages/network-controller/tests/network-client/helpers.ts index bc6fface4ba..4f0dcb128ea 100644 --- a/packages/network-controller/tests/network-client/helpers.ts +++ b/packages/network-controller/tests/network-client/helpers.ts @@ -430,8 +430,6 @@ export async function waitForPromiseToBeFulfilledAfterRunningAllTimers( let hasPromiseBeenFulfilled = false; let numTimesClockHasBeenAdvanced = 0; - // This is a mistake, we are catching this promise. - // eslint-disable-next-line promise/catch-or-return promise // TODO: Replace `any` with type // eslint-disable-next-line @typescript-eslint/no-explicit-any diff --git a/packages/permission-controller/src/PermissionController.test.ts b/packages/permission-controller/src/PermissionController.test.ts index 6bbdf7c417c..16c6768905e 100644 --- a/packages/permission-controller/src/PermissionController.test.ts +++ b/packages/permission-controller/src/PermissionController.test.ts @@ -6207,8 +6207,6 @@ describe('PermissionController', () => { 'Unauthorized to perform action. Try requesting the required permission(s) first. For more information, see: https://docs.metamask.io/guide/rpc-api.html#permissions', }); - // ESLint is confused; this signature is async. - // eslint-disable-next-line @typescript-eslint/await-thenable const response = await engine.handle(request); assertIsJsonRpcFailure(response); expect(response.error).toMatchObject( @@ -6231,8 +6229,6 @@ describe('PermissionController', () => { const expectedError = errors.methodNotFound('wallet_foo', { origin }); - // ESLint is confused; this signature is async. - // eslint-disable-next-line @typescript-eslint/await-thenable const response = await engine.handle(request); assertIsJsonRpcFailure(response); const { error } = response; @@ -6282,8 +6278,6 @@ describe('PermissionController', () => { { request: { ...request } }, ); - // ESLint is confused; this signature is async. - // eslint-disable-next-line @typescript-eslint/await-thenable const response = await engine.handle(request); assertIsJsonRpcFailure(response); const { error } = response; diff --git a/packages/permission-controller/src/SubjectMetadataController.ts b/packages/permission-controller/src/SubjectMetadataController.ts index f959674cad9..a74f7cc0cab 100644 --- a/packages/permission-controller/src/SubjectMetadataController.ts +++ b/packages/permission-controller/src/SubjectMetadataController.ts @@ -145,15 +145,11 @@ export class SubjectMetadataController extends BaseController< this.subjectsWithoutPermissionsEncounteredSinceStartup = new Set(); this.messenger.registerActionHandler( - // ESLint is confused by the string literal type. - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions `${this.name}:getSubjectMetadata`, this.getSubjectMetadata.bind(this), ); this.messenger.registerActionHandler( - // ESLint is confused by the string literal type. - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions `${this.name}:addSubjectMetadata`, this.addSubjectMetadata.bind(this), ); diff --git a/packages/permission-controller/src/rpc-methods/getPermissions.test.ts b/packages/permission-controller/src/rpc-methods/getPermissions.test.ts index f7724f4617b..c55edc7924d 100644 --- a/packages/permission-controller/src/rpc-methods/getPermissions.test.ts +++ b/packages/permission-controller/src/rpc-methods/getPermissions.test.ts @@ -2,8 +2,8 @@ import { JsonRpcEngine } from '@metamask/json-rpc-engine'; import type { JsonRpcRequest, PendingJsonRpcResponse } from '@metamask/utils'; import { assertIsJsonRpcSuccess } from '@metamask/utils'; -import type { PermissionConstraint } from '../Permission'; import { getPermissionsHandler } from './getPermissions'; +import type { PermissionConstraint } from '../Permission'; describe('getPermissions RPC method', () => { it('returns the values of the object returned by getPermissionsForOrigin', async () => { diff --git a/packages/permission-controller/src/rpc-methods/requestPermissions.ts b/packages/permission-controller/src/rpc-methods/requestPermissions.ts index a74ba986966..ae77a2dfae5 100644 --- a/packages/permission-controller/src/rpc-methods/requestPermissions.ts +++ b/packages/permission-controller/src/rpc-methods/requestPermissions.ts @@ -54,9 +54,8 @@ async function requestPermissionsImplementation( } const [requestedPermissions] = params; - const [grantedPermissions] = await requestPermissionsForOrigin( - requestedPermissions, - ); + const [grantedPermissions] = + await requestPermissionsForOrigin(requestedPermissions); // `wallet_requestPermission` is specified to return an array. res.result = Object.values(grantedPermissions); diff --git a/packages/permission-controller/src/rpc-methods/revokePermissions.test.ts b/packages/permission-controller/src/rpc-methods/revokePermissions.test.ts index 5d9a9fdc216..60465a1b475 100644 --- a/packages/permission-controller/src/rpc-methods/revokePermissions.test.ts +++ b/packages/permission-controller/src/rpc-methods/revokePermissions.test.ts @@ -83,8 +83,6 @@ describe('revokePermissions RPC method', () => { .serialize(); delete expectedError.stack; - // ESLint is confused; this signature is async. - // eslint-disable-next-line @typescript-eslint/await-thenable const response = await engine.handle(req); assertIsJsonRpcFailure(response); delete response.error.stack; @@ -120,8 +118,6 @@ describe('revokePermissions RPC method', () => { .serialize(); delete expectedError.stack; - // ESLint is confused; this signature is async. - // eslint-disable-next-line @typescript-eslint/await-thenable const response = await engine.handle(req); assertIsJsonRpcFailure(response); delete response.error.stack; @@ -156,8 +152,6 @@ describe('revokePermissions RPC method', () => { .serialize(); delete expectedError.stack; - // ESLint is confused; this signature is async. - // eslint-disable-next-line @typescript-eslint/await-thenable const response = await engine.handle(req); assertIsJsonRpcFailure(response); delete response.error.stack; @@ -193,8 +187,6 @@ describe('revokePermissions RPC method', () => { .serialize(); delete expectedError.stack; - // ESLint is confused; this signature is async. - // eslint-disable-next-line @typescript-eslint/await-thenable const response = await engine.handle(req); assertIsJsonRpcFailure(response); delete response.error.stack; diff --git a/packages/permission-log-controller/src/PermissionLogController.ts b/packages/permission-log-controller/src/PermissionLogController.ts index fb52ae08d14..846a7073fbe 100644 --- a/packages/permission-log-controller/src/PermissionLogController.ts +++ b/packages/permission-log-controller/src/PermissionLogController.ts @@ -58,6 +58,7 @@ export type PermissionHistory = Record; /** * * Permission log controller state + * * @property permissionHistory - permission history * @property permissionActivityLog - permission activity logs */ @@ -108,7 +109,7 @@ export class PermissionLogController extends BaseController< PermissionLogControllerState, PermissionLogControllerMessenger > { - #restrictedMethods: Set; + readonly #restrictedMethods: Set; constructor({ messenger, @@ -151,8 +152,6 @@ export class PermissionLogController extends BaseController< return; } const newEntries = { - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention eth_accounts: { accounts: this.#getAccountToTimeMap(accounts, Date.now()), }, @@ -319,8 +318,6 @@ export class PermissionLogController extends BaseController< // a set of accounts if the RPC method is "eth_requestAccounts". const accounts = result as string[]; newEntries = { - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention eth_accounts: { accounts: this.#getAccountToTimeMap(accounts, time), lastApproved: time, diff --git a/packages/permission-log-controller/src/enums.ts b/packages/permission-log-controller/src/enums.ts index fde713341dc..598852aedc3 100644 --- a/packages/permission-log-controller/src/enums.ts +++ b/packages/permission-log-controller/src/enums.ts @@ -9,14 +9,8 @@ export const LOG_IGNORE_METHODS = [ 'wallet_watchAsset', ]; -// TODO: Either fix this lint violation or explain why it's necessary to ignore. -// eslint-disable-next-line @typescript-eslint/naming-convention export enum LOG_METHOD_TYPES { - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention restricted = 'restricted', - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention internal = 'internal', } diff --git a/packages/permission-log-controller/tests/helpers.ts b/packages/permission-log-controller/tests/helpers.ts index 88a66b3aa92..eab0c88831e 100644 --- a/packages/permission-log-controller/tests/helpers.ts +++ b/packages/permission-log-controller/tests/helpers.ts @@ -23,14 +23,8 @@ const SUBJECTS = { }; const PERM_NAMES = Object.freeze({ - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention eth_accounts: 'eth_accounts', - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention test_method: 'test_method', - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention does_not_exist: 'does_not_exist', }); @@ -59,8 +53,6 @@ const CAVEATS = { * @param accounts - The accounts for the caveat * @returns An eth_accounts restrictReturnedAccounts caveats */ - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention eth_accounts: (accounts: string[]) => { return [ { @@ -85,11 +77,7 @@ const PERMS = { * * @returns A permissions request object with eth_accounts */ - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention eth_accounts: () => { - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention return { eth_accounts: {} }; }, @@ -98,11 +86,7 @@ const PERMS = { * * @returns A permissions request object with test_method */ - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention test_method: () => { - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention return { test_method: {} }; }, @@ -111,11 +95,7 @@ const PERMS = { * * @returns A permissions request object with does_not_exist */ - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention does_not_exist: () => { - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention return { does_not_exist: {} }; }, }, @@ -132,8 +112,6 @@ const PERMS = { * @param accounts - The accounts for the eth_accounts permission caveat * @returns A granted permissions object with eth_accounts and its caveat */ - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention eth_accounts: (accounts: string[]) => { return { parentCapability: PERM_NAMES.eth_accounts, @@ -146,8 +124,6 @@ const PERMS = { * * @returns A granted permissions object with test_method */ - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention test_method: () => { return { parentCapability: PERM_NAMES.test_method, @@ -193,8 +169,6 @@ export const getters = deepFreeze({ * @param origin - The origin of the request * @returns An RPC request object */ - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention eth_accounts: (origin: string) => { return { ...JsonRpcRequestStruct.TYPE, @@ -211,8 +185,6 @@ export const getters = deepFreeze({ * @param param - The request param * @returns An RPC request object */ - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention test_method: (origin: string, param = false) => { return { ...JsonRpcRequestStruct.TYPE, @@ -228,8 +200,6 @@ export const getters = deepFreeze({ * @param origin - The origin of the request * @returns An RPC request object */ - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention eth_requestAccounts: (origin: string) => { return { ...JsonRpcRequestStruct.TYPE, @@ -284,8 +254,6 @@ export const getters = deepFreeze({ * @param args - Any other data for the request's subjectMetadata * @returns An RPC request object */ - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention metamask_sendDomainMetadata: ( origin: string, name: string, diff --git a/packages/phishing-controller/src/PhishingController.ts b/packages/phishing-controller/src/PhishingController.ts index ddad8ece2d3..e11b622aaf9 100644 --- a/packages/phishing-controller/src/PhishingController.ts +++ b/packages/phishing-controller/src/PhishingController.ts @@ -95,6 +95,7 @@ export type ListTypes = * * Configuration response from the eth-phishing-detect package * consisting of approved and unapproved website origins + * * @property blacklist - List of unapproved origins * @property fuzzylist - List of fuzzy-matched unapproved origins * @property tolerance - Fuzzy match tolerance level @@ -113,6 +114,7 @@ export type EthPhishingResponse = { * @type C2DomainBlocklistResponse * * Response for blocklist update requests + * * @property recentlyAdded - List of c2 domains recently added to the blocklist * @property recentlyRemoved - List of c2 domains recently removed from the blocklist * @property lastFetchedAt - Timestamp of the last fetch request @@ -148,6 +150,7 @@ export type PhishingStalelist = { * @type PhishingListState * * type defining the persisted list state. This is the persisted state that is updated frequently with `this.maybeUpdateState()`. + * * @property allowlist - List of approved origins (legacy naming "whitelist") * @property blocklist - List of unapproved origins (legacy naming "blacklist") * @property blocklistPaths - Trie of unapproved origins with paths (hostname + path, no query params). @@ -174,6 +177,7 @@ export type PhishingListState = { * @type HotlistDiff * * type defining the expected type of the diffs in hotlist.json file. + * * @property url - Url of the diff entry. * @property timestamp - Timestamp at which the diff was identified. * @property targetList - The list name where the diff was identified. @@ -194,6 +198,7 @@ export type DataResultWrapper = { * @type Hotlist * * Type defining expected hotlist.json file. + * * @property url - Url of the diff entry. * @property timestamp - Timestamp at which the diff was identified. * @property targetList - The list name where the diff was identified. diff --git a/packages/polling-controller/src/AbstractPollingController.ts b/packages/polling-controller/src/AbstractPollingController.ts index f22455e4b13..3957ccb3f97 100644 --- a/packages/polling-controller/src/AbstractPollingController.ts +++ b/packages/polling-controller/src/AbstractPollingController.ts @@ -17,8 +17,6 @@ export const getKey = (input: PollingInput): PollingTokenSetId => * @param Base - The base class to mix onto. * @returns The composed class. */ -// TODO: Either fix this lint violation or explain why it's necessary to ignore. -// eslint-disable-next-line @typescript-eslint/naming-convention export function AbstractPollingControllerBaseMixin< TBase extends Constructor, PollingInput extends Json, @@ -29,8 +27,10 @@ export function AbstractPollingControllerBaseMixin< { readonly #pollingTokenSets: Map> = new Map(); - #callbacks: Map void>> = - new Map(); + readonly #callbacks: Map< + PollingTokenSetId, + Set<(input: PollingInput) => void> + > = new Map(); abstract _executePoll(input: PollingInput): Promise; diff --git a/packages/polling-controller/src/BlockTrackerPollingController.ts b/packages/polling-controller/src/BlockTrackerPollingController.ts index f7221768f90..f58ead95a0e 100644 --- a/packages/polling-controller/src/BlockTrackerPollingController.ts +++ b/packages/polling-controller/src/BlockTrackerPollingController.ts @@ -26,8 +26,6 @@ export type BlockTrackerPollingInput = { * @param Base - The base class to mix onto. * @returns The composed class. */ -// TODO: Either fix this lint violation or explain why it's necessary to ignore. -// eslint-disable-next-line @typescript-eslint/naming-convention function BlockTrackerPollingControllerMixin< TBase extends Constructor, PollingInput extends BlockTrackerPollingInput, @@ -58,8 +56,6 @@ function BlockTrackerPollingControllerMixin< this.#activeListeners[key] = updateOnNewBlock; } else { throw new Error( - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions `Unable to retrieve blockTracker for networkClientId ${input.networkClientId}`, ); } diff --git a/packages/polling-controller/src/StaticIntervalPollingController.ts b/packages/polling-controller/src/StaticIntervalPollingController.ts index 5076dfcffdf..ec0d9074ab2 100644 --- a/packages/polling-controller/src/StaticIntervalPollingController.ts +++ b/packages/polling-controller/src/StaticIntervalPollingController.ts @@ -18,8 +18,6 @@ import type { * @param Base - The base class to mix onto. * @returns The composed class. */ -// TODO: Either fix this lint violation or explain why it's necessary to ignore. -// eslint-disable-next-line @typescript-eslint/naming-convention function StaticIntervalPollingControllerMixin< TBase extends Constructor, PollingInput extends Json, diff --git a/packages/rate-limit-controller/src/RateLimitController.ts b/packages/rate-limit-controller/src/RateLimitController.ts index 3afe1fe5ef2..f41a650ce7c 100644 --- a/packages/rate-limit-controller/src/RateLimitController.ts +++ b/packages/rate-limit-controller/src/RateLimitController.ts @@ -217,8 +217,6 @@ export class RateLimitController< Object.assign(state, { requests: { ...(state.requests as RateLimitedRequests), - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/restrict-plus-operands [api]: { [origin]: previous + 1 }, }, }); diff --git a/packages/remote-feature-flag-controller/src/client-config-api-service/client-config-api-service.test.ts b/packages/remote-feature-flag-controller/src/client-config-api-service/client-config-api-service.test.ts index 0cd8756d47c..ad6f5088f7f 100644 --- a/packages/remote-feature-flag-controller/src/client-config-api-service/client-config-api-service.test.ts +++ b/packages/remote-feature-flag-controller/src/client-config-api-service/client-config-api-service.test.ts @@ -1,3 +1,4 @@ +import { ClientConfigApiService } from './client-config-api-service'; import { BASE_URL } from '../constants'; import type { ApiDataResponse, @@ -8,7 +9,6 @@ import { DistributionType, EnvironmentType, } from '../remote-feature-flag-controller-types'; -import { ClientConfigApiService } from './client-config-api-service'; const mockServerFeatureFlagsResponse: ApiDataResponse = [ { feature1: false }, @@ -249,6 +249,7 @@ describe('ClientConfigApiService', () => { /** * Creates a mock fetch function with configurable response data and options + * * @template T - The type of data to be returned by the fetch response * @param params - Configuration parameters * @param params.response - Optional Response properties to override defaults diff --git a/packages/remote-feature-flag-controller/src/client-config-api-service/client-config-api-service.ts b/packages/remote-feature-flag-controller/src/client-config-api-service/client-config-api-service.ts index 73e642526d8..e91ffb0b3b4 100644 --- a/packages/remote-feature-flag-controller/src/client-config-api-service/client-config-api-service.ts +++ b/packages/remote-feature-flag-controller/src/client-config-api-service/client-config-api-service.ts @@ -21,15 +21,15 @@ import type { * This service is responsible for fetching feature flags from the ClientConfig API. */ export class ClientConfigApiService implements AbstractClientConfigApiService { - #fetch: typeof fetch; + readonly #fetch: typeof fetch; readonly #policy: ServicePolicy; - #client: ClientType; + readonly #client: ClientType; - #distribution: DistributionType; + readonly #distribution: DistributionType; - #environment: EnvironmentType; + readonly #environment: EnvironmentType; /** * Constructs a new ClientConfigApiService object. @@ -172,6 +172,7 @@ export class ClientConfigApiService implements AbstractClientConfigApiService { /** * Fetches feature flags from the API with specific client, distribution, and environment parameters. * Provides structured error handling, including fallback to cached data if available. + * * @returns An object of feature flags and their boolean values or a structured error object. */ public async fetchRemoteFeatureFlags(): Promise { @@ -203,6 +204,7 @@ export class ClientConfigApiService implements AbstractClientConfigApiService { /** * Flattens an array of feature flag objects into a single feature flags object. + * * @param responseData - Array of objects containing feature flag key-value pairs * @returns A single object containing all feature flags merged together * @example diff --git a/packages/remote-feature-flag-controller/src/remote-feature-flag-controller.ts b/packages/remote-feature-flag-controller/src/remote-feature-flag-controller.ts index a20131996e5..0ff29495912 100644 --- a/packages/remote-feature-flag-controller/src/remote-feature-flag-controller.ts +++ b/packages/remote-feature-flag-controller/src/remote-feature-flag-controller.ts @@ -109,7 +109,7 @@ export class RemoteFeatureFlagController extends BaseController< #inProgressFlagUpdate?: Promise; - #getMetaMetricsId: () => string; + readonly #getMetaMetricsId: () => string; /** * Constructs a new RemoteFeatureFlagController instance. @@ -157,7 +157,6 @@ export class RemoteFeatureFlagController extends BaseController< * Checks if the cached feature flags are expired based on the fetch interval. * * @returns Whether the cache is expired (`true`) or still valid (`false`). - * @private */ #isCacheExpired(): boolean { return Date.now() - this.state.cacheTimestamp > this.#fetchInterval; @@ -197,7 +196,6 @@ export class RemoteFeatureFlagController extends BaseController< * Updates the controller's state with new feature flags and resets the cache timestamp. * * @param remoteFeatureFlags - The new feature flags to cache. - * @private */ async #updateCache(remoteFeatureFlags: FeatureFlags) { const processedRemoteFeatureFlags = diff --git a/packages/remote-feature-flag-controller/src/utils/user-segmentation-utils.ts b/packages/remote-feature-flag-controller/src/utils/user-segmentation-utils.ts index b14056c453c..07519d03ce3 100644 --- a/packages/remote-feature-flag-controller/src/utils/user-segmentation-utils.ts +++ b/packages/remote-feature-flag-controller/src/utils/user-segmentation-utils.ts @@ -5,6 +5,7 @@ import type { FeatureFlagScopeValue } from '../remote-feature-flag-controller-ty /** * Converts a UUID string to a BigInt by removing dashes and converting to hexadecimal. + * * @param uuid - The UUID string to convert * @returns The UUID as a BigInt value */ @@ -22,6 +23,7 @@ const UUID_V4_VALUE_RANGE_BIGINT = MAX_UUID_V4_BIGINT - MIN_UUID_V4_BIGINT; * Generates a deterministic random number between 0 and 1 based on a metaMetricsId. * This is useful for A/B testing and feature flag rollouts where we want * consistent group assignment for the same user. + * * @param metaMetricsId - The unique identifier used to generate the deterministic random number. Must be either: * - A UUIDv4 string (e.g., '123e4567-e89b-12d3-a456-426614174000' * - A hex string with '0x' prefix (e.g., '0x86bacb9b2bf9a7e8d2b147eadb95ac9aaa26842327cd24afc8bd4b3c1d136420') diff --git a/packages/sample-controllers/src/sample-gas-prices-service/sample-gas-prices-service.test.ts b/packages/sample-controllers/src/sample-gas-prices-service/sample-gas-prices-service.test.ts index 2c82b73f7c6..1796ea2bd6e 100644 --- a/packages/sample-controllers/src/sample-gas-prices-service/sample-gas-prices-service.test.ts +++ b/packages/sample-controllers/src/sample-gas-prices-service/sample-gas-prices-service.test.ts @@ -297,8 +297,6 @@ describe('SampleGasPricesService', () => { type RootMessenger = Messenger< MockAnyNamespace, MessengerActions, - // TODO: Disable this lint rule - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-arguments MessengerEvents >; diff --git a/packages/sample-controllers/src/sample-gas-prices-service/sample-gas-prices-service.ts b/packages/sample-controllers/src/sample-gas-prices-service/sample-gas-prices-service.ts index f8747e54dad..15611143ec8 100644 --- a/packages/sample-controllers/src/sample-gas-prices-service/sample-gas-prices-service.ts +++ b/packages/sample-controllers/src/sample-gas-prices-service/sample-gas-prices-service.ts @@ -52,8 +52,6 @@ type AllowedEvents = never; export type SampleGasPricesServiceMessenger = Messenger< typeof serviceName, SampleGasPricesServiceActions | AllowedActions, - // TODO: Disable this lint rule - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-arguments SampleGasPricesServiceEvents | AllowedEvents >; diff --git a/packages/shield-controller/src/polling-with-policy.test.ts b/packages/shield-controller/src/polling-with-policy.test.ts index 5187d2f68dd..bfe60b59c40 100644 --- a/packages/shield-controller/src/polling-with-policy.test.ts +++ b/packages/shield-controller/src/polling-with-policy.test.ts @@ -23,7 +23,6 @@ describe('PollingWithCockatielPolicy', () => { setTimeout(() => { // eslint-disable-next-line jest/no-conditional-in-test if (invocationCount < 3) { - // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors -- HttpError is a valid error which extends Error class reject(new HttpError(412, 'Results are not available yet')); } resolve('test'); @@ -41,7 +40,6 @@ describe('PollingWithCockatielPolicy', () => { .fn() .mockImplementation(async (_abortSignal: AbortSignal) => { return new Promise((_resolve, reject) => { - // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors -- HttpError is a valid error which extends Error class reject(new HttpError(500, 'Internal server error')); }); }); @@ -61,7 +59,6 @@ describe('PollingWithCockatielPolicy', () => { .mockImplementation(async (_abortSignal: AbortSignal) => { return new Promise((_resolve, reject) => { setTimeout(() => { - // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors -- HttpError is a valid error which extends Error class reject(new HttpError(412, 'Results are not available yet')); }, 100); }); @@ -86,7 +83,7 @@ describe('PollingWithCockatielPolicy', () => { if (abortSignal.aborted) { reject(new Error('test error')); } - // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors -- HttpError is a valid error which extends Error class + reject(new HttpError(412, 'Results are not available yet')); }, 100); }); diff --git a/packages/signature-controller/src/utils/validation.test.ts b/packages/signature-controller/src/utils/validation.test.ts index 1d313b6634a..effa714ab81 100644 --- a/packages/signature-controller/src/utils/validation.test.ts +++ b/packages/signature-controller/src/utils/validation.test.ts @@ -234,8 +234,6 @@ describe('Validation Utils', () => { version, }), ).toThrow( - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - `Provided chainId "${convertHexToDecimal( CHAIN_ID_MOCK, // TODO: Either fix this lint violation or explain why it's necessary to ignore. diff --git a/packages/transaction-controller/src/helpers/ResimulateHelper.ts b/packages/transaction-controller/src/helpers/ResimulateHelper.ts index 6bb1a51c23c..7a3403fc800 100644 --- a/packages/transaction-controller/src/helpers/ResimulateHelper.ts +++ b/packages/transaction-controller/src/helpers/ResimulateHelper.ts @@ -88,7 +88,6 @@ export class ResimulateHelper { } const listener = () => { - // eslint-disable-next-line promise/catch-or-return this.#simulateTransaction(transactionMeta) .catch((error) => { /* istanbul ignore next */ diff --git a/packages/user-operation-controller/src/UserOperationController.test.ts b/packages/user-operation-controller/src/UserOperationController.test.ts index 07a7ee0d4a2..6f3c0e9e900 100644 --- a/packages/user-operation-controller/src/UserOperationController.test.ts +++ b/packages/user-operation-controller/src/UserOperationController.test.ts @@ -98,6 +98,7 @@ const ADD_USER_OPERATION_OPTIONS_MOCK: AddUserOperationOptions = { /** * Creates a mock user operation messenger. + * * @returns The mock user operation messenger. */ function createMessengerMock() { @@ -111,6 +112,7 @@ function createMessengerMock() { /** * Creates a mock smart contract account. + * * @returns The mock smart contract account. */ function createSmartContractAccountMock() { @@ -123,6 +125,7 @@ function createSmartContractAccountMock() { /** * Creates a mock bundler. + * * @returns The mock bundler. */ function createBundlerMock() { @@ -134,6 +137,7 @@ function createBundlerMock() { /** * Creates a mock PendingUserOperationTracker. + * * @returns The mock PendingUserOperationTracker. */ function createPendingUserOperationTrackerMock() { @@ -237,8 +241,6 @@ describe('UserOperationController', () => { return approvalControllerAddRequestMock(); } - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions throw new Error(`Unexpected mock messenger action: ${action}`); }, ); diff --git a/packages/user-operation-controller/src/UserOperationController.ts b/packages/user-operation-controller/src/UserOperationController.ts index 7a55e632753..af6c00fbd09 100644 --- a/packages/user-operation-controller/src/UserOperationController.ts +++ b/packages/user-operation-controller/src/UserOperationController.ts @@ -82,22 +82,16 @@ type Events = { }; export type UserOperationControllerEventEmitter = EventEmitter & { - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention on( eventName: T, listener: (...args: Events[T]) => void, ): UserOperationControllerEventEmitter; - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention once( eventName: T, listener: (...args: Events[T]) => void, ): UserOperationControllerEventEmitter; - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention emit(eventName: T, ...args: Events[T]): boolean; }; @@ -205,11 +199,11 @@ export class UserOperationController extends BaseController< > { hub: UserOperationControllerEventEmitter; - #entrypoint: string; + readonly #entrypoint: string; - #getGasFeeEstimates: () => Promise; + readonly #getGasFeeEstimates: () => Promise; - #pendingUserOperationTracker: PendingUserOperationTracker; + readonly #pendingUserOperationTracker: PendingUserOperationTracker; /** * Construct a UserOperationController instance. @@ -711,8 +705,6 @@ export class UserOperationController extends BaseController< (metadata) => { log('In listener...'); this.hub.emit('user-operation-confirmed', metadata); - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions this.hub.emit(`${metadata.id}:confirmed`, metadata); }, ); @@ -721,8 +713,6 @@ export class UserOperationController extends BaseController< 'user-operation-failed', (metadata, error) => { this.hub.emit('user-operation-failed', metadata, error); - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions this.hub.emit(`${metadata.id}:failed`, metadata, error); }, ); diff --git a/packages/user-operation-controller/src/helpers/Bundler.test.ts b/packages/user-operation-controller/src/helpers/Bundler.test.ts index d629a025bb3..8572894b439 100644 --- a/packages/user-operation-controller/src/helpers/Bundler.test.ts +++ b/packages/user-operation-controller/src/helpers/Bundler.test.ts @@ -1,5 +1,5 @@ -import type { UserOperation } from '../types'; import { Bundler } from './Bundler'; +import type { UserOperation } from '../types'; const URL_MOCK = 'http://test.com'; const ENTRYPOINT_MOCK = '0x123'; @@ -46,6 +46,7 @@ describe('Bundler', () => { /** * Mock fetch to return a JSON response. + * * @param jsonResponse - The JSON response to return. */ function mockJsonResponse(jsonResponse: Record) { diff --git a/packages/user-operation-controller/src/helpers/Bundler.ts b/packages/user-operation-controller/src/helpers/Bundler.ts index 2b800cd3a6d..7e66581aeed 100644 --- a/packages/user-operation-controller/src/helpers/Bundler.ts +++ b/packages/user-operation-controller/src/helpers/Bundler.ts @@ -1,5 +1,3 @@ -/* eslint-disable jsdoc/require-jsdoc */ - import { createModuleLogger, projectLogger } from '../logger'; import type { UserOperation, UserOperationReceipt } from '../types'; @@ -27,7 +25,7 @@ export type BundlerEstimateUserOperationGasResponse = { * A helper class for interacting with a bundler. */ export class Bundler { - #url: string; + readonly #url: string; constructor(url: string) { this.#url = url; @@ -58,6 +56,7 @@ export class Bundler { /** * Retrieve the receipt for a user operation. + * * @param hash - The hash of the user operation. * @returns The receipt for the user operation, or `undefined` if the user operation is pending. */ @@ -74,6 +73,7 @@ export class Bundler { /** * Submit a user operation to the bundler. + * * @param userOperation - The signed user operation to submit. * @param entrypoint - The address of entrypoint to use for the user operation. * @returns The hash of the user operation. @@ -98,8 +98,6 @@ export class Bundler { return hash; } - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention async #query(method: string, params: unknown[]): Promise { const request = { method: 'POST', diff --git a/packages/user-operation-controller/src/helpers/PendingUserOperationTracker.test.ts b/packages/user-operation-controller/src/helpers/PendingUserOperationTracker.test.ts index 3291e07fdb8..f74254646f8 100644 --- a/packages/user-operation-controller/src/helpers/PendingUserOperationTracker.test.ts +++ b/packages/user-operation-controller/src/helpers/PendingUserOperationTracker.test.ts @@ -1,11 +1,11 @@ import { query } from '@metamask/controller-utils'; import type { NetworkControllerGetNetworkClientByIdAction } from '@metamask/network-controller'; +import * as BundlerHelper from './Bundler'; +import { PendingUserOperationTracker } from './PendingUserOperationTracker'; import type { UserOperationMetadata, UserOperationReceipt } from '../types'; import { UserOperationStatus } from '../types'; import type { UserOperationControllerMessenger } from '../UserOperationController'; -import * as BundlerHelper from './Bundler'; -import { PendingUserOperationTracker } from './PendingUserOperationTracker'; const CHAIN_ID_MOCK = '0x5'; const NETWORK_CLIENT_ID_MOCK = 'testNetworkClientId'; @@ -44,6 +44,7 @@ jest.mock('@metamask/controller-utils', () => ({ /** * Creates a mock user operation messenger. + * * @returns The mock user operation messenger. */ function createMessengerMock() { @@ -55,6 +56,7 @@ function createMessengerMock() { /** * Creates a mock bundler. + * * @returns The mock bundler. */ function createBundlerMock() { @@ -70,6 +72,7 @@ describe('PendingUserOperationTracker', () => { /** * Simulate the scenario where a user operation is confirmed. + * * @param beforeCallback - An optional callback to execute before the scenario is run. * @param overrideReceipt - An optional receipt to override the default mock receipt. */ @@ -100,6 +103,7 @@ describe('PendingUserOperationTracker', () => { /** * Simulate the scenario where a user operation fails. + * * @param beforeCallback - An optional callback to execute before the scenario is run. */ async function onFailedUserOperation( @@ -131,7 +135,9 @@ describe('PendingUserOperationTracker', () => { blockTracker: { getCurrentBlock: () => BLOCK_NUMBER_MOCK }, configuration: { chainId: CHAIN_ID_MOCK }, provider: {}, - } as unknown as ReturnType); + } as unknown as ReturnType< + NetworkControllerGetNetworkClientByIdAction['handler'] + >); }); describe('_executePoll', () => { diff --git a/packages/user-operation-controller/src/helpers/PendingUserOperationTracker.ts b/packages/user-operation-controller/src/helpers/PendingUserOperationTracker.ts index 551ac6736a1..379c616bd59 100644 --- a/packages/user-operation-controller/src/helpers/PendingUserOperationTracker.ts +++ b/packages/user-operation-controller/src/helpers/PendingUserOperationTracker.ts @@ -11,11 +11,11 @@ import { createModuleLogger, type Hex } from '@metamask/utils'; // eslint-disable-next-line import-x/no-nodejs-modules import EventEmitter from 'events'; +import { Bundler } from './Bundler'; import { projectLogger } from '../logger'; import type { UserOperationMetadata, UserOperationReceipt } from '../types'; import { UserOperationStatus } from '../types'; import type { UserOperationControllerMessenger } from '../UserOperationController'; -import { Bundler } from './Bundler'; const log = createModuleLogger(projectLogger, 'pending-user-operations'); @@ -26,22 +26,16 @@ type Events = { }; export type PendingUserOperationTrackerEventEmitter = EventEmitter & { - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention on( eventName: T, listener: (...args: Events[T]) => void, ): PendingUserOperationTrackerEventEmitter; - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention once( eventName: T, listener: (...args: Events[T]) => void, ): PendingUserOperationTrackerEventEmitter; - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention emit(eventName: T, ...args: Events[T]): boolean; }; @@ -57,9 +51,9 @@ type PendingUserOperationPollingInput = { export class PendingUserOperationTracker extends BlockTrackerPollingControllerOnly() { hub: PendingUserOperationTrackerEventEmitter; - #getUserOperations: () => UserOperationMetadata[]; + readonly #getUserOperations: () => UserOperationMetadata[]; - #messenger: UserOperationControllerMessenger; + readonly #messenger: UserOperationControllerMessenger; constructor({ getUserOperations, diff --git a/packages/user-operation-controller/src/helpers/SnapSmartContractAccount.test.ts b/packages/user-operation-controller/src/helpers/SnapSmartContractAccount.test.ts index 11475aa0386..e958ed1e33b 100644 --- a/packages/user-operation-controller/src/helpers/SnapSmartContractAccount.test.ts +++ b/packages/user-operation-controller/src/helpers/SnapSmartContractAccount.test.ts @@ -1,5 +1,6 @@ import type { KeyringController } from '@metamask/keyring-controller'; +import { SnapSmartContractAccount } from './SnapSmartContractAccount'; import { ADDRESS_ZERO, EMPTY_BYTES, VALUE_ZERO } from '../constants'; import type { PrepareUserOperationResponse, @@ -11,7 +12,6 @@ import type { import { type PrepareUserOperationRequest } from '../types'; import type { UserOperationControllerMessenger } from '../UserOperationController'; import { toEip155ChainId } from '../utils/chain-id'; -import { SnapSmartContractAccount } from './SnapSmartContractAccount'; const PREPARE_USER_OPERATION_REQUEST_MOCK: PrepareUserOperationRequest = { chainId: '0x1', @@ -74,6 +74,7 @@ const SIGN_USER_OPERATION_RESPONSE_MOCK: Awaited< /** * Creates a mock of the UserOperationControllerMessenger. + * * @returns The mock instance. */ function createMessengerMock() { diff --git a/packages/user-operation-controller/src/helpers/SnapSmartContractAccount.ts b/packages/user-operation-controller/src/helpers/SnapSmartContractAccount.ts index f4bf60de2d4..78cddc4ccd7 100644 --- a/packages/user-operation-controller/src/helpers/SnapSmartContractAccount.ts +++ b/packages/user-operation-controller/src/helpers/SnapSmartContractAccount.ts @@ -12,7 +12,7 @@ import type { UserOperationControllerMessenger } from '../UserOperationControlle import { toEip155ChainId } from '../utils/chain-id'; export class SnapSmartContractAccount implements SmartContractAccount { - #messenger: UserOperationControllerMessenger; + readonly #messenger: UserOperationControllerMessenger; constructor(messenger: UserOperationControllerMessenger) { this.#messenger = messenger; diff --git a/packages/user-operation-controller/src/types.ts b/packages/user-operation-controller/src/types.ts index 0e827cc3c19..b4f66cf0f40 100644 --- a/packages/user-operation-controller/src/types.ts +++ b/packages/user-operation-controller/src/types.ts @@ -283,6 +283,7 @@ export type SignUserOperationResponse = { export type SmartContractAccount = { /** * Retrieve the initial values required to create a user operation. + * * @param request - The data needed by the smart contract account to provide the initial user operation values. * @returns The initial values required to create a user operation. */ @@ -293,6 +294,7 @@ export type SmartContractAccount = { /** * Retrieve additional data required to create a user operation, such as the paymasterAndData value. * If gas values were not provided in the prepare response, this will be called after estimating gas using the bundler. + * * @param request - The data needed by the smart contract account to provide the additional user operation values. * @returns The additional values required to create a user operation. */ @@ -302,6 +304,7 @@ export type SmartContractAccount = { /** * Sign the final user operation. + * * @param request - The data needed by the smart contract account to generate the signature. * @returns The final values required to sign a user operation. */ diff --git a/packages/user-operation-controller/src/utils/gas-fees.ts b/packages/user-operation-controller/src/utils/gas-fees.ts index 8cb9876892b..a86c980aee8 100644 --- a/packages/user-operation-controller/src/utils/gas-fees.ts +++ b/packages/user-operation-controller/src/utils/gas-fees.ts @@ -37,6 +37,7 @@ type SuggestedGasFees = { /** * Populates the gas fee properties for a user operation. + * * @param request - The request to update the gas fees. * @param request.getGasFeeEstimates - A callback to get gas fee estimates. * @param request.metadata - The metadata for the user operation. @@ -80,6 +81,7 @@ export async function updateGasFees(request: UpdateGasFeesRequest) { /** * Gets the maxFeePerGas for a user operation. + * * @param originalRequest - The original request to add the user operation. * @param getGetFasEstimates - A callback to get gas fee estimates. * @param transaction - The transaction that created the user operation. @@ -116,6 +118,7 @@ async function getMaxFeePerGas( /** * Gets the maxPriorityFeePerGas for a user operation. + * * @param originalRequest - The original request to add the user operation. * @param getGetFasEstimates - A callback to get gas fee estimates. * @param userOperation - The user operation being updated. @@ -160,6 +163,7 @@ async function getMaxPriorityFeePerGas( /** * Gets the userFeeLevel for a user operation. + * * @param metadata - The metadata for the user operation. * @param originalRequest - The original request to add the user operation. * @param suggestedGasFees - The suggested gas fees, if any. @@ -208,6 +212,7 @@ function getUserFeeLevel( /** * Gets suggested gas fees. + * * @param request - The request to update the gas fees. * @param request.getGasFeeEstimates - A callback to get gas fee estimates. * @param request.provider - A provider to query the network. @@ -281,6 +286,7 @@ async function getSuggestedGasFees( /** * Converts a GWEI decimal string to a WEI hexadecimal string. + * * @param value - The GWEI decimal string to convert. * @returns The WEI hexadecimal string. */ @@ -290,6 +296,7 @@ function gweiDecimalToWeiHex(value: string) { /** * Checks if a gas fee property is empty. + * * @param value - The gas fee value to check. * @returns Whether the gas fee property is empty. */ diff --git a/packages/user-operation-controller/src/utils/gas.test.ts b/packages/user-operation-controller/src/utils/gas.test.ts index bb40ac09873..a4ec99dce68 100644 --- a/packages/user-operation-controller/src/utils/gas.test.ts +++ b/packages/user-operation-controller/src/utils/gas.test.ts @@ -1,5 +1,6 @@ import { cloneDeep } from 'lodash'; +import { updateGas } from './gas'; import { VALUE_ZERO } from '../constants'; import type { BundlerEstimateUserOperationGasResponse } from '../helpers/Bundler'; import { Bundler } from '../helpers/Bundler'; @@ -7,7 +8,6 @@ import type { PrepareUserOperationResponse, UserOperationMetadata, } from '../types'; -import { updateGas } from './gas'; jest.mock('../helpers/Bundler', () => ({ Bundler: jest.fn(), @@ -36,6 +36,7 @@ const ESTIMATE_RESPONSE_HEX_MOCK: BundlerEstimateUserOperationGasResponse = { /** * Creates a mock bundler. + * * @returns The mock bundler. */ function createBundlerMock() { diff --git a/packages/user-operation-controller/src/utils/gas.ts b/packages/user-operation-controller/src/utils/gas.ts index 94ca9d70f91..3d5715832fc 100644 --- a/packages/user-operation-controller/src/utils/gas.ts +++ b/packages/user-operation-controller/src/utils/gas.ts @@ -19,6 +19,7 @@ const GAS_ESTIMATE_MULTIPLIER = 1.5; /** * Populates the gas properties for a user operation. + * * @param metadata - The metadata for the user operation. * @param prepareResponse - The prepare response from the smart contract account. * @param entrypoint - Address of the entrypoint contract. @@ -78,6 +79,7 @@ export async function updateGas( /** * Normalizes a gas estimate value from the bundler. + * * @param rawValue - The raw value to normalize. * @returns The normalized value as a hexadecimal string. */ diff --git a/packages/user-operation-controller/src/utils/transaction.test.ts b/packages/user-operation-controller/src/utils/transaction.test.ts index 1decdee6216..50b7e6b146d 100644 --- a/packages/user-operation-controller/src/utils/transaction.test.ts +++ b/packages/user-operation-controller/src/utils/transaction.test.ts @@ -1,3 +1,4 @@ +import { getTransactionMetadata } from './transaction'; import type { TransactionParams } from '../../../transaction-controller/src'; import { TransactionStatus, @@ -7,7 +8,6 @@ import { import { EMPTY_BYTES, VALUE_ZERO } from '../constants'; import type { UserOperation } from '../types'; import { UserOperationStatus, type UserOperationMetadata } from '../types'; -import { getTransactionMetadata } from './transaction'; const USER_OPERATION_METADATA_MOCK: UserOperationMetadata = { id: 'testUserOperationId', diff --git a/packages/user-operation-controller/src/utils/transaction.ts b/packages/user-operation-controller/src/utils/transaction.ts index 0e606536af6..72e90be3cec 100644 --- a/packages/user-operation-controller/src/utils/transaction.ts +++ b/packages/user-operation-controller/src/utils/transaction.ts @@ -17,6 +17,7 @@ import type { UserOperationMetadata } from '../types'; /** * Converts a user operation metadata object into a transaction metadata object. + * * @param metadata - The user operation metadata object to convert. * @returns The equivalent transaction metadata object. */ @@ -148,6 +149,7 @@ export function getTransactionMetadata( /** * Adds the given hexadecimal values together. + * * @param values - The hexadecimal values to add together. * @returns The sum of the given hexadecimal values. */ diff --git a/packages/user-operation-controller/src/utils/validation.test.ts b/packages/user-operation-controller/src/utils/validation.test.ts index 180221394f3..a3c58262e27 100644 --- a/packages/user-operation-controller/src/utils/validation.test.ts +++ b/packages/user-operation-controller/src/utils/validation.test.ts @@ -3,6 +3,13 @@ import { TransactionType } from '@metamask/transaction-controller'; import { cloneDeep } from 'lodash'; +import { + validateAddUserOperationOptions, + validateAddUserOperationRequest, + validatePrepareUserOperationResponse, + validateSignUserOperationResponse, + validateUpdateUserOperationResponse, +} from './validation'; import type { PrepareUserOperationResponse, SignUserOperationResponse, @@ -12,13 +19,6 @@ import type { AddUserOperationOptions, AddUserOperationRequest, } from '../UserOperationController'; -import { - validateAddUserOperationOptions, - validateAddUserOperationRequest, - validatePrepareUserOperationResponse, - validateSignUserOperationResponse, - validateUpdateUserOperationResponse, -} from './validation'; const ADD_USER_OPERATION_REQUEST_MOCK: AddUserOperationRequest = { data: '0x1', @@ -65,13 +65,12 @@ const SIGN_USER_OPERATION_RESPONSE_MOCK: SignUserOperationResponse = { /** * Copy an object and set a property path to a given value. + * * @param object - The object to copy. * @param pathString - The property path to set. * @param value - The value to set. * @returns The copied object with the property path set to the given value. */ -// TODO: Either fix this lint violation or explain why it's necessary to ignore. -// eslint-disable-next-line @typescript-eslint/naming-convention function setPropertyPath(object: T, pathString: string, value: unknown): T { const copy = cloneDeep(object); const path = pathString.split('.'); @@ -89,6 +88,7 @@ function setPropertyPath(object: T, pathString: string, value: unknown): T { /** * Expect a validation error to be thrown. + * * @param validateFunction - The validation function to call. * @param input - The input to validate. * @param propertyName - The property name to set. @@ -97,8 +97,6 @@ function setPropertyPath(object: T, pathString: string, value: unknown): T { * @param expectedInternalError - The specific validation error. * @param rootPropertyName - The name of the root input. */ -// TODO: Either fix this lint violation or explain why it's necessary to ignore. -// eslint-disable-next-line @typescript-eslint/naming-convention function expectValidationError( validateFunction: (request: T) => void, input: T, diff --git a/packages/user-operation-controller/src/utils/validation.ts b/packages/user-operation-controller/src/utils/validation.ts index 88a8ac5dd14..3e06d4b500f 100644 --- a/packages/user-operation-controller/src/utils/validation.ts +++ b/packages/user-operation-controller/src/utils/validation.ts @@ -27,6 +27,7 @@ import type { /** * Validate a request to add a user operation. + * * @param request - The request to validate. */ export function validateAddUserOperationRequest( @@ -49,6 +50,7 @@ export function validateAddUserOperationRequest( /** * Validate the options when adding a user operation. + * * @param options - The options to validate. */ export function validateAddUserOperationOptions( @@ -90,6 +92,7 @@ export function validateAddUserOperationOptions( /** * Validate the response from a smart contract account when preparing the user operation. + * * @param response - The response to validate. */ export function validatePrepareUserOperationResponse( @@ -135,6 +138,7 @@ export function validatePrepareUserOperationResponse( /** * Validate the response from a smart contract account when updating the user operation. + * * @param response - The response to validate. */ export function validateUpdateUserOperationResponse( @@ -158,6 +162,7 @@ export function validateUpdateUserOperationResponse( /** * Validate the response from a smart contract account when signing the user operation. + * * @param response - The response to validate. */ export function validateSignUserOperationResponse( @@ -178,12 +183,11 @@ export function validateSignUserOperationResponse( /** * Validate data against a struct. + * * @param data - The data to validate. * @param struct - The struct to validate against. * @param message - The message to throw if validation fails. */ -// TODO: Either fix this lint violation or explain why it's necessary to ignore. -// eslint-disable-next-line @typescript-eslint/naming-convention function validate(data: unknown, struct: Struct, message: string) { try { assert(data, struct, message); @@ -207,6 +211,7 @@ function validate(data: unknown, struct: Struct, message: string) { /** * Define the Hex type used by superstruct. + * * @returns The Hex superstruct type. */ function defineHex() { @@ -217,6 +222,7 @@ function defineHex() { /** * Define the HexOrEmptyBytes type used by superstruct. + * * @returns The HexOrEmptyBytes superstruct type. */ function defineHexOrEmptyBytes() { diff --git a/scripts/create-package/cli.test.ts b/scripts/create-package/cli.test.ts index f366586fc08..612bedaf942 100644 --- a/scripts/create-package/cli.test.ts +++ b/scripts/create-package/cli.test.ts @@ -25,8 +25,6 @@ function getMockArgv(...args: string[]) { */ function getParsedArgv(name: string, description: string) { return { - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention _: [], $0: 'create-package', name: `@metamask/${name}`, diff --git a/scripts/create-package/commands.test.ts b/scripts/create-package/commands.test.ts index e557dd51506..cb6889d834c 100644 --- a/scripts/create-package/commands.test.ts +++ b/scripts/create-package/commands.test.ts @@ -26,8 +26,6 @@ describe('create-package/commands', () => { }); const args: Arguments = { - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/naming-convention _: [], $0: 'create-package', name: '@metamask/new-package', diff --git a/scripts/create-package/utils.ts b/scripts/create-package/utils.ts index 935342ec2aa..8ea5355fcac 100644 --- a/scripts/create-package/utils.ts +++ b/scripts/create-package/utils.ts @@ -22,10 +22,9 @@ const allPlaceholdersRegex = new RegExp( // Our lint config really hates this, but it works. // eslint-disable-next-line -const prettierRc = require(path.join( - REPO_ROOT, - '.prettierrc.js', -)) as PrettierOptions; +const prettierRc = require( + path.join(REPO_ROOT, '.prettierrc.js'), +) as PrettierOptions; /** * The data necessary to create a new package. diff --git a/tests/fake-block-tracker.ts b/tests/fake-block-tracker.ts index 76b29df8af0..1c42fd84ecb 100644 --- a/tests/fake-block-tracker.ts +++ b/tests/fake-block-tracker.ts @@ -20,7 +20,7 @@ export class FakeBlockTracker< }); // Don't start the polling loop // TODO: Replace `any` with type - // eslint-disable-next-line @typescript-eslint/no-empty-function, @typescript-eslint/no-explicit-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any (this as any).start = () => {}; } diff --git a/tests/fake-provider.ts b/tests/fake-provider.ts index 6122dbe681b..f46b314b03a 100644 --- a/tests/fake-provider.ts +++ b/tests/fake-provider.ts @@ -124,9 +124,9 @@ export class FakeProvider { calledStubs: FakeProviderStub[]; - #originalStubs: FakeProviderStub[]; + readonly #originalStubs: FakeProviderStub[]; - #stubs: FakeProviderStub[]; + readonly #stubs: FakeProviderStub[]; /** * Makes a new instance of the fake provider. diff --git a/tests/mock-network.ts b/tests/mock-network.ts index 85984f67173..2b22eeba945 100644 --- a/tests/mock-network.ts +++ b/tests/mock-network.ts @@ -82,11 +82,11 @@ function getErrorMessage(error: unknown): string { * JSON-RPC requests that are sent to a network. */ class MockedNetwork { - #networkClientConfiguration: NetworkClientConfiguration; + readonly #networkClientConfiguration: NetworkClientConfiguration; - #requestMocks: JsonRpcRequestMock[]; + readonly #requestMocks: JsonRpcRequestMock[]; - #nockScope: nock.Scope; + readonly #nockScope: nock.Scope; readonly #rpcUrl: string; @@ -110,9 +110,7 @@ class MockedNetwork { this.#requestMocks = mocks; const rpcUrl = networkClientConfiguration.type === 'infura' - ? // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions - `https://${networkClientConfiguration.network}.infura.io` + ? `https://${networkClientConfiguration.network}.infura.io` : networkClientConfiguration.rpcUrl; this.#nockScope = nock(rpcUrl); this.#rpcUrl = rpcUrl; diff --git a/tests/setupAfterEnv/matchers.ts b/tests/setupAfterEnv/matchers.ts index 8acf1206dd5..e51a630c460 100644 --- a/tests/setupAfterEnv/matchers.ts +++ b/tests/setupAfterEnv/matchers.ts @@ -51,8 +51,6 @@ expect.extend({ if (rejectionValue !== UNRESOLVED) { return { message: () => - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - // eslint-disable-next-line @typescript-eslint/restrict-template-expressions `Expected promise to be fulfilled, but it was rejected with ${rejectionValue}.`, pass: false, }; @@ -110,12 +108,9 @@ expect.extend({ : { message: () => { return `Expected promise to never resolve after ${TIME_TO_WAIT_UNTIL_UNRESOLVED}ms, but it ${ - // TODO: Either fix this lint violation or explain why it's necessary to ignore. - /* eslint-disable @typescript-eslint/restrict-template-expressions */ rejectionValue ? `was rejected with ${rejectionValue}` : `resolved with ${resolutionValue}` - /* eslint-enable @typescript-eslint/restrict-template-expressions */ }`; }, pass: false,