diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 702bdbb..12cb927 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -13,6 +13,15 @@ module.exports = { ], // Subpath exports support is missing: https://github.com/import-js/eslint-plugin-import/issues/1810 '@exodus/import/no-unresolved': [2, { ignore: ['@exodus/bytes/\\w+'] }], + // Hermes (and some other targets we ship to) does not support BigInt literal syntax. + 'no-restricted-syntax': [ + 'error', + { + selector: 'Literal[bigint]', + message: + 'BigInt literals (e.g. 1n) are not supported by all targets we ship to (e.g. Hermes); use BigInt(1) instead.', + }, + ], 'one-var': 'off', 'unicorn/no-for-loop': 'off', 'unicorn/no-new-array': 'off', @@ -28,5 +37,12 @@ module.exports = { 'unicorn/no-useless-spread': 'off', // test vectors grouping }, }, + { + // Tests and benchmarks are not shipped, so BigInt literals are fine in fixtures. + files: ['**/{tests,benchmarks}/**/*.?([cm])js'], + rules: { + 'no-restricted-syntax': 'off', + }, + }, ], } diff --git a/base58.js b/base58.js index 669a428..d487d9d 100644 --- a/base58.js +++ b/base58.js @@ -162,7 +162,7 @@ function fromBase58core(str, alphabet, codes, format = 'uint8') { while (x) { let y = Number(x & _0xffffffffn) - x >>= 32n + x >>= _32n res[--at] = y & 0xff y >>>= 8 if (!x && !y) break