Bump dev (w/ eslint config updates) (#9472)

This commit is contained in:
Jaco 2023-05-21 09:04:36 +03:00 committed by GitHub
parent a93388466b
commit e0e2605564
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
70 changed files with 327 additions and 184 deletions

View File

@ -1,28 +0,0 @@
// Copyright 2017-2023 @polkadot/apps authors & contributors
// SPDX-License-Identifier: Apache-2.0
const base = require('@polkadot/dev/config/eslint.cjs');
// add override for any (a metric ton of them, initial conversion)
module.exports = {
...base,
ignorePatterns: [
...base.ignorePatterns,
'jest/**/*',
'scripts/**/*',
'*.cjs'
],
parserOptions: {
...base.parserOptions,
project: [
'./tsconfig.eslint.json'
]
},
rules: {
...base.rules,
// needs to be switched on at some point
'@typescript-eslint/no-explicit-any': 'off',
// this seems very broken atm, false positives
'@typescript-eslint/unbound-method': 'off'
}
};

4
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,4 @@
{
"eslint.enable": true,
"eslint.experimental.useFlatConfig": true
}

16
eslint.config.js Normal file
View File

@ -0,0 +1,16 @@
// Copyright 2017-2023 @polkadot/dev authors & contributors
// SPDX-License-Identifier: Apache-2.0
import baseConfig from '@polkadot/dev/config/eslint';
export default [
...baseConfig,
{
rules: {
// add override for any (a metric ton of them, initial conversion)
'@typescript-eslint/no-explicit-any': 'off',
// we generally use this in isFunction, not via calling
'@typescript-eslint/unbound-method': 'off'
}
}
];

View File

@ -15,6 +15,7 @@
"url": "https://github.com/polkadot-js/apps.git" "url": "https://github.com/polkadot-js/apps.git"
}, },
"sideEffects": false, "sideEffects": false,
"type": "module",
"version": "0.130.2-15-x", "version": "0.130.2-15-x",
"versions": { "versions": {
"git": "0.130.2-15-x", "git": "0.130.2-15-x",
@ -68,7 +69,7 @@
"devDependencies": { "devDependencies": {
"@crustio/crust-pin": "^1.0.0", "@crustio/crust-pin": "^1.0.0",
"@pinata/sdk": "^1.2.1", "@pinata/sdk": "^1.2.1",
"@polkadot/dev": "^0.74.1", "@polkadot/dev": "^0.75.2",
"@types/chart.js": "^2.9.37", "@types/chart.js": "^2.9.37",
"@types/file-saver": "^2.0.5", "@types/file-saver": "^2.0.5",
"@types/react-beautiful-dnd": "^13.1.4", "@types/react-beautiful-dnd": "^13.1.4",

View File

@ -37,6 +37,7 @@ export const typesBundle = ${JSON.stringify(typesBundle, null, 2)} as unknown as
describe('specs', (): void => { describe('specs', (): void => {
for (const [k, v] of specEntries) { for (const [k, v] of specEntries) {
// eslint-disable-next-line jest/expect-expect
it(`adds ${k}`, (): void => { it(`adds ${k}`, (): void => {
const value = objectSpread<{ derives: unknown }>({}, v); const value = objectSpread<{ derives: unknown }>({}, v);
@ -49,6 +50,7 @@ export const typesBundle = ${JSON.stringify(typesBundle, null, 2)} as unknown as
describe('chains', (): void => { describe('chains', (): void => {
for (const [k, v] of chainEntries) { for (const [k, v] of chainEntries) {
// eslint-disable-next-line jest/expect-expect
it(`adds ${k}`, (): void => { it(`adds ${k}`, (): void => {
const value = objectSpread<{ derives: unknown }>({}, v); const value = objectSpread<{ derives: unknown }>({}, v);

View File

@ -93,7 +93,7 @@ describe('urls are not duplicated', (): void => {
}, {} as Record<string, string[]>); }, {} as Record<string, string[]>);
for (const [url, paths] of Object.entries<string[]>(map)) { for (const [url, paths] of Object.entries<string[]>(map)) {
it(url, (): void => { it(`${url}`, (): void => {
assert(paths.length === 1, `${url} appears multiple times - ${paths.map((p) => `\n\t"${p}"`).join('')}`); assert(paths.length === 1, `${url} appears multiple times - ${paths.map((p) => `\n\t"${p}"`).join('')}`);
}); });
} }
@ -118,7 +118,7 @@ describe('endpopints naming', (): void => {
}), {}); }), {});
for (const [key, { name, provider }] of Object.entries<Endpoint>(endpoints)) { for (const [key, { name, provider }] of Object.entries<Endpoint>(endpoints)) {
describe(key, (): void => { describe(`${key}`, (): void => {
it(`[${key}] has no emojis`, (): void => { it(`[${key}] has no emojis`, (): void => {
assert(!emoji.test(name), `${name} should not contain any emojis`); assert(!emoji.test(name), `${name} should not contain any emojis`);
assert(!emoji.test(provider), `${name}:: ${provider} should not contain any emojis`); assert(!emoji.test(provider), `${name}:: ${provider} should not contain any emojis`);

View File

@ -1,6 +1,7 @@
// Copyright 2017-2023 @polkadot/apps-config authors & contributors // Copyright 2017-2023 @polkadot/apps-config authors & contributors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import type React from 'react';
import type { Option } from '../settings/types.js'; import type { Option } from '../settings/types.js';
interface BaseOption { interface BaseOption {

View File

@ -1,6 +1,8 @@
// Copyright 2017-2023 @polkadot/apps-config authors & contributors // Copyright 2017-2023 @polkadot/apps-config authors & contributors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import type React from 'react';
export interface Option { export interface Option {
info?: string; info?: string;
isDisabled?: boolean; isDisabled?: boolean;

View File

@ -15,7 +15,7 @@
"sideEffects": false, "sideEffects": false,
"version": "0.130.2-15-x", "version": "0.130.2-15-x",
"dependencies": { "dependencies": {
"@polkadot/dev": "^0.74.1", "@polkadot/dev": "^0.75.2",
"@polkadot/react-components": "^0.130.2-15-x", "@polkadot/react-components": "^0.130.2-15-x",
"electron-log": "^5.0.0-beta.23", "electron-log": "^5.0.0-beta.23",
"electron-updater": "^5.3.0", "electron-updater": "^5.3.0",

View File

@ -39,8 +39,8 @@ describe('Remote Electron Store', () => {
remoteStore.all(cb); remoteStore.all(cb);
await Promise.resolve(); await Promise.resolve();
expect(cb).nthCalledWith(1, 1, 'a'); expect(cb).toHaveBeenNthCalledWith(1, 1, 'a');
expect(cb).nthCalledWith(2, 2, 'b'); expect(cb).toHaveBeenNthCalledWith(2, 2, 'b');
}); });
}); });
@ -52,8 +52,8 @@ describe('Remote Electron Store', () => {
remoteStore.get('1', cb); remoteStore.get('1', cb);
await Promise.resolve(); await Promise.resolve();
expect(accountStore.get).toBeCalledWith('1'); expect(accountStore.get).toHaveBeenCalledWith('1');
expect(cb).toBeCalledWith('a'); expect(cb).toHaveBeenCalledWith('a');
}); });
it('calls callback with null if no accounts found', async () => { it('calls callback with null if no accounts found', async () => {
@ -63,7 +63,7 @@ describe('Remote Electron Store', () => {
remoteStore.get('1', cb); remoteStore.get('1', cb);
await Promise.resolve(); await Promise.resolve();
expect(cb).toBeCalledWith(null); expect(cb).toHaveBeenCalledWith(null);
}); });
}); });
@ -75,8 +75,8 @@ describe('Remote Electron Store', () => {
remoteStore.remove('1', cb); remoteStore.remove('1', cb);
await Promise.resolve(); await Promise.resolve();
expect(accountStore.remove).toBeCalledWith('1'); expect(accountStore.remove).toHaveBeenCalledWith('1');
expect(cb).toBeCalledTimes(1); expect(cb).toHaveBeenCalledTimes(1);
}); });
}); });
@ -88,8 +88,8 @@ describe('Remote Electron Store', () => {
remoteStore.set('1', 'a' as unknown as KeyringJson, cb); remoteStore.set('1', 'a' as unknown as KeyringJson, cb);
await Promise.resolve(); await Promise.resolve();
expect(accountStore.set).toBeCalledWith('1', 'a'); expect(accountStore.set).toHaveBeenCalledWith('1', 'a');
expect(cb).toBeCalledTimes(1); expect(cb).toHaveBeenCalledTimes(1);
}); });
}); });
}); });

View File

@ -2,6 +2,7 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import type { IconName } from '@fortawesome/fontawesome-svg-core'; import type { IconName } from '@fortawesome/fontawesome-svg-core';
import type React from 'react';
import type { ApiPromise } from '@polkadot/api'; import type { ApiPromise } from '@polkadot/api';
import type { AppProps, BareProps } from '@polkadot/react-components/types'; import type { AppProps, BareProps } from '@polkadot/react-components/types';

View File

@ -18,7 +18,7 @@
"dependencies": { "dependencies": {
"@polkadot/apps-config": "^0.130.2-15-x", "@polkadot/apps-config": "^0.130.2-15-x",
"@polkadot/apps-routing": "^0.130.2-15-x", "@polkadot/apps-routing": "^0.130.2-15-x",
"@polkadot/dev": "^0.74.1", "@polkadot/dev": "^0.75.2",
"@polkadot/react-api": "^0.130.2-15-x", "@polkadot/react-api": "^0.130.2-15-x",
"@polkadot/react-components": "^0.130.2-15-x", "@polkadot/react-components": "^0.130.2-15-x",
"@polkadot/react-hooks": "^0.130.2-15-x", "@polkadot/react-hooks": "^0.130.2-15-x",

View File

@ -12,7 +12,6 @@ const webpack = require('webpack');
const findPackages = require('../../scripts/findPackages.cjs'); const findPackages = require('../../scripts/findPackages.cjs');
function createWebpack (context, mode = 'production') { function createWebpack (context, mode = 'production') {
const pkgJson = require(path.join(context, 'package.json'));
const alias = findPackages().reduce((alias, { dir, name }) => { const alias = findPackages().reduce((alias, { dir, name }) => {
alias[name] = path.resolve(context, `../${dir}/src`); alias[name] = path.resolve(context, `../${dir}/src`);
@ -38,7 +37,7 @@ function createWebpack (context, mode = 'production') {
rules: [ rules: [
{ {
scheme: 'data', scheme: 'data',
type: 'asset/resource', type: 'asset/resource'
}, },
{ {
include: /node_modules/, include: /node_modules/,

View File

@ -25,6 +25,7 @@ import { BN } from '@polkadot/util';
import { AccountsPage } from '../../test/pages/accountsPage.js'; import { AccountsPage } from '../../test/pages/accountsPage.js';
// FIXME isSplit Table // FIXME isSplit Table
// eslint-disable-next-line jest/no-disabled-tests
describe.skip('Accounts page', () => { describe.skip('Accounts page', () => {
let accountsPage: AccountsPage; let accountsPage: AccountsPage;
@ -46,6 +47,7 @@ describe.skip('Accounts page', () => {
accountsPage.render([]); accountsPage.render([]);
}); });
// eslint-disable-next-line jest/expect-expect
it('shows sort-by controls', async () => { it('shows sort-by controls', async () => {
await accountsPage.reverseSortingOrder(); await accountsPage.reverseSortingOrder();
}); });
@ -62,6 +64,7 @@ describe.skip('Accounts page', () => {
expect(accountRows).toHaveLength(0); expect(accountRows).toHaveLength(0);
}); });
// eslint-disable-next-line jest/expect-expect
it('the accounts table contains a message about no accounts available', async () => { it('the accounts table contains a message about no accounts available', async () => {
const noAccountsMessage = 'You don\'t have any accounts. Some features are currently hidden and will only become available once you have accounts.'; const noAccountsMessage = 'You don\'t have any accounts. Some features are currently hidden and will only become available once you have accounts.';
const accountsTable = await accountsPage.getTable(); const accountsTable = await accountsPage.getTable();
@ -84,6 +87,7 @@ describe.skip('Accounts page', () => {
expect(accountRows).toHaveLength(2); expect(accountRows).toHaveLength(2);
}); });
// eslint-disable-next-line jest/expect-expect
it('account rows display the total balance info', async () => { it('account rows display the total balance info', async () => {
accountsPage.renderAccountsWithDefaultAddresses( accountsPage.renderAccountsWithDefaultAddresses(
anAccountWithBalance({ freeBalance: balance(500) }), anAccountWithBalance({ freeBalance: balance(500) }),
@ -96,6 +100,7 @@ describe.skip('Accounts page', () => {
await rows[1].assertBalancesTotal(balance(350)); await rows[1].assertBalancesTotal(balance(350));
}); });
// eslint-disable-next-line jest/expect-expect
it('account rows display the details balance info', async () => { it('account rows display the details balance info', async () => {
accountsPage.renderAccountsWithDefaultAddresses( accountsPage.renderAccountsWithDefaultAddresses(
anAccountWithBalance({ freeBalance: balance(500), lockedBalance: balance(30) }), anAccountWithBalance({ freeBalance: balance(500), lockedBalance: balance(30) }),
@ -113,6 +118,7 @@ describe.skip('Accounts page', () => {
}); });
// FIXME multiple tables // FIXME multiple tables
// eslint-disable-next-line jest/no-disabled-tests
it.skip('derived account displays parent account info', async () => { it.skip('derived account displays parent account info', async () => {
accountsPage.renderAccountsWithDefaultAddresses( accountsPage.renderAccountsWithDefaultAddresses(
anAccountWithMeta({ isInjected: true, name: 'ALICE', whenCreated: 200 }), anAccountWithMeta({ isInjected: true, name: 'ALICE', whenCreated: 200 }),
@ -126,6 +132,7 @@ describe.skip('Accounts page', () => {
}); });
// FIXME broken after column rework // FIXME broken after column rework
// eslint-disable-next-line jest/no-disabled-tests, jest/expect-expect
it.skip('a separate column for parent account is not displayed', async () => { it.skip('a separate column for parent account is not displayed', async () => {
accountsPage.renderDefaultAccounts(1); accountsPage.renderDefaultAccounts(1);
const accountsTable = await accountsPage.getTable(); const accountsTable = await accountsPage.getTable();
@ -146,6 +153,7 @@ describe.skip('Accounts page', () => {
await accountRows[0].assertShortAddress(aliceShortAddress); await accountRows[0].assertShortAddress(aliceShortAddress);
}); });
// eslint-disable-next-line jest/expect-expect
it('when account is not tagged, account row details displays none info', async () => { it('when account is not tagged, account row details displays none info', async () => {
accountsPage.renderDefaultAccounts(1); accountsPage.renderDefaultAccounts(1);
const rows = await accountsPage.getAccountRows(); const rows = await accountsPage.getAccountRows();
@ -153,6 +161,7 @@ describe.skip('Accounts page', () => {
await rows[0].assertTags('none'); await rows[0].assertTags('none');
}); });
// eslint-disable-next-line jest/expect-expect
it('when account is tagged, account row details displays tags', async () => { it('when account is tagged, account row details displays tags', async () => {
accountsPage.renderAccountsWithDefaultAddresses( accountsPage.renderAccountsWithDefaultAddresses(
anAccountWithInfo({ tags: ['my tag', 'Super Tag'] }) anAccountWithInfo({ tags: ['my tag', 'Super Tag'] })
@ -295,6 +304,7 @@ describe.skip('Accounts page', () => {
}); });
// FIXME multiple tables now // FIXME multiple tables now
// eslint-disable-next-line jest/no-disabled-tests
describe.skip('when sorting is used', () => { describe.skip('when sorting is used', () => {
let accountsTable: Table; let accountsTable: Table;
@ -320,26 +330,31 @@ describe.skip('Accounts page', () => {
.toHaveTextContent('balances'); .toHaveTextContent('balances');
}); });
// eslint-disable-next-line jest/expect-expect
it('sorts by parent if asked', async () => { it('sorts by parent if asked', async () => {
await accountsPage.sortBy('parent'); await accountsPage.sortBy('parent');
await accountsTable.assertRowsOrder([3, 1, 2]); await accountsTable.assertRowsOrder([3, 1, 2]);
}); });
// eslint-disable-next-line jest/expect-expect
it('sorts by name if asked', async () => { it('sorts by name if asked', async () => {
await accountsPage.sortBy('name'); await accountsPage.sortBy('name');
await accountsTable.assertRowsOrder([3, 2, 1]); await accountsTable.assertRowsOrder([3, 2, 1]);
}); });
// eslint-disable-next-line jest/expect-expect
it('sorts by date if asked', async () => { it('sorts by date if asked', async () => {
await accountsPage.sortBy('date'); await accountsPage.sortBy('date');
await accountsTable.assertRowsOrder([3, 1, 2]); await accountsTable.assertRowsOrder([3, 1, 2]);
}); });
// eslint-disable-next-line jest/expect-expect
it('sorts by balances if asked', async () => { it('sorts by balances if asked', async () => {
await accountsPage.sortBy('balances'); await accountsPage.sortBy('balances');
await accountsTable.assertRowsOrder([1, 2, 3]); await accountsTable.assertRowsOrder([1, 2, 3]);
}); });
// eslint-disable-next-line jest/expect-expect
it('implements stable sort', async () => { it('implements stable sort', async () => {
await accountsPage.sortBy('name'); await accountsPage.sortBy('name');
await accountsTable.assertRowsOrder([3, 2, 1]); await accountsTable.assertRowsOrder([3, 2, 1]);
@ -347,6 +362,7 @@ describe.skip('Accounts page', () => {
await accountsTable.assertRowsOrder([1, 2, 3]); await accountsTable.assertRowsOrder([1, 2, 3]);
}); });
// eslint-disable-next-line jest/expect-expect
it('respects reverse button', async () => { it('respects reverse button', async () => {
await accountsPage.sortBy('name'); await accountsPage.sortBy('name');
await accountsTable.assertRowsOrder([3, 2, 1]); await accountsTable.assertRowsOrder([3, 2, 1]);
@ -394,14 +410,17 @@ describe.skip('Accounts page', () => {
await aliceRow.assertAccountName('ALICE'); await aliceRow.assertAccountName('ALICE');
}); });
// eslint-disable-next-line jest/expect-expect
it('the development badge is displayed', async () => { it('the development badge is displayed', async () => {
await aliceRow.assertBadge('wrench-badge'); await aliceRow.assertBadge('wrench-badge');
}); });
// eslint-disable-next-line jest/expect-expect
it('the all networks badge is not displayed', () => { it('the all networks badge is not displayed', () => {
aliceRow.assertNoBadge('exclamation-triangle-badge'); aliceRow.assertNoBadge('exclamation-triangle-badge');
}); });
// eslint-disable-next-line jest/expect-expect
it('the regular badge is not displayed', () => { it('the regular badge is not displayed', () => {
aliceRow.assertNoBadge('transparent-badge'); aliceRow.assertNoBadge('transparent-badge');
}); });
@ -415,14 +434,17 @@ describe.skip('Accounts page', () => {
await bobRow.assertAccountName('BOB'); await bobRow.assertAccountName('BOB');
}); });
// eslint-disable-next-line jest/expect-expect
it('the development badge is not displayed', () => { it('the development badge is not displayed', () => {
bobRow.assertNoBadge('wrench-badge'); bobRow.assertNoBadge('wrench-badge');
}); });
// eslint-disable-next-line jest/expect-expect
it('the all networks badge is displayed', async () => { it('the all networks badge is displayed', async () => {
await bobRow.assertBadge('exclamation-triangle-badge'); await bobRow.assertBadge('exclamation-triangle-badge');
}); });
// eslint-disable-next-line jest/expect-expect
it('the regular badge is not displayed', () => { it('the regular badge is not displayed', () => {
bobRow.assertNoBadge('transparent-badge'); bobRow.assertNoBadge('transparent-badge');
}); });
@ -437,14 +459,17 @@ describe.skip('Accounts page', () => {
accountRows = await accountsPage.getAccountRows(); accountRows = await accountsPage.getAccountRows();
}); });
// eslint-disable-next-line jest/expect-expect
it('the development badge is not displayed', () => { it('the development badge is not displayed', () => {
accountRows[0].assertNoBadge('wrench-badge'); accountRows[0].assertNoBadge('wrench-badge');
}); });
// eslint-disable-next-line jest/expect-expect
it('the all networks badge is not displayed', () => { it('the all networks badge is not displayed', () => {
accountRows[0].assertNoBadge('exclamation-triangle-badge'); accountRows[0].assertNoBadge('exclamation-triangle-badge');
}); });
// eslint-disable-next-line jest/expect-expect
it('the regular badge is displayed', async () => { it('the regular badge is displayed', async () => {
await accountRows[0].assertBadge('badge'); await accountRows[0].assertBadge('badge');
}); });
@ -458,6 +483,7 @@ describe.skip('Accounts page', () => {
accountRows = await accountsPage.getAccountRows(); accountRows = await accountsPage.getAccountRows();
}); });
// eslint-disable-next-line jest/expect-expect
it('development', async () => { it('development', async () => {
await accountRows[0].assertBadge('wrench-badge'); await accountRows[0].assertBadge('wrench-badge');
const badgePopup = getPopupById(/wrench-badge-hover.*/); const badgePopup = getPopupById(/wrench-badge-hover.*/);
@ -510,7 +536,7 @@ describe.skip('Accounts page', () => {
const badgePopup = accountsPage.getById(popupId); const badgePopup = accountsPage.getById(popupId);
if (!badgePopup) { if (!badgePopup) {
fail('badge popup should be found'); throw new Error('badge popup should be found');
} }
return badgePopup; return badgePopup;

View File

@ -46,6 +46,7 @@ const renderAccounts = () => {
); );
}; };
// eslint-disable-next-line jest/no-disabled-tests
describe.skip('--SLOW--: Account Create', () => { describe.skip('--SLOW--: Account Create', () => {
it('created account is added to list', async () => { it('created account is added to list', async () => {
const { findByTestId, findByText, queryByText } = renderAccounts(); const { findByTestId, findByText, queryByText } = renderAccounts();

View File

@ -24,7 +24,7 @@ interface Props {
onStatusChange: (status: ActionStatus) => void; onStatusChange: (status: ActionStatus) => void;
} }
interface Match { interface MatchState {
isMatchValid: boolean; isMatchValid: boolean;
match: string; match: string;
} }
@ -59,7 +59,7 @@ function VanityApp ({ className = '', onStatusChange }: Props): React.ReactEleme
matches: [], matches: [],
startAt: 0 startAt: 0
}); });
const [{ isMatchValid, match }, setMatch] = useState<Match>({ isMatchValid: true, match: DEFAULT_MATCH }); const [{ isMatchValid, match }, setMatch] = useState<MatchState>({ isMatchValid: true, match: DEFAULT_MATCH });
const [type, setType] = useState<KeypairType>('ed25519'); const [type, setType] = useState<KeypairType>('ed25519');
const [withCase, setWithCase] = useState(true); const [withCase, setWithCase] = useState(true);

View File

@ -33,6 +33,7 @@ describe('Create an account modal', () => {
accountsPage = new AccountsPage(); accountsPage = new AccountsPage();
}); });
// eslint-disable-next-line jest/expect-expect
it('creates an account', async () => { it('creates an account', async () => {
await accountsPage.enterCreateAccountModal(); await accountsPage.enterCreateAccountModal();
@ -52,6 +53,7 @@ describe('Create an account modal', () => {
expectCreateAnAccountCall(); expectCreateAnAccountCall();
}); });
// eslint-disable-next-line jest/expect-expect
it('navigates through the modal flow with enter key', async () => { it('navigates through the modal flow with enter key', async () => {
await accountsPage.enterCreateAccountModal(); await accountsPage.enterCreateAccountModal();
@ -72,6 +74,7 @@ describe('Create an account modal', () => {
expectCreateAnAccountCall(); expectCreateAnAccountCall();
}); });
// eslint-disable-next-line jest/expect-expect
it('gives an error message when entering invalid derivation path', async () => { it('gives an error message when entering invalid derivation path', async () => {
await accountsPage.enterCreateAccountModal(); await accountsPage.enterCreateAccountModal();
@ -105,7 +108,7 @@ function pressEnterKey () {
} }
function expectCreateAnAccountCall () { function expectCreateAnAccountCall () {
expect(spy).toBeCalledWith( expect(spy).toHaveBeenCalledWith(
expect.anything(), expect.anything(),
newAccountPassword, newAccountPassword,
expect.objectContaining({ expect.objectContaining({

View File

@ -16,7 +16,7 @@ import { BN_ZERO } from '@polkadot/util';
import { useTranslation } from '../translate.js'; import { useTranslation } from '../translate.js';
type PrevProxy = [AccountId | null, KitchensinkRuntimeProxyType]; type PrevProxyProp = [AccountId | null, KitchensinkRuntimeProxyType];
interface Props { interface Props {
className?: string; className?: string;
@ -28,7 +28,7 @@ interface Props {
interface ValueProps { interface ValueProps {
index: number; index: number;
typeOpts: { text: string; value: number }[]; typeOpts: { text: string; value: number }[];
value: PrevProxy; value: PrevProxyProp;
} }
interface NewProxyProps extends ValueProps { interface NewProxyProps extends ValueProps {
@ -168,8 +168,8 @@ function ProxyOverview ({ className, onClose, previousProxy: [existing] = EMPTY_
const [batchPrevious, setBatchPrevious] = useState<SubmittableExtrinsic<'promise'>[]>([]); const [batchPrevious, setBatchPrevious] = useState<SubmittableExtrinsic<'promise'>[]>([]);
const [batchAdded, setBatchAdded] = useState<SubmittableExtrinsic<'promise'>[]>([]); const [batchAdded, setBatchAdded] = useState<SubmittableExtrinsic<'promise'>[]>([]);
const [txs, setTxs] = useState<SubmittableExtrinsic<'promise'>[] | null>(null); const [txs, setTxs] = useState<SubmittableExtrinsic<'promise'>[] | null>(null);
const [previous, setPrevious] = useState<PrevProxy[]>(() => existing.map(({ delegate, proxyType }) => [delegate, proxyType])); const [previous, setPrevious] = useState<PrevProxyProp[]>(() => existing.map(({ delegate, proxyType }) => [delegate, proxyType]));
const [added, setAdded] = useState<PrevProxy[]>([]); const [added, setAdded] = useState<PrevProxyProp[]>([]);
const extrinsics = useTxBatch(txs, BATCH_OPTS); const extrinsics = useTxBatch(txs, BATCH_OPTS);
const reservedAmount = useMemo( const reservedAmount = useMemo(

View File

@ -1,6 +1,8 @@
// Copyright 2017-2023 @polkadot/page-accounts authors & contributors // Copyright 2017-2023 @polkadot/page-accounts authors & contributors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
/* global expect */
import { within } from '@testing-library/react'; import { within } from '@testing-library/react';
import { Row } from '@polkadot/test-support/pagesElements'; import { Row } from '@polkadot/test-support/pagesElements';

View File

@ -1,6 +1,8 @@
// Copyright 2017-2023 @polkadot/page-accounts authors & contributors // Copyright 2017-2023 @polkadot/page-accounts authors & contributors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
/* global expect */
import type { Sidebar } from '@polkadot/test-support/pagesElements'; import type { Sidebar } from '@polkadot/test-support/pagesElements';
import type { AccountOverrides } from '@polkadot/test-support/types'; import type { AccountOverrides } from '@polkadot/test-support/types';

View File

@ -16,6 +16,7 @@ import { keyring } from '@polkadot/ui-keyring';
import { AddressesPage } from '../../test/pages/addressesPage.js'; import { AddressesPage } from '../../test/pages/addressesPage.js';
// FIXME isSplit Table // FIXME isSplit Table
// eslint-disable-next-line jest/no-disabled-tests
describe.skip('Addresses page', () => { describe.skip('Addresses page', () => {
let addressesPage: AddressesPage; let addressesPage: AddressesPage;
@ -48,6 +49,7 @@ describe.skip('Addresses page', () => {
expect(await addressesTable.getRows()).toHaveLength(0); expect(await addressesTable.getRows()).toHaveLength(0);
}); });
// eslint-disable-next-line jest/expect-expect
it('the contacts table contains a message about no contacts available', async () => { it('the contacts table contains a message about no contacts available', async () => {
const noContactsMessage = 'no addresses saved yet, add any existing address'; const noContactsMessage = 'no addresses saved yet, add any existing address';
@ -70,6 +72,7 @@ describe.skip('Addresses page', () => {
expect(rows).toHaveLength(2); expect(rows).toHaveLength(2);
}); });
// eslint-disable-next-line jest/expect-expect
it('contact rows display the total balance info', async () => { it('contact rows display the total balance info', async () => {
addressesPage.renderContactsWithDefaultAddresses( addressesPage.renderContactsWithDefaultAddresses(
aContactWithBalance({ freeBalance: balance(500) }), aContactWithBalance({ freeBalance: balance(500) }),
@ -82,6 +85,7 @@ describe.skip('Addresses page', () => {
await rows[1].assertBalancesTotal(balance(350)); await rows[1].assertBalancesTotal(balance(350));
}); });
// eslint-disable-next-line jest/expect-expect
it('contact rows display the details balance info', async () => { it('contact rows display the details balance info', async () => {
addressesPage.renderContactsWithDefaultAddresses( addressesPage.renderContactsWithDefaultAddresses(
aContactWithBalance({ freeBalance: balance(500), lockedBalance: balance(30) }), aContactWithBalance({ freeBalance: balance(500), lockedBalance: balance(30) }),
@ -98,6 +102,7 @@ describe.skip('Addresses page', () => {
{ amount: balance(150), name: 'reserved' }]); { amount: balance(150), name: 'reserved' }]);
}); });
// eslint-disable-next-line jest/expect-expect
it('when a contact is not tagged, details row displays no tags info', async () => { it('when a contact is not tagged, details row displays no tags info', async () => {
addressesPage.renderDefaultContacts(1); addressesPage.renderDefaultContacts(1);
const rows = await addressesPage.getAddressesRows(); const rows = await addressesPage.getAddressesRows();

View File

@ -1,6 +1,8 @@
// Copyright 2017-2023 @polkadot/page-addresses authors & contributors // Copyright 2017-2023 @polkadot/page-addresses authors & contributors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
/* global jest */
import type { Row } from '@polkadot/test-support/pagesElements'; import type { Row } from '@polkadot/test-support/pagesElements';
import type { AccountOverrides as ContactOverrides } from '@polkadot/test-support/types'; import type { AccountOverrides as ContactOverrides } from '@polkadot/test-support/types';

View File

@ -18,13 +18,13 @@ import Transfer from './Transfer.js';
// eslint-disable-next-line @typescript-eslint/ban-ts-comment // eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore This looks correct in the editor, but incorrect in composite mode // @ts-ignore This looks correct in the editor, but incorrect in composite mode
interface Account extends PalletAssetsAssetAccount { interface AccountExt extends PalletAssetsAssetAccount {
isFrozen?: bool; isFrozen?: bool;
sufficient?: bool sufficient?: bool
} }
interface Props { interface Props {
account: Account; account: AccountExt;
accountId: string; accountId: string;
assetId: BN; assetId: BN;
className?: string; className?: string;

View File

@ -46,6 +46,7 @@ const renderBounties = () => {
); );
}; };
// eslint-disable-next-line jest/no-disabled-tests
describe.skip('--SLOW--: Bounties', () => { describe.skip('--SLOW--: Bounties', () => {
it('list shows an existing bounty', async () => { it('list shows an existing bounty', async () => {
const api = await createApi(); const api = await createApi();

View File

@ -3,6 +3,8 @@
/// <reference types="@polkadot/dev-test/globals.d.ts" /> /// <reference types="@polkadot/dev-test/globals.d.ts" />
/* eslint-disable jest/expect-expect */
import type { ApiPromise } from '@polkadot/api'; import type { ApiPromise } from '@polkadot/api';
import type { SubmittableExtrinsic } from '@polkadot/api/types'; import type { SubmittableExtrinsic } from '@polkadot/api/types';
import type { DeriveCollectiveProposal } from '@polkadot/api-derive/types'; import type { DeriveCollectiveProposal } from '@polkadot/api-derive/types';
@ -431,7 +433,7 @@ describe('Bounties', () => {
}); });
describe('award beneficiary action modal', () => { describe('award beneficiary action modal', () => {
it('awards the beneficiary ', async () => { it('awards the beneficiary', async () => {
const bounty = aBounty({ status: bountyStatusWith({ curator: alice }) }); const bounty = aBounty({ status: bountyStatusWith({ curator: alice }) });
bountiesPage.renderOne(bounty); bountiesPage.renderOne(bounty);

View File

@ -1,6 +1,8 @@
// Copyright 2017-2023 @polkadot/app-bounties authors & contributors // Copyright 2017-2023 @polkadot/app-bounties authors & contributors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
/* global jest */
import type { SubmittableExtrinsicFunction } from '@polkadot/api/types'; import type { SubmittableExtrinsicFunction } from '@polkadot/api/types';
import type { DeriveBounties } from '@polkadot/api-derive/types'; import type { DeriveBounties } from '@polkadot/api-derive/types';
import type { BountyApi } from '../../src/hooks/index.js'; import type { BountyApi } from '../../src/hooks/index.js';

View File

@ -1,6 +1,8 @@
// Copyright 2017-2023 @polkadot/app-bounties authors & contributors // Copyright 2017-2023 @polkadot/app-bounties authors & contributors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
/* global jest, expect */
import type { RenderResult } from '@testing-library/react'; import type { RenderResult } from '@testing-library/react';
import type { ApiPromise } from '@polkadot/api'; import type { ApiPromise } from '@polkadot/api';
import type { DeriveCollectiveProposal } from '@polkadot/api-derive/types'; import type { DeriveCollectiveProposal } from '@polkadot/api-derive/types';

View File

@ -1,6 +1,7 @@
// Copyright 2017-2023 @polkadot/app-contracts authors & contributors // Copyright 2017-2023 @polkadot/app-contracts authors & contributors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import type React from 'react';
import type { Abi } from '@polkadot/api-contract'; import type { Abi } from '@polkadot/api-contract';
import type { WeightV2 } from '@polkadot/types/interfaces'; import type { WeightV2 } from '@polkadot/types/interfaces';
import type { BN } from '@polkadot/util'; import type { BN } from '@polkadot/util';

View File

@ -104,10 +104,6 @@ describe('curveThreshold', (): void => {
).toEqual('499999999'); ).toEqual('499999999');
}); });
}); });
// describe('Stepped', (): void => {
// });
}); });
describe('curveDelay', (): void => { describe('curveDelay', (): void => {

View File

@ -13,7 +13,7 @@ import { settings } from '@polkadot/ui-settings';
import { useTranslation } from '../translate.js'; import { useTranslation } from '../translate.js';
import StringInput from './StringInput.js'; import StringInput from './StringInput.js';
type Progress = [[number, number, number], Record<string, [number, number, number]>]; type ProgressType = [[number, number, number], Record<string, [number, number, number]>];
type Strings = Record<string, string>; type Strings = Record<string, string>;
type StringsMod = Record<string, Strings>; type StringsMod = Record<string, Strings>;
@ -94,7 +94,7 @@ async function retrieveAll (): Promise<Defaults> {
}; };
} }
function calcProgress (english: StringsMod, language: Strings): Progress { function calcProgress (english: StringsMod, language: Strings): ProgressType {
const breakdown: Record<string, [number, number, number]> = {}; const breakdown: Record<string, [number, number, number]> = {};
let done = 0; let done = 0;
let total = 0; let total = 0;
@ -150,7 +150,7 @@ function Translate ({ className }: Props): React.ReactElement<Props> {
const [withEmpty, toggleWithEmpty] = useToggle(); const [withEmpty, toggleWithEmpty] = useToggle();
const [{ english, keys, modules }, setDefaults] = useState<Defaults>({ english: {}, keys: [], modules: [] }); const [{ english, keys, modules }, setDefaults] = useState<Defaults>({ english: {}, keys: [], modules: [] });
const [lng, setLng] = useState<string>('zh'); const [lng, setLng] = useState<string>('zh');
const [[modProgress, allProgress], setProgress] = useState<Progress>([[0, 0, 0], {}]); const [[modProgress, allProgress], setProgress] = useState<ProgressType>([[0, 0, 0], {}]);
const [record, setRecord] = useState<string>('app-accounts.json'); const [record, setRecord] = useState<string>('app-accounts.json');
const [strings, setStrings] = useState<Strings | null>(null); const [strings, setStrings] = useState<Strings | null>(null);
@ -187,7 +187,7 @@ function Translate ({ className }: Props): React.ReactElement<Props> {
if (hasPrevVal !== !!sanitized) { if (hasPrevVal !== !!sanitized) {
const [progress, breakdown] = calcProgress(english, languageCache[lng]); const [progress, breakdown] = calcProgress(english, languageCache[lng]);
setProgress(([counters]): Progress => { setProgress(([counters]): ProgressType => {
progress[2] = Math.max(0, progress[0] - counters[0]); progress[2] = Math.max(0, progress[0] - counters[0]);
return [progress, breakdown]; return [progress, breakdown];

View File

@ -23,11 +23,11 @@ interface Props {
onSelectTip: (hash: string, isSelected: boolean, value: BN) => void, onSelectTip: (hash: string, isSelected: boolean, value: BN) => void,
} }
type Tip = [string, PalletTipsOpenTip | OpenTipTo225]; type TipType = [string, PalletTipsOpenTip | OpenTipTo225];
const TIP_OPTS = { withParams: true }; const TIP_OPTS = { withParams: true };
function extractTips (tipsWithHashes?: [[string[]], Option<PalletTipsOpenTip>[]], inHashes?: string[] | null): Tip[] | undefined { function extractTips (tipsWithHashes?: [[string[]], Option<PalletTipsOpenTip>[]], inHashes?: string[] | null): TipType[] | undefined {
if (!tipsWithHashes || !inHashes) { if (!tipsWithHashes || !inHashes) {
return undefined; return undefined;
} }

View File

@ -16,9 +16,9 @@ const specDir = path.join(process.cwd(), srcRel);
describe('lightSpecs', (): void => { describe('lightSpecs', (): void => {
for (const [k, specs] of Object.entries(lightSpecs)) { for (const [k, specs] of Object.entries(lightSpecs)) {
describe(k, (): void => { describe(`${k}`, (): void => {
for (const [k, info] of Object.entries(specs)) { for (const [k, info] of Object.entries(specs)) {
it(k, (): void => { it(`${k}`, (): void => {
assert( assert(
fs.existsSync(path.join(specDir, info)), fs.existsSync(path.join(specDir, info)),
`${srcRel}/${info.slice(2)} does not exist` `${srcRel}/${info.slice(2)} does not exist`

View File

@ -1,6 +1,7 @@
// Copyright 2017-2023 @polkadot/react-api authors & contributors // Copyright 2017-2023 @polkadot/react-api authors & contributors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import type React from 'react';
import type { ApiPromise } from '@polkadot/api'; import type { ApiPromise } from '@polkadot/api';
import type { SubmittableExtrinsicFunction } from '@polkadot/api/promise/types'; import type { SubmittableExtrinsicFunction } from '@polkadot/api/promise/types';
import type { LinkOption } from '@polkadot/apps-config/endpoints/types'; import type { LinkOption } from '@polkadot/apps-config/endpoints/types';

View File

@ -1,6 +1,7 @@
// Copyright 2017-2023 @polkadot/react-api authors & contributors // Copyright 2017-2023 @polkadot/react-api authors & contributors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import type React from 'react';
import type { Subscription } from 'rxjs'; import type { Subscription } from 'rxjs';
import type { CallState } from '../types.js'; import type { CallState } from '../types.js';

View File

@ -19,6 +19,7 @@ import { keyring } from '@polkadot/ui-keyring';
import { AccountsPage } from '../../../page-accounts/test/pages/accountsPage.js'; import { AccountsPage } from '../../../page-accounts/test/pages/accountsPage.js';
// FIXME: these all need to be wrapped in waitFor .... // FIXME: these all need to be wrapped in waitFor ....
// eslint-disable-next-line jest/no-disabled-tests
describe.skip('Sidebar', () => { describe.skip('Sidebar', () => {
let accountsPage: AccountsPage; let accountsPage: AccountsPage;
let sideBar: Sidebar; let sideBar: Sidebar;
@ -61,10 +62,12 @@ describe.skip('Sidebar', () => {
expect(changedAccount?.meta?.name).toEqual(newName); expect(changedAccount?.meta?.name).toEqual(newName);
}); });
// eslint-disable-next-line jest/expect-expect
it('within sidebar', async () => { it('within sidebar', async () => {
await sideBar.assertAccountName(newName); await sideBar.assertAccountName(newName);
}); });
// eslint-disable-next-line jest/expect-expect
it('within account row', async () => { it('within account row', async () => {
const accountRows = await accountsPage.getAccountRows(); const accountRows = await accountsPage.getAccountRows();
@ -78,7 +81,7 @@ describe.skip('Sidebar', () => {
await sideBar.clickByText('none'); await sideBar.clickByText('none');
expect(sideBar.queryByRole('combobox')).toBeFalsy(); expect(sideBar.queryByRole('combobox')).toBeFalsy();
await expect(sideBar.typeAccountName(newName)).rejects.toThrowError(nameInputNotFoundError); await expect(sideBar.typeAccountName(newName)).rejects.toThrow(nameInputNotFoundError);
}); });
it('when isEditable is false account name is not editable', async () => { it('when isEditable is false account name is not editable', async () => {
@ -88,7 +91,7 @@ describe.skip('Sidebar', () => {
sideBar = await accountsPage.openSidebarForRow(0); sideBar = await accountsPage.openSidebarForRow(0);
sideBar.edit(); sideBar.edit();
await expect(sideBar.typeAccountName(newName)).rejects.toThrowError(nameInputNotFoundError); await expect(sideBar.typeAccountName(newName)).rejects.toThrow(nameInputNotFoundError);
}); });
describe('on edit cancel', () => { describe('on edit cancel', () => {
@ -102,6 +105,7 @@ describe.skip('Sidebar', () => {
sideBar.edit(); sideBar.edit();
}); });
// eslint-disable-next-line jest/expect-expect
it('restores tags and name to state from keyring', async () => { it('restores tags and name to state from keyring', async () => {
await sideBar.typeAccountName(newName); await sideBar.typeAccountName(newName);
await sideBar.selectTag(defaultTag); await sideBar.selectTag(defaultTag);
@ -145,6 +149,7 @@ describe.skip('Sidebar', () => {
expect(sideBar.queryByRole('button', { name: 'Cancel' })).toBeTruthy(); expect(sideBar.queryByRole('button', { name: 'Cancel' })).toBeTruthy();
}); });
// eslint-disable-next-line jest/expect-expect
it('cancels editing and changes name when opening sidebar for another account', async () => { it('cancels editing and changes name when opening sidebar for another account', async () => {
await waitFor(() => sideBar.assertAccountInput('alice')); await waitFor(() => sideBar.assertAccountInput('alice'));
@ -188,6 +193,7 @@ describe.skip('Sidebar', () => {
expect(subAccount).toHaveTextContent('BOB'); expect(subAccount).toHaveTextContent('BOB');
}); });
// eslint-disable-next-line jest/expect-expect
it('displays picked sub in sidebar', async () => { it('displays picked sub in sidebar', async () => {
const subAccount = subs[0].childNodes[1]; const subAccount = subs[0].childNodes[1];
@ -199,6 +205,7 @@ describe.skip('Sidebar', () => {
}); });
describe('judgements', () => { describe('judgements', () => {
// eslint-disable-next-line jest/expect-expect
it('displays several judgements', async () => { it('displays several judgements', async () => {
mockApiHooks.setJudgements(mockRegistration.judgements as RegistrationJudgement[]); mockApiHooks.setJudgements(mockRegistration.judgements as RegistrationJudgement[]);
accountsPage.renderDefaultAccounts(1); accountsPage.renderDefaultAccounts(1);
@ -209,6 +216,7 @@ describe.skip('Sidebar', () => {
await sideBar.assertJudgement('1 Erroneous'); await sideBar.assertJudgement('1 Erroneous');
}); });
// eslint-disable-next-line jest/expect-expect
it('displays no judgements', async () => { it('displays no judgements', async () => {
accountsPage.renderDefaultAccounts(1); accountsPage.renderDefaultAccounts(1);
sideBar = await accountsPage.openSidebarForRow(0); sideBar = await accountsPage.openSidebarForRow(0);
@ -227,12 +235,14 @@ describe.skip('Sidebar', () => {
sideBar = await accountsPage.openSidebarForRow(0); sideBar = await accountsPage.openSidebarForRow(0);
}); });
// eslint-disable-next-line jest/expect-expect
it('singular registrar', async () => { it('singular registrar', async () => {
const judgementTag = await sideBar.getJudgement('1 Known good'); const judgementTag = await sideBar.getJudgement('1 Known good');
await judgementTag.assertRegistrars([charlieShortAddress]); await judgementTag.assertRegistrars([charlieShortAddress]);
}); });
// eslint-disable-next-line jest/expect-expect
it('multiple registrars', async () => { it('multiple registrars', async () => {
const judgementTag = await sideBar.getJudgement('2 Reasonable'); const judgementTag = await sideBar.getJudgement('2 Reasonable');

View File

@ -2,6 +2,7 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import type { IconName } from '@fortawesome/fontawesome-svg-core'; import type { IconName } from '@fortawesome/fontawesome-svg-core';
import type React from 'react';
export type Button$Callback = () => void | Promise<void>; export type Button$Callback = () => void | Promise<void>;

View File

@ -61,6 +61,7 @@ describe('Modal Component', () => {
await i18next.changeLanguage('en'); await i18next.changeLanguage('en');
}); });
// eslint-disable-next-line jest/expect-expect
it('opens and closes modal', async () => { it('opens and closes modal', async () => {
renderModal(); renderModal();
@ -73,6 +74,7 @@ describe('Modal Component', () => {
}); });
}); });
// eslint-disable-next-line jest/expect-expect
it('renders all modal sections', async () => { it('renders all modal sections', async () => {
renderModal(); renderModal();
@ -87,6 +89,7 @@ describe('Modal Component', () => {
}); });
}); });
// eslint-disable-next-line jest/expect-expect
it('closes modal with ESC button', async () => { it('closes modal with ESC button', async () => {
renderModal(); renderModal();

View File

@ -42,6 +42,7 @@ describe('Popup Component', () => {
await i18next.changeLanguage('en'); await i18next.changeLanguage('en');
}); });
// eslint-disable-next-line jest/expect-expect
it('opens and closes', async () => { it('opens and closes', async () => {
renderPopup(); renderPopup();
@ -54,6 +55,7 @@ describe('Popup Component', () => {
}); });
}); });
// eslint-disable-next-line jest/expect-expect
it('closes popup with outside click', async () => { it('closes popup with outside click', async () => {
renderPopup(); renderPopup();

View File

@ -104,4 +104,6 @@ export * from './modals/index.js';
export * from './themes.js'; export * from './themes.js';
// external exports // external exports
// See https://github.com/import-js/eslint-plugin-import/issues/2556
// eslint-disable-next-line import/export
export * from '@polkadot/react-qr'; export * from '@polkadot/react-qr';

View File

@ -2,6 +2,7 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import type { IconName } from '@fortawesome/fontawesome-svg-core'; import type { IconName } from '@fortawesome/fontawesome-svg-core';
import type React from 'react';
import type { WithTranslation } from 'react-i18next'; import type { WithTranslation } from 'react-i18next';
import type { SubmittableExtrinsic } from '@polkadot/api/types'; import type { SubmittableExtrinsic } from '@polkadot/api/types';
import type { Abi } from '@polkadot/api-contract'; import type { Abi } from '@polkadot/api-contract';

View File

@ -1,6 +1,7 @@
// Copyright 2017-2023 @polkadot/react-components authors & contributors // Copyright 2017-2023 @polkadot/react-components authors & contributors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import type React from 'react';
import type { RegistrarIndex } from '@polkadot/types/interfaces/identity/types'; import type { RegistrarIndex } from '@polkadot/types/interfaces/identity/types';
import type { DisplayedJudgement } from '../types.js'; import type { DisplayedJudgement } from '../types.js';

View File

@ -1,6 +1,7 @@
// Copyright 2017-2023 @polkadot/react-hooks authors & contributors // Copyright 2017-2023 @polkadot/react-hooks authors & contributors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import type React from 'react';
import type { ApiPromise } from '@polkadot/api'; import type { ApiPromise } from '@polkadot/api';
import type { SubmittableExtrinsic } from '@polkadot/api/types'; import type { SubmittableExtrinsic } from '@polkadot/api/types';
import type { DeriveAccountFlags, DeriveAccountRegistration } from '@polkadot/api-derive/types'; import type { DeriveAccountFlags, DeriveAccountRegistration } from '@polkadot/api-derive/types';
@ -12,13 +13,16 @@ import type { KeyringJson$Meta } from '@polkadot/ui-keyring/types';
import type { BN } from '@polkadot/util'; import type { BN } from '@polkadot/util';
import type { HexString } from '@polkadot/util/types'; import type { HexString } from '@polkadot/util/types';
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type CallParam = any; export type CallParam = any;
export type CallParams = [] | CallParam[]; export type CallParams = [] | CallParam[];
export interface CallOptions <T> { export interface CallOptions <T> {
defaultValue?: T; defaultValue?: T;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
paramMap?: (params: any) => CallParams; paramMap?: (params: any) => CallParams;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
transform?: (value: any, api: ApiPromise) => T; transform?: (value: any, api: ApiPromise) => T;
withParams?: boolean; withParams?: boolean;
withParamsTransform?: boolean; withParamsTransform?: boolean;

View File

@ -1,6 +1,8 @@
// Copyright 2017-2023 @polkadot/react-hooks authors & contributors // Copyright 2017-2023 @polkadot/react-hooks authors & contributors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import type React from 'react';
import { useEffect, useRef } from 'react'; import { useEffect, useRef } from 'react';
import { createNamedHook } from './createNamedHook.js'; import { createNamedHook } from './createNamedHook.js';

View File

@ -1,7 +1,7 @@
// Copyright 2017-2023 @polkadot/react-hooks authors & contributors // Copyright 2017-2023 @polkadot/react-hooks authors & contributors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import type { RefObject } from 'react'; import type React from 'react';
import { useCallback, useEffect } from 'react'; import { useCallback, useEffect } from 'react';
@ -14,7 +14,7 @@ function isRefClicked (refs: React.RefObject<HTMLDivElement>[], e: MouseEvent):
); );
} }
function useOutsideClickImpl (refs: RefObject<HTMLDivElement>[], callback: () => void): void { function useOutsideClickImpl (refs: React.RefObject<HTMLDivElement>[], callback: () => void): void {
const handleClick = useCallback( const handleClick = useCallback(
(e: MouseEvent): void => { (e: MouseEvent): void => {
if (refs.length && !isRefClicked(refs, e)) { if (refs.length && !isRefClicked(refs, e)) {

View File

@ -1,6 +1,8 @@
// Copyright 2017-2023 @polkadot/react-hooks authors & contributors // Copyright 2017-2023 @polkadot/react-hooks authors & contributors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import type React from 'react';
import { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
import { keyring } from '@polkadot/ui-keyring'; import { keyring } from '@polkadot/ui-keyring';

View File

@ -1,6 +1,8 @@
// Copyright 2017-2023 @polkadot/react-hooks authors & contributors // Copyright 2017-2023 @polkadot/react-hooks authors & contributors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import type React from 'react';
import { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
import store from 'store'; import store from 'store';

View File

@ -1,6 +1,7 @@
// Copyright 2017-2023 @polkadot/react-hooks authors & contributors // Copyright 2017-2023 @polkadot/react-hooks authors & contributors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import type React from 'react';
import type { ThemeDef } from '@polkadot/react-components/types'; import type { ThemeDef } from '@polkadot/react-components/types';
import { useContext, useMemo } from 'react'; import { useContext, useMemo } from 'react';

View File

@ -62,6 +62,7 @@ function useWeightImpl (call?: Call | null): Result {
const { api } = useApi(); const { api } = useApi();
const mountedRef = useIsMountedRef(); const mountedRef = useIsMountedRef();
const [state, setState] = useState<Result>(() => objectSpread({ const [state, setState] = useState<Result>(() => objectSpread({
// eslint-disable-next-line @typescript-eslint/unbound-method
isWeightV2: !isFunction(api.registry.createType<V1Weight>('Weight').toBn) isWeightV2: !isFunction(api.registry.createType<V1Weight>('Weight').toBn)
}, EMPTY_STATE)); }, EMPTY_STATE));

View File

@ -57,7 +57,7 @@ function isExtrinsic (value: unknown): value is IExtrinsic {
// This is no doubt NOT the way to do things - however there is no other option // This is no doubt NOT the way to do things - however there is no other option
function getRawSignature (value: IExtrinsic): ExtrinsicSignature | undefined { function getRawSignature (value: IExtrinsic): ExtrinsicSignature | undefined {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
return (value as any)._raw?.signature?.multiSignature as ExtrinsicSignature; return (value as any)._raw?.signature?.multiSignature as ExtrinsicSignature;
} }

View File

@ -9,7 +9,7 @@ import Bare from './Bare.js';
interface Props { interface Props {
className?: string; className?: string;
defaultValue?: any; defaultValue?: unknown;
isDisabled?: boolean; isDisabled?: boolean;
isError?: boolean; isError?: boolean;
label?: React.ReactNode; label?: React.ReactNode;

View File

@ -36,6 +36,7 @@ function VoteThresholdParam ({ className = '', defaultValue: { value }, isDisabl
); );
const defaultValue = useMemo( const defaultValue = useMemo(
// eslint-disable-next-line @typescript-eslint/unbound-method
() => isFunction((value as BN).toNumber) () => isFunction((value as BN).toNumber)
? (value as BN).toNumber() ? (value as BN).toNumber()
: bnToBn(value as number).toNumber(), : bnToBn(value as number).toNumber(),

View File

@ -1,6 +1,7 @@
// Copyright 2017-2023 @polkadot/react-params authors & contributors // Copyright 2017-2023 @polkadot/react-params authors & contributors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import type React from 'react';
import type { Registry, TypeDef } from '@polkadot/types/types'; import type { Registry, TypeDef } from '@polkadot/types/types';
import type { ComponentMap, Props } from '../types.js'; import type { ComponentMap, Props } from '../types.js';
@ -41,6 +42,7 @@ import Vote from './Vote.js';
import VoteThreshold from './VoteThreshold.js'; import VoteThreshold from './VoteThreshold.js';
interface TypeToComponent { interface TypeToComponent {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
c: React.ComponentType<any>; c: React.ComponentType<any>;
t: string[]; t: string[];
} }

View File

@ -1,6 +1,7 @@
// Copyright 2017-2023 @polkadot/react-params authors & contributors // Copyright 2017-2023 @polkadot/react-params authors & contributors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import type React from 'react';
import type { Registry, TypeDef } from '@polkadot/types/types'; import type { Registry, TypeDef } from '@polkadot/types/types';
import type { HexString } from '@polkadot/util/types'; import type { HexString } from '@polkadot/util/types';

View File

@ -34,6 +34,7 @@ function formatKeys (keys: [ValidatorId, Keys][]): string {
} }
function toHuman (value: Codec | Codec[]): unknown { function toHuman (value: Codec | Codec[]): unknown {
// eslint-disable-next-line @typescript-eslint/unbound-method
return isFunction((value as Codec).toHuman) return isFunction((value as Codec).toHuman)
? (value as Codec).toHuman() ? (value as Codec).toHuman()
: Array.isArray(value) : Array.isArray(value)
@ -41,7 +42,7 @@ function toHuman (value: Codec | Codec[]): unknown {
: value.toString(); : value.toString();
} }
export function toHumanJson (value: any): string { export function toHumanJson (value: unknown): string {
return stringify(value, 2) return stringify(value, 2)
.replace(/,\n/g, '\n') .replace(/,\n/g, '\n')
.replace(/"/g, '') .replace(/"/g, '')
@ -56,6 +57,7 @@ export default function valueToText (type: string, value: Codec | undefined | nu
return div( return div(
{}, {},
// eslint-disable-next-line @typescript-eslint/unbound-method
['Bytes', 'Raw', 'Option<Keys>', 'Keys'].includes(type) && isFunction(value.toU8a) ['Bytes', 'Raw', 'Option<Keys>', 'Keys'].includes(type) && isFunction(value.toU8a)
? u8aToHex(value.toU8a(true)) ? u8aToHex(value.toU8a(true))
// HACK Handle Keys as hex-only (this should go away once the node value is // HACK Handle Keys as hex-only (this should go away once the node value is

View File

@ -1,6 +1,8 @@
// Copyright 2017-2023 @polkadot/page-accounts authors & contributors // Copyright 2017-2023 @polkadot/page-accounts authors & contributors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
/* global jest, fail */
import type { RenderResult } from '@testing-library/react'; import type { RenderResult } from '@testing-library/react';
import type { ApiProps } from '@polkadot/react-api/types'; import type { ApiProps } from '@polkadot/react-api/types';
import type { PartialQueueTxExtrinsic, QueueProps, QueueTxExtrinsicAdd } from '@polkadot/react-components/Status/types'; import type { PartialQueueTxExtrinsic, QueueProps, QueueTxExtrinsicAdd } from '@polkadot/react-components/Status/types';

View File

@ -1,6 +1,8 @@
// Copyright 2017-2023 @polkadot/test-supports authors & contributors // Copyright 2017-2023 @polkadot/test-supports authors & contributors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
/* global fail */
import { fireEvent, screen, within } from '@testing-library/react'; import { fireEvent, screen, within } from '@testing-library/react';
export class JudgementTag { export class JudgementTag {

View File

@ -1,6 +1,8 @@
// Copyright 2017-2023 @polkadot/test-supports authors & contributors // Copyright 2017-2023 @polkadot/test-supports authors & contributors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
/* global expect */
import type { Balance } from '@polkadot/types/interfaces'; import type { Balance } from '@polkadot/types/interfaces';
import { fireEvent, screen, within } from '@testing-library/react'; import { fireEvent, screen, within } from '@testing-library/react';

View File

@ -1,6 +1,8 @@
// Copyright 2017-2023 @polkadot/test-supports authors & contributors // Copyright 2017-2023 @polkadot/test-supports authors & contributors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
/* global expect */
import { fireEvent, screen, within } from '@testing-library/react'; import { fireEvent, screen, within } from '@testing-library/react';
import { JudgementTag } from './JudgementTag.js'; import { JudgementTag } from './JudgementTag.js';

View File

@ -1,6 +1,8 @@
// Copyright 2017-2023 @polkadot/test-supports authors & contributors // Copyright 2017-2023 @polkadot/test-supports authors & contributors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
/* global expect */
import { within } from '@testing-library/react'; import { within } from '@testing-library/react';
import { showBalance } from '../utils/balance.js'; import { showBalance } from '../utils/balance.js';

View File

@ -6,6 +6,7 @@ import type React from 'react';
import { useApi } from '@polkadot/react-hooks'; import { useApi } from '@polkadot/react-hooks';
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const WaitForApi = ({ children }: { children: React.ReactNode }): PropsWithChildren<any> | null => { export const WaitForApi = ({ children }: { children: React.ReactNode }): PropsWithChildren<any> | null => {
const api = useApi(); const api = useApi();

View File

@ -43,8 +43,7 @@ export const emptyAccounts: Accounts = {
// here it's extremely hard to reconstruct the entire DeriveBalancesAll upfront, so we incrementally add properties // here it's extremely hard to reconstruct the entire DeriveBalancesAll upfront, so we incrementally add properties
// instead along the way; thus the need to tell the tsc we know what we are doing here // instead along the way; thus the need to tell the tsc we know what we are doing here
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment export const defaultBalanceAccount = {
export const defaultBalanceAccount: DeriveBalancesAll = {
accountNonce: new BN(1), accountNonce: new BN(1),
additional: [], additional: [],
availableBalance: balanceOf(0), availableBalance: balanceOf(0),
@ -53,12 +52,11 @@ export const defaultBalanceAccount: DeriveBalancesAll = {
lockedBreakdown: [], lockedBreakdown: [],
namedReserves: [], namedReserves: [],
reservedBalance: balanceOf(0) reservedBalance: balanceOf(0)
} as any; } as unknown as DeriveBalancesAll;
// here it's extremely hard to reconstruct the entire DeriveStakingAccount upfront, // here it's extremely hard to reconstruct the entire DeriveStakingAccount upfront,
// so we set just the properties that we use in page-accounts // so we set just the properties that we use in page-accounts
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment export const defaultStakingAccount = {
export const defaultStakingAccount: DeriveStakingAccount = {
nextSessionIds: [], nextSessionIds: [],
nominators: [], nominators: [],
redeemable: balanceOf(0), redeemable: balanceOf(0),
@ -78,15 +76,14 @@ export const defaultStakingAccount: DeriveStakingAccount = {
value: balanceOf(0) value: balanceOf(0)
} }
] ]
} as any; } as unknown as DeriveStakingAccount;
export const defaultMeta: KeyringJson$Meta = {}; export const defaultMeta: KeyringJson$Meta = {};
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment export const defaultAccountInfo = {
export const defaultAccountInfo: UseAccountInfo = {
flags: {}, flags: {},
identity: { email: 'user@email.com', isExistent: true, judgements: [] }, identity: { email: 'user@email.com', isExistent: true, judgements: [] },
tags: [] tags: []
} as any; } as unknown as UseAccountInfo;
class MockAccountHooks { class MockAccountHooks {
public useAccounts: Accounts = emptyAccounts; public useAccounts: Accounts = emptyAccounts;
@ -109,32 +106,25 @@ class MockAccountHooks {
const balance = { ...defaultBalanceAccount }; const balance = { ...defaultBalanceAccount };
const info = { ...defaultAccountInfo }; const info = { ...defaultAccountInfo };
// Typescript does not recognize that keys and values from Object.entries are safe,
// so we have to use "any" here.
Object Object
.entries(props.meta || meta) .entries(props.meta || meta)
.forEach(([key, value]) => { .forEach(([key, value]) => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access (meta as Record<string, unknown>)[key] = value;
(meta as any)[key] = value;
}); });
Object Object
.entries(props.balance || balance) .entries(props.balance || balance)
.forEach(([key, value]) => { .forEach(([key, value]) => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access (balance as Record<string, unknown>)[key] = value;
(balance as any)[key] = value;
}); });
Object Object
.entries(props.staking || staking) .entries(props.staking || staking)
.forEach(([key, value]) => { .forEach(([key, value]) => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access (staking as Record<string, unknown>)[key] = value;
(staking as any)[key] = value;
}); });
Object Object
.entries(props.info || info) .entries(props.info || info)
.forEach(([key, value]) => { .forEach(([key, value]) => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access (info as Record<string, unknown>)[key] = value;
(info as any)[key] = value;
}); });
this.accountsMap[address] = { this.accountsMap[address] = {

View File

@ -1,6 +1,8 @@
// Copyright 2017-2023 @polkadot/test-supports authors & contributors // Copyright 2017-2023 @polkadot/test-supports authors & contributors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
/* global expect */
import { fireEvent, screen } from '@testing-library/react'; import { fireEvent, screen } from '@testing-library/react';
export const clickButton = async (buttonName: string): Promise<void> => { export const clickButton = async (buttonName: string): Promise<void> => {

View File

@ -4,9 +4,14 @@
const fs = require('node:fs'); const fs = require('node:fs');
const path = require('node:path'); const path = require('node:path');
/** @type {Record<string, string[]>} */
const defaults = {}; const defaults = {};
const i18nRoot = path.join(__dirname, '../packages/apps/public/locales'); const i18nRoot = path.join(__dirname, '../packages/apps/public/locales');
/**
* @param {string} langRoot
* @returns {string[]}
*/
function getEntries (langRoot) { function getEntries (langRoot) {
return fs return fs
.readdirSync(langRoot) .readdirSync(langRoot)
@ -19,6 +24,9 @@ function getEntries (langRoot) {
.sort(); .sort();
} }
/**
* @param {string} lang
*/
function checkLanguage (lang) { function checkLanguage (lang) {
console.log(`*** Checking ${lang}`); console.log(`*** Checking ${lang}`);

View File

@ -8,6 +8,10 @@ const i18nRoot = path.join(__dirname, '../packages/apps/public/locales');
const SKIP_NS = ['translation'].map((f) => `${f}.json`); const SKIP_NS = ['translation'].map((f) => `${f}.json`);
/**
* @param {string} langRoot
* @returns {string[]}
*/
function getEntries (langRoot) { function getEntries (langRoot) {
return fs return fs
.readdirSync(langRoot) .readdirSync(langRoot)
@ -20,19 +24,26 @@ function getEntries (langRoot) {
.sort(); .sort();
} }
/**
* @param {string} lang
*/
function sortLanguage (lang) { function sortLanguage (lang) {
const langRoot = path.join(i18nRoot, lang); const langRoot = path.join(i18nRoot, lang);
const entries = getEntries(langRoot); const entries = getEntries(langRoot);
/** @type {Record<String, boolean>} */
const hasKeys = {}; const hasKeys = {};
entries.forEach((entry) => { entries.forEach((entry) => {
const filename = path.join(langRoot, entry); const filename = path.join(langRoot, entry);
const json = require(filename); const json = require(filename);
const sorted = Object.keys(json).sort().reduce((result, key) => { const sorted = Object
result[key] = json[key]; .keys(json)
.sort()
.reduce((/** @type {Record<String, string>} */ result, key) => {
result[key] = json[key];
return result; return result;
}, {}); }, {});
hasKeys[entry] = Object.keys(sorted).length !== 0; hasKeys[entry] = Object.keys(sorted).length !== 0;

View File

@ -11,27 +11,36 @@ const MAX_SIZE = 48 * 1024;
// FIXME The sorting here and the sorting from linting seems like a mismatch... // FIXME The sorting here and the sorting from linting seems like a mismatch...
const HEADER = '// Copyright 2017-2023 @polkadot/apps authors & contributors\n// SPDX-License-Identifier: Apache-2.0\n\n// Do not edit. Auto-generated via node scripts/imgConvert.mjs\n\n'; const HEADER = '// Copyright 2017-2023 @polkadot/apps authors & contributors\n// SPDX-License-Identifier: Apache-2.0\n\n// Do not edit. Auto-generated via node scripts/imgConvert.mjs\n\n';
/** @type {Record<string, string>} */
const MIME = { const MIME = {
gif: 'image/gif', gif: 'image/gif',
jpeg: 'image/jpeg', jpeg: 'image/jpeg',
png: 'image/png', png: 'image/png',
svg: 'image/svg+xml' svg: 'image/svg+xml'
} };
/**
* @param {string} k
* @param {string} contents
* @returns {string}
*/
function makeContents (k, contents) { function makeContents (k, contents) {
return `${HEADER}export const ${k} = '${contents}';\n`; return `${HEADER}export const ${k} = '${contents}';\n`;
} }
/** @type {Record<string, string>} */
const all = {}; const all = {};
/** @type {Record<string, number>} */
const oversized = {}; const oversized = {};
for (let dir of ['extensions', 'external', 'chains', 'nodes']) { for (const dir of ['extensions', 'external', 'chains', 'nodes']) {
const sub = path.join('packages/apps-config/src/ui/logos', dir); const sub = path.join('packages/apps-config/src/ui/logos', dir);
const generated = path.join(sub, 'generated'); const generated = path.join(sub, 'generated');
/** @type {Record<string, string>} */
const result = {}; const result = {};
if (fs.existsSync(generated)) { if (fs.existsSync(generated)) {
fs.rmSync(generated, { recursive: true, force: true }); fs.rmSync(generated, { force: true, recursive: true });
} }
fs.mkdirSync(generated); fs.mkdirSync(generated);
@ -67,45 +76,46 @@ for (let dir of ['extensions', 'external', 'chains', 'nodes']) {
} }
}); });
if (Object.keys(result).length) { if (Object.keys(result).length) {
let srcs = ''; let srcs = '';
for (let dir of ['endpoints', 'extensions', 'links']) { for (const dir of ['endpoints', 'extensions', 'links']) {
const srcroot = path.join('packages/apps-config/src', dir); const srcroot = path.join('packages/apps-config/src', dir);
fs fs
.readdirSync(srcroot) .readdirSync(srcroot)
.forEach((file) => { .forEach((file) => {
const full = path.join(srcroot, file); const full = path.join(srcroot, file);
if (fs.lstatSync(full).isFile() && file.endsWith('.ts')) { if (fs.lstatSync(full).isFile() && file.endsWith('.ts')) {
srcs += fs.readFileSync(full).toString(); srcs += fs.readFileSync(full).toString();
} }
}); });
}
const notfound = Object
.keys(result)
.filter((k) => !srcs.includes(k));
if (notfound.length) {
console.log('\n', notfound.length.toString().padStart(3), 'not referenced in', dir, '::\n\n\t', notfound.join(', '), '\n');
}
fs.writeFileSync(path.join(sub, 'index.ts'), `${HEADER}${
Object
.keys(result)
.sort((a, b) => result[a].localeCompare(result[b]))
.map((k) => `export { ${k} } from './${result[k]}.js';`)
.join('\n')
}\n`);
} }
const notfound = Object
.keys(result)
.filter((k) => !srcs.includes(k));
if (notfound.length) {
console.log('\n', notfound.length.toString().padStart(3), 'not referenced in', dir, '::\n\n\t', notfound.join(', '), '\n');
}
fs.writeFileSync(path.join(sub, 'index.ts'), `${HEADER}${
Object
.keys(result)
.sort((a, b) => result[a].localeCompare(result[b]))
.map((k) => `export { ${k} } from './${result[k]}.js';`)
.join('\n')
}\n`);
}
} }
const allKeys = Object.keys(all); const allKeys = Object.keys(all);
/** @type {Record<string, string[]>} */
const dupes = {}; const dupes = {};
allKeys.forEach((a) => { allKeys.forEach((a) => {
const d = allKeys.filter((b) => const d = allKeys.filter((b) =>
a !== b && a !== b &&
all[a] === all[b] all[a] === all[b]
@ -114,14 +124,14 @@ const dupes = {};
if (d.length) { if (d.length) {
dupes[a] = d; dupes[a] = d;
} }
}); });
if (Object.keys(dupes).length) { if (Object.keys(dupes).length) {
const errMsg = `${Object.keys(dupes).length.toString().padStart(3)} dupes found`; const errMsg = `${Object.keys(dupes).length.toString().padStart(3)} dupes found`;
console.log('\n', errMsg, '::\n'); console.log('\n', errMsg, '::\n');
for (let [k, d] of Object.entries(dupes)) { for (const [k, d] of Object.entries(dupes)) {
console.log('\t', k.padStart(30), ' >> ', d.join(', ')); console.log('\t', k.padStart(30), ' >> ', d.join(', '));
} }
@ -137,8 +147,8 @@ if (numOversized) {
console.log('\n', errMsg, '::\n'); console.log('\n', errMsg, '::\n');
for (let [k, v] of Object.entries(oversized)) { for (const [k, v] of Object.entries(oversized)) {
console.log('\t', k.padStart(30), formatNumber(v).padStart(15), `(+${formatNumber(v - MAX_SIZE)} bytes)`) console.log('\t', k.padStart(30), formatNumber(v).padStart(15), `(+${formatNumber(v - MAX_SIZE)} bytes)`);
} }
console.log(); console.log();

View File

@ -1,14 +1,20 @@
// Copyright 2017-2023 @polkadot/apps authors & contributors // Copyright 2017-2023 @polkadot/apps authors & contributors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-nocheck Currently we have a bit too many of these
import CrustPinner from '@crustio/crust-pin'; import CrustPinner from '@crustio/crust-pin';
import PinataSDK from '@pinata/sdk'; import PinataSDK from '@pinata/sdk';
// @ts-expect-error No definition file
import cloudflare from 'dnslink-cloudflare'; import cloudflare from 'dnslink-cloudflare';
import fs from 'node:fs'; import fs from 'node:fs';
// @ts-expect-error No definition file
import { execSync } from '@polkadot/dev/scripts/util.mjs'; import { execSync } from '@polkadot/dev/scripts/util.mjs';
// @ts-ignore // eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore Using ignore since the file won't be there in dev
import { createWsEndpoints } from '../packages/apps-config/build/endpoints/index.js'; import { createWsEndpoints } from '../packages/apps-config/build/endpoints/index.js';
console.log('$ scripts/ipfsUpload.mjs', process.argv.slice(2).join(' ')); console.log('$ scripts/ipfsUpload.mjs', process.argv.slice(2).join(' '));

View File

@ -12,15 +12,23 @@ const HEADER = `// Copyright 2017-2023 @polkadot/react-components authors & cont
/* eslint-disable simple-import-sort/imports */`; /* eslint-disable simple-import-sort/imports */`;
const PATH = 'packages/react-components/src/IdentityIcon/RoboHash'; const PATH = 'packages/react-components/src/IdentityIcon/RoboHash';
/**
* @param {number} index
* @returns {string}
*/
function getCounter (index) { function getCounter (index) {
return `000${index}`.slice(-3); return `000${index}`.slice(-3);
} }
/**
* @param {string} dir
* @returns {string[]}
*/
function getFiles (dir) { function getFiles (dir) {
const genpath = path.join(dir, 'generated'); const genpath = path.join(dir, 'generated');
if (!fs.existsSync(genpath)) { if (!fs.existsSync(genpath)) {
fs.mkdirSync(genpath, { force: true }); fs.mkdirSync(genpath, { recursive: true });
} }
const all = fs const all = fs
@ -51,7 +59,7 @@ function getFiles (dir) {
: 0 : 0
); );
for (let f of all) { for (const f of all) {
if (f.endsWith('.png')) { if (f.endsWith('.png')) {
fs.writeFileSync(path.join(dir, `generated/${f}`).replace('.png', '.ts'), `${HEADER}\n\nexport default 'data:image/png;base64,${fs.readFileSync(path.join(dir, f)).toString('base64')}';\n`); fs.writeFileSync(path.join(dir, `generated/${f}`).replace('.png', '.ts'), `${HEADER}\n\nexport default 'data:image/png;base64,${fs.readFileSync(path.join(dir, f)).toString('base64')}';\n`);
} }
@ -62,6 +70,7 @@ function getFiles (dir) {
function extractBg () { function extractBg () {
const root = path.join(__dirname, '..', PATH, 'backgrounds'); const root = path.join(__dirname, '..', PATH, 'backgrounds');
/** @type {string[]} */
const files = []; const files = [];
getFiles(root).forEach((sub) => { getFiles(root).forEach((sub) => {
@ -79,6 +88,7 @@ function extractSets () {
) )
); );
/** @type {string[]} */
const imports = []; const imports = [];
let list = '['; let list = '[';

View File

@ -4,6 +4,17 @@
"baseUrl": "./packages", "baseUrl": "./packages",
"composite": false "composite": false
}, },
"include": [
"packages/**/public/env-config.js",
"packages/**/src/**/*",
"packages/**/scripts/**/*",
"packages/**/test/**/*",
"packages/**/webpack.*.cjs",
"scripts/*",
".prettierrc.cjs",
"eslint.config.js",
"i18next-scanner.config.cjs"
],
"exclude": [ "exclude": [
"build/**/*", "build/**/*",
"**/build/**/*", "**/build/**/*",

View File

@ -13,7 +13,8 @@
"verbatimModuleSyntax": false "verbatimModuleSyntax": false
}, },
"include": [ "include": [
"packages/**/src/**/*" "packages/**/src/**/*",
"scripts/*"
], ],
"exclude": [ "exclude": [
"**/node_modules/**/*" "**/node_modules/**/*"

View File

@ -390,10 +390,10 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@eslint/js@npm:8.40.0, @eslint/js@npm:^8.40.0": "@eslint/js@npm:8.41.0, @eslint/js@npm:^8.41.0":
version: 8.40.0 version: 8.41.0
resolution: "@eslint/js@npm:8.40.0" resolution: "@eslint/js@npm:8.41.0"
checksum: e84936b8ebd1c8fd90e860182e95d1404006da4cbca722b14950b298aeeca102b080aa9b62c8e69f90824ec54e19f1ba79b239046223624d1414ee82e8e628ac checksum: af013d70fe8d0429cdf5cd8b5dcc6fc384ed026c1eccb0cfe30f5849b968ab91645111373fd1b83282b38955b1bdfbe667c1a7dbda3b06cae753521223cad775
languageName: node languageName: node
linkType: hard linkType: hard
@ -1865,7 +1865,7 @@ __metadata:
version: 0.0.0-use.local version: 0.0.0-use.local
resolution: "@polkadot/apps-electron@workspace:packages/apps-electron" resolution: "@polkadot/apps-electron@workspace:packages/apps-electron"
dependencies: dependencies:
"@polkadot/dev": ^0.74.1 "@polkadot/dev": ^0.75.2
"@polkadot/react-components": ^0.130.2-15-x "@polkadot/react-components": ^0.130.2-15-x
"@types/tmp": ^0.2.3 "@types/tmp": ^0.2.3
copy-webpack-plugin: ^11.0.0 copy-webpack-plugin: ^11.0.0
@ -1897,7 +1897,7 @@ __metadata:
dependencies: dependencies:
"@polkadot/apps-config": ^0.130.2-15-x "@polkadot/apps-config": ^0.130.2-15-x
"@polkadot/apps-routing": ^0.130.2-15-x "@polkadot/apps-routing": ^0.130.2-15-x
"@polkadot/dev": ^0.74.1 "@polkadot/dev": ^0.75.2
"@polkadot/react-api": ^0.130.2-15-x "@polkadot/react-api": ^0.130.2-15-x
"@polkadot/react-components": ^0.130.2-15-x "@polkadot/react-components": ^0.130.2-15-x
"@polkadot/react-hooks": ^0.130.2-15-x "@polkadot/react-hooks": ^0.130.2-15-x
@ -1931,34 +1931,34 @@ __metadata:
languageName: unknown languageName: unknown
linkType: soft linkType: soft
"@polkadot/dev-test@npm:^0.74.1": "@polkadot/dev-test@npm:^0.75.2":
version: 0.74.1 version: 0.75.2
resolution: "@polkadot/dev-test@npm:0.74.1" resolution: "@polkadot/dev-test@npm:0.75.2"
dependencies: dependencies:
jsdom: ^22.0.0 jsdom: ^22.0.0
tslib: ^2.5.1 tslib: ^2.5.2
checksum: b7b532bb068ae4616ac1359c5ba63c3d9ff28936d23281eb9d316ca9efa81e4b10672336b66ad2314de2dccea04877632aa56f6e725d8c8e41522f0eb09dcd40 checksum: e20e2488f138c9691daf3e8f6787c922e94374a3242a854ce48fe29b49c6b4bd7fbc1b244f205060652927670caf2577fad56883bb6dbbc143e1499bfddd2641
languageName: node languageName: node
linkType: hard linkType: hard
"@polkadot/dev-ts@npm:^0.74.1": "@polkadot/dev-ts@npm:^0.75.2":
version: 0.74.1 version: 0.75.2
resolution: "@polkadot/dev-ts@npm:0.74.1" resolution: "@polkadot/dev-ts@npm:0.75.2"
dependencies: dependencies:
json5: ^2.2.3 json5: ^2.2.3
tslib: ^2.5.1 tslib: ^2.5.2
typescript: ^5.0.4 typescript: ^5.0.4
checksum: 6e1c21dc15cf958033ce59c577474c24f0bad61210cd9fa0eed821ba222e736a4c7688e367b9cba1f42c848884182682732fbc333330cbd6a2b5bc5acf09e915 checksum: cd01aaca014ccb0ea064511ae52c7dd6ebd7115e64cb9f15bebfc8d6295cf9fd5ffdb2fc78e7cb5e46a346e6a2f513c6fec4cf5dc9a9626577547ef68f33cac7
languageName: node languageName: node
linkType: hard linkType: hard
"@polkadot/dev@npm:^0.74.1": "@polkadot/dev@npm:^0.75.2":
version: 0.74.1 version: 0.75.2
resolution: "@polkadot/dev@npm:0.74.1" resolution: "@polkadot/dev@npm:0.75.2"
dependencies: dependencies:
"@eslint/js": ^8.40.0 "@eslint/js": ^8.41.0
"@polkadot/dev-test": ^0.74.1 "@polkadot/dev-test": ^0.75.2
"@polkadot/dev-ts": ^0.74.1 "@polkadot/dev-ts": ^0.75.2
"@rollup/plugin-alias": ^5.0.0 "@rollup/plugin-alias": ^5.0.0
"@rollup/plugin-commonjs": ^25.0.0 "@rollup/plugin-commonjs": ^25.0.0
"@rollup/plugin-dynamic-import-vars": ^2.0.3 "@rollup/plugin-dynamic-import-vars": ^2.0.3
@ -1969,7 +1969,7 @@ __metadata:
"@tsconfig/strictest": ^2.0.1 "@tsconfig/strictest": ^2.0.1
"@typescript-eslint/eslint-plugin": ^5.59.6 "@typescript-eslint/eslint-plugin": ^5.59.6
"@typescript-eslint/parser": ^5.59.6 "@typescript-eslint/parser": ^5.59.6
eslint: ^8.40.0 eslint: ^8.41.0
eslint-config-standard: ^17.0.0 eslint-config-standard: ^17.0.0
eslint-import-resolver-node: ^0.3.7 eslint-import-resolver-node: ^0.3.7
eslint-plugin-deprecation: ^1.4.1 eslint-plugin-deprecation: ^1.4.1
@ -1985,6 +1985,7 @@ __metadata:
eslint-plugin-sort-destructure-keys: ^1.5.0 eslint-plugin-sort-destructure-keys: ^1.5.0
gh-pages: ^5.0.0 gh-pages: ^5.0.0
gh-release: ^7.0.2 gh-release: ^7.0.2
globals: ^13.20.0
json5: ^2.2.3 json5: ^2.2.3
madge: ^6.0.0 madge: ^6.0.0
react: ^18.2.0 react: ^18.2.0
@ -1993,7 +1994,7 @@ __metadata:
rollup: ^3.22.0 rollup: ^3.22.0
rollup-plugin-cleanup: ^3.2.1 rollup-plugin-cleanup: ^3.2.1
styled-components: ^5.3.10 styled-components: ^5.3.10
tslib: ^2.5.1 tslib: ^2.5.2
typescript: ^5.0.4 typescript: ^5.0.4
webpack: ^5.83.1 webpack: ^5.83.1
webpack-cli: ^5.1.1 webpack-cli: ^5.1.1
@ -2025,7 +2026,7 @@ __metadata:
polkadot-exec-rollup: scripts/polkadot-exec-rollup.mjs polkadot-exec-rollup: scripts/polkadot-exec-rollup.mjs
polkadot-exec-tsc: scripts/polkadot-exec-tsc.mjs polkadot-exec-tsc: scripts/polkadot-exec-tsc.mjs
polkadot-exec-webpack: scripts/polkadot-exec-webpack.mjs polkadot-exec-webpack: scripts/polkadot-exec-webpack.mjs
checksum: 89c8cd6ae49c509a24b4daf280f03da555d06c21758d40dcaac22fe95bdf221fd12370e7bd60c7872659e01ec549e0c017902362a1813bf116821e1abf155f6f checksum: 389694c7080aae84f36362991c77059422f80ab647dec11ce28a3bb7cc2d9809c789336780a63b28296795359585d36c1172ed6f37fbe294f7bd973ba755557c
languageName: node languageName: node
linkType: hard linkType: hard
@ -8172,14 +8173,14 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"eslint@npm:^8.40.0": "eslint@npm:^8.41.0":
version: 8.40.0 version: 8.41.0
resolution: "eslint@npm:8.40.0" resolution: "eslint@npm:8.41.0"
dependencies: dependencies:
"@eslint-community/eslint-utils": ^4.2.0 "@eslint-community/eslint-utils": ^4.2.0
"@eslint-community/regexpp": ^4.4.0 "@eslint-community/regexpp": ^4.4.0
"@eslint/eslintrc": ^2.0.3 "@eslint/eslintrc": ^2.0.3
"@eslint/js": 8.40.0 "@eslint/js": 8.41.0
"@humanwhocodes/config-array": ^0.11.8 "@humanwhocodes/config-array": ^0.11.8
"@humanwhocodes/module-importer": ^1.0.1 "@humanwhocodes/module-importer": ^1.0.1
"@nodelib/fs.walk": ^1.2.8 "@nodelib/fs.walk": ^1.2.8
@ -8199,13 +8200,12 @@ __metadata:
find-up: ^5.0.0 find-up: ^5.0.0
glob-parent: ^6.0.2 glob-parent: ^6.0.2
globals: ^13.19.0 globals: ^13.19.0
grapheme-splitter: ^1.0.4 graphemer: ^1.4.0
ignore: ^5.2.0 ignore: ^5.2.0
import-fresh: ^3.0.0 import-fresh: ^3.0.0
imurmurhash: ^0.1.4 imurmurhash: ^0.1.4
is-glob: ^4.0.0 is-glob: ^4.0.0
is-path-inside: ^3.0.3 is-path-inside: ^3.0.3
js-sdsl: ^4.1.4
js-yaml: ^4.1.0 js-yaml: ^4.1.0
json-stable-stringify-without-jsonify: ^1.0.1 json-stable-stringify-without-jsonify: ^1.0.1
levn: ^0.4.1 levn: ^0.4.1
@ -8218,7 +8218,7 @@ __metadata:
text-table: ^0.2.0 text-table: ^0.2.0
bin: bin:
eslint: bin/eslint.js eslint: bin/eslint.js
checksum: b79eba37f52f517a420eec99a80ae9f284d2cbe73afc0d4d3d4d5ed1cce0b06f21badc0374bfb7ac239efd2d49a1fd7c6111d6c3d52888521f377ba33de77e61 checksum: 09979a6f8451dcc508a7005b6670845c8a518376280b3fd96657a406b8b6ef29d0e480d1ba11b4eb48da93d607e0c55c9b877676fe089d09973ec152354e23b2
languageName: node languageName: node
linkType: hard linkType: hard
@ -9479,12 +9479,12 @@ fsevents@~2.3.2:
languageName: node languageName: node
linkType: hard linkType: hard
"globals@npm:^13.19.0": "globals@npm:^13.19.0, globals@npm:^13.20.0":
version: 13.19.0 version: 13.20.0
resolution: "globals@npm:13.19.0" resolution: "globals@npm:13.20.0"
dependencies: dependencies:
type-fest: ^0.20.2 type-fest: ^0.20.2
checksum: a000dbd00bcf28f0941d8a29c3522b1c3b8e4bfe4e60e262c477a550c3cbbe8dbe2925a6905f037acd40f9a93c039242e1f7079c76b0fd184bc41dcc3b5c8e2e checksum: ad1ecf914bd051325faad281d02ea2c0b1df5d01bd94d368dcc5513340eac41d14b3c61af325768e3c7f8d44576e72780ec0b6f2d366121f8eec6e03c3a3b97a
languageName: node languageName: node
linkType: hard linkType: hard
@ -9659,6 +9659,13 @@ fsevents@~2.3.2:
languageName: node languageName: node
linkType: hard linkType: hard
"graphemer@npm:^1.4.0":
version: 1.4.0
resolution: "graphemer@npm:1.4.0"
checksum: bab8f0be9b568857c7bec9fda95a89f87b783546d02951c40c33f84d05bb7da3fd10f863a9beb901463669b6583173a8c8cc6d6b306ea2b9b9d5d3d943c3a673
languageName: node
linkType: hard
"gud@npm:^1.0.0": "gud@npm:^1.0.0":
version: 1.0.0 version: 1.0.0
resolution: "gud@npm:1.0.0" resolution: "gud@npm:1.0.0"
@ -11225,13 +11232,6 @@ fsevents@~2.3.2:
languageName: node languageName: node
linkType: hard linkType: hard
"js-sdsl@npm:^4.1.4":
version: 4.1.4
resolution: "js-sdsl@npm:4.1.4"
checksum: 1977cea4ab18e0e03e28bdf0371d8b443fad65ca0988e0faa216406faf6bb943714fe8f7cc7a5bfe5f35ba3d94ddae399f4d10200f547f2c3320688b0670d726
languageName: node
linkType: hard
"js-sha3@npm:0.8.0, js-sha3@npm:^0.8.0": "js-sha3@npm:0.8.0, js-sha3@npm:^0.8.0":
version: 0.8.0 version: 0.8.0
resolution: "js-sha3@npm:0.8.0" resolution: "js-sha3@npm:0.8.0"
@ -13731,7 +13731,7 @@ fsevents@~2.3.2:
dependencies: dependencies:
"@crustio/crust-pin": ^1.0.0 "@crustio/crust-pin": ^1.0.0
"@pinata/sdk": ^1.2.1 "@pinata/sdk": ^1.2.1
"@polkadot/dev": ^0.74.1 "@polkadot/dev": ^0.75.2
"@types/chart.js": ^2.9.37 "@types/chart.js": ^2.9.37
"@types/file-saver": ^2.0.5 "@types/file-saver": ^2.0.5
"@types/react-beautiful-dnd": ^13.1.4 "@types/react-beautiful-dnd": ^13.1.4
@ -16875,7 +16875,7 @@ fsevents@~2.3.2:
languageName: node languageName: node
linkType: hard linkType: hard
"tslib@npm:^2.0.3, tslib@npm:^2.1.0, tslib@npm:^2.3.1, tslib@npm:^2.4.0, tslib@npm:^2.5.0, tslib@npm:^2.5.1": "tslib@npm:^2.0.3, tslib@npm:^2.1.0, tslib@npm:^2.3.1, tslib@npm:^2.4.0, tslib@npm:^2.5.0, tslib@npm:^2.5.2":
version: 2.5.2 version: 2.5.2
resolution: "tslib@npm:2.5.2" resolution: "tslib@npm:2.5.2"
checksum: 4d3c1e238b94127ed0e88aa0380db3c2ddae581dc0f4bae5a982345e9f50ee5eda90835b8bfba99b02df10a5734470be197158c36f9129ac49fdc14a6a9da222 checksum: 4d3c1e238b94127ed0e88aa0380db3c2ddae581dc0f4bae5a982345e9f50ee5eda90835b8bfba99b02df10a5734470be197158c36f9129ac49fdc14a6a9da222