From 32e7fa4fbd35498ecaafaae96f20e0dc603a4d0c Mon Sep 17 00:00:00 2001 From: Leandro Facchinetti Date: Fri, 3 Apr 2020 17:06:43 -0400 Subject: [PATCH] Update prettier --- package-lock.json | 6 +++--- package.json | 4 ++-- src/check.ts | 2 +- src/index.tsx | 34 +++++++++++++++++----------------- src/test.ts | 26 +++++++++++++------------- 5 files changed, 36 insertions(+), 36 deletions(-) diff --git a/package-lock.json b/package-lock.json index f1662c6..00bbb22 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6342,9 +6342,9 @@ "dev": true }, "prettier": { - "version": "1.19.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.19.1.tgz", - "integrity": "sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.0.2.tgz", + "integrity": "sha512-5xJQIPT8BraI7ZnaDwSbu5zLrB6vvi8hVV58yHQ+QK64qrY40dULy0HSRlQ2/2IdzeBpjhDkqdcFBnFeDEMVdg==", "dev": true }, "pretty-format": { diff --git a/package.json b/package.json index 0cfd3a7..f0b4181 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "scripts": { "start": "concurrently \"tsc --watch\" \"nodemon lib\"", - "test": "tsc && jest && prettier --check 'src/**'" + "test": "tsc && jest && prettier --check src" }, "dependencies": { "caddy-npm": "^2.0.0-beta.20", @@ -31,7 +31,7 @@ "jest": "^25.2.4", "nodemailer": "^6.4.6", "nodemon": "^2.0.2", - "prettier": "^1.19.1", + "prettier": "^2.0.2", "qs": "^6.9.3", "typescript": "^3.8.3" }, diff --git a/src/check.ts b/src/check.ts index 16ce00a..b5e12a4 100644 --- a/src/check.ts +++ b/src/check.ts @@ -4,7 +4,7 @@ import fs from "fs"; console.log("STARTED"); for (const feed of fs .readdirSync("static/feeds") - .filter(file => !file.startsWith("."))) { + .filter((file) => !file.startsWith("."))) { try { const xml: any = xmlbuilder2.convert( fs.readFileSync(`static/feeds/${feed}`, "utf8"), diff --git a/src/index.tsx b/src/index.tsx index 794a0d9..bdd4c40 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -38,7 +38,7 @@ export const webServer = express() ) ); - })().catch(error => { + })().catch((error) => { console.error( `Error creating feed: ${JSON.stringify({ name, identifier }, null, 2)}` ); @@ -83,7 +83,7 @@ export const emailServer = new SMTPServer({ title: email.subject ?? "", author: email.from?.text ?? "", content: - typeof email.html === "string" ? email.html : email.textAsHtml ?? "" + typeof email.html === "string" ? email.html : email.textAsHtml ?? "", }); for (const { address } of session.envelope.rcptTo) { const match = address.match(/^(\w+)@kill-the-newsletter.com$/); @@ -102,7 +102,7 @@ export const emailServer = new SMTPServer({ await writeFileAtomic(path, renderXML(xml)); } callback(); - })().catch(error => { + })().catch((error) => { console.error( `Error receiving email: ${JSON.stringify({ session, email }, null, 2)}` ); @@ -110,7 +110,7 @@ export const emailServer = new SMTPServer({ stream.resume(); callback(new Error("Failed to receive message. Please try again.")); }); - } + }, }).listen(process.env.EMAIL_PORT ?? 2525); function Layout({ children }: { children: React.ReactNode }) { @@ -226,13 +226,13 @@ function Feed({ name, identifier }: { name: string; identifier: string }) { { "@rel": "self", "@type": "application/atom+xml", - "@href": feedURL(identifier) + "@href": feedURL(identifier), }, { "@rel": "alternate", "@type": "text/html", - "@href": "https://www.kill-the-newsletter.com/" - } + "@href": "https://www.kill-the-newsletter.com/", + }, ], id: urn(identifier), title: name, @@ -246,16 +246,16 @@ function Feed({ name, identifier }: { name: string; identifier: string }) { author: "Kill the Newsletter!", content: ReactDOMServer.renderToStaticMarkup( - ) - }) - } + ), + }), + }, }; } function Entry({ title, author, - content + content, }: { title: string; author: string; @@ -270,17 +270,17 @@ function Entry({ link: { "@rel": "alternate", "@type": "text/html", - "@href": "https://www.kill-the-newsletter.com/entry" + "@href": "https://www.kill-the-newsletter.com/entry", }, - content: { "@type": "html", "#": content } - } + content: { "@type": "html", "#": content }, + }, }; } function createIdentifier(): string { return cryptoRandomString({ length: 20, - characters: "1234567890qwertyuiopasdfghjklzxcvbnm" + characters: "1234567890qwertyuiopasdfghjklzxcvbnm", }); } @@ -312,13 +312,13 @@ function renderXML(xml: object): string { return xmlbuilder2.convert({ invalidCharReplacement: "" }, xml, { format: "xml", noDoubleEncoding: true, - prettyPrint: true + prettyPrint: true, }); } function parseXML(xml: string): any { return xmlbuilder2.convert({ invalidCharReplacement: "" }, xml, { format: "object", - noDoubleEncoding: true + noDoubleEncoding: true, }); } diff --git a/src/test.ts b/src/test.ts index 5aabb79..ca72d11 100644 --- a/src/test.ts +++ b/src/test.ts @@ -18,7 +18,7 @@ describe("receive email", () => { from: "publisher@example.com", to: `${identifier}@kill-the-newsletter.com`, subject: "New Message", - html: "

HTML content

" + html: "

HTML content

", }); const after = await getFeed(identifier); expect(after.match(/(.*)<\/updated>/)![1]).not.toMatch( @@ -32,7 +32,7 @@ describe("receive email", () => { from: "publisher@example.com", to: `${identifier}@kill-the-newsletter.com`, subject: "New Message", - html: "

HTML content

" + html: "

HTML content

", }); const feed = await getFeed(identifier); expect(feed).toMatch("publisher@example.com"); @@ -46,7 +46,7 @@ describe("receive email", () => { from: "publisher@example.com", to: `${identifier}@kill-the-newsletter.com`, subject: "New Message", - text: "TEXT content" + text: "TEXT content", }); const feed = await getFeed(identifier); expect(feed).toMatch("TEXT content"); @@ -58,7 +58,7 @@ describe("receive email", () => { from: "publisher@example.com", to: `${identifier}@kill-the-newsletter.com`, subject: "New Message", - text: "TEXT content\n\nhttps://www.kill-the-newsletter.com\n\nMore text" + text: "TEXT content\n\nhttps://www.kill-the-newsletter.com\n\nMore text", }); const feed = await getFeed(identifier); expect(feed).toMatch("TEXT content"); @@ -71,7 +71,7 @@ describe("receive email", () => { from: "publisher@example.com", to: `${identifier}@kill-the-newsletter.com`, subject: "New Message", - html: "

Invalid XML character (backspace): ‘\b’

" + html: "

Invalid XML character (backspace): ‘\b’

", }); const feed = await getFeed(identifier); expect(feed).toMatch("Invalid XML character (backspace): ‘’"); @@ -83,7 +83,7 @@ describe("receive email", () => { from: "publisher@example.com", to: `${identifier}@kill-the-newsletter.com`, subject: "New Message", - text: "Invalid XML character (backspace): ‘\b’" + text: "Invalid XML character (backspace): ‘\b’", }); const feed = await getFeed(identifier); expect(feed).toMatch( @@ -96,7 +96,7 @@ describe("receive email", () => { await emailClient.sendMail({ from: "publisher@example.com", to: `${identifier}@kill-the-newsletter.com`, - subject: "New Message" + subject: "New Message", }); const feed = await getFeed(identifier); expect(feed).toMatch("New Message"); @@ -107,7 +107,7 @@ describe("receive email", () => { await emailClient.sendMail({ from: "publisher@example.com", to: `${identifier}@kill-the-newsletter.com`, - html: "

HTML content

" + html: "

HTML content

", }); const feed = await getFeed(identifier); expect(feed).toMatch("HTML content"); @@ -120,7 +120,7 @@ describe("receive email", () => { from: "publisher@example.com", to: `${identifier}@kill-the-newsletter.com`, subject: "New Message", - text: `REPETITION ${repetition} `.repeat(10_000) + text: `REPETITION ${repetition} `.repeat(10_000), }); const feed = await getFeed(identifier); expect(feed).toMatch("REPETITION 3"); @@ -132,7 +132,7 @@ describe("receive email", () => { from: "publisher@example.com", to: "nonexistent@kill-the-newsletter.com", subject: "New Message", - html: "

HTML content

" + html: "

HTML content

", }); }); @@ -141,7 +141,7 @@ describe("receive email", () => { await emailClient.sendMail({ to: `${identifier}@kill-the-newsletter.com`, subject: "New Message", - html: "

HTML content

" + html: "

HTML content

", }); const feed = await getFeed(identifier); expect(feed).toMatch("HTML content"); @@ -154,7 +154,7 @@ afterAll(() => { }); const webClient = axios.create({ - baseURL: `http://localhost:${(webServer.address() as AddressInfo).port}` + baseURL: `http://localhost:${(webServer.address() as AddressInfo).port}`, }); const emailClient = nodemailer.createTransport( `smtp://localhost:${(emailServer.address() as AddressInfo).port}` @@ -165,7 +165,7 @@ async function createFeed(): Promise { await webClient.post( "/", qs.stringify({ - name: "My Feed" + name: "My Feed", }) ) ).data.match(/(\w{20}).xml/)![1];