diff --git a/.editorconfig b/.editorconfig index d4f444678..f4d3f0f2e 100644 --- a/.editorconfig +++ b/.editorconfig @@ -10,3 +10,4 @@ indent_style = space insert_final_newline = true trim_trailing_whitespace = true indent_size = 2 +quote_type = double \ No newline at end of file diff --git a/package.json b/package.json index d059e0940..fb3b7f4bc 100644 --- a/package.json +++ b/package.json @@ -46,25 +46,20 @@ }, "scripts": { "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: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'", - "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: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", "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 .", "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-snapshots": "npx playwright test -g 'profile picture' --update-snapshots", "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\"", - "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:win32": "yarn build-release-non-linux", @@ -259,7 +254,10 @@ "mac": { "category": "public.app-category.social-networking", "icon": "build/icon-mac.icns", - "target": ["dmg", "zip"], + "target": [ + "dmg", + "zip" + ], "bundleVersion": "1", "hardenedRuntime": true, "gatekeeperAssess": false, @@ -293,7 +291,11 @@ "StartupWMClass": "Session" }, "asarUnpack": "node_modules/spellchecker/vendor/hunspell_dictionaries", - "target": ["deb", "rpm", "freebsd"], + "target": [ + "deb", + "rpm", + "freebsd" + ], "icon": "build/icon-linux.icns" }, "asarUnpack": [ diff --git a/ts/node/database_utility.ts b/ts/node/database_utility.ts index cbab12e81..1a8087342 100644 --- a/ts/node/database_utility.ts +++ b/ts/node/database_utility.ts @@ -78,8 +78,7 @@ const allowedKeysFormatRowOfConversation = [ 'conversationIdOrigin', 'identityPrivateKey', ]; - -//tslint-disable cyclomatic-complexity +// tslint:disable: cyclomatic-complexity export function formatRowOfConversation(row?: Record): ConversationAttributes | null { if (!row) { return null; diff --git a/ts/session/apis/snode_api/SnodeRequestTypes.ts b/ts/session/apis/snode_api/SnodeRequestTypes.ts index ac11da8d9..80aa52689 100644 --- a/ts/session/apis/snode_api/SnodeRequestTypes.ts +++ b/ts/session/apis/snode_api/SnodeRequestTypes.ts @@ -1,4 +1,3 @@ - export type SwarmForSubRequest = { method: 'get_swarm'; params: { pubkey: string } }; type RetrieveMaxCountSize = { max_count?: number; max_size?: number }; @@ -124,11 +123,10 @@ export type SnodeApiSubRequests = | StoreOnNodeSubRequest | NetworkTimeSubRequest; -//tslint-disable: array-type +// tslint:disable: array-type export type NonEmptyArray = [T, ...T[]]; export type NotEmptyArrayOfBatchResults = NonEmptyArray<{ code: number; body: Record; }>; - diff --git a/ts/session/apis/snode_api/batchRequest.ts b/ts/session/apis/snode_api/batchRequest.ts index eef3aff04..7946ece0b 100644 --- a/ts/session/apis/snode_api/batchRequest.ts +++ b/ts/session/apis/snode_api/batchRequest.ts @@ -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 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 - * @returns */ export async function doSnodeBatchRequest( subRequests: Array, diff --git a/ts/session/apis/snode_api/swarmPolling.ts b/ts/session/apis/snode_api/swarmPolling.ts index 19c8d1957..63b6a1b56 100644 --- a/ts/session/apis/snode_api/swarmPolling.ts +++ b/ts/session/apis/snode_api/swarmPolling.ts @@ -244,7 +244,6 @@ export class SwarmPolling { return group; }); } else if (isGroup) { - debugger; window?.log?.info( `Polled for group(${ed25519Str( pubkey.key @@ -291,7 +290,6 @@ export class SwarmPolling { namespaces, UserUtils.getOurPubKeyStrFromCache() ); - debugger; if (!results.length) { return []; } diff --git a/ts/session/group/closed-group.ts b/ts/session/group/closed-group.ts index 317bf039a..abd9379f5 100644 --- a/ts/session/group/closed-group.ts +++ b/ts/session/group/closed-group.ts @@ -79,10 +79,10 @@ export async function initiateClosedGroupUpdate( groupName: string, members: Array ) { - const isV3 = PubKey.isClosedGroupV3(groupId); + const isGroupV3 = PubKey.isClosedGroupV3(groupId); const convo = await getConversationController().getOrCreateAndWait( groupId, - isV3 ? ConversationTypeEnum.GROUPV3 : ConversationTypeEnum.GROUP + isGroupV3 ? ConversationTypeEnum.GROUPV3 : ConversationTypeEnum.GROUP ); if (!convo.isMediumGroup()) { diff --git a/ts/session/utils/Bencoding.ts b/ts/session/utils/Bencoding.ts index fef98289d..ea8b73bd2 100644 --- a/ts/session/utils/Bencoding.ts +++ b/ts/session/utils/Bencoding.ts @@ -214,7 +214,6 @@ export class BEncode { if (isArray(item)) { let content = new Uint8Array(); - //tslint disable prefer-for-of for (let index = 0; index < item.length; index++) { const encodedItem = this.encodeItem(item[index]); const encodedItemLength = encodedItem.length; diff --git a/ts/test/session/unit/libsession_wrapper/libsession_wrapper_test.ts b/ts/test/session/unit/libsession_wrapper/libsession_wrapper_test_skip.ts similarity index 85% rename from ts/test/session/unit/libsession_wrapper/libsession_wrapper_test.ts rename to ts/test/session/unit/libsession_wrapper/libsession_wrapper_test_skip.ts index a8d115ec2..6e27d4730 100644 --- a/ts/test/session/unit/libsession_wrapper/libsession_wrapper_test.ts +++ b/ts/test/session/unit/libsession_wrapper/libsession_wrapper_test_skip.ts @@ -1,15 +1,20 @@ import { expect } from 'chai'; -import * as SessionUtilWrapper from 'session_util_wrapper'; import { stringToUint8Array } from '../../../../session/utils/String'; import { from_hex, to_hex } from 'libsodium-wrappers-sumo'; 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', () => { - 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). // To do this, you can cd to the node_module/libsession_wrapper folder and do // 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( '0123456789abcdef0123456789abcdef000000000000000000000000000000004cb76fdc6d32278e3f83dbf608360ecc6b65727934b85d2fb86862ff98c46ab7' @@ -67,54 +72,39 @@ describe('libsession_wrapper', () => { pushResult = conf.push(); expect(pushResult.seqno).to.be.eq(1); - const exp_hash0 = from_hex('ea173b57beca8af18c3519a7bbf69c3e7a05d1c049fa9558341d8ebb48b0c965'); - - // prettier-ignore - const exp_push1_start = "d" + - "1:#" +"i1e"+ - "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"; + const expHash0 = from_hex('ea173b57beca8af18c3519a7bbf69c3e7a05d1c049fa9558341d8ebb48b0c965'); + + const expPush1Start = + 'd1:#i1e1:&d1:n6:Kallie1:p34:http://example.org/omg-pic-123.bmp1:q6:secrete1: { expect(conf2.needsDump()).to.be.false; // 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); // Our state has changed, so we need to dump: diff --git a/ts/test/session/unit/sogsv3/knownBlindedKeys_test.ts b/ts/test/session/unit/sogsv3/knownBlindedKeys_test.ts index c12782545..9b09f9c4b 100644 --- a/ts/test/session/unit/sogsv3/knownBlindedKeys_test.ts +++ b/ts/test/session/unit/sogsv3/knownBlindedKeys_test.ts @@ -580,7 +580,7 @@ describe('knownBlindedKeys', () => { 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 }); }); diff --git a/tslint.json b/tslint.json index 4e6e28901..357cccdee 100644 --- a/tslint.json +++ b/tslint.json @@ -26,6 +26,9 @@ "object-literal-sort-keys": false, "no-async-without-await": true, "no-empty-interface": false, + "prefer-for-of": false, + "chai-vague-errors": false, + "no-useless-files": false, "ordered-imports": [ true, { diff --git a/yarn.lock b/yarn.lock index 24c053925..e1bed7451 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8205,7 +8205,7 @@ serialize-javascript@6.0.0: "session_util_wrapper@https://github.com/oxen-io/libsession-util-nodejs": 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: bindings "^1.5.0" nan "^2.17.0"