diff --git a/deltachat-jsonrpc/typescript/report_api_coverage.mjs b/deltachat-jsonrpc/typescript/report_api_coverage.mjs index 7a1c23859..6448289e8 100644 --- a/deltachat-jsonrpc/typescript/report_api_coverage.mjs +++ b/deltachat-jsonrpc/typescript/report_api_coverage.mjs @@ -5,24 +5,24 @@ const json = JSON.parse(readFileSync("./coverage/coverage-final.json")); const jsonCoverage = json[Object.keys(json).find((k) => k.includes(generatedFile))]; const fnMap = Object.keys(jsonCoverage.fnMap).map( - (key) => jsonCoverage.fnMap[key] + (key) => jsonCoverage.fnMap[key], ); const htmlCoverage = readFileSync( "./coverage/" + generatedFile + ".html", - "utf8" + "utf8", ); const uncoveredLines = htmlCoverage .split("\n") .filter((line) => line.includes(`"function not covered"`)); const uncoveredFunctions = uncoveredLines.map( - (line) => />([\w_]+)\(/.exec(line)[1] + (line) => />([\w_]+)\(/.exec(line)[1], ); console.log( "\nUncovered api functions:\n" + uncoveredFunctions .map((uF) => fnMap.find(({ name }) => name === uF)) .map( - ({ name, line }) => `.${name.padEnd(40)} (${generatedFile}:${line})` + ({ name, line }) => `.${name.padEnd(40)} (${generatedFile}:${line})`, ) - .join("\n") + .join("\n"), ); diff --git a/deltachat-jsonrpc/typescript/scripts/generate-constants.js b/deltachat-jsonrpc/typescript/scripts/generate-constants.js index 4f20a5038..254972a28 100755 --- a/deltachat-jsonrpc/typescript/scripts/generate-constants.js +++ b/deltachat-jsonrpc/typescript/scripts/generate-constants.js @@ -24,7 +24,7 @@ while (null != (match = regex.exec(header_data))) { const constants = data .filter( - ({ key }) => key.toUpperCase()[0] === key[0] // check if define name is uppercase + ({ key }) => key.toUpperCase()[0] === key[0], // check if define name is uppercase ) .sort((lhs, rhs) => { if (lhs.key < rhs.key) return -1; @@ -50,5 +50,5 @@ const constants = data writeFileSync( resolve(__dirname, "../generated/constants.ts"), - `// Generated!\n\nexport enum C {\n${constants.replace(/:/g, " =")},\n}\n` + `// Generated!\n\nexport enum C {\n${constants.replace(/:/g, " =")},\n}\n`, ); diff --git a/deltachat-jsonrpc/typescript/src/client.ts b/deltachat-jsonrpc/typescript/src/client.ts index 32b86e738..03bda79a7 100644 --- a/deltachat-jsonrpc/typescript/src/client.ts +++ b/deltachat-jsonrpc/typescript/src/client.ts @@ -8,13 +8,13 @@ import { TinyEmitter } from "@deltachat/tiny-emitter"; type Events = { ALL: (accountId: number, event: EventType) => void } & { [Property in EventType["kind"]]: ( accountId: number, - event: Extract + event: Extract, ) => void; }; type ContextEvents = { ALL: (event: EventType) => void } & { [Property in EventType["kind"]]: ( - event: Extract + event: Extract, ) => void; }; @@ -25,7 +25,7 @@ export type DcEventType = Extract< >; export class BaseDeltaChat< - Transport extends BaseTransport + Transport extends BaseTransport, > extends TinyEmitter { rpc: RawClient; account?: T.Account; @@ -34,7 +34,10 @@ export class BaseDeltaChat< //@ts-ignore private eventTask: Promise; - constructor(public transport: Transport, startEventLoop: boolean) { + constructor( + public transport: Transport, + startEventLoop: boolean, + ) { super(); this.rpc = new RawClient(this.transport); if (startEventLoop) { @@ -53,7 +56,7 @@ export class BaseDeltaChat< this.contextEmitters[event.contextId].emit( event.event.kind, //@ts-ignore - event.event as any + event.event as any, ); this.contextEmitters[event.contextId].emit("ALL", event.event as any); } @@ -83,7 +86,10 @@ export class StdioDeltaChat extends BaseDeltaChat { } export class StdioTransport extends BaseTransport { - constructor(public input: any, public output: any) { + constructor( + public input: any, + public output: any, + ) { super(); var buffer = ""; diff --git a/deltachat-jsonrpc/typescript/test/basic.ts b/deltachat-jsonrpc/typescript/test/basic.ts index b3ba3b6fa..ac28818a2 100644 --- a/deltachat-jsonrpc/typescript/test/basic.ts +++ b/deltachat-jsonrpc/typescript/test/basic.ts @@ -31,14 +31,14 @@ describe("basic tests", () => { expect( await Promise.all( - validAddresses.map((email) => dc.rpc.checkEmailValidity(email)) - ) + validAddresses.map((email) => dc.rpc.checkEmailValidity(email)), + ), ).to.not.contain(false); expect( await Promise.all( - invalidAddresses.map((email) => dc.rpc.checkEmailValidity(email)) - ) + invalidAddresses.map((email) => dc.rpc.checkEmailValidity(email)), + ), ).to.not.contain(true); }); @@ -84,7 +84,7 @@ describe("basic tests", () => { const contactId = await dc.rpc.createContact( accountId, "example@delta.chat", - null + null, ); expect((await dc.rpc.getContact(accountId, contactId)).isBlocked).to.be .false; @@ -126,7 +126,7 @@ describe("basic tests", () => { await dc.rpc.batchSetConfig(accountId, config); const retrieved = await dc.rpc.batchGetConfig( accountId, - Object.keys(config) + Object.keys(config), ); expect(retrieved).to.deep.equal(config); }); @@ -138,7 +138,7 @@ describe("basic tests", () => { await dc.rpc.batchSetConfig(accountId, config); const retrieved = await dc.rpc.batchGetConfig( accountId, - Object.keys(config) + Object.keys(config), ); expect(retrieved).to.deep.equal(config); }); @@ -152,7 +152,7 @@ describe("basic tests", () => { await dc.rpc.batchSetConfig(accountId, config); const retrieved = await dc.rpc.batchGetConfig( accountId, - Object.keys(config) + Object.keys(config), ); expect(retrieved).to.deep.equal(config); }); diff --git a/deltachat-jsonrpc/typescript/test/online.ts b/deltachat-jsonrpc/typescript/test/online.ts index e92071426..91238d6f0 100644 --- a/deltachat-jsonrpc/typescript/test/online.ts +++ b/deltachat-jsonrpc/typescript/test/online.ts @@ -17,12 +17,12 @@ describe("online tests", function () { if (process.env.COVERAGE && !process.env.COVERAGE_OFFLINE) { console.error( "CAN NOT RUN COVERAGE correctly: Missing CHATMAIL_DOMAIN environment variable!\n\n", - "You can set COVERAGE_OFFLINE=1 to circumvent this check and skip the online tests, but those coverage results will be wrong, because some functions can only be tested in the online test" + "You can set COVERAGE_OFFLINE=1 to circumvent this check and skip the online tests, but those coverage results will be wrong, because some functions can only be tested in the online test", ); process.exit(1); } console.log( - "Missing CHATMAIL_DOMAIN environment variable!, skip integration tests" + "Missing CHATMAIL_DOMAIN environment variable!, skip integration tests", ); this.skip(); } @@ -36,7 +36,7 @@ describe("online tests", function () { account1 = createTempUser(process.env.CHATMAIL_DOMAIN); if (!account1 || !account1.email || !account1.password) { console.log( - "We didn't got back an account from the api, skip integration tests" + "We didn't got back an account from the api, skip integration tests", ); this.skip(); } @@ -44,7 +44,7 @@ describe("online tests", function () { account2 = createTempUser(process.env.CHATMAIL_DOMAIN); if (!account2 || !account2.email || !account2.password) { console.log( - "We didn't got back an account2 from the api, skip integration tests" + "We didn't got back an account2 from the api, skip integration tests", ); this.skip(); } @@ -92,7 +92,7 @@ describe("online tests", function () { accountId2, chatIdOnAccountB, false, - false + false, ); expect(messageList).have.length(1); @@ -124,11 +124,11 @@ describe("online tests", function () { accountId2, chatIdOnAccountB, false, - false + false, ); const message = await dc.rpc.getMessage( accountId2, - messageList.reverse()[0] + messageList.reverse()[0], ); expect(message.text).equal("Hello2"); // Send message back from B to A @@ -150,7 +150,7 @@ describe("online tests", function () { const info = await dc.rpc.getProviderInfo(acc, "example.com"); expect(info).to.be.not.null; expect(info?.overviewPage).to.equal( - "https://providers.delta.chat/example-com" + "https://providers.delta.chat/example-com", ); expect(info?.status).to.equal(3); }); @@ -167,12 +167,12 @@ async function waitForEvent( dc: DeltaChat, eventType: T, accountId: number, - timeout: number = EVENT_TIMEOUT + timeout: number = EVENT_TIMEOUT, ): Promise> { return new Promise((resolve, reject) => { const rejectTimeout = setTimeout( () => reject(new Error("Timeout reached before event came in")), - timeout + timeout, ); const callback = (contextId: number, event: DcEvent) => { if (contextId == accountId) { diff --git a/deltachat-jsonrpc/typescript/test/test_base.ts b/deltachat-jsonrpc/typescript/test/test_base.ts index c834a2b9e..9196c4169 100644 --- a/deltachat-jsonrpc/typescript/test/test_base.ts +++ b/deltachat-jsonrpc/typescript/test/test_base.ts @@ -14,7 +14,7 @@ export async function startServer(): Promise { const tmpDir = await mkdtemp(join(tmpdir(), "deltachat-jsonrpc-test")); const pathToServerBinary = resolve( - join(await getTargetDir(), "debug/deltachat-rpc-server") + join(await getTargetDir(), "debug/deltachat-rpc-server"), ); const server = spawn(pathToServerBinary, { @@ -29,7 +29,7 @@ export async function startServer(): Promise { throw new Error( "Failed to start server executable " + pathToServerBinary + - ", make sure you built it first." + ", make sure you built it first.", ); }); let shouldClose = false; @@ -83,7 +83,7 @@ function getTargetDir(): Promise { reject(error); } } - } + }, ); }); }