mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-07-01 06:11:45 +02:00
more strict linting & typing
This commit is contained in:
parent
94bc2295f2
commit
9ea7ed70bd
16
.eslintrc
16
.eslintrc
|
@ -20,26 +20,12 @@
|
|||
],
|
||||
"plugins": ["@typescript-eslint", "prettier"],
|
||||
"rules": {
|
||||
"@typescript-eslint/member-delimiter-style": [
|
||||
"error",
|
||||
{ "multiline": { "delimiter": "none" } }
|
||||
],
|
||||
"@typescript-eslint/ban-ts-ignore": "off",
|
||||
"@typescript-eslint/indent": "off",
|
||||
"@typescript-eslint/no-explicit-any": "off",
|
||||
"@typescript-eslint/no-inferrable-types": "off",
|
||||
"@typescript-eslint/no-non-null-assertion": "off",
|
||||
"@typescript-eslint/explicit-function-return-type": "off",
|
||||
"@typescript-eslint/explicit-member-accessibility": "off",
|
||||
"@typescript-eslint/no-var-requires": "off",
|
||||
"@typescript-eslint/no-use-before-define": "off",
|
||||
"@typescript-eslint/no-object-literal-type-assertion": "off",
|
||||
"@typescript-eslint/no-parameter-properties": "off",
|
||||
"no-empty": ["error", { "allowEmptyCatch": true }],
|
||||
"prefer-destructuring": ["warn"],
|
||||
"no-dupe-class-members": ["warn"],
|
||||
"no-useless-constructor": ["warn"],
|
||||
"dot-notation": 0
|
||||
"no-useless-constructor": ["warn"]
|
||||
},
|
||||
"env": {
|
||||
"es6": true,
|
||||
|
|
|
@ -29,7 +29,7 @@ export default class ContractHandler extends Instantiable {
|
|||
this.setInstanceConfig(config)
|
||||
}
|
||||
|
||||
public async get(what: string, optional: boolean = false): Promise<Contract> {
|
||||
public async get(what: string, optional = false): Promise<Contract> {
|
||||
const where = (await this.ocean.network.getNetworkName()).toLowerCase()
|
||||
const networkId = await this.ocean.network.getNetworkId()
|
||||
try {
|
||||
|
|
|
@ -14,7 +14,7 @@ export class EventHandler extends Instantiable {
|
|||
|
||||
private interval = 200
|
||||
|
||||
private polling: boolean = false
|
||||
private polling = false
|
||||
|
||||
private lastTimeout: NodeJS.Timeout
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ export class DDO {
|
|||
return new DDO(ddo)
|
||||
}
|
||||
|
||||
public '@context': string = 'https://w3id.org/did/v1'
|
||||
public '@context' = 'https://w3id.org/did/v1'
|
||||
|
||||
/**
|
||||
* DID, descentralized ID.
|
||||
|
|
|
@ -365,7 +365,7 @@ export class Assets extends Instantiable {
|
|||
creator: Account,
|
||||
cost: string,
|
||||
datePublished: string,
|
||||
timeout: number = 0
|
||||
timeout = 0
|
||||
): Promise<ServiceAccess> {
|
||||
return {
|
||||
type: 'access',
|
||||
|
@ -387,7 +387,7 @@ export class Assets extends Instantiable {
|
|||
did: string,
|
||||
serviceType: string,
|
||||
consumerAddress: string,
|
||||
serviceIndex: number = -1
|
||||
serviceIndex = -1
|
||||
): Promise<string> {
|
||||
if (serviceIndex === -1) {
|
||||
const service = await this.getServiceByType(did, serviceType)
|
||||
|
|
|
@ -126,7 +126,7 @@ export class Provider extends Instantiable {
|
|||
destination: string,
|
||||
account: Account,
|
||||
files: File[],
|
||||
index: number = -1
|
||||
index = -1
|
||||
): Promise<any> {
|
||||
await this.getNonce(account.getId())
|
||||
const signature = await this.createSignature(account, did + this.nonce)
|
||||
|
|
|
@ -3,7 +3,7 @@ import { LoggerInstance } from './Logger'
|
|||
// Ox transformer
|
||||
export const zeroX = (input: string): string => zeroXTransformer(input, true)
|
||||
export const noZeroX = (input: string): string => zeroXTransformer(input, false)
|
||||
export function zeroXTransformer(input: string = '', zeroOutput: boolean): string {
|
||||
export function zeroXTransformer(input = '', zeroOutput: boolean): string {
|
||||
const { valid, output } = inputMatch(input, /^(?:0x)*([a-f0-9]+)$/i, 'zeroXTransformer')
|
||||
return (zeroOutput && valid ? '0x' : '') + output
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ export function zeroXTransformer(input: string = '', zeroOutput: boolean): strin
|
|||
// did:op: transformer
|
||||
export const didPrefixed = (input: string): string => didTransformer(input, true)
|
||||
export const noDidPrefixed = (input: string): string => didTransformer(input, false)
|
||||
export function didTransformer(input: string = '', prefixOutput: boolean): string {
|
||||
export function didTransformer(input = '', prefixOutput: boolean): string {
|
||||
const { valid, output } = inputMatch(
|
||||
input,
|
||||
/^(?:0x|did:op:)*([a-f0-9]{64})$/i,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
export class SubscribableObserver<T, P> {
|
||||
public completed: boolean = false
|
||||
public completed = false
|
||||
|
||||
private subscriptions = new Set<{
|
||||
onNext?: (next: T) => void
|
||||
|
|
|
@ -274,10 +274,10 @@ describe('Compute flow', () => {
|
|||
assert(order != null)
|
||||
const computeOrder = JSON.parse(order)
|
||||
const tx = await datatoken.transferWei(
|
||||
computeOrder['dataToken'],
|
||||
computeOrder['to'],
|
||||
String(computeOrder['numTokens']),
|
||||
computeOrder['from']
|
||||
computeOrder.dataToken,
|
||||
computeOrder.to,
|
||||
String(computeOrder.numTokens),
|
||||
computeOrder.from
|
||||
)
|
||||
const response = await ocean.compute.start(
|
||||
ddo.id,
|
||||
|
@ -342,10 +342,10 @@ describe('Compute flow', () => {
|
|||
)
|
||||
const algoOrder = JSON.parse(orderalgo)
|
||||
const algoTx = await datatoken.transferWei(
|
||||
algoOrder['dataToken'],
|
||||
algoOrder['to'],
|
||||
String(algoOrder['numTokens']),
|
||||
algoOrder['from']
|
||||
algoOrder.dataToken,
|
||||
algoOrder.to,
|
||||
String(algoOrder.numTokens),
|
||||
algoOrder.from
|
||||
)
|
||||
const order = await ocean.compute.order(
|
||||
bob.getId(),
|
||||
|
@ -357,10 +357,10 @@ describe('Compute flow', () => {
|
|||
assert(order != null)
|
||||
const computeOrder = JSON.parse(order)
|
||||
const tx = await datatoken.transferWei(
|
||||
computeOrder['dataToken'],
|
||||
computeOrder['to'],
|
||||
String(computeOrder['numTokens']),
|
||||
computeOrder['from']
|
||||
computeOrder.dataToken,
|
||||
computeOrder.to,
|
||||
String(computeOrder.numTokens),
|
||||
computeOrder.from
|
||||
)
|
||||
const response = await ocean.compute.start(
|
||||
ddo.id,
|
||||
|
|
|
@ -155,13 +155,13 @@ describe('Marketplace flow', () => {
|
|||
it('Bob consumes asset 1', async () => {
|
||||
await ocean.assets
|
||||
.order(ddo.id, accessService.type, bob.getId())
|
||||
.then(async (res: string) => {
|
||||
.then(async (res: any) => {
|
||||
res = JSON.parse(res)
|
||||
return await datatoken.transferWei(
|
||||
res['dataToken'],
|
||||
res['to'],
|
||||
String(res['numTokens']),
|
||||
res['from']
|
||||
res.dataToken,
|
||||
res.to,
|
||||
String(res.numTokens),
|
||||
res.from
|
||||
)
|
||||
})
|
||||
.then(async (tx) => {
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
"declaration": true,
|
||||
"module": "commonjs",
|
||||
"target": "es5",
|
||||
"noImplicitAny": false,
|
||||
"removeComments": true,
|
||||
"experimentalDecorators": true,
|
||||
"preserveConstEnums": true,
|
||||
|
|
Loading…
Reference in New Issue
Block a user