diff --git a/integration/cf-compiler-test.ts b/integration/cf-compiler-test.ts index c6ae70fd4e4..0fb9b321771 100644 --- a/integration/cf-compiler-test.ts +++ b/integration/cf-compiler-test.ts @@ -6,7 +6,7 @@ import glob from "glob"; import { createFixtureProject, js, json } from "./helpers/create-fixture.js"; -const searchFiles = async (pattern: string | RegExp, files: string[]) => { +const searchFiles = (pattern: string | RegExp, files: string[]) => { let result = shell.grep("-l", pattern, files); return result.stdout .trim() @@ -14,7 +14,7 @@ const searchFiles = async (pattern: string | RegExp, files: string[]) => { .filter((line) => line.length > 0); }; -const findCodeFiles = async (directory: string) => +const findCodeFiles = (directory: string) => glob.sync("**/*.@(js|jsx|ts|tsx)", { cwd: directory, absolute: true, diff --git a/integration/defer-loader-test.ts b/integration/defer-loader-test.ts index 141c507eeb9..eae6950de76 100644 --- a/integration/defer-loader-test.ts +++ b/integration/defer-loader-test.ts @@ -72,7 +72,7 @@ test.beforeAll(async () => { appFixture = await createAppFixture(fixture); }); -test.afterAll(async () => appFixture.close()); +test.afterAll(() => appFixture.close()); test("deferred response can redirect on document request", async ({ page }) => { let app = new PlaywrightFixture(appFixture, page); diff --git a/integration/deno-compiler-test.ts b/integration/deno-compiler-test.ts index 6da8b70d59b..219ccb7bebe 100644 --- a/integration/deno-compiler-test.ts +++ b/integration/deno-compiler-test.ts @@ -19,12 +19,12 @@ const importPattern = (importSpecifier: string) => String.raw`import\s*{.*}\s*from\s*"` + importSpecifier + String.raw`"` ); -const findCodeFiles = async (directory: string) => +const findCodeFiles = (directory: string) => glob.sync("**/*.@(js|jsx|ts|tsx)", { cwd: directory, absolute: true, }); -const searchFiles = async (pattern: string | RegExp, files: string[]) => { +const searchFiles = (pattern: string | RegExp, files: string[]) => { let result = shell.grep("-l", pattern, files); return result.stdout .trim() diff --git a/integration/fetch-globals-test.ts b/integration/fetch-globals-test.ts index 3592f230aea..12463b0f22b 100644 --- a/integration/fetch-globals-test.ts +++ b/integration/fetch-globals-test.ts @@ -35,7 +35,7 @@ test.beforeAll(async () => { appFixture = await createAppFixture(fixture); }); -test.afterAll(async () => appFixture.close()); +test.afterAll(() => appFixture.close()); test("returned variable from fetch() should be instance of global Response", async () => { let response = await fixture.requestDocument("/"); diff --git a/integration/flat-routes-test.ts b/integration/flat-routes-test.ts index 53eae110e1d..a45128260fc 100644 --- a/integration/flat-routes-test.ts +++ b/integration/flat-routes-test.ts @@ -159,14 +159,14 @@ test.describe("flat routes", () => { }); } - test("allows ignoredRouteFiles to be configured", async () => { + test("allows ignoredRouteFiles to be configured", () => { let routeIds = Object.keys(fixture.build.routes); expect(routeIds).not.toContain(IGNORED_ROUTE); }); }); -test.describe("emits warnings for route conflicts", async () => { +test.describe("emits warnings for route conflicts", () => { let buildStdio = new PassThrough(); let buildOutput: string; diff --git a/integration/route-collisions-test.ts b/integration/route-collisions-test.ts index 52bc3c445da..df881b36538 100644 --- a/integration/route-collisions-test.ts +++ b/integration/route-collisions-test.ts @@ -37,7 +37,7 @@ test.describe("build failures", () => { let originalConsoleWarn = console.warn; let originalConsoleError = console.error; - test.beforeAll(async () => { + test.beforeAll(() => { console.log = () => {}; console.warn = () => {}; console.error = () => {}; diff --git a/packages/remix-dev/compiler/css/plugins/bundleEntry.ts b/packages/remix-dev/compiler/css/plugins/bundleEntry.ts index 4eaa3f4cb0b..7e0de4acf17 100644 --- a/packages/remix-dev/compiler/css/plugins/bundleEntry.ts +++ b/packages/remix-dev/compiler/css/plugins/bundleEntry.ts @@ -21,7 +21,7 @@ export function cssBundleEntryModulePlugin({ config }: Context): Plugin { }; }); - build.onLoad({ filter }, async () => { + build.onLoad({ filter }, () => { return { resolveDir: config.appDirectory, loader: "js", diff --git a/packages/remix-dev/compiler/js/plugins/hmr.ts b/packages/remix-dev/compiler/js/plugins/hmr.ts index d221eb589f5..8b4420dc1e1 100644 --- a/packages/remix-dev/compiler/js/plugins/hmr.ts +++ b/packages/remix-dev/compiler/js/plugins/hmr.ts @@ -8,7 +8,7 @@ import type { Context } from "../../context"; export let hmrPlugin = ({ config }: Context): esbuild.Plugin => { return { name: "remix-hmr", - setup: async (build) => { + setup: (build) => { let cache = new Map(); build.onResolve({ filter: /^remix:hmr$/ }, (args) => { diff --git a/packages/remix-dev/compiler/js/plugins/routes.ts b/packages/remix-dev/compiler/js/plugins/routes.ts index c9891585a0d..9c54cbd27cb 100644 --- a/packages/remix-dev/compiler/js/plugins/routes.ts +++ b/packages/remix-dev/compiler/js/plugins/routes.ts @@ -27,7 +27,7 @@ export function browserRouteModulesPlugin( ): esbuild.Plugin { return { name: "browser-route-modules", - async setup(build) { + setup(build) { let routesByFile: Map = Object.keys(config.routes).reduce( (map, key) => { let route = config.routes[key]; diff --git a/packages/remix-dev/compiler/plugins/absoluteCssUrlsPlugin.ts b/packages/remix-dev/compiler/plugins/absoluteCssUrlsPlugin.ts index 21df14e5a45..81e0d983130 100644 --- a/packages/remix-dev/compiler/plugins/absoluteCssUrlsPlugin.ts +++ b/packages/remix-dev/compiler/plugins/absoluteCssUrlsPlugin.ts @@ -8,7 +8,7 @@ import type { Plugin, PluginBuild } from "esbuild"; export const absoluteCssUrlsPlugin = (): Plugin => { return { name: "absolute-css-urls-plugin", - setup: async (build: PluginBuild) => { + setup: (build: PluginBuild) => { build.onResolve({ filter: /.*/ }, async (args) => { let { kind, path: resolvePath } = args; if (kind === "url-token" && path.isAbsolute(resolvePath)) { diff --git a/packages/remix-dev/compiler/plugins/cssImports.ts b/packages/remix-dev/compiler/plugins/cssImports.ts index 8fe9aaaaaf6..dbaddb863cb 100644 --- a/packages/remix-dev/compiler/plugins/cssImports.ts +++ b/packages/remix-dev/compiler/plugins/cssImports.ts @@ -97,7 +97,7 @@ export function cssFilePlugin(ctx: Context): esbuild.Plugin { ? [ { name: "postcss-plugin", - async setup(build) { + setup(build) { build.onLoad( { filter: /\.css$/, namespace: "file" }, async (args) => { diff --git a/packages/remix-dev/compiler/server/plugins/entry.ts b/packages/remix-dev/compiler/server/plugins/entry.ts index a7c9634b94b..c98f92e971d 100644 --- a/packages/remix-dev/compiler/server/plugins/entry.ts +++ b/packages/remix-dev/compiler/server/plugins/entry.ts @@ -25,7 +25,7 @@ export function serverEntryModulePlugin({ config, options }: Context): Plugin { }; }); - build.onLoad({ filter }, async () => { + build.onLoad({ filter }, () => { return { resolveDir: config.appDirectory, loader: "js", diff --git a/packages/remix-dev/devServer_unstable/env.ts b/packages/remix-dev/devServer_unstable/env.ts index d41c6449897..de810f6c6b4 100644 --- a/packages/remix-dev/devServer_unstable/env.ts +++ b/packages/remix-dev/devServer_unstable/env.ts @@ -2,7 +2,7 @@ import fse from "fs-extra"; import * as path from "node:path"; // Import environment variables from: .env, failing gracefully if it doesn't exist -export async function loadEnv(rootDirectory: string): Promise { +export function loadEnv(rootDirectory: string) { let envPath = path.join(rootDirectory, ".env"); if (!fse.existsSync(envPath)) return; diff --git a/packages/remix-node/crypto.ts b/packages/remix-node/crypto.ts index cf85ef6547d..9f32b06bdd2 100644 --- a/packages/remix-node/crypto.ts +++ b/packages/remix-node/crypto.ts @@ -1,13 +1,10 @@ import cookieSignature from "cookie-signature"; import type { SignFunction, UnsignFunction } from "@remix-run/server-runtime"; -export const sign: SignFunction = async (value, secret) => { +export const sign: SignFunction = (value, secret) => { return cookieSignature.sign(value, secret); }; -export const unsign: UnsignFunction = async ( - signed: string, - secret: string -) => { +export const unsign: UnsignFunction = (signed: string, secret: string) => { return cookieSignature.unsign(signed, secret); }; diff --git a/packages/remix-server-runtime/crypto.ts b/packages/remix-server-runtime/crypto.ts index daedea742bf..74ddea533e2 100644 --- a/packages/remix-server-runtime/crypto.ts +++ b/packages/remix-server-runtime/crypto.ts @@ -1,9 +1,14 @@ -export type SignFunction = (value: string, secret: string) => Promise; +import type { Promisable } from "type-fest"; + +export type SignFunction = ( + value: string, + secret: string +) => Promisable; export type UnsignFunction = ( cookie: string, secret: string -) => Promise; +) => Promisable; // TODO: Once Node v19 is supported we should use the globally provided // Web Crypto API's and re-enable this code-path in "./cookies.ts" diff --git a/packages/remix-server-runtime/sessions.ts b/packages/remix-server-runtime/sessions.ts index c00eedb2321..65be7ec4642 100644 --- a/packages/remix-server-runtime/sessions.ts +++ b/packages/remix-server-runtime/sessions.ts @@ -1,4 +1,5 @@ import type { CookieParseOptions, CookieSerializeOptions } from "cookie"; +import type { Promisable } from "type-fest"; import type { Cookie, CookieOptions, CreateCookieFunction } from "./cookies"; import { isCookie } from "./cookies"; @@ -223,12 +224,14 @@ export interface SessionIdStorageStrategy< createData: ( data: FlashSessionData, expires?: Date - ) => Promise; + ) => Promisable; /** * Returns data for a given session id, or `null` if there isn't any. */ - readData: (id: string) => Promise | null>; + readData: ( + id: string + ) => Promisable | null>; /** * Updates data for the given session id. @@ -237,12 +240,12 @@ export interface SessionIdStorageStrategy< id: string, data: FlashSessionData, expires?: Date - ) => Promise; + ) => Promisable; /** * Deletes data for a given session id from the data store. */ - deleteData: (id: string) => Promise; + deleteData: (id: string) => Promisable; } export type CreateSessionStorageFunction = < diff --git a/scripts/playground/template/app/models/user.server.ts b/scripts/playground/template/app/models/user.server.ts index 32e030b4be5..62388ada2a8 100644 --- a/scripts/playground/template/app/models/user.server.ts +++ b/scripts/playground/template/app/models/user.server.ts @@ -5,11 +5,11 @@ import { prisma } from "~/db.server"; export type { User } from "@prisma/client"; -export async function getUserById(id: User["id"]) { +export function getUserById(id: User["id"]) { return prisma.user.findUnique({ where: { id } }); } -export async function getUserByEmail(email: User["email"]) { +export function getUserByEmail(email: User["email"]) { return prisma.user.findUnique({ where: { email } }); } @@ -28,7 +28,7 @@ export async function createUser(email: User["email"], password: string) { }); } -export async function deleteUserByEmail(email: User["email"]) { +export function deleteUserByEmail(email: User["email"]) { return prisma.user.delete({ where: { email } }); } diff --git a/scripts/playground/template/app/routes/logout.tsx b/scripts/playground/template/app/routes/logout.tsx index 749332539fe..c017b00290a 100644 --- a/scripts/playground/template/app/routes/logout.tsx +++ b/scripts/playground/template/app/routes/logout.tsx @@ -7,6 +7,6 @@ export async function action({ request }: ActionFunctionArgs) { return logout(request); } -export async function loader() { +export function loader() { return redirect("/"); }