Skip to content

Commit fe0bd9d

Browse files
committed
Lint: add TS rule to enforce declaring Uint8Array<ArrayBuffer>
Following incompatible interface change between ArrayBuffer and ArrayBufferLike (enforced in TS v5.9)
1 parent 59bda32 commit fe0bd9d

4 files changed

Lines changed: 21 additions & 3 deletions

File tree

.eslintrc.cjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ module.exports = {
2222
'@typescript-eslint',
2323
'chai-friendly',
2424
'import',
25-
'unicorn'
25+
'unicorn',
26+
'@protontech/enforce-uint8array-arraybuffer'
2627
],
2728

2829
'settings': {
@@ -139,6 +140,7 @@ module.exports = {
139140
'@typescript-eslint/no-unused-expressions': 0,
140141
'chai-friendly/no-unused-expressions': [2, { 'allowShortCircuit': true }],
141142
'unicorn/switch-case-braces': ['error', 'avoid'],
143+
'@protontech/enforce-uint8array-arraybuffer/enforce-uint8array-arraybuffer': 'error',
142144

143145
// Custom warnings:
144146
'no-console': 1

package-lock.json

Lines changed: 16 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
"@openpgp/seek-bzip": "^1.0.5-git",
7373
"@openpgp/tweetnacl": "^1.0.4-1",
7474
"@openpgp/web-stream-tools": "~0.1.3",
75+
"@protontech/eslint-plugin-enforce-uint8array-arraybuffer": "^1.0.0",
7576
"@rollup/plugin-alias": "^5.1.1",
7677
"@rollup/plugin-commonjs": "^25.0.8",
7778
"@rollup/plugin-node-resolve": "^15.3.0",

src/crypto/biginteger.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
const _0n = BigInt(0);
44
const _1n = BigInt(1);
55

6-
export function uint8ArrayToBigInt(bytes: Uint8Array) {
6+
export function uint8ArrayToBigInt(bytes: Uint8Array<ArrayBuffer>) {
77
const hexAlphabet = '0123456789ABCDEF';
88
let s = '';
99
bytes.forEach(v => {

0 commit comments

Comments
 (0)