Move to @pezkuwi/dev 0.86.4 (eslint 10 toolchain)

- dev ^0.86.4 at the root and in packages/apps; directives renamed by
  pezkuwi-dev-migrate-eslint10.
- eslint --fix with the 0.86.4 config; one fix broke syntax
  (typescript-eslint prefer-optional-chain turned
  `(isStarted && onStart) && onStart()` into `(isStarted && onStart?.();`
  in TxButton) and is corrected by hand.
- The remaining findings fixed rather than disabled: optional chains
  (each suggestion reviewed), `cause` on rethrown errors, `if` instead of
  `a && promise` in effects, parallel instead of sequential awaits in
  Promise.all, Error rejections, no `delete` on arrays (the storage query
  cache is a Map; an upload's file list no longer keeps a hole), no
  `[object Object]` stringification (TFunction's second argument is text
  or options), dead code removed (referenda's never-shown expand button,
  react-query's unused CoreDescriptor).
This commit is contained in:
Satoshi Qazi Muhammed authored and SatoshiQaziMuhammed committed 2026-10-10 02:06:12 +04:00
1 parent c800e9affb
commit 45d479d2ec
325 files changed
+2942 -3531

No files matched your search

@@ -36,7 +36,7 @@ function AccountMenuButtons ({ className = '', flags, isEditing, isEditingName,
const _onForgetAddress = useCallback(
(): void => {
onForgetAddress();
onUpdateName && onUpdateName();
onUpdateName?.();
},
[onForgetAddress, onUpdateName]
);
@@ -49,7 +49,7 @@ function AccountMenuButtons ({ className = '', flags, isEditing, isEditingName,
const _onUpdateName = useCallback(
(): void => {
onSaveName();
onUpdateName && onUpdateName();
onUpdateName?.();
},
[onSaveName, onUpdateName]
);
@@ -39,8 +39,8 @@ function Identity ({ address, identity }: Props): React.ReactElement<Props> | nu
key={sub.toString()}
value={sub}
/>
)
, [subs]
),
[subs]
);
if (!identity || !identity.isExistent || !apiIdentity.query.identity?.identityOf) {
@@ -16,7 +16,6 @@ function UserIcon (): React.ReactElement {
<circle
cx='20'
cy='20'
// eslint-disable-next-line react/no-unknown-property
fill='url(#pattern0)'
r='20'
/>
@@ -487,7 +487,7 @@ function createBalanceItems (formatIndex: number, lookup: Record<string, string>
</div>
</React.Fragment>
);
} else if (bestNumber && votingOf && votingOf.isDirect) {
} else if (bestNumber && votingOf?.isDirect) {
const { prior: [unlockAt, balance] } = votingOf.asDirect;
balance.gt(BN_ZERO) && unlockAt.gt(BN_ZERO) && allItems.push(
@@ -30,7 +30,7 @@ function AddressToggle ({ address, className = '', filter, isHidden, noToggle, o
);
const _onClick = useCallback(
() => onChange && onChange(!value),
() => onChange?.(!value),
[onChange, value]
);
@@ -105,10 +105,8 @@ function ChartHorizBar ({ aspectRatio = 8, className = '', max = 100, showLabels
return (
<div className={`${className} ui--Chart-HorizBar`}>
<Bar
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
data={chartData as any}
height={null as unknown as number}
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
options={chartOptions as any}
width={null as unknown as number}
/>
@@ -88,7 +88,6 @@ function getOptions (options: ChartOptions = {}): DatasetChartOptions<'line'> {
// Re-spread plugins for deep(er) copy
plugins: objectSpread({}, BASE_OPTS.plugins, options.plugins, {
// Same applied to plugins, we may want specific values
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
annotation: objectSpread({}, BASE_OPTS.plugins?.annotation, options.plugins?.annotation),
crosshair: objectSpread({}, BASE_OPTS.plugins?.crosshair, options.plugins?.crosshair),
tooltip: objectSpread({}, BASE_OPTS.plugins?.tooltip, options.plugins?.tooltip)
+1 -1
View File
@@ -17,7 +17,7 @@ interface Props {
function Checkbox ({ className = '', isDisabled, label, onChange, value }: Props): React.ReactElement<Props> {
const _onClick = useCallback(
(): void => {
!isDisabled && onChange && onChange(!value);
!isDisabled && onChange?.(!value);
},
[isDisabled, onChange, value]
);
@@ -27,7 +27,7 @@ function createOptions (blockTime: BN, voteLockingPeriod: BN, t: (key: string, o
text: t('{{value}}x voting balance, locked for {{duration}}x duration{{period}}', {
replace: {
duration,
period: voteLockingPeriod && voteLockingPeriod.gt(BN_ZERO)
period: voteLockingPeriod?.gt(BN_ZERO)
? ` (${calcBlockTime(blockTime, durationBn.mul(voteLockingPeriod), t)[1]})`
: '',
value
+1 -1
View File
@@ -31,7 +31,7 @@ function CopyButton ({ children, className = '', icon = 'copy', label, type, val
const _onCopy = useCallback(
(): void => {
queueAction && queueAction({
queueAction?.({
action: t('clipboard'),
message: t('{{type}} copied', { replace: { type: type || t('value') } }),
status: 'queued'
@@ -43,7 +43,7 @@ function groupLocks (t: (key: string, options?: { replace: Record<string, unknow
return {
maxBalance: bnMax(...locks.map(({ balance }) => balance).filter((b): b is Balance => !!b)),
sorted: locks
.map((info): [Partial<DeriveDemocracyLock>, BN] => [info, info.unlockAt && info.unlockAt.gt(bestNumber) ? info.unlockAt.sub(bestNumber) : BN_ZERO])
.map((info): [Partial<DeriveDemocracyLock>, BN] => [info, info.unlockAt?.gt(bestNumber) ? info.unlockAt.sub(bestNumber) : BN_ZERO])
.sort((a, b) => (a[0].referendumId || BN_ZERO).cmp(b[0].referendumId || BN_ZERO))
.sort((a, b) => a[1].cmp(b[1]))
.sort((a, b) => a[0].isFinished === b[0].isFinished ? 0 : (a[0].isFinished ? -1 : 1))
+3 -3
View File
@@ -42,7 +42,7 @@ interface Props<Option extends DropdownItemProps> {
export type IDropdown<Option extends DropdownItemProps> = React.ComponentType<Props<Option>> & {
Header: React.ComponentType<{ content: React.ReactNode }>;
}
};
function DropdownBase<Option extends DropdownItemProps> ({ allowAdd = false, children, className = '', defaultValue, dropdownClassName, isButton, isDisabled, isError, isFull, isMultiple, label, labelExtra, onAdd, onBlur, onChange, onClose, onSearch, options, placeholder, renderLabel, searchInput, tabIndex, transform, value, withEllipsis, withLabel }: Props<Option>): React.ReactElement<Props<Option>> {
const lastUpdate = useRef<string>('');
@@ -57,7 +57,7 @@ function DropdownBase<Option extends DropdownItemProps> ({ allowAdd = false, chi
setStored(value);
onChange && onChange(
onChange?.(
transform
? transform(value)
: value
@@ -73,7 +73,7 @@ function DropdownBase<Option extends DropdownItemProps> ({ allowAdd = false, chi
const _onAdd = useCallback(
(_: React.SyntheticEvent<HTMLElement>, { value }: DropdownProps): void =>
onAdd && onAdd(value),
onAdd?.(value),
[onAdd]
);
+1 -5
View File
@@ -2,10 +2,6 @@
// SPDX-License-Identifier: Apache-2.0
// Something is seriously going wrong here...
/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-call */
import CodeFlask from 'codeflask';
import React, { useEffect, useRef, useState } from 'react';
@@ -58,7 +54,7 @@ function Editor ({ className = '', code, isValid, onEdit }: Props): React.ReactE
}, []);
useEffect((): void => {
editorRef.current && editorRef.current.updateCode(code);
editorRef.current?.updateCode(code);
}, [code]);
return (
@@ -47,7 +47,7 @@ class ErrorBoundary extends React.Component<Props> {
public override componentDidCatch (error: Error): void {
const { doThrow, onError } = this.props;
onError && onError();
onError?.();
if (doThrow) {
throw error;
+1 -1
View File
@@ -65,7 +65,7 @@ function Expander ({ children, className = '', isHeader, isLeft, isOpen, isPadde
const [isExpanded, toggleExpanded] = useToggle(isOpen, onClick);
const demandChildren = useMemo(
() => isExpanded && renderChildren && renderChildren(),
() => isExpanded && renderChildren?.(),
[isExpanded, renderChildren]
);
@@ -69,7 +69,6 @@ function IdentityIcon ({ className = '', forceIconType, prefix, size = 24, theme
prefix={prefix}
size={size}
// bizinikiwi is valid in pezkuwi-sdk, cast to any for type compatibility
// eslint-disable-next-line @typescript-eslint/no-explicit-any
theme={(forceIconType || (isEthereum ? 'ethereum' : thisTheme)) as any}
value={isCodec(value) ? value.toString() : value}
/>
+8 -8
View File
@@ -97,37 +97,37 @@ function Input ({ autoFocus = false, children, className, defaultValue, icon, in
const [initialValue] = useState(() => defaultValue);
useEffect((): void => {
initialValue && onChange && onChange(initialValue);
initialValue && onChange?.(initialValue);
}, [initialValue, onChange]);
const _onBlur = useCallback(
() => onBlur && onBlur(),
() => onBlur?.(),
[onBlur]
);
const _onChange = useCallback(
({ target }: React.SyntheticEvent<HTMLInputElement>): void =>
onChange && onChange((target as HTMLInputElement).value),
onChange?.((target as HTMLInputElement).value),
[onChange]
);
const _onKeyDown = useCallback(
(event: React.KeyboardEvent<HTMLInputElement>): void =>
onKeyDown && onKeyDown(event),
onKeyDown?.(event),
[onKeyDown]
);
const _onKeyUp = useCallback(
(event: React.KeyboardEvent<HTMLInputElement>): void => {
onKeyUp && onKeyUp(event);
onKeyUp?.(event);
// eslint-disable-next-line deprecation/deprecation
// eslint-disable-next-line @typescript-eslint/no-deprecated
if (onEnter && (event.key === 'Enter' || event.keyCode === 13)) {
(event.target as HTMLInputElement).blur();
isFunction(onEnter) && onEnter();
}
// eslint-disable-next-line deprecation/deprecation
// eslint-disable-next-line @typescript-eslint/no-deprecated
if (onEscape && (event.key === 'Escape' || event.keyCode === 27)) {
(event.target as HTMLInputElement).blur();
onEscape();
@@ -138,7 +138,7 @@ function Input ({ autoFocus = false, children, className, defaultValue, icon, in
const _onPaste = useCallback(
(event: React.ClipboardEvent<HTMLInputElement>): void =>
onPaste && onPaste(event),
onPaste?.(event),
[onPaste]
);
@@ -280,7 +280,7 @@ class InputAddress extends React.PureComponent<Props, State> {
!filter && setLastValue(type, address);
onChange && onChange(
onChange?.(
!!address && (this.hasValue(address) || (type === 'allPlus' && isAddress(address)))
? transformToAccountId(address)
: null
@@ -39,7 +39,7 @@ function InputAddressSimple ({ autoFocus, bytesLength, children, className = '',
: address;
setAddress(output);
onChange && onChange(output);
onChange?.(output);
},
[bytesLength, noConvert, onChange]
);
@@ -29,7 +29,7 @@ function InputCalls ({ className, label, onChange, withLabel }: Props): React.Re
const [value, setValue] = useState<DefinitionCallNamed | null>(() => defaultValue);
useEffect((): void => {
value && onChange && onChange(value);
value && onChange?.(value);
}, [onChange, value]);
const _onMethodChange = useCallback(
@@ -52,7 +52,7 @@ function InputConsts ({ className = '', defaultValue, label, onChange, withLabel
const updated = { meta, method, section };
setValue(updated);
onChange && onChange(updated);
onChange?.(updated);
}
},
[api, onChange, value]
@@ -21,7 +21,7 @@ export default function createOptions (api: ApiPromise, sectionName: string): Dr
.filter((s) => !s.startsWith('$'))
.sort()
.map((value): DropdownOption => {
const method = (section[value] as ConstantCodec);
const method = section[value] as ConstantCodec;
return {
className: 'ui--DropdownLinked-Item',
@@ -38,7 +38,7 @@ function InputExtrinsic ({ className = '', defaultValue, filter, isDisabled, lab
if (value !== newValue) {
// set this via callback, since the we are setting a function (alternatively... we have issues)
setValue((): SubmittableExtrinsicFunction<'promise'> => newValue);
onChange && onChange(newValue);
onChange?.(newValue);
}
},
[onChange, value]
+1 -1
View File
@@ -79,7 +79,7 @@ function InputFile ({ accept, className = '', clearContent, isDisabled, isError
const name = file.name;
const data = convertResult(target.result as ArrayBuffer);
onChange && onChange(data, name);
onChange?.(data, name);
dropRef && setFile({
name,
size: data.length
@@ -168,7 +168,7 @@ function InputNumber ({ autoFocus, bitLength = DEFAULT_BITLENGTH, children, clas
const [isPreKeyDown, setIsPreKeyDown] = useState(false);
useEffect((): void => {
onChange && onChange(isValid ? valueBn : undefined);
onChange?.(isValid ? valueBn : undefined);
}, [isValid, onChange, valueBn]);
const _onChangeWithSi = useCallback(
@@ -33,7 +33,7 @@ function InputRpc ({ className = '', defaultValue, label, onChange, withLabel }:
const [value, setValue] = useState<DefinitionRpcExt>((): DefinitionRpcExt => defaultValue);
useEffect((): void => {
onChange && onChange(value);
onChange?.(value);
}, [onChange, value]);
const _onMethodChange = useCallback(
@@ -22,7 +22,6 @@ interface Props {
function transform (api: ApiPromise, { value }: Props): (method: string) => QueryableStorageEntry<'promise'> {
return function (method: string): QueryableStorageEntry<'promise'> {
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return api.query[value.creator.section]
? api.query[value.creator.section][method] as any
: value;
@@ -35,7 +35,7 @@ function InputStorage ({ className = '', defaultValue, label, onChange, withLabe
if (value !== newValue) {
// set via callback
setValue(() => newValue);
onChange && onChange(newValue);
onChange?.(newValue);
}
},
[onChange, value]
+1 -1
View File
@@ -27,7 +27,7 @@ interface Props {
onClose?: () => void;
openOnFocus?: boolean;
placeholder?: string;
searchInput?: {autoFocus: boolean};
searchInput?: { autoFocus: boolean };
value?: string[];
withLabel?: boolean;
}
@@ -28,7 +28,7 @@ function ModalBase ({ children, className = '', header, onClose, size = 'medium'
const { themeClassName } = useTheme();
const listenKeyboard = useCallback((event: KeyboardEvent) => {
// eslint-disable-next-line deprecation/deprecation
// eslint-disable-next-line @typescript-eslint/no-deprecated
if (event.key === 'Escape' || event.keyCode === 27) {
onClose();
}
+2 -2
View File
@@ -87,12 +87,12 @@ function ParaLink ({ className, id, showLogo = true, type = ParaLinkType.PJS }:
className='chainAlign'
href={`${window.location.origin}${window.location.pathname}?rpc=${encodeURIComponent(value)}`}
>
{typeof text === 'string' ? text : text?.toString()}
{text}
</a>
)}
</>
)
: type === ParaLinkType.PJS ? (typeof text === 'string' ? text : text?.toString()) : null
: type === ParaLinkType.PJS ? text : null
}
</StyledDiv>
);
+2 -2
View File
@@ -10,9 +10,9 @@ export interface ElementPosition {
height: number,
}
export type HorizontalPosition = 'left' | 'middle' | 'right'
export type HorizontalPosition = 'left' | 'middle' | 'right';
export type VerticalPosition = 'top' | 'bottom'
export type VerticalPosition = 'top' | 'bottom';
export interface PopupWindowProps {
className?: string;
+1 -1
View File
@@ -39,7 +39,7 @@ function Row ({ address, buttons, children, className = '', defaultName, details
const [isEditingTags, toggleIsEditingTags] = useToggle();
const _onSaveName = useCallback((): void => {
onSaveName && onSaveName();
onSaveName?.();
toggleIsEditingName();
}, [onSaveName, toggleIsEditingName]);
+2 -2
View File
@@ -39,8 +39,8 @@ function Tags ({ children, className = '', isEditable, isEditing, onChange, onSa
const _onSave = useCallback(
(): void => {
onSave && onSave();
onToggleIsEditing && onToggleIsEditing();
onSave?.();
onToggleIsEditing?.();
},
[onSave, onToggleIsEditing]
);
+1 -1
View File
@@ -20,7 +20,7 @@ interface Props {
function TextArea ({ children, className, isError, isReadOnly, label, onChange, seed, withLabel }: Props): React.ReactElement<Props> {
const _onChange = useCallback(
({ target: { value } }: React.ChangeEvent<HTMLTextAreaElement>): void => {
onChange && onChange(value);
onChange?.(value);
},
[onChange]
);
+1 -1
View File
@@ -24,7 +24,7 @@ function Toggle ({ className = '', isDisabled, isRadio, label, onChange, prevent
event.stopPropagation();
}
onChange && onChange(!value);
onChange?.(!value);
}
},
[isDisabled, onChange, preventDefault, value]
+4 -4
View File
@@ -21,14 +21,14 @@ function TxButton ({ accountId, className = '', extrinsic: propsExtrinsic, icon,
const [isStarted, setIsStarted] = useState(false);
useEffect((): void => {
(isStarted && onStart) && onStart();
isStarted && onStart?.();
}, [isStarted, onStart]);
const _onFailed = useCallback(
(result: Error | SubmittableResult | null): void => {
mountedRef.current && setIsSending(false);
onFailed && onFailed(result);
onFailed?.(result);
},
[onFailed, setIsSending, mountedRef]
);
@@ -37,7 +37,7 @@ function TxButton ({ accountId, className = '', extrinsic: propsExtrinsic, icon,
(result: SubmittableResult): void => {
mountedRef.current && setIsSending(false);
onSuccess && onSuccess(result);
onSuccess?.(result);
},
[onSuccess, setIsSending, mountedRef]
);
@@ -83,7 +83,7 @@ function TxButton ({ accountId, className = '', extrinsic: propsExtrinsic, icon,
});
});
onClick && onClick();
onClick?.();
},
[_onFailed, _onStart, _onSuccess, accountId, isUnsigned, mountedRef, onClick, onFailed, onSuccess, onUpdate, params, propsExtrinsic, queueExtrinsic, tx, withSpinner]
);
-1
View File
@@ -106,5 +106,4 @@ export * from './themes.js';
// external exports
// See https://github.com/import-js/eslint-plugin-import/issues/2556
// eslint-disable-next-line import/export
export * from '@pezkuwi/react-qr';
+1 -1
View File
@@ -18,7 +18,7 @@ declare module 'react-copy-to-clipboard' {
options?: Options;
}
function CopyToClipboard(props: Props): ReactElement;
function CopyToClipboard (props: Props): ReactElement;
export = CopyToClipboard;
}
+1 -1
View File
@@ -96,7 +96,7 @@ export interface Judgement {
registrars: (Registrar | undefined)[];
}
export type UseJudgements = Judgement[]
export type UseJudgements = Judgement[];
export interface TabItem {
alias?: string;