Skip to content

Commit

Permalink
chore: let ESLint rule pass
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaKGoldberg authored and MichaelDeBoey committed Aug 15, 2023
1 parent ae92f57 commit 5b59529
Show file tree
Hide file tree
Showing 22 changed files with 44 additions and 36 deletions.
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/cssBundlePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function cssBundlePlugin(refs: {
}): Plugin {
return {
name: pluginName,
async setup(build) {
setup(build) {
let preventInfiniteLoop = {};
build.onResolve({ filter: /^@remix-run\/css-bundle$/ }, async (args) => {
// Prevent plugin from infinitely trying to resolve itself
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 { PromiseOrSync } from "./utils";

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

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

// TODO: Once node v16 is available on AWS we should use the globally provided
// webcrypto "crypto" variable and re-enable this code-path in "./cookies.ts"
Expand Down
2 changes: 2 additions & 0 deletions packages/remix-server-runtime/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,5 @@ export type {
UploadHandler,
UploadHandlerPart,
} from "./reexport";

export type { PromiseOrSync } from "./utils";
11 changes: 7 additions & 4 deletions packages/remix-server-runtime/sessions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { CookieParseOptions, CookieSerializeOptions } from "cookie";
import type { Cookie, CookieOptions, CreateCookieFunction } from "./cookies";
import { isCookie } from "./cookies";
import { warnOnce } from "./warnings";
import type { PromiseOrSync } from "./utils";

/**
* An object of name/value pairs to be used in the session.
Expand Down Expand Up @@ -223,12 +224,14 @@ export interface SessionIdStorageStrategy<
createData: (
data: FlashSessionData<Data, FlashData>,
expires?: Date
) => Promise<string>;
) => PromiseOrSync<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
) => PromiseOrSync<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>;
) => PromiseOrSync<void>;

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

export type CreateSessionStorageFunction = <
Expand Down
8 changes: 4 additions & 4 deletions packages/remix-server-runtime/sessions/memoryStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ export const createMemorySessionStorageFactory =

return createSessionStorage({
cookie,
async createData(data, expires) {
createData(data, expires) {
let id = (++uniqueId).toString();
map.set(id, { data, expires });
return id;
},
async readData(id) {
readData(id) {
if (map.has(id)) {
let { data, expires } = map.get(id)!;

Expand All @@ -64,10 +64,10 @@ export const createMemorySessionStorageFactory =

return null;
},
async updateData(id, data, expires) {
updateData(id, data, expires) {
map.set(id, { data, expires });
},
async deleteData(id) {
deleteData(id) {
map.delete(id);
},
});
Expand Down
1 change: 1 addition & 0 deletions packages/remix-server-runtime/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type PromiseOrSync<T> = Promise<T> | T;
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"]) {
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 }: ActionArgs) {
return logout(request);
}

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

0 comments on commit 5b59529

Please sign in to comment.