chore: lint

pull/2620/head
Audric Ackermann 1 year ago
parent 9749529e25
commit 65df3157bd

@ -10,3 +10,4 @@ indent_style = space
insert_final_newline = true insert_final_newline = true
trim_trailing_whitespace = true trim_trailing_whitespace = true
indent_size = 2 indent_size = 2
quote_type = double

@ -46,25 +46,20 @@
}, },
"scripts": { "scripts": {
"start-prod": "cross-env NODE_ENV=production NODE_APP_INSTANCE=devprod$MULTI electron .", "start-prod": "cross-env NODE_ENV=production NODE_APP_INSTANCE=devprod$MULTI electron .",
"build-everything": "yarn clean && yarn protobuf && grunt && yarn sass && tsc && yarn parcel-util-worker", "build-everything": "yarn clean && yarn protobuf && grunt && yarn sass && tsc && yarn parcel-util-worker",
"build-everything:watch": "yarn clean && yarn protobuf && grunt && yarn sass && yarn parcel-util-worker && tsc -w", "build-everything:watch": "yarn clean && yarn protobuf && grunt && yarn sass && yarn parcel-util-worker && tsc -w",
"watch": "yarn clean && yarn protobuf && grunt && concurrently 'yarn build-everything:watch' 'yarn sass:watch'", "watch": "yarn clean && yarn protobuf && grunt && concurrently 'yarn build-everything:watch' 'yarn sass:watch'",
"protobuf": "pbjs --target static-module --wrap commonjs --out ts/protobuf/compiled.js protos/*.proto && pbts --out ts/protobuf/compiled.d.ts ts/protobuf/compiled.js --force-long", "protobuf": "pbjs --target static-module --wrap commonjs --out ts/protobuf/compiled.js protos/*.proto && pbts --out ts/protobuf/compiled.d.ts ts/protobuf/compiled.js --force-long",
"sass": "rimraf 'stylesheets/dist/' && parcel build --target sass --no-autoinstall --no-cache", "sass": "rimraf 'stylesheets/dist/' && parcel build --target sass --no-autoinstall --no-cache",
"sass:watch": "rimraf 'stylesheets/dist/' && parcel watch --target sass --no-autoinstall --no-cache", "sass:watch": "rimraf 'stylesheets/dist/' && parcel watch --target sass --no-autoinstall --no-cache",
"parcel-util-worker": "rimraf ts/webworker/workers/util.worker.js && parcel build --target util-worker --no-autoinstall --no-cache", "parcel-util-worker": "rimraf ts/webworker/workers/util.worker.js && parcel build --target util-worker --no-autoinstall --no-cache",
"clean": "rimraf 'ts/**/*.js' 'ts/*.js' 'ts/*.js.map' 'ts/**/*.js.map' && rimraf tsconfig.tsbuildinfo;", "clean": "rimraf 'ts/**/*.js' 'ts/*.js' 'ts/*.js.map' 'ts/**/*.js.map' && rimraf tsconfig.tsbuildinfo;",
"lint-full": "yarn format-full && eslint . && tslint --format stylish --project .", "lint-full": "yarn format-full && eslint . && tslint --format stylish --project .",
"format-full": "prettier --list-different --write \"*.{css,js,json,scss,ts,tsx}\" \"./**/*.{css,js,json,scss,ts,tsx}\"", "format-full": "prettier --list-different --write \"*.{css,js,json,scss,ts,tsx}\" \"./**/*.{css,js,json,scss,ts,tsx}\"",
"integration-test": "npx playwright test", "integration-test": "npx playwright test",
"integration-test-snapshots": "npx playwright test -g 'profile picture' --update-snapshots", "integration-test-snapshots": "npx playwright test -g 'profile picture' --update-snapshots",
"test": "mocha -r jsdom-global/register --recursive --exit --timeout 10000 \"./ts/test/**/*_test.js\"", "test": "mocha -r jsdom-global/register --recursive --exit --timeout 10000 \"./ts/test/**/*_test.js\"",
"coverage": "nyc --reporter=html mocha -r jsdom-global/register --recursive --exit --timeout 10000 \"./ts/test/**/*_test.js\"", "coverage": "nyc --reporter=html mocha -r jsdom-global/register --recursive --exit --timeout 10000 \"./ts/test/**/*_test.js\"",
"build-release": "run-script-os", "build-release": "run-script-os",
"build-release-non-linux": "yarn build-everything && cross-env SIGNAL_ENV=production electron-builder --config.extraMetadata.environment=production --publish=never --config.directories.output=release", "build-release-non-linux": "yarn build-everything && cross-env SIGNAL_ENV=production electron-builder --config.extraMetadata.environment=production --publish=never --config.directories.output=release",
"build-release:win32": "yarn build-release-non-linux", "build-release:win32": "yarn build-release-non-linux",
@ -259,7 +254,10 @@
"mac": { "mac": {
"category": "public.app-category.social-networking", "category": "public.app-category.social-networking",
"icon": "build/icon-mac.icns", "icon": "build/icon-mac.icns",
"target": ["dmg", "zip"], "target": [
"dmg",
"zip"
],
"bundleVersion": "1", "bundleVersion": "1",
"hardenedRuntime": true, "hardenedRuntime": true,
"gatekeeperAssess": false, "gatekeeperAssess": false,
@ -293,7 +291,11 @@
"StartupWMClass": "Session" "StartupWMClass": "Session"
}, },
"asarUnpack": "node_modules/spellchecker/vendor/hunspell_dictionaries", "asarUnpack": "node_modules/spellchecker/vendor/hunspell_dictionaries",
"target": ["deb", "rpm", "freebsd"], "target": [
"deb",
"rpm",
"freebsd"
],
"icon": "build/icon-linux.icns" "icon": "build/icon-linux.icns"
}, },
"asarUnpack": [ "asarUnpack": [

@ -78,8 +78,7 @@ const allowedKeysFormatRowOfConversation = [
'conversationIdOrigin', 'conversationIdOrigin',
'identityPrivateKey', 'identityPrivateKey',
]; ];
// tslint:disable: cyclomatic-complexity
//tslint-disable cyclomatic-complexity
export function formatRowOfConversation(row?: Record<string, any>): ConversationAttributes | null { export function formatRowOfConversation(row?: Record<string, any>): ConversationAttributes | null {
if (!row) { if (!row) {
return null; return null;

@ -1,4 +1,3 @@
export type SwarmForSubRequest = { method: 'get_swarm'; params: { pubkey: string } }; export type SwarmForSubRequest = { method: 'get_swarm'; params: { pubkey: string } };
type RetrieveMaxCountSize = { max_count?: number; max_size?: number }; type RetrieveMaxCountSize = { max_count?: number; max_size?: number };
@ -124,11 +123,10 @@ export type SnodeApiSubRequests =
| StoreOnNodeSubRequest | StoreOnNodeSubRequest
| NetworkTimeSubRequest; | NetworkTimeSubRequest;
//tslint-disable: array-type // tslint:disable: array-type
export type NonEmptyArray<T> = [T, ...T[]]; export type NonEmptyArray<T> = [T, ...T[]];
export type NotEmptyArrayOfBatchResults = NonEmptyArray<{ export type NotEmptyArrayOfBatchResults = NonEmptyArray<{
code: number; code: number;
body: Record<string, any>; body: Record<string, any>;
}>; }>;

@ -12,7 +12,6 @@ import { NotEmptyArrayOfBatchResults, SnodeApiSubRequests } from './SnodeRequest
* @param targetNode the node to do the request to, once all the onion routing is done * @param targetNode the node to do the request to, once all the onion routing is done
* @param timeout the timeout at which we should cancel this request. * @param timeout the timeout at which we should cancel this request.
* @param associatedWith used mostly for handling 421 errors, we need the pubkey the change is associated to * @param associatedWith used mostly for handling 421 errors, we need the pubkey the change is associated to
* @returns
*/ */
export async function doSnodeBatchRequest( export async function doSnodeBatchRequest(
subRequests: Array<SnodeApiSubRequests>, subRequests: Array<SnodeApiSubRequests>,

@ -244,7 +244,6 @@ export class SwarmPolling {
return group; return group;
}); });
} else if (isGroup) { } else if (isGroup) {
debugger;
window?.log?.info( window?.log?.info(
`Polled for group(${ed25519Str( `Polled for group(${ed25519Str(
pubkey.key pubkey.key
@ -291,7 +290,6 @@ export class SwarmPolling {
namespaces, namespaces,
UserUtils.getOurPubKeyStrFromCache() UserUtils.getOurPubKeyStrFromCache()
); );
debugger;
if (!results.length) { if (!results.length) {
return []; return [];
} }

@ -79,10 +79,10 @@ export async function initiateClosedGroupUpdate(
groupName: string, groupName: string,
members: Array<string> members: Array<string>
) { ) {
const isV3 = PubKey.isClosedGroupV3(groupId); const isGroupV3 = PubKey.isClosedGroupV3(groupId);
const convo = await getConversationController().getOrCreateAndWait( const convo = await getConversationController().getOrCreateAndWait(
groupId, groupId,
isV3 ? ConversationTypeEnum.GROUPV3 : ConversationTypeEnum.GROUP isGroupV3 ? ConversationTypeEnum.GROUPV3 : ConversationTypeEnum.GROUP
); );
if (!convo.isMediumGroup()) { if (!convo.isMediumGroup()) {

@ -214,7 +214,6 @@ export class BEncode {
if (isArray(item)) { if (isArray(item)) {
let content = new Uint8Array(); let content = new Uint8Array();
//tslint disable prefer-for-of
for (let index = 0; index < item.length; index++) { for (let index = 0; index < item.length; index++) {
const encodedItem = this.encodeItem(item[index]); const encodedItem = this.encodeItem(item[index]);
const encodedItemLength = encodedItem.length; const encodedItemLength = encodedItem.length;

@ -1,15 +1,20 @@
import { expect } from 'chai'; import { expect } from 'chai';
import * as SessionUtilWrapper from 'session_util_wrapper';
import { stringToUint8Array } from '../../../../session/utils/String'; import { stringToUint8Array } from '../../../../session/utils/String';
import { from_hex, to_hex } from 'libsodium-wrappers-sumo'; import { from_hex, to_hex } from 'libsodium-wrappers-sumo';
import { concatUInt8Array } from '../../../../session/crypto'; import { concatUInt8Array } from '../../../../session/crypto';
import * as SessionUtilWrapper from 'session_util_wrapper';
// tslint:disable: chai-vague-errors no-unused-expression no-http-string no-octal-literal whitespace
describe('libsession_wrapper', () => { describe('libsession_wrapper', () => {
it.skip('[config][user_profile][c]', () => { it('[config][user_profile][c]', () => {
// Note: To run this test, you need to compile the libsession wrapper for node (and not for electron). // Note: To run this test, you need to compile the libsession wrapper for node (and not for electron).
// To do this, you can cd to the node_module/libsession_wrapper folder and do // To do this, you can cd to the node_module/libsession_wrapper folder and do
// yarn configure && yarn build // yarn configure && yarn build
// once that is done, you can rename this file and remove the _skip suffix so that test is run.
// We have to disable it by filename as nodejs tries to load the module during the import step above, and fails as it is not compiled for nodejs but for electron.
const edSecretKey = from_hex( const edSecretKey = from_hex(
'0123456789abcdef0123456789abcdef000000000000000000000000000000004cb76fdc6d32278e3f83dbf608360ecc6b65727934b85d2fb86862ff98c46ab7' '0123456789abcdef0123456789abcdef000000000000000000000000000000004cb76fdc6d32278e3f83dbf608360ecc6b65727934b85d2fb86862ff98c46ab7'
@ -67,54 +72,39 @@ describe('libsession_wrapper', () => {
pushResult = conf.push(); pushResult = conf.push();
expect(pushResult.seqno).to.be.eq(1); expect(pushResult.seqno).to.be.eq(1);
const exp_hash0 = from_hex('ea173b57beca8af18c3519a7bbf69c3e7a05d1c049fa9558341d8ebb48b0c965'); const expHash0 = from_hex('ea173b57beca8af18c3519a7bbf69c3e7a05d1c049fa9558341d8ebb48b0c965');
// prettier-ignore const expPush1Start =
const exp_push1_start = "d" + 'd1:#i1e1:&d1:n6:Kallie1:p34:http://example.org/omg-pic-123.bmp1:q6:secrete1:<lli0e32:';
"1:#" +"i1e"+ const expPush1End = 'deee1:=d1:n0:1:p0:1:q0:ee';
"1:&" +"d"+
"1:n" +"6:Kallie"+
"1:p" +"34:http://example.org/omg-pic-123.bmp"+
"1:q" +"6:secret"+
"e"+
"1:<"+ "l"+
"l" +"i0e" +"32:" ;
// prettier-ignore
const exp_push1_end = "de"+ "e"+
"e"+
"1:="+ "d"+
"1:n" +"0:"+
"1:p" +"0:"+
"1:q" +"0:"+
"e"+
"e";
// The data to be actually pushed, expanded like this to make it somewhat human-readable: // The data to be actually pushed, expanded like this to make it somewhat human-readable:
const exp_push1_decrypted = concatUInt8Array( const expPush1Decrypted = concatUInt8Array(
stringToUint8Array(exp_push1_start), stringToUint8Array(expPush1Start),
exp_hash0, expHash0,
stringToUint8Array(exp_push1_end) stringToUint8Array(expPush1End)
); );
const exp_push1_encrypted = from_hex( const expPush1Encrypted = from_hex(
'a2952190dcb9797bc48e48f6dc7b3254d004bde9091cfc9ec3433cbc5939a3726deb04f58a546d7d79e6f80ea185d43bf93278398556304998ae882304075c77f15c67f9914c4d10005a661f29ff7a79e0a9de7f21725ba3b5a6c19eaa3797671b8fa4008d62e9af2744629cbb46664c4d8048e2867f66ed9254120371bdb24e95b2d92341fa3b1f695046113a768ceb7522269f937ead5591bfa8a5eeee3010474002f2db9de043f0f0d1cfb1066a03e7b5d6cfb70a8f84a20cd2df5a510cd3d175708015a52dd4a105886d916db0005dbea5706e5a5dc37ffd0a0ca2824b524da2e2ad181a48bb38e21ed9abe136014a4ee1e472cb2f53102db2a46afa9d68' 'a2952190dcb9797bc48e48f6dc7b3254d004bde9091cfc9ec3433cbc5939a3726deb04f58a546d7d79e6f80ea185d43bf93278398556304998ae882304075c77f15c67f9914c4d10005a661f29ff7a79e0a9de7f21725ba3b5a6c19eaa3797671b8fa4008d62e9af2744629cbb46664c4d8048e2867f66ed9254120371bdb24e95b2d92341fa3b1f695046113a768ceb7522269f937ead5591bfa8a5eeee3010474002f2db9de043f0f0d1cfb1066a03e7b5d6cfb70a8f84a20cd2df5a510cd3d175708015a52dd4a105886d916db0005dbea5706e5a5dc37ffd0a0ca2824b524da2e2ad181a48bb38e21ed9abe136014a4ee1e472cb2f53102db2a46afa9d68'
); );
expect(to_hex(pushResult.data)).to.be.deep.eq(to_hex(exp_push1_encrypted)); expect(to_hex(pushResult.data)).to.be.deep.eq(to_hex(expPush1Encrypted));
// We haven't dumped, so still need to dump: // We haven't dumped, so still need to dump:
expect(conf.needsDump()).to.be.true; expect(conf.needsDump()).to.be.true;
// We did call push, but we haven't confirmed it as stored yet, so this will still return true: // We did call push, but we haven't confirmed it as stored yet, so this will still return true:
expect(conf.needsPush()).to.be.true; expect(conf.needsPush()).to.be.true;
let dumped = conf.dump(); const dumped = conf.dump();
// (in a real client we'd now store this to disk) // (in a real client we'd now store this to disk)
expect(conf.needsDump()).to.be.false; expect(conf.needsDump()).to.be.false;
// prettier-ignore const expectedDump = concatUInt8Array(
const expected_dump = concatUInt8Array(stringToUint8Array("d" + stringToUint8Array('d' + '1:!' + 'i2e' + '1:$' + `${expPush1Decrypted.length}` + ':'),
"1:!" +"i2e"+ expPush1Decrypted,
"1:$" + `${exp_push1_decrypted.length}` + ':'), exp_push1_decrypted, stringToUint8Array("e")); stringToUint8Array('e')
expect(to_hex(dumped)).to.be.deep.eq(to_hex(expected_dump)); );
expect(to_hex(dumped)).to.be.deep.eq(to_hex(expectedDump));
// So now imagine we got back confirmation from the swarm that the push has been stored: // So now imagine we got back confirmation from the swarm that the push has been stored:
conf.confirmPushed(pushResult.seqno); conf.confirmPushed(pushResult.seqno);
@ -134,7 +124,7 @@ describe('libsession_wrapper', () => {
expect(conf2.needsDump()).to.be.false; expect(conf2.needsDump()).to.be.false;
// Now imagine we just pulled down the encrypted string from the swarm; we merge it into conf2: // Now imagine we just pulled down the encrypted string from the swarm; we merge it into conf2:
const accepted = conf2.merge([exp_push1_encrypted]); const accepted = conf2.merge([expPush1Encrypted]);
expect(accepted).to.be.eq(1); expect(accepted).to.be.eq(1);
// Our state has changed, so we need to dump: // Our state has changed, so we need to dump:

@ -580,7 +580,7 @@ describe('knownBlindedKeys', () => {
expect(real).to.eq(undefined); expect(real).to.eq(undefined);
}); });
it('does iterate over all the conversations but is not private so must fail: groupv3', async () => { it('does iterate over all the conversations but is not private so must fail: groupv3', () => {
// we actually cannot test this one as we would need to create a conversation with groupv3 as type but 05 as prefix, and the conversation controller denies it, as expected // we actually cannot test this one as we would need to create a conversation with groupv3 as type but 05 as prefix, and the conversation controller denies it, as expected
}); });
}); });

@ -26,6 +26,9 @@
"object-literal-sort-keys": false, "object-literal-sort-keys": false,
"no-async-without-await": true, "no-async-without-await": true,
"no-empty-interface": false, "no-empty-interface": false,
"prefer-for-of": false,
"chai-vague-errors": false,
"no-useless-files": false,
"ordered-imports": [ "ordered-imports": [
true, true,
{ {

@ -8205,7 +8205,7 @@ serialize-javascript@6.0.0:
"session_util_wrapper@https://github.com/oxen-io/libsession-util-nodejs": "session_util_wrapper@https://github.com/oxen-io/libsession-util-nodejs":
version "0.1.0" version "0.1.0"
resolved "https://github.com/oxen-io/libsession-util-nodejs#08bebd19042dee4d53f617bf93d51ab8fe9d8282" resolved "https://github.com/oxen-io/libsession-util-nodejs#d1519f038c738cb446b23714913db5fd33ef1d9c"
dependencies: dependencies:
bindings "^1.5.0" bindings "^1.5.0"
nan "^2.17.0" nan "^2.17.0"

Loading…
Cancel
Save