Page MenuHomePhabricator

[ecashaddrjs] Implement typescript linting and add to arclint
ClosedPublic

Authored by bytesofman on Nov 21 2024, 23:43.

Details

Summary

Now that webpack is out, we can properly implement typescript linting. Do this, and add to arc lint.

Test Plan

npm test, arc lint -- modules/ecashaddrjs/**/*

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

update changelog, back out unrelated style pref change, apply correct types, build lint

Tail of the build log:

> ecashaddrjs@1.6.2 build
> tsc


added 577 packages, and audited 578 packages in 4s

66 packages are looking for funding
  run `npm fund` for details

2 vulnerabilities (1 moderate, 1 high)

To address all issues, run:
  npm audit fix

Run `npm audit` for details.
CI not configured to test build.

> ecashaddrjs@1.6.2 test
> mocha --reporter mocha-junit-reporter --reporter-options mochaFile=test_results/ecashaddrjs-junit.xml --reporter-options testsuitesTitle=Ecashaddrjs Unit Tests --reporter-options rootSuiteTitle=Ecashaddrjs


TSError: ⨯ Unable to compile TypeScript:
test/base32.test.ts(10,24): error TS7016: Could not find a declaration file for module 'chai'. '/work/modules/ecashaddrjs/node_modules/chai/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/chai` if it exists or add a new declaration (.d.ts) file containing `declare module 'chai';`

    at createTSError (/work/modules/ecashaddrjs/node_modules/ts-node/src/index.ts:859:12)
    at reportTSError (/work/modules/ecashaddrjs/node_modules/ts-node/src/index.ts:863:19)
    at getOutput (/work/modules/ecashaddrjs/node_modules/ts-node/src/index.ts:1077:36)
    at Object.compile (/work/modules/ecashaddrjs/node_modules/ts-node/src/index.ts:1433:41)
    at Module.m._compile (/work/modules/ecashaddrjs/node_modules/ts-node/src/index.ts:1617:30)
    at module.exports (/usr/lib/node_modules/nyc/node_modules/default-require-extensions/js.js:7:9)
    at /usr/lib/node_modules/nyc/node_modules/append-transform/index.js:64:4
    at require.extensions.<computed> (/work/modules/ecashaddrjs/node_modules/ts-node/src/index.ts:1621:12)
    at Object.<anonymous> (/usr/lib/node_modules/nyc/node_modules/append-transform/index.js:64:4)
    at Module.load (node:internal/modules/cjs/loader:1288:32)
    at Function.Module._load (node:internal/modules/cjs/loader:1104:12)
    at Module.require (node:internal/modules/cjs/loader:1311:19)
    at require (node:internal/modules/helpers:179:18)
    at Object.exports.requireOrImport (/work/modules/ecashaddrjs/node_modules/mocha/lib/nodejs/esm-utils.js:53:16)
    at async Object.exports.loadFilesAsync (/work/modules/ecashaddrjs/node_modules/mocha/lib/nodejs/esm-utils.js:100:20)
    at async singleRun (/work/modules/ecashaddrjs/node_modules/mocha/lib/cli/run-helpers.js:125:3)
    at async Object.exports.handler (/work/modules/ecashaddrjs/node_modules/mocha/lib/cli/run.js:370:5)
----------|---------|----------|---------|---------|-------------------
File      | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
----------|---------|----------|---------|---------|-------------------
All files |       0 |        0 |       0 |       0 |                   
----------|---------|----------|---------|---------|-------------------

##teamcity[blockOpened name='Code Coverage Summary']
##teamcity[buildStatisticValue key='CodeCoverageAbsBCovered' value='0']
##teamcity[buildStatisticValue key='CodeCoverageAbsBTotal' value='0']
##teamcity[buildStatisticValue key='CodeCoverageAbsRCovered' value='0']
##teamcity[buildStatisticValue key='CodeCoverageAbsRTotal' value='0']
##teamcity[buildStatisticValue key='CodeCoverageAbsMCovered' value='0']
##teamcity[buildStatisticValue key='CodeCoverageAbsMTotal' value='0']
##teamcity[buildStatisticValue key='CodeCoverageAbsLCovered' value='0']
##teamcity[buildStatisticValue key='CodeCoverageAbsLTotal' value='0']
##teamcity[blockClosed name='Code Coverage Summary']
mv: cannot stat 'test_results/ecashaddrjs-junit.xml': No such file or directory
Build ecashaddrjs-tests failed with exit code 1

improve clarity of type change on test

Tail of the build log:

> ecashaddrjs@1.6.2 build
> tsc


added 577 packages, and audited 578 packages in 4s

66 packages are looking for funding
  run `npm fund` for details

2 vulnerabilities (1 moderate, 1 high)

To address all issues, run:
  npm audit fix

Run `npm audit` for details.
CI not configured to test build.

> ecashaddrjs@1.6.2 test
> mocha --reporter mocha-junit-reporter --reporter-options mochaFile=test_results/ecashaddrjs-junit.xml --reporter-options testsuitesTitle=Ecashaddrjs Unit Tests --reporter-options rootSuiteTitle=Ecashaddrjs


TSError: ⨯ Unable to compile TypeScript:
test/base32.test.ts(10,24): error TS7016: Could not find a declaration file for module 'chai'. '/work/modules/ecashaddrjs/node_modules/chai/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/chai` if it exists or add a new declaration (.d.ts) file containing `declare module 'chai';`

    at createTSError (/work/modules/ecashaddrjs/node_modules/ts-node/src/index.ts:859:12)
    at reportTSError (/work/modules/ecashaddrjs/node_modules/ts-node/src/index.ts:863:19)
    at getOutput (/work/modules/ecashaddrjs/node_modules/ts-node/src/index.ts:1077:36)
    at Object.compile (/work/modules/ecashaddrjs/node_modules/ts-node/src/index.ts:1433:41)
    at Module.m._compile (/work/modules/ecashaddrjs/node_modules/ts-node/src/index.ts:1617:30)
    at module.exports (/usr/lib/node_modules/nyc/node_modules/default-require-extensions/js.js:7:9)
    at /usr/lib/node_modules/nyc/node_modules/append-transform/index.js:64:4
    at require.extensions.<computed> (/work/modules/ecashaddrjs/node_modules/ts-node/src/index.ts:1621:12)
    at Object.<anonymous> (/usr/lib/node_modules/nyc/node_modules/append-transform/index.js:64:4)
    at Module.load (node:internal/modules/cjs/loader:1288:32)
    at Function.Module._load (node:internal/modules/cjs/loader:1104:12)
    at Module.require (node:internal/modules/cjs/loader:1311:19)
    at require (node:internal/modules/helpers:179:18)
    at Object.exports.requireOrImport (/work/modules/ecashaddrjs/node_modules/mocha/lib/nodejs/esm-utils.js:53:16)
    at async Object.exports.loadFilesAsync (/work/modules/ecashaddrjs/node_modules/mocha/lib/nodejs/esm-utils.js:100:20)
    at async singleRun (/work/modules/ecashaddrjs/node_modules/mocha/lib/cli/run-helpers.js:125:3)
    at async Object.exports.handler (/work/modules/ecashaddrjs/node_modules/mocha/lib/cli/run.js:370:5)
----------|---------|----------|---------|---------|-------------------
File      | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
----------|---------|----------|---------|---------|-------------------
All files |       0 |        0 |       0 |       0 |                   
----------|---------|----------|---------|---------|-------------------

##teamcity[blockOpened name='Code Coverage Summary']
##teamcity[buildStatisticValue key='CodeCoverageAbsBCovered' value='0']
##teamcity[buildStatisticValue key='CodeCoverageAbsBTotal' value='0']
##teamcity[buildStatisticValue key='CodeCoverageAbsRCovered' value='0']
##teamcity[buildStatisticValue key='CodeCoverageAbsRTotal' value='0']
##teamcity[buildStatisticValue key='CodeCoverageAbsMCovered' value='0']
##teamcity[buildStatisticValue key='CodeCoverageAbsMTotal' value='0']
##teamcity[buildStatisticValue key='CodeCoverageAbsLCovered' value='0']
##teamcity[buildStatisticValue key='CodeCoverageAbsLTotal' value='0']
##teamcity[blockClosed name='Code Coverage Summary']
mv: cannot stat 'test_results/ecashaddrjs-junit.xml': No such file or directory
Build ecashaddrjs-tests failed with exit code 1

Failed tests logs:

====== routes.js: "after all" hook for "/blacklist/:tokenId returns expected error if database fails to lookup a valid tokenId".routes.js "after all" hook for "/blacklist/:tokenId returns expected error if database fails to lookup a valid tokenId" ======
Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/work/apps/token-server/src/routes.test.ts)
    at listOnTimeout (node:internal/timers:581:17)
    at processTimers (node:internal/timers:519:7)

Each failure log is accessible here:
routes.js: "after all" hook for "/blacklist/:tokenId returns expected error if database fails to lookup a valid tokenId".routes.js "after all" hook for "/blacklist/:tokenId returns expected error if database fails to lookup a valid tokenId"

Tail of the build log:

> ecashaddrjs@1.6.2 build
> tsc


added 577 packages, and audited 578 packages in 4s

66 packages are looking for funding
  run `npm fund` for details

2 vulnerabilities (1 moderate, 1 high)

To address all issues, run:
  npm audit fix

Run `npm audit` for details.
CI not configured to test build.

> ecashaddrjs@1.6.2 test
> mocha --reporter mocha-junit-reporter --reporter-options mochaFile=test_results/ecashaddrjs-junit.xml --reporter-options testsuitesTitle=Ecashaddrjs Unit Tests --reporter-options rootSuiteTitle=Ecashaddrjs


TSError: ⨯ Unable to compile TypeScript:
test/base32.test.ts(10,24): error TS7016: Could not find a declaration file for module 'chai'. '/work/modules/ecashaddrjs/node_modules/chai/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/chai` if it exists or add a new declaration (.d.ts) file containing `declare module 'chai';`

    at createTSError (/work/modules/ecashaddrjs/node_modules/ts-node/src/index.ts:859:12)
    at reportTSError (/work/modules/ecashaddrjs/node_modules/ts-node/src/index.ts:863:19)
    at getOutput (/work/modules/ecashaddrjs/node_modules/ts-node/src/index.ts:1077:36)
    at Object.compile (/work/modules/ecashaddrjs/node_modules/ts-node/src/index.ts:1433:41)
    at Module.m._compile (/work/modules/ecashaddrjs/node_modules/ts-node/src/index.ts:1617:30)
    at module.exports (/usr/lib/node_modules/nyc/node_modules/default-require-extensions/js.js:7:9)
    at /usr/lib/node_modules/nyc/node_modules/append-transform/index.js:64:4
    at require.extensions.<computed> (/work/modules/ecashaddrjs/node_modules/ts-node/src/index.ts:1621:12)
    at Object.<anonymous> (/usr/lib/node_modules/nyc/node_modules/append-transform/index.js:64:4)
    at Module.load (node:internal/modules/cjs/loader:1288:32)
    at Function.Module._load (node:internal/modules/cjs/loader:1104:12)
    at Module.require (node:internal/modules/cjs/loader:1311:19)
    at require (node:internal/modules/helpers:179:18)
    at Object.exports.requireOrImport (/work/modules/ecashaddrjs/node_modules/mocha/lib/nodejs/esm-utils.js:53:16)
    at async Object.exports.loadFilesAsync (/work/modules/ecashaddrjs/node_modules/mocha/lib/nodejs/esm-utils.js:100:20)
    at async singleRun (/work/modules/ecashaddrjs/node_modules/mocha/lib/cli/run-helpers.js:125:3)
    at async Object.exports.handler (/work/modules/ecashaddrjs/node_modules/mocha/lib/cli/run.js:370:5)
----------|---------|----------|---------|---------|-------------------
File      | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
----------|---------|----------|---------|---------|-------------------
All files |       0 |        0 |       0 |       0 |                   
----------|---------|----------|---------|---------|-------------------

##teamcity[blockOpened name='Code Coverage Summary']
##teamcity[buildStatisticValue key='CodeCoverageAbsBCovered' value='0']
##teamcity[buildStatisticValue key='CodeCoverageAbsBTotal' value='0']
##teamcity[buildStatisticValue key='CodeCoverageAbsRCovered' value='0']
##teamcity[buildStatisticValue key='CodeCoverageAbsRTotal' value='0']
##teamcity[buildStatisticValue key='CodeCoverageAbsMCovered' value='0']
##teamcity[buildStatisticValue key='CodeCoverageAbsMTotal' value='0']
##teamcity[buildStatisticValue key='CodeCoverageAbsLCovered' value='0']
##teamcity[buildStatisticValue key='CodeCoverageAbsLTotal' value='0']
##teamcity[blockClosed name='Code Coverage Summary']
mv: cannot stat 'test_results/ecashaddrjs-junit.xml': No such file or directory
Build ecashaddrjs-tests failed with exit code 1

Tail of the build log:

  File "/work/abc-ci-builds/ecash-lib-integration-tests/test/functional/test_runner.py", line 362, in main
    os.makedirs(tmpdir)
  File "<frozen os>", line 225, in makedirs
FileExistsError: [Errno 17] File exists: '/work/abc-ci-builds/ecash-lib-integration-tests/test/tmp/test_runner_₿₵_🏃_20241122_000838'
Test runner completed with code 1
----------------------------|---------|----------|---------|---------|------------------------------
File                        | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s            
----------------------------|---------|----------|---------|---------|------------------------------
All files                   |   64.33 |     53.1 |   64.35 |   64.32 |                              
 ecash-lib                  |       0 |        0 |       0 |       0 |                              
  eslint.config.js          |       0 |        0 |       0 |       0 |                              
 ecash-lib/src              |   75.79 |    56.13 |   76.25 |   75.47 |                              
  consts.ts                 |       0 |      100 |     100 |       0 | 6-8                          
  ecc.ts                    |   57.14 |    83.33 |      40 |   57.14 | 23-31                        
  hash.ts                   |   88.88 |    83.33 |      80 |   88.88 | 14                           
  index.ts                  |       0 |        0 |       0 |       0 |                              
  indexBrowser.ts           |       0 |        0 |       0 |       0 |                              
  indexNodeJs.ts            |       0 |        0 |       0 |       0 |                              
  initBrowser.ts            |       0 |      100 |       0 |       0 | 11-13                        
  initNodeJs.ts             |     100 |      100 |     100 |     100 |                              
  op.ts                     |      40 |    44.44 |   66.66 |      40 | ...4,107,109,117-122,133-161 
  opcode.ts                 |     100 |    83.33 |     100 |     100 | 1                            
  script.ts                 |   52.63 |    38.09 |      60 |    50.9 | ...4-135,146,156,166,188-199 
  sigHashType.ts            |   77.77 |       44 |   85.71 |   77.77 | 26-38                        
  tx.ts                     |   93.47 |    79.16 |    90.9 |   93.18 | 123-125                      
  txBuilder.ts              |   80.89 |    59.25 |   84.61 |   80.23 | ...1,154,173-178,183,236-240 
  unsignedTx.ts             |      75 |    57.14 |   85.71 |    75.3 | ...3,151,159,184,192,198-201 
 ecash-lib/src/ffi          |   28.26 |    15.94 |   16.98 |   28.98 |                              
  ecash_lib_wasm_browser.js |       0 |        0 |       0 |       0 | 3-336                        
  ecash_lib_wasm_nodejs.js  |    61.9 |       55 |   39.13 |   62.75 | ...1,197-215,237,250-251,255 
 ecash-lib/src/io           |   59.55 |    60.29 |   70.58 |   58.77 |                              
  bytes.ts                  |     7.4 |    71.42 |    12.5 |     7.4 | 13-64                        
  hex.ts                    |   82.05 |     62.5 |      80 |   82.35 | 41-45,50,58                  
  int.ts                    |       0 |        0 |       0 |       0 |                              
  str.ts                    |   85.71 |    83.33 |   66.66 |   85.71 | 15                           
  varsize.ts                |      32 |    36.36 |   66.66 |      32 | 14-24,40-47                  
  writer.ts                 |       0 |        0 |       0 |       0 |                              
  writerbytes.ts            |   83.33 |    68.42 |     100 |   83.33 | 33,43,53,63,79               
  writerlength.ts           |     100 |    83.33 |     100 |     100 | 1                            
 ecash-lib/src/test         |   89.02 |    54.16 |   89.47 |   89.47 |                              
  testRunner.ts             |   89.02 |    54.16 |   89.47 |   89.47 | 73-75,88-89,112,123,166      
 ecash-lib/src/token        |   87.15 |    72.85 |   93.33 |   87.07 |                              
  alp.ts                    |   82.92 |    89.47 |   83.33 |   82.92 | 110-123,142                  
  common.ts                 |     100 |    83.33 |     100 |     100 | 1                            
  empp.ts                   |    92.3 |       75 |     100 |   91.66 | 12                           
  slp.ts                    |   89.74 |    62.16 |     100 |   89.74 | ...9,161,167,175,178,197,202 
----------------------------|---------|----------|---------|---------|------------------------------

##teamcity[blockOpened name='Code Coverage Summary']
##teamcity[buildStatisticValue key='CodeCoverageAbsBCovered' value='808']
##teamcity[buildStatisticValue key='CodeCoverageAbsBTotal' value='1256']
##teamcity[buildStatisticValue key='CodeCoverageAbsRCovered' value='248']
##teamcity[buildStatisticValue key='CodeCoverageAbsRTotal' value='467']
##teamcity[buildStatisticValue key='CodeCoverageAbsMCovered' value='139']
##teamcity[buildStatisticValue key='CodeCoverageAbsMTotal' value='216']
##teamcity[buildStatisticValue key='CodeCoverageAbsLCovered' value='788']
##teamcity[buildStatisticValue key='CodeCoverageAbsLTotal' value='1225']
##teamcity[blockClosed name='Code Coverage Summary']
mv: cannot stat 'test_results/ecash-lib-integration-tests-junit.xml': No such file or directory
Build ecash-lib-integration-tests failed with exit code 1
This revision is now accepted and ready to land.Nov 22 2024, 07:18