diff --git a/.eslintrc.json b/.eslintrc.json index 7b9c821..fa72280 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -15,6 +15,7 @@ "@typescript-eslint" ], "rules": { - "indent": ["error", 2, { "SwitchCase": 1 }] + "indent": ["error", 2, { "SwitchCase": 1 }], + "@typescript-eslint/no-explicit-any": "off" } } \ No newline at end of file diff --git a/src/cmds/cns-cmds/auction-cmds/bid-cmds/reveal.ts b/src/cmds/cns-cmds/auction-cmds/bid-cmds/reveal.ts index 652f103..9017a38 100644 --- a/src/cmds/cns-cmds/auction-cmds/bid-cmds/reveal.ts +++ b/src/cmds/cns-cmds/auction-cmds/bid-cmds/reveal.ts @@ -28,7 +28,7 @@ export const handler = async (argv: Arguments) => { const reveal = fs.readFileSync(path.resolve(filePath)); const result = await registry.revealBid({ auctionId, reveal: reveal.toString('hex') }, privateKey, fee); - const success = `{"success":${result.code == 0}}`; + const success = `{"success":${result.code === 0}}`; txOutput(result, success, argv.output, argv.verbose); }; diff --git a/src/cmds/cns-cmds/authority-cmds/bond-cmds/set.ts b/src/cmds/cns-cmds/authority-cmds/bond-cmds/set.ts index 31fb0bc..c869659 100644 --- a/src/cmds/cns-cmds/authority-cmds/bond-cmds/set.ts +++ b/src/cmds/cns-cmds/authority-cmds/bond-cmds/set.ts @@ -24,7 +24,7 @@ export const handler = async (argv: Arguments) => { const registry = new Registry(gqlEndpoint, restEndpoint, chainId); const fee = getGasAndFees(argv, cnsConfig); const result = await registry.setAuthorityBond({ name, bondId }, privateKey, fee); - const success = `{"success":${result.code == 0}}`; + const success = `{"success":${result.code === 0}}`; txOutput(result, success, argv.output, argv.verbose); }; diff --git a/src/cmds/cns-cmds/authority-cmds/reserve.ts b/src/cmds/cns-cmds/authority-cmds/reserve.ts index c81e174..cd228bf 100644 --- a/src/cmds/cns-cmds/authority-cmds/reserve.ts +++ b/src/cmds/cns-cmds/authority-cmds/reserve.ts @@ -31,6 +31,6 @@ export const handler = async (argv: Arguments) => { const fee = getGasAndFees(argv, cnsConfig); const result = await registry.reserveAuthority({ name, owner }, privateKey, fee); - const success = `{"success":${result.code == 0}}`; + const success = `{"success":${result.code === 0}}`; txOutput(result, success, argv.output, argv.verbose); }; diff --git a/src/cmds/cns-cmds/bond-cmds/associate.ts b/src/cmds/cns-cmds/bond-cmds/associate.ts index 17c1f9f..bc708a6 100644 --- a/src/cmds/cns-cmds/bond-cmds/associate.ts +++ b/src/cmds/cns-cmds/bond-cmds/associate.ts @@ -30,6 +30,6 @@ export const handler = async (argv: Arguments) => { const registry = new Registry(gqlEndpoint, restEndpoint, chainId); const fee = getGasAndFees(argv, cnsConfig); const result = await registry.associateBond({ recordId: id, bondId }, privateKey, fee); - const success = `{"success":${result.code == 0}}`; + const success = `{"success":${result.code === 0}}`; txOutput(result, success, argv.output, argv.verbose); }; diff --git a/src/cmds/cns-cmds/bond-cmds/cancel.ts b/src/cmds/cns-cmds/bond-cmds/cancel.ts index 7447b1a..823c064 100644 --- a/src/cmds/cns-cmds/bond-cmds/cancel.ts +++ b/src/cmds/cns-cmds/bond-cmds/cancel.ts @@ -22,6 +22,6 @@ export const handler = async (argv: Arguments) => { const registry = new Registry(gqlEndpoint, restEndpoint, chainId); const fee = getGasAndFees(argv, cnsConfig); const result = await registry.cancelBond({ id }, privateKey, fee); - const success = `{"success":${result.code == 0}}`; + const success = `{"success":${result.code === 0}}`; txOutput(result, success, argv.output, argv.verbose); }; diff --git a/src/cmds/cns-cmds/bond-cmds/create.ts b/src/cmds/cns-cmds/bond-cmds/create.ts index 95d35d8..fe237dc 100644 --- a/src/cmds/cns-cmds/bond-cmds/create.ts +++ b/src/cmds/cns-cmds/bond-cmds/create.ts @@ -18,7 +18,7 @@ export const builder = { }; export const handler = async (argv: Arguments) => { - const { config, verbose } = argv; + const { config } = argv; const denom = argv.type as string; const amount = argv.quantity as string; diff --git a/src/cmds/cns-cmds/bond-cmds/dissociate.ts b/src/cmds/cns-cmds/bond-cmds/dissociate.ts index 7f8b7f2..7b25709 100644 --- a/src/cmds/cns-cmds/bond-cmds/dissociate.ts +++ b/src/cmds/cns-cmds/bond-cmds/dissociate.ts @@ -22,6 +22,6 @@ export const handler = async (argv: Arguments) => { const registry = new Registry(gqlEndpoint, restEndpoint, chainId); const fee = getGasAndFees(argv, cnsConfig); const result = await registry.dissociateBond({ recordId: id }, privateKey, fee); - const success = `{"success":${result.code == 0}}`; + const success = `{"success":${result.code === 0}}`; txOutput(result, success, argv.output, argv.verbose); }; diff --git a/src/cmds/cns-cmds/bond-cmds/records-cmds/dissociate.ts b/src/cmds/cns-cmds/bond-cmds/records-cmds/dissociate.ts index aeeaa64..83b2bb7 100644 --- a/src/cmds/cns-cmds/bond-cmds/records-cmds/dissociate.ts +++ b/src/cmds/cns-cmds/bond-cmds/records-cmds/dissociate.ts @@ -28,6 +28,6 @@ export const handler = async (argv: Arguments) => { const registry = new Registry(gqlEndpoint, restEndpoint, chainId); const fee = getGasAndFees(argv, cnsConfig); const result = await registry.dissociateRecords({ bondId }, privateKey, fee); - const success = `{"success":${result.code == 0}}`; + const success = `{"success":${result.code === 0}}`; txOutput(result, success, argv.output, argv.verbose); }; diff --git a/src/cmds/cns-cmds/bond-cmds/records-cmds/reassociate.ts b/src/cmds/cns-cmds/bond-cmds/records-cmds/reassociate.ts index 5a2f509..5f08a1d 100644 --- a/src/cmds/cns-cmds/bond-cmds/records-cmds/reassociate.ts +++ b/src/cmds/cns-cmds/bond-cmds/records-cmds/reassociate.ts @@ -33,6 +33,6 @@ export const handler = async (argv: Arguments) => { const registry = new Registry(gqlEndpoint, restEndpoint, chainId); const fee = getGasAndFees(argv, cnsConfig); const result = await registry.reassociateRecords({ oldBondId, newBondId }, privateKey, fee); - const success = `{"success":${result.code == 0}}`; + const success = `{"success":${result.code === 0}}`; txOutput(result, success, argv.output, argv.verbose); }; diff --git a/src/cmds/cns-cmds/bond-cmds/refill.ts b/src/cmds/cns-cmds/bond-cmds/refill.ts index 14a804c..dab83f1 100644 --- a/src/cmds/cns-cmds/bond-cmds/refill.ts +++ b/src/cmds/cns-cmds/bond-cmds/refill.ts @@ -3,7 +3,6 @@ import assert from 'assert'; import { Registry } from '@cerc-io/laconic-sdk'; import { getConfig, getConnectionInfo, getGasAndFees, txOutput } from '../../../util'; -import { isNil } from 'lodash'; export const command = 'refill'; @@ -37,6 +36,6 @@ export const handler = async (argv: Arguments) => { const registry = new Registry(gqlEndpoint, restEndpoint, chainId); const fee = getGasAndFees(argv, cnsConfig); const result = await registry.refillBond({ id, denom, amount }, privateKey, fee); - const success = `{"success":${result.code == 0}}`; + const success = `{"success":${result.code === 0}}`; txOutput(result, success, argv.output, argv.verbose); }; diff --git a/src/cmds/cns-cmds/bond-cmds/withdraw.ts b/src/cmds/cns-cmds/bond-cmds/withdraw.ts index 61eadc2..d4a5ed9 100644 --- a/src/cmds/cns-cmds/bond-cmds/withdraw.ts +++ b/src/cmds/cns-cmds/bond-cmds/withdraw.ts @@ -36,6 +36,6 @@ export const handler = async (argv: Arguments) => { const registry = new Registry(gqlEndpoint, restEndpoint, chainId); const fee = getGasAndFees(argv, cnsConfig); const result = await registry.withdrawBond({ id, denom, amount }, privateKey, fee); - const success = `{"success":${result.code == 0}}`; + const success = `{"success":${result.code === 0}}`; txOutput(result, success, argv.output, argv.verbose); }; diff --git a/src/cmds/cns-cmds/name-cmds/delete.ts b/src/cmds/cns-cmds/name-cmds/delete.ts index 78d1af1..4fbbc67 100644 --- a/src/cmds/cns-cmds/name-cmds/delete.ts +++ b/src/cmds/cns-cmds/name-cmds/delete.ts @@ -23,6 +23,6 @@ export const handler = async (argv: Arguments) => { const fee = getGasAndFees(argv, cnsConfig); const result = await registry.deleteName({ crn: name }, privateKey, fee); - const success = `{"success":${result.code == 0}}`; + const success = `{"success":${result.code === 0}}`; txOutput(result, success, argv.output, argv.verbose); }; diff --git a/src/cmds/cns-cmds/name-cmds/set.ts b/src/cmds/cns-cmds/name-cmds/set.ts index ddaea05..1713611 100644 --- a/src/cmds/cns-cmds/name-cmds/set.ts +++ b/src/cmds/cns-cmds/name-cmds/set.ts @@ -25,6 +25,6 @@ export const handler = async (argv: Arguments) => { const fee = getGasAndFees(argv, cnsConfig); const result = await registry.setName({ crn: name, cid: id }, privateKey, fee); - const success = `{"success":${result.code == 0}}`; + const success = `{"success":${result.code === 0}}`; txOutput(result, success, argv.output, argv.verbose); }; diff --git a/src/cmds/cns-cmds/record-cmds/publish.ts b/src/cmds/cns-cmds/record-cmds/publish.ts index 7282cff..fa7e333 100644 --- a/src/cmds/cns-cmds/record-cmds/publish.ts +++ b/src/cmds/cns-cmds/record-cmds/publish.ts @@ -1,6 +1,5 @@ import { Arguments } from 'yargs'; import assert from 'assert'; -import path from 'path'; import yaml from 'js-yaml'; import fs from 'fs'; import { Registry } from '@cerc-io/laconic-sdk'; @@ -18,7 +17,7 @@ export const builder = { }; export const handler = async (argv: Arguments) => { - const { txKey, filename, verbose, config } = argv; + const { txKey, filename, config } = argv; const { services: { cns: cnsConfig } } = getConfig(config as string); const { restEndpoint, gqlEndpoint, userKey, bondId, chainId } = getConnectionInfo(argv, cnsConfig); diff --git a/src/index.ts b/src/index.ts index eff7e67..9b5b473 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,7 @@ import yargs from 'yargs/yargs'; import { hideBin } from 'yargs/helpers'; +// eslint-disable-next-line no-unused-expressions yargs(hideBin(process.argv)) .options({ verbose: { diff --git a/src/util/fees.ts b/src/util/fees.ts index 15ac09c..045b5c3 100644 --- a/src/util/fees.ts +++ b/src/util/fees.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ import assert from 'assert'; import { Arguments } from 'yargs'; diff --git a/src/util/output.ts b/src/util/output.ts index c66e0c6..7b1603a 100644 --- a/src/util/output.ts +++ b/src/util/output.ts @@ -1,6 +1,6 @@ export const txOutput = (result:any, msg:string, output:unknown, verbose:unknown) => { - if (output == 'json') { + if (output === 'json') { console.log(verbose ? JSON.parse(JSON.stringify(result)) : JSON.parse(msg)); } else { console.log(verbose ? JSON.stringify(result, undefined, 2) : msg); @@ -8,7 +8,7 @@ export const txOutput = (result:any, msg:string, output:unknown, verbose:unknown }; export const queryOutput = (result: any, output: unknown) => { - if (output == 'json') { + if (output === 'json') { console.log(JSON.parse(JSON.stringify(result))); } else { console.log(JSON.stringify(result, (key, value) => { diff --git a/test/helpers.ts b/test/helpers.ts index c0a3684..30e4341 100644 --- a/test/helpers.ts +++ b/test/helpers.ts @@ -117,5 +117,5 @@ export function getBidObj(params: { bidder: string, status?: string }): any { } export async function delay (ms: number): Promise { - return new Promise(res => setTimeout(res, ms)); + return new Promise((resolve) => setTimeout(resolve, ms)); }