Skip to content

Commit 4fe6211

Browse files
authored
Lint no floating promises 2 (#370)
* await creating the default list * for completeness: also assert organization * lint for await * ooops - put the eslint config for ts in the right place * eslint should ignore .mailing directories * add tsconfig's to parserOptions.project in @typescript-eslint/parser block * await async functions * don't ignore __test__ from tsconfig in core * linter says that this expect must be awaited * tsconfig covers all the .ts files in the root directory: jest.config.ts testSetup.integration.ts testUtilIntegration.ts jest.integration.config.ts testSetup.ts * tsconfig should include e2e/**/* * src/cli/generator_templates/**/* is not a directory in packages/cli * await some async functions * we're using plain js in e2e/mailing_tests so don't need a tsconfig * fix typo * await analytics calls * eslintignore these 2 files: packages/cli/src/generator_templates packages/cli/src/emails because they are ignored in tsconfig.json * update files attribute in package.json * don't actually want to ignore those * this is my workaround for typescript-eslint/typescript-eslint#2987 * noop? * simplify tsconfigs? * fix all the lints * oops * try void * async await * smaller change * fix server build * Revert "fix server build" This reverts commit e24e0ed. * await -> void in init * remove trailing comma in json * cypress does not actually need to reset the web db, so remove * server: try cd into .mailing and then npx next build with the current directory * pull posthog api key into its own file so it does not bloat the next build by pulling in posthog-node * import from the righ tplaÿce
1 parent e155434 commit 4fe6211

File tree

30 files changed

+65
-61
lines changed

30 files changed

+65
-61
lines changed

.eslintrc.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,23 @@
3535
{
3636
"files": ["**/*.ts", "**/*.tsx"],
3737
"parser": "@typescript-eslint/parser",
38+
"parserOptions": {
39+
"project": [
40+
"./tsconfig.json",
41+
"./packages/cli/tsconfig.json",
42+
"./packages/core/tsconfig.json",
43+
"./packages/web/tsconfig.json",
44+
"./packages/cli/cypress/tsconfig.json"
45+
]
46+
},
3847
"plugins": ["@typescript-eslint"],
3948
"extends": [
4049
"eslint:recommended",
4150
"plugin:@typescript-eslint/recommended"
4251
],
4352
"rules": {
4453
"no-unused-vars": "off",
54+
"@typescript-eslint/no-floating-promises": "error",
4555
"@typescript-eslint/no-explicit-any": "off",
4656
"@typescript-eslint/no-unused-vars": [
4757
"error",

.husky/pre-commit

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#!/usr/bin/env sh
22
. "$(dirname "$0")/_/husky.sh"
33

4+
yarn lint:unlink
45
yarn lint-staged
6+
yarn lint:link

.lintstagedrc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@
33
"*.rb": "rubocop --autocorrect",
44
"packages/cli/src/generator_templates/ts/**/*.{ts,tsx}": "scripts/build-js-templates"
55
}
6-

e2e/mailing_tests/cypress/tsconfig.json

Lines changed: 0 additions & 8 deletions
This file was deleted.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
"packages/*"
1010
],
1111
"scripts": {
12-
"lint": "eslint .",
12+
"lint": "yarn lint:unlink; eslint .; yarn lint:link",
13+
"lint:unlink": "rm packages/cli/src/emails",
14+
"lint:link": "ln -s 'generator_templates/ts/emails/' packages/cli/src/emails",
1315
"dev": "cd packages/cli && yarn dev",
1416
"dev:js": "yarn link:emails:js && yarn dev",
1517
"dev:init": "cd packages/cli && rm -rf previews_html; rm -rf .mailing emails mailing.config.json; src/dev.js",

packages/cli/cypressIntegration.config.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import { defineConfig } from "cypress";
22
import cliPrisma from "./prisma";
3-
import webPrisma from "../../packages/web/prisma";
4-
import type { PrismaTableName } from "../../testUtilIntegration";
3+
4+
interface PrismaTableName {
5+
table_name: string;
6+
}
57

68
const resetDb = async () => {
79
await truncateDatabases();
@@ -31,12 +33,8 @@ export async function truncateCliDatabase() {
3133
await truncateTables(cliPrisma);
3234
}
3335

34-
export async function truncateWebDatabase() {
35-
await truncateTables(webPrisma);
36-
}
37-
3836
export async function truncateDatabases() {
39-
return Promise.all([truncateCliDatabase(), truncateWebDatabase()]);
37+
await truncateCliDatabase();
4038
}
4139

4240
async function truncateTables(client: any) {

packages/cli/src/commands/init.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export const handler = buildHandler(
8686
try {
8787
const url = `${getMailingAPIBaseURL()}/api/newsletterSubscribers`;
8888

89-
fetch(url, {
89+
void fetch(url, {
9090
method: "POST",
9191
headers: { "Content-Type": "application/json" },
9292
body: JSON.stringify({ email }),
@@ -109,7 +109,7 @@ export const handler = buildHandler(
109109
_: argv._,
110110
};
111111

112-
previewHandler(previewHandlerArgv);
112+
await previewHandler(previewHandlerArgv);
113113
},
114114
{
115115
captureOptions: () => {

packages/cli/src/commands/preview/server/__integration__/livereload.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ describe("livereload", () => {
3434
done();
3535
});
3636

37-
touchTemplate();
37+
void touchTemplate();
3838
});
3939
});
4040
});

packages/cli/src/commands/preview/server/livereload.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export function startChangeWatcher(server: Server, emailsDir: string) {
5050
if (WATCH_IGNORE.test(filename)) return;
5151
log(`detected ${eventType} on ${filename}, reloading`);
5252
delete require.cache[resolve(changeWatchPath, filename)];
53-
reload();
53+
void reload();
5454
}
5555
);
5656

packages/cli/src/commands/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export const handler = buildHandler(
6666
stdio: "inherit",
6767
});
6868

69-
execSync("npx next build .mailing", {
69+
execSync("cd .mailing && npx next build", {
7070
stdio: "inherit",
7171
});
7272
}

0 commit comments

Comments
 (0)