Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: let @typescript-eslint/require-await ESLint rule pass #7123

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions integration/cf-compiler-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ 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()
.split("\n")
.filter((line) => line.length > 0);
};

const findCodeFiles = async (directory: string) =>
const findCodeFiles = (directory: string) =>
glob.sync("**/*.@(js|jsx|ts|tsx)", {
cwd: directory,
absolute: true,
Expand Down
2 changes: 1 addition & 1 deletion integration/defer-loader-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions integration/deno-compiler-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion integration/fetch-globals-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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("/");
Expand Down
4 changes: 2 additions & 2 deletions integration/flat-routes-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion integration/route-collisions-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {};
Expand Down
2 changes: 1 addition & 1 deletion packages/remix-dev/compiler/css/plugins/bundleEntry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function cssBundleEntryModulePlugin({ config }: Context): Plugin {
};
});

build.onLoad({ filter }, async () => {
build.onLoad({ filter }, () => {
return {
resolveDir: config.appDirectory,
loader: "js",
Expand Down
2 changes: 1 addition & 1 deletion packages/remix-dev/compiler/js/plugins/hmr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/remix-dev/compiler/js/plugins/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function browserRouteModulesPlugin(
): esbuild.Plugin {
return {
name: "browser-route-modules",
async setup(build) {
setup(build) {
let routesByFile: Map<string, Route> = Object.keys(config.routes).reduce(
(map, key) => {
let route = config.routes[key];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion packages/remix-dev/compiler/plugins/cssImports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/remix-dev/compiler/server/plugins/entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function serverEntryModulePlugin({ config, options }: Context): Plugin {
};
});

build.onLoad({ filter }, async () => {
build.onLoad({ filter }, () => {
return {
resolveDir: config.appDirectory,
loader: "js",
Expand Down
2 changes: 1 addition & 1 deletion packages/remix-dev/devServer_unstable/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
export function loadEnv(rootDirectory: string) {
let envPath = path.join(rootDirectory, ".env");
if (!fse.existsSync(envPath)) return;

Expand Down
7 changes: 2 additions & 5 deletions packages/remix-node/crypto.ts
Original file line number Diff line number Diff line change
@@ -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);
};
9 changes: 7 additions & 2 deletions packages/remix-server-runtime/crypto.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
export type SignFunction = (value: string, secret: string) => Promise<string>;
import type { Promisable } from "type-fest";

export type SignFunction = (
value: string,
secret: string
) => Promisable<string>;

export type UnsignFunction = (
cookie: string,
secret: string
) => Promise<string | false>;
) => Promisable<string | false>;

MichaelDeBoey marked this conversation as resolved.
Show resolved Hide resolved
// 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"
Expand Down
11 changes: 7 additions & 4 deletions packages/remix-server-runtime/sessions.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -223,12 +224,14 @@ export interface SessionIdStorageStrategy<
createData: (
data: FlashSessionData<Data, FlashData>,
expires?: Date
) => Promise<string>;
) => Promisable<string>;

/**
* Returns data for a given session id, or `null` if there isn't any.
*/
readData: (id: string) => Promise<FlashSessionData<Data, FlashData> | null>;
readData: (
id: string
) => Promisable<FlashSessionData<Data, FlashData> | null>;

/**
* Updates data for the given session id.
Expand All @@ -237,12 +240,12 @@ export interface SessionIdStorageStrategy<
id: string,
data: FlashSessionData<Data, FlashData>,
expires?: Date
) => Promise<void>;
) => Promisable<void>;

/**
* Deletes data for a given session id from the data store.
*/
deleteData: (id: string) => Promise<void>;
deleteData: (id: string) => Promisable<void>;
}

export type CreateSessionStorageFunction = <
Expand Down
6 changes: 3 additions & 3 deletions scripts/playground/template/app/models/user.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import { prisma } from "~/db.server";

export type { User } from "@prisma/client";

export async function getUserById(id: User["id"]) {
MichaelDeBoey marked this conversation as resolved.
Show resolved Hide resolved
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 } });
}

Expand All @@ -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 } });
}

Expand Down
2 changes: 1 addition & 1 deletion scripts/playground/template/app/routes/logout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ export async function action({ request }: ActionFunctionArgs) {
return logout(request);
}

export async function loader() {
export function loader() {
return redirect("/");
}
Loading