mirror of
https://github.com/fluencelabs/fluence-js.git
synced 2024-12-04 18:00:18 +00:00
fix prettier and eslint issues
This commit is contained in:
parent
3432968cd4
commit
16e821bd5b
@ -14,7 +14,7 @@ module.exports = {
|
||||
rules: {
|
||||
indent: ['off'],
|
||||
'linebreak-style': ['error', 'unix'],
|
||||
quotes: ['error', 'single', { avoidEscape: true }],
|
||||
quotes: ['error', 'single', { avoidEscape: true, allowTemplateLiterals: true }],
|
||||
semi: ['error', 'always'],
|
||||
'no-empty-function': 'off',
|
||||
'@typescript-eslint/no-empty-function': ['off'],
|
||||
|
5
.prettierignore
Normal file
5
.prettierignore
Normal file
@ -0,0 +1,5 @@
|
||||
docs
|
||||
.github
|
||||
.prettierrc.js
|
||||
tsconfig.json
|
||||
dist/
|
19
package-lock.json
generated
19
package-lock.json
generated
@ -35,6 +35,7 @@
|
||||
"eslint-plugin-simple-import-sort": "^7.0.0",
|
||||
"jest": "^26.6.3",
|
||||
"js-base64": "^3.7.2",
|
||||
"prettier": "^2.5.1",
|
||||
"ts-jest": "^26.5.4",
|
||||
"typedoc": "^0.21.9",
|
||||
"typescript": "^4.0.0"
|
||||
@ -7063,6 +7064,18 @@
|
||||
"node": ">= 0.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/prettier": {
|
||||
"version": "2.5.1",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.5.1.tgz",
|
||||
"integrity": "sha512-vBZcPRUR5MZJwoyi3ZoyQlc1rXeEck8KgeC9AwwOn+exuxLxq5toTRDTSaVrXHxelDMHy9zlicw8u66yxoSUFg==",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"prettier": "bin-prettier.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.13.0"
|
||||
}
|
||||
},
|
||||
"node_modules/pretty-format": {
|
||||
"version": "26.6.2",
|
||||
"resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-26.6.2.tgz",
|
||||
@ -14778,6 +14791,12 @@
|
||||
"integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=",
|
||||
"dev": true
|
||||
},
|
||||
"prettier": {
|
||||
"version": "2.5.1",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.5.1.tgz",
|
||||
"integrity": "sha512-vBZcPRUR5MZJwoyi3ZoyQlc1rXeEck8KgeC9AwwOn+exuxLxq5toTRDTSaVrXHxelDMHy9zlicw8u66yxoSUFg==",
|
||||
"dev": true
|
||||
},
|
||||
"pretty-format": {
|
||||
"version": "26.6.2",
|
||||
"resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-26.6.2.tgz",
|
||||
|
@ -46,6 +46,7 @@
|
||||
"eslint-plugin-simple-import-sort": "^7.0.0",
|
||||
"jest": "^26.6.3",
|
||||
"js-base64": "^3.7.2",
|
||||
"prettier": "^2.5.1",
|
||||
"ts-jest": "^26.5.4",
|
||||
"typedoc": "^0.21.9",
|
||||
"typescript": "^4.0.0"
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { Fluence, FluencePeer } from '../../..';
|
||||
import { callFunction } from '../../../internal/compilerSupport/v2';
|
||||
import { Particle } from '../../../internal/Particle';
|
||||
import { handleTimeout } from '../../../internal/utils';
|
||||
import { registerHandlersHelper } from '../../util';
|
||||
import { callMeBack, registerHelloWorld } from './gen1';
|
||||
import { callFunction } from '../../../internal/compilerSupport/v2';
|
||||
import { handleTimeout } from '../../../internal/utils';
|
||||
|
||||
describe('Compiler support infrastructure tests', () => {
|
||||
it('Compiled code for function should work', async () => {
|
||||
|
@ -1,3 +1,4 @@
|
||||
/* eslint-disable */
|
||||
import { ResultCodes, RequestFlow, RequestFlowBuilder, CallParams } from '../../../internal/compilerSupport/v1';
|
||||
import { Fluence, FluencePeer } from '../../../index';
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
/* eslint-disable */
|
||||
import { CallParams, registerService, callFunction } from '../../../internal/compilerSupport/v2';
|
||||
import { FluencePeer } from '../../../index';
|
||||
|
||||
|
@ -1,8 +1,9 @@
|
||||
import { Multiaddr } from 'multiaddr';
|
||||
import { nodes } from '../connection';
|
||||
|
||||
import { Fluence, FluencePeer, setLogLevel } from '../../index';
|
||||
import { checkConnection, doNothing, handleTimeout } from '../../internal/utils';
|
||||
import { Particle } from '../../internal/Particle';
|
||||
import { checkConnection, doNothing, handleTimeout } from '../../internal/utils';
|
||||
import { nodes } from '../connection';
|
||||
import { registerHandlersHelper } from '../util';
|
||||
|
||||
const anotherPeer = new FluencePeer();
|
||||
@ -134,7 +135,7 @@ describe('Typescript usage suite', () => {
|
||||
it('check connection should work', async function () {
|
||||
await anotherPeer.start({ connectTo: nodes[0] });
|
||||
|
||||
let isConnected = await checkConnection(anotherPeer);
|
||||
const isConnected = await checkConnection(anotherPeer);
|
||||
|
||||
expect(isConnected).toEqual(true);
|
||||
});
|
||||
@ -142,7 +143,7 @@ describe('Typescript usage suite', () => {
|
||||
it('check connection should work with ttl', async function () {
|
||||
await anotherPeer.start({ connectTo: nodes[0] });
|
||||
|
||||
let isConnected = await checkConnection(anotherPeer, 10000);
|
||||
const isConnected = await checkConnection(anotherPeer, 10000);
|
||||
|
||||
expect(isConnected).toEqual(true);
|
||||
});
|
||||
@ -328,7 +329,7 @@ describe('Typescript usage suite', () => {
|
||||
// assert
|
||||
await expect(res).rejects.toMatchObject({
|
||||
msg: expect.stringContaining(
|
||||
`No handler has been registered for serviceId='incorrect' fnName='incorrect' args=''\"'`,
|
||||
`No handler has been registered for serviceId='incorrect' fnName='incorrect' args=''"'`,
|
||||
),
|
||||
instruction: 'call %init_peer_id% ("incorrect" "incorrect") [] res',
|
||||
});
|
||||
|
@ -1,5 +1,6 @@
|
||||
import * as bs58 from 'bs58';
|
||||
import * as base64 from 'base64-js';
|
||||
import * as bs58 from 'bs58';
|
||||
|
||||
import { KeyPair } from '../../internal/KeyPair';
|
||||
|
||||
describe('KeyPair tests', () => {
|
||||
|
@ -1,9 +1,10 @@
|
||||
import { CallServiceData } from '../../internal/commonTypes';
|
||||
import each from 'jest-each';
|
||||
import { BuiltInServiceContext, builtInServices } from '../../internal/builtInServices';
|
||||
import { KeyPair } from '../../internal/KeyPair';
|
||||
import { toUint8Array } from 'js-base64';
|
||||
|
||||
import { BuiltInServiceContext, builtInServices } from '../../internal/builtInServices';
|
||||
import { CallServiceData } from '../../internal/commonTypes';
|
||||
import { KeyPair } from '../../internal/KeyPair';
|
||||
|
||||
const key = '+cmeYlZKj+MfSa9dpHV+BmLPm6wq4inGlsPlQ1GvtPk=';
|
||||
|
||||
const context = (async () => {
|
||||
@ -49,17 +50,17 @@ describe('Tests for default handler', () => {
|
||||
${'op'} | ${'concat'} | ${[]} | ${0} | ${[]}
|
||||
${'op'} | ${'concat'} | ${[1, [1, 2], 1]} | ${1} | ${"All arguments of 'concat' must be arrays: arguments 0, 2 are not"}
|
||||
|
||||
${'op'} | ${'string_to_b58'} | ${["test"]} | ${0} | ${"3yZe7d"}
|
||||
${'op'} | ${'string_to_b58'} | ${["test", 1]} | ${1} | ${"string_to_b58 accepts only one string argument"}
|
||||
${'op'} | ${'string_to_b58'} | ${['test']} | ${0} | ${'3yZe7d'}
|
||||
${'op'} | ${'string_to_b58'} | ${['test', 1]} | ${1} | ${'string_to_b58 accepts only one string argument'}
|
||||
|
||||
${'op'} | ${'string_from_b58'} | ${["3yZe7d"]} | ${0} | ${"test"}
|
||||
${'op'} | ${'string_from_b58'} | ${["3yZe7d", 1]} | ${1} | ${"string_from_b58 accepts only one string argument"}
|
||||
${'op'} | ${'string_from_b58'} | ${['3yZe7d']} | ${0} | ${'test'}
|
||||
${'op'} | ${'string_from_b58'} | ${['3yZe7d', 1]} | ${1} | ${'string_from_b58 accepts only one string argument'}
|
||||
|
||||
${'op'} | ${'bytes_to_b58'} | ${[[116, 101, 115, 116]]} | ${0} | ${"3yZe7d"}
|
||||
${'op'} | ${'bytes_to_b58'} | ${[[116, 101, 115, 116], 1]} | ${1} | ${"bytes_to_b58 accepts only single argument: array of numbers"}
|
||||
${'op'} | ${'bytes_to_b58'} | ${[[116, 101, 115, 116]]} | ${0} | ${'3yZe7d'}
|
||||
${'op'} | ${'bytes_to_b58'} | ${[[116, 101, 115, 116], 1]} | ${1} | ${'bytes_to_b58 accepts only single argument: array of numbers'}
|
||||
|
||||
${'op'} | ${'bytes_from_b58'} | ${["3yZe7d"]} | ${0} | ${[116, 101, 115, 116]}
|
||||
${'op'} | ${'bytes_from_b58'} | ${["3yZe7d", 1]} | ${1} | ${"bytes_from_b58 accepts only one string argument"}
|
||||
${'op'} | ${'bytes_from_b58'} | ${['3yZe7d']} | ${0} | ${[116, 101, 115, 116]}
|
||||
${'op'} | ${'bytes_from_b58'} | ${['3yZe7d', 1]} | ${1} | ${'bytes_from_b58 accepts only one string argument'}
|
||||
|
||||
${'peer'} | ${'timeout'} | ${[200, []]} | ${0} | ${[]}}
|
||||
${'peer'} | ${'timeout'} | ${[200, ['test']]} | ${0} | ${['test']}}
|
||||
@ -249,7 +250,7 @@ describe('Tests for default handler', () => {
|
||||
// assert
|
||||
expect(res).toMatchObject({
|
||||
retCode: 1,
|
||||
result: expect.stringContaining("Only data from the following services is allowed to be signed:"),
|
||||
result: expect.stringContaining('Only data from the following services is allowed to be signed:'),
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
import each from 'jest-each';
|
||||
|
||||
import { Fluence, FluencePeer } from '../..';
|
||||
import { forTests } from '../../internal/compilerSupport/v2';
|
||||
|
||||
|
@ -3,8 +3,8 @@ import { Particle } from '../internal/Particle';
|
||||
import { MakeServiceCall } from '../internal/utils';
|
||||
|
||||
export const registerHandlersHelper = (peer: FluencePeer, particle: Particle, handlers) => {
|
||||
for (let serviceId in handlers) {
|
||||
for (let fnName in handlers[serviceId]) {
|
||||
for (const serviceId in handlers) {
|
||||
for (const fnName in handlers[serviceId]) {
|
||||
// of type [args] => result
|
||||
const h = handlers[serviceId][fnName];
|
||||
peer.internals.regHandler.forParticle(particle.id, serviceId, fnName, MakeServiceCall(h));
|
||||
|
Loading…
Reference in New Issue
Block a user