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

- @pezkuwi/dev, dev-test, dev-ts ^0.86.3
- rethrown errors carry the original as `cause` (hw-ledger, address decode)
- optional chain in isEthereumAddress, includes() in bip39 validation
- logger calls the lazy formatter through a typed function
- x-global: an assertion to the type the value already has removed,
  with the comment and directive that explained it
- type-only re-exports of modules that emit no JavaScript
- disable directives renamed for the new rule names, or removed where
  the rule no longer reports
This commit is contained in:
Satoshi Qazi Muhammed authored and SatoshiQaziMuhammed committed 2026-10-09 16:32:28 +04:00
1 parent 82d6a12c24
commit c46ce1a9e6
23 files changed
+2630 -3264

No files matched your search

+1 -1
View File
@@ -36,7 +36,7 @@
"test:one": "pezkuwi-dev-run-test --env browser"
},
"devDependencies": {
"@pezkuwi/dev": "^0.85.12",
"@pezkuwi/dev": "^0.86.3",
"@types/node": "^22.7.5"
},
"resolutions": {
+2 -2
View File
@@ -37,10 +37,10 @@ async function wrapError <T extends WrappedResult> (promise: Promise<T>): Promis
// The response code use to be part of the result, but with the latest breaking changes from 0.42.x
// the interface and it's types have completely changed.
if ((e as ResponseError).returnCode) {
throw new Error(`${(e as ResponseError).returnCode}: ${(e as ResponseError).errorMessage}`);
throw new Error(`${(e as ResponseError).returnCode}: ${(e as ResponseError).errorMessage}`, { cause: e });
}
throw new Error((e as Error).message);
throw new Error((e as Error).message, { cause: e });
}
return result;
+1 -1
View File
@@ -3,6 +3,6 @@
// This is necessary to ensure users still have access to class Ledger even though its deprecated.
//
// eslint-disable-next-line deprecation/deprecation
// eslint-disable-next-line @typescript-eslint/no-deprecated
export { Ledger } from './Ledger.js';
export { LedgerGeneric } from './LedgerGeneric.js';
+1 -1
View File
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
// all external
// eslint-disable-next-line deprecation/deprecation
// eslint-disable-next-line @typescript-eslint/no-deprecated
export { decodeAddress, encodeAddress, setSS58Format } from '@pezkuwi/util-crypto';
// all named
+1 -1
View File
@@ -49,7 +49,7 @@ describe('keypair', (): void => {
});
it('adds from a mnemonic, with correct ss58', (): void => {
// eslint-disable-next-line deprecation/deprecation
// eslint-disable-next-line @typescript-eslint/no-deprecated
setSS58Format(20); // this would not be used
keyring.setSS58Format(2); // this would be used
+2 -2
View File
@@ -107,12 +107,12 @@ describe('pair', (): void => {
it('allows encoding of address with different prefixes', (): void => {
expect(keyring.alice.address).toEqual('5GoKvZWG5ZPYL1WUovuHW3zJBWBP5eT8CbqjdRY4Q6iMaQua');
// eslint-disable-next-line deprecation/deprecation
// eslint-disable-next-line @typescript-eslint/no-deprecated
setSS58Format(255);
expect(keyring.alice.address).toEqual('yGHU8YKprxHbHdEv7oUK4rzMZXtsdhcXVG2CAMyC9WhzhjH2k');
// eslint-disable-next-line deprecation/deprecation
// eslint-disable-next-line @typescript-eslint/no-deprecated
setSS58Format(42);
});
+1 -1
View File
@@ -36,6 +36,6 @@ export function decodeAddress (encoded?: string | Uint8Array | null, ignoreCheck
return decoded.slice(ss58Length, endPos);
} catch (error) {
throw new Error(`Decoding ${encoded}: ${(error as Error).message}`);
throw new Error(`Decoding ${encoded}: ${(error as Error).message}`, { cause: error });
}
}
+1 -1
View File
@@ -17,5 +17,5 @@ export { createKeyMulti } from './keyMulti.js';
export { sortAddresses } from './sort.js';
export { validateAddress } from './validate.js';
// eslint-disable-next-line deprecation/deprecation
// eslint-disable-next-line @typescript-eslint/no-deprecated
export { setSS58Format } from './setSS58Format.js';
@@ -7,7 +7,7 @@ import { encodeAddress, setSS58Format } from './index.js';
describe('setSS58Format', (): void => {
beforeEach((): void => {
// eslint-disable-next-line deprecation/deprecation
// eslint-disable-next-line @typescript-eslint/no-deprecated
setSS58Format(2);
});
@@ -6,7 +6,7 @@ import { isHex } from '@pezkuwi/util';
import { isEthereumChecksum } from './isChecksum.js';
export function isEthereumAddress (address?: string): boolean {
if (!address || address.length !== 42 || !isHex(address)) {
if (address?.length !== 42 || !isHex(address)) {
return false;
} else if (/^(0x)?[0-9a-f]{40}$/.test(address) || /^(0x)?[0-9A-F]{40}$/.test(address)) {
return true;
@@ -46,7 +46,7 @@ describe('bip39', (): void => {
split
).toHaveLength(length);
expect(
split.some((w) => words.indexOf(w) === -1)
split.some((w) => !words.includes(w))
).toEqual(false);
};
+1 -1
View File
@@ -1,7 +1,7 @@
// Copyright 2017-2026 @pezkuwi/util-crypto authors & contributors
// SPDX-License-Identifier: Apache-2.0
/* eslint-disable brace-style,camelcase,comma-spacing,curly,one-var,padding-line-between-statements,space-infix-ops */
/* eslint-disable @stylistic/brace-style, camelcase, @stylistic/comma-spacing, curly, one-var, @stylistic/padding-line-between-statements, @stylistic/space-infix-ops */
// Adapted from https://github.com/dchest/tweetnacl-js/blob/6a9594a35a27f9c723c5f1c107e376d1c65c23b3/nacl.js
//
@@ -27,7 +27,7 @@ export function secp256k1Recover (msgHash: string | Uint8Array, signature: strin
// time in @noble/curves 1.9 but not in its types (secp256k1 is still
// typed as the legacy CurveFn); 2.x has it typed but is ESM-only, which
// would break this package's CommonJS build. Kept until then.
// eslint-disable-next-line deprecation/deprecation
// eslint-disable-next-line @typescript-eslint/no-deprecated
.recoverPublicKey(msg)
.toBytes();
+2 -2
View File
@@ -1,8 +1,8 @@
// Copyright 2017-2026 @pezkuwi/util-crypto authors & contributors
// SPDX-License-Identifier: Apache-2.0
export * from './address/types.js';
export * from './json/types.js';
export type * from './address/types.js';
export type * from './json/types.js';
export interface Keypair {
/** The publicKey for this pair */
+1 -1
View File
@@ -16,7 +16,7 @@ class ExtString extends String {
// NOTE Hex value outputs created via online conversion tool:
// https://www.h-schmidt.net/FloatConverter/IEEE754.html
// eslint-disable-next-line @typescript-eslint/ban-types
// eslint-disable-next-line @typescript-eslint/no-wrapper-object-types
const TESTS: [isLe: boolean | undefined, bitLength: 32 | 64 | undefined, input: String | string | number | Number, output: string][] = [
[undefined, undefined, +0.0, '0x00000000'],
[undefined, undefined, -0.0, '0x00000080'],
+1 -1
View File
@@ -11,7 +11,7 @@ interface Options {
* @description Converts a float into a U8a representation (While we don't use BE in SCALE
* we still allow for either representation, although, as elsewhere, isLe is default)
*/
// eslint-disable-next-line @typescript-eslint/ban-types
// eslint-disable-next-line @typescript-eslint/no-wrapper-object-types
export function floatToU8a (value: String | string | number | Number = 0.0, { bitLength = 32, isLe = true }: Options = {}): Uint8Array {
if (bitLength !== 32 && bitLength !== 64) {
throw new Error('Invalid bitLength provided, expected 32 or 64');
+1 -1
View File
@@ -1,7 +1,7 @@
// Copyright 2017-2026 @pezkuwi/util authors & contributors
// SPDX-License-Identifier: Apache-2.0
// eslint-disable-next-line @typescript-eslint/ban-types
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
type FnType = Function;
/**
+1 -1
View File
@@ -15,7 +15,7 @@
* console.log('isInstanceOf', isInstanceOf(new Array(0), Array)); // => true
* ```
*/
// eslint-disable-next-line @typescript-eslint/ban-types
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
export function isInstanceOf (value: unknown, Clazz: Function): boolean {
return (
((value && (value as Record<string, unknown>).constructor) === Clazz) ||
-1
View File
@@ -15,7 +15,6 @@
* console.log('isUndefined', isUndefined(void(0))); // => true
* ```
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function isUndefined (value?: unknown): value is undefined {
return value === undefined;
}
+1 -1
View File
@@ -67,7 +67,7 @@ function formatWithLength (maxLength: number): (v: unknown) => unknown {
function apply (log: LogType, type: string, values: unknown[], maxSize = -1): void {
if (values.length === 1 && isFunction(values[0])) {
const fnResult = values[0]() as unknown;
const fnResult = (values[0] as () => unknown)();
return apply(log, type, Array.isArray(fnResult) ? fnResult : [fnResult], maxSize);
}
+2 -2
View File
@@ -62,9 +62,9 @@ export interface Time {
export type Memoized<F> = F & {
unmemoize: (...args: unknown[]) => void;
}
};
// eslint-disable-next-line @typescript-eslint/ban-types
// eslint-disable-next-line @typescript-eslint/no-wrapper-object-types
export type AnyString = string | String;
export type HexDigit = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | 'a' | 'b' | 'c' | 'd' | 'e' | 'f';
+1 -5
View File
@@ -48,13 +48,9 @@ export const xglobal = /*#__PURE__*/ (
* Extracts a known global from the environment, applying a fallback if not found
*/
export function extractGlobal <N extends GlobalNames, T extends GlobalType<N>> (name: N, fallback: unknown): T {
// Not quite sure why this is here - snuck in with TS 4.7.2 with no real idea
// (as of now) as to why this looks like an "any" when we do cast it to a T
//
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return typeof xglobal[name] === 'undefined'
? fallback as T
: xglobal[name] as T;
: xglobal[name];
}
/**
+2605 -3234
View File
File diff suppressed because it is too large. Load diff