[WIP] Setup lint #1

Closed
prathamesh wants to merge 4 commits from pm-setup-lint into pm-add-tests
19 changed files with 21 additions and 20 deletions
Showing only changes of commit a3c6319801 - Show all commits

View File

@ -15,6 +15,7 @@
"@typescript-eslint" "@typescript-eslint"
], ],
"rules": { "rules": {
"indent": ["error", 2, { "SwitchCase": 1 }] "indent": ["error", 2, { "SwitchCase": 1 }],
"@typescript-eslint/no-explicit-any": "off"
} }
} }

View File

@ -28,7 +28,7 @@ export const handler = async (argv: Arguments) => {
const reveal = fs.readFileSync(path.resolve(filePath)); const reveal = fs.readFileSync(path.resolve(filePath));
const result = await registry.revealBid({ auctionId, reveal: reveal.toString('hex') }, privateKey, fee); 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); txOutput(result, success, argv.output, argv.verbose);
}; };

View File

@ -24,7 +24,7 @@ export const handler = async (argv: Arguments) => {
const registry = new Registry(gqlEndpoint, restEndpoint, chainId); const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
const fee = getGasAndFees(argv, cnsConfig); const fee = getGasAndFees(argv, cnsConfig);
const result = await registry.setAuthorityBond({ name, bondId }, privateKey, fee); 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); txOutput(result, success, argv.output, argv.verbose);
}; };

View File

@ -31,6 +31,6 @@ export const handler = async (argv: Arguments) => {
const fee = getGasAndFees(argv, cnsConfig); const fee = getGasAndFees(argv, cnsConfig);
const result = await registry.reserveAuthority({ name, owner }, privateKey, fee); 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); txOutput(result, success, argv.output, argv.verbose);
}; };

View File

@ -30,6 +30,6 @@ export const handler = async (argv: Arguments) => {
const registry = new Registry(gqlEndpoint, restEndpoint, chainId); const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
const fee = getGasAndFees(argv, cnsConfig); const fee = getGasAndFees(argv, cnsConfig);
const result = await registry.associateBond({ recordId: id, bondId }, privateKey, fee); 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); txOutput(result, success, argv.output, argv.verbose);
}; };

View File

@ -22,6 +22,6 @@ export const handler = async (argv: Arguments) => {
const registry = new Registry(gqlEndpoint, restEndpoint, chainId); const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
const fee = getGasAndFees(argv, cnsConfig); const fee = getGasAndFees(argv, cnsConfig);
const result = await registry.cancelBond({ id }, privateKey, fee); 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); txOutput(result, success, argv.output, argv.verbose);
}; };

View File

@ -18,7 +18,7 @@ export const builder = {
}; };
export const handler = async (argv: Arguments) => { export const handler = async (argv: Arguments) => {
const { config, verbose } = argv; const { config } = argv;
const denom = argv.type as string; const denom = argv.type as string;
const amount = argv.quantity as string; const amount = argv.quantity as string;

View File

@ -22,6 +22,6 @@ export const handler = async (argv: Arguments) => {
const registry = new Registry(gqlEndpoint, restEndpoint, chainId); const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
const fee = getGasAndFees(argv, cnsConfig); const fee = getGasAndFees(argv, cnsConfig);
const result = await registry.dissociateBond({ recordId: id }, privateKey, fee); 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); txOutput(result, success, argv.output, argv.verbose);
}; };

View File

@ -28,6 +28,6 @@ export const handler = async (argv: Arguments) => {
const registry = new Registry(gqlEndpoint, restEndpoint, chainId); const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
const fee = getGasAndFees(argv, cnsConfig); const fee = getGasAndFees(argv, cnsConfig);
const result = await registry.dissociateRecords({ bondId }, privateKey, fee); 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); txOutput(result, success, argv.output, argv.verbose);
}; };

View File

@ -33,6 +33,6 @@ export const handler = async (argv: Arguments) => {
const registry = new Registry(gqlEndpoint, restEndpoint, chainId); const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
const fee = getGasAndFees(argv, cnsConfig); const fee = getGasAndFees(argv, cnsConfig);
const result = await registry.reassociateRecords({ oldBondId, newBondId }, privateKey, fee); 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); txOutput(result, success, argv.output, argv.verbose);
}; };

View File

@ -3,7 +3,6 @@ import assert from 'assert';
import { Registry } from '@cerc-io/laconic-sdk'; import { Registry } from '@cerc-io/laconic-sdk';
import { getConfig, getConnectionInfo, getGasAndFees, txOutput } from '../../../util'; import { getConfig, getConnectionInfo, getGasAndFees, txOutput } from '../../../util';
import { isNil } from 'lodash';
export const command = 'refill'; export const command = 'refill';
@ -37,6 +36,6 @@ export const handler = async (argv: Arguments) => {
const registry = new Registry(gqlEndpoint, restEndpoint, chainId); const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
const fee = getGasAndFees(argv, cnsConfig); const fee = getGasAndFees(argv, cnsConfig);
const result = await registry.refillBond({ id, denom, amount }, privateKey, fee); 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); txOutput(result, success, argv.output, argv.verbose);
}; };

View File

@ -36,6 +36,6 @@ export const handler = async (argv: Arguments) => {
const registry = new Registry(gqlEndpoint, restEndpoint, chainId); const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
const fee = getGasAndFees(argv, cnsConfig); const fee = getGasAndFees(argv, cnsConfig);
const result = await registry.withdrawBond({ id, denom, amount }, privateKey, fee); 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); txOutput(result, success, argv.output, argv.verbose);
}; };

View File

@ -23,6 +23,6 @@ export const handler = async (argv: Arguments) => {
const fee = getGasAndFees(argv, cnsConfig); const fee = getGasAndFees(argv, cnsConfig);
const result = await registry.deleteName({ crn: name }, privateKey, fee); 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); txOutput(result, success, argv.output, argv.verbose);
}; };

View File

@ -25,6 +25,6 @@ export const handler = async (argv: Arguments) => {
const fee = getGasAndFees(argv, cnsConfig); const fee = getGasAndFees(argv, cnsConfig);
const result = await registry.setName({ crn: name, cid: id }, privateKey, fee); 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); txOutput(result, success, argv.output, argv.verbose);
}; };

View File

@ -1,6 +1,5 @@
import { Arguments } from 'yargs'; import { Arguments } from 'yargs';
import assert from 'assert'; import assert from 'assert';
import path from 'path';
import yaml from 'js-yaml'; import yaml from 'js-yaml';
import fs from 'fs'; import fs from 'fs';
import { Registry } from '@cerc-io/laconic-sdk'; import { Registry } from '@cerc-io/laconic-sdk';
@ -18,7 +17,7 @@ export const builder = {
}; };
export const handler = async (argv: Arguments) => { 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 { services: { cns: cnsConfig } } = getConfig(config as string);
const { restEndpoint, gqlEndpoint, userKey, bondId, chainId } = getConnectionInfo(argv, cnsConfig); const { restEndpoint, gqlEndpoint, userKey, bondId, chainId } = getConnectionInfo(argv, cnsConfig);

View File

@ -1,6 +1,7 @@
import yargs from 'yargs/yargs'; import yargs from 'yargs/yargs';
import { hideBin } from 'yargs/helpers'; import { hideBin } from 'yargs/helpers';
// eslint-disable-next-line no-unused-expressions
yargs(hideBin(process.argv)) yargs(hideBin(process.argv))
.options({ .options({
verbose: { verbose: {

View File

@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import assert from 'assert'; import assert from 'assert';
import { Arguments } from 'yargs'; import { Arguments } from 'yargs';

View File

@ -1,6 +1,6 @@
export const txOutput = (result:any, msg:string, output:unknown, verbose:unknown) => { 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)); console.log(verbose ? JSON.parse(JSON.stringify(result)) : JSON.parse(msg));
} else { } else {
console.log(verbose ? JSON.stringify(result, undefined, 2) : msg); 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) => { export const queryOutput = (result: any, output: unknown) => {
if (output == 'json') { if (output === 'json') {
console.log(JSON.parse(JSON.stringify(result))); console.log(JSON.parse(JSON.stringify(result)));
} else { } else {
console.log(JSON.stringify(result, (key, value) => { console.log(JSON.stringify(result, (key, value) => {

View File

@ -116,5 +116,5 @@ export function getBidObject (params: { bidder: string, status?: string }): any
} }
export async function delay (ms: number): Promise<any> { export async function delay (ms: number): Promise<any> {
return new Promise(res => setTimeout(res, ms)); return new Promise((resolve) => setTimeout(resolve, ms));
} }