Skip to content

Commit f37d85e

Browse files
chore(all): disable promise/avoid-new eslint rule (#1062)
1 parent bb582f4 commit f37d85e

File tree

13 files changed

+16
-28
lines changed

13 files changed

+16
-28
lines changed

.eslintrc.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,10 @@ module.exports = {
3030
'no-invalid-this': 0,
3131
'react/prop-types': 'off',
3232
'max-len': 'off', // prettier is already handling this automatically,
33-
// note: prod webpack config strips console logs anyway, nevertheless
34-
// we don't want the dev build to be spammed by needless logging
3533
'@typescript-eslint/no-explicit-any': ['error'],
3634
'no-console': ['error', { allow: ['warn', 'error', 'info', 'debug'] }],
37-
'lodash/import-scope': ['error', 'method']
35+
'lodash/import-scope': ['error', 'method'],
36+
'promise/avoid-new': 'off',
3837
},
3938
overrides: [
4039
{

apps/browser-extension-wallet/src/features/dapp/components/Connect.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ const NonSSLBanner = () => {
6767
const authorize = (authorization: 'deny' | 'just-once' | 'allow', url: string) => {
6868
const api$ = of({
6969
allowOrigin(origin: cip30.Origin): Promise<'deny' | 'just-once' | 'allow'> {
70-
/* eslint-disable-next-line promise/avoid-new */
7170
if (!url.startsWith(origin)) {
7271
return Promise.reject();
7372
}

apps/browser-extension-wallet/src/hooks/__tests__/useBuildDelegation.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ jest.mock('../../stores', () => ({
4949
})
5050
}));
5151

52-
// eslint-disable-next-line promise/avoid-new
5352
const flushPromises = () => new Promise(setImmediate);
5453

5554
describe('Testing useBuildDelegation hook', () => {

apps/browser-extension-wallet/src/lib/scripts/background/util.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ export const launchCip30Popup = async (url: string, windowType: Windows.CreateTy
8686
};
8787

8888
const waitForTabLoad = (tab: Tabs.Tab) =>
89-
// eslint-disable-next-line promise/avoid-new
9089
new Promise<void>((resolve) => {
9190
const listener = (tabId: number, changeInfo: Tabs.OnUpdatedChangeInfoType) => {
9291
// make sure the status is 'complete' and it's the right tab

apps/browser-extension-wallet/src/utils/__tests__/createQueue.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/* eslint-disable @typescript-eslint/no-explicit-any */
2-
/* eslint-disable promise/avoid-new */
32
import { createQueue, TaskQueue } from '../taskQueue';
43

54
describe('createQueue', () => {
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
const DEFAULT_TIMEOUT = 1000;
22

33
export const fakeApiRequest = <TResponse>(response: TResponse, timeout = DEFAULT_TIMEOUT): Promise<TResponse> =>
4-
// eslint-disable-next-line promise/avoid-new
54
new Promise<TResponse>((resolve) => {
65
setTimeout(() => resolve(response), timeout);
76
});

apps/browser-extension-wallet/src/utils/taskQueue.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ export const createQueue = (batchTasks: number, intervalBetweenBatch: number): T
3737
if (sent >= batchTasks) {
3838
// Reset the sent count
3939
sent = 0;
40-
// eslint-disable-next-line promise/avoid-new
4140
await new Promise((resolve) => setTimeout(resolve, intervalBetweenBatch));
4241
}
4342
execute();

packages/cardano/src/wallet/lib/__tests__/get-block-info-by-hash.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/* eslint-disable no-magic-numbers */
22
/* eslint-disable @typescript-eslint/no-explicit-any */
33
/* eslint-disable @typescript-eslint/no-unused-vars */
4-
/* eslint-disable promise/avoid-new */
54
import '@testing-library/jest-dom';
65
import { getBlockInfoByHash } from '../get-block-info-by-hash';
76
import { stakepoolSearchProviderStub, mockedStakePools } from '../../test/mocks/StakepoolSearchProviderStub';

packages/cardano/src/wallet/lib/__tests__/get-inputs-value.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/* eslint-disable no-magic-numbers */
22
/* eslint-disable @typescript-eslint/no-explicit-any */
33
/* eslint-disable @typescript-eslint/no-unused-vars */
4-
/* eslint-disable promise/avoid-new */
54
/* eslint-disable max-len */
65
/* eslint-disable sonarjs/no-identical-functions */
76
import '@testing-library/jest-dom';

packages/cardano/src/wallet/test/mocks/AssetsProviderStub.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,13 @@ export const mockedAssets: Asset.AssetInfo[] = [
2222
];
2323

2424
export const assetsProviderStub = (assets: Asset.AssetInfo[] = mockedAssets): AssetProvider => ({
25-
getAsset: jest.fn().mockImplementation(
26-
({ assetId }) =>
27-
// eslint-disable-next-line promise/avoid-new
28-
new Promise((resolve) => resolve(assets.find((asset) => asset.assetId === assetId) || assets[0]))
29-
),
30-
getAssets: jest.fn().mockImplementation(
31-
({ assetIds }) =>
32-
// eslint-disable-next-line promise/avoid-new
33-
new Promise((resolve) => resolve(assets.filter((asset) => assetIds.includes(asset.assetId)) || assets[0]))
34-
),
25+
getAsset: jest
26+
.fn()
27+
.mockImplementation(async ({ assetId }) => assets.find((asset) => asset.assetId === assetId) || assets[0]),
28+
getAssets: jest
29+
.fn()
30+
.mockImplementation(
31+
async ({ assetIds }) => assets.filter((asset) => assetIds.includes(asset.assetId)) || assets[0]
32+
),
3533
healthCheck: jest.fn().mockResolvedValue({ ok: true })
3634
});

0 commit comments

Comments
 (0)