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

remove some return awaits #1607

Merged
merged 1 commit into from
Aug 17, 2023
Merged
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
2 changes: 1 addition & 1 deletion docs/docs/actions/triggers.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export default class CreateEventAction extends CreateEventActionBase {
if (!this.input.address) {
return;
}
return await CreateAddressAction.create(builder.viewer, {
return CreateAddressAction.create(builder.viewer, {
...this.input.address,
ownerID: builder,
ownerType: NodeType.Event,
Expand Down
2 changes: 1 addition & 1 deletion ts/src/action/action.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ function getUserEditBuilder(
async function createUser(): Promise<User> {
const builder = getUserCreateBuilder();
await builder.saveX();
return await builder.editedEntX();
return builder.editedEntX();
}

async function createEdgeRows(edges: string[]) {
Expand Down
5 changes: 2 additions & 3 deletions ts/src/action/executor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -752,9 +752,8 @@ function commonTests() {
async function doNothing(): Promise<void> {}
action.getTriggers = () => [
{
changeset: async () => {
return await Promise.all([userAction.changeset(), doNothing()]);
},
changeset: async () =>
Promise.all([userAction.changeset(), doNothing()]),
},
];

Expand Down
4 changes: 2 additions & 2 deletions ts/src/action/experimental_action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,12 @@ export class BaseAction<

async save(): Promise<TEnt | null> {
await this.builder.save();
return await this.builder.editedEnt();
return this.builder.editedEnt();
}

async saveX(): Promise<TEnt> {
await this.builder.saveX();
return await this.builder.editedEntX();
return this.builder.editedEntX();
}

getInput() {
Expand Down
2 changes: 1 addition & 1 deletion ts/src/core/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ export class Postgres implements Connection {
}

async close() {
return await this.pool.end();
return this.pool.end();
}
}

Expand Down
2 changes: 1 addition & 1 deletion ts/src/core/ent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function getUserEditBuilder(
async function createUser(): Promise<User> {
const builder = getUserCreateBuilder();
await builder.saveX();
return await builder.editedEntX();
return builder.editedEntX();
}

async function createEdgeRows(edges: string[], table?: string) {
Expand Down
8 changes: 4 additions & 4 deletions ts/src/core/ent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ export async function loadEntXFromClause<
context: viewer.context,
};
const row = await loadRowX(rowOptions);
return await applyPrivacyPolicyForRowX(viewer, options, row);
return applyPrivacyPolicyForRowX(viewer, options, row);
}

export async function loadEnts<
Expand Down Expand Up @@ -709,7 +709,7 @@ export async function loadDerivedEntX<
loader: new (viewer: TViewer, data: Data) => TEnt,
): Promise<TEnt> {
const ent = new loader(viewer, data);
return await applyPrivacyPolicyForEntX(viewer, ent, data, { ent: loader });
return applyPrivacyPolicyForEntX(viewer, ent, data, { ent: loader });
}

interface FieldPrivacyOptions<
Expand Down Expand Up @@ -1505,7 +1505,7 @@ export async function loadUniqueNode<
if (!edge) {
return null;
}
return await loadEnt(viewer, edge.id2, options);
return loadEnt(viewer, edge.id2, options);
}

export async function loadRawEdgeCountX(
Expand Down Expand Up @@ -1608,7 +1608,7 @@ async function applyPrivacyPolicyForRowX<
row: Data,
): Promise<TEnt> {
const ent = new options.ent(viewer, row);
return await applyPrivacyPolicyForEntX(viewer, ent, row, options);
return applyPrivacyPolicyForEntX(viewer, ent, row, options);
}

// deprecated. doesn't use entcache
Expand Down
2 changes: 1 addition & 1 deletion ts/src/core/ent_data.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,7 @@ function commonTests() {
};

const testEnt = async (vc: Viewer) => {
return await loadTestEnt(
return loadTestEnt(
() => ent.loadEntX(vc, 1, User.loaderOptions()),
() => {
const qOption = {
Expand Down
2 changes: 1 addition & 1 deletion ts/src/core/loaders/assoc_count_loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class AssocEdgeCountLoader implements Loader<ID, number> {
});
}
const loader = await this.loaderFn();
return await loader.load(id);
return loader.load(id);
}

clearAll() {
Expand Down
2 changes: 1 addition & 1 deletion ts/src/core/loaders/query_loader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ function commonTests() {
ids.map(async (id) => {
// have to use different loader for each to get results
const loader = getNonGroupableLoader(id);
return await loader.load(id);
return loader.load(id);
}),
);
ml.verifyNoErrors();
Expand Down
2 changes: 1 addition & 1 deletion ts/src/core/loaders/raw_count_loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export class RawCountLoader<K extends any> implements Loader<K, number> {

async load(id: K): Promise<number> {
if (this.loader) {
return await this.loader.load(id);
return this.loader.load(id);
}

const rows = await simpleCase(this.options, id, this.context);
Expand Down
2 changes: 1 addition & 1 deletion ts/src/core/query/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ export abstract class BaseEdgeQuery<

// this is basically just raw rows
readonly queryEdges = async (): Promise<TEdge[]> => {
return await this.querySingleEdge("queryEdges");
return this.querySingleEdge("queryEdges");
};

abstract queryRawCount(): Promise<number>;
Expand Down
2 changes: 1 addition & 1 deletion ts/src/core/query/shared_assoc_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ export function assocTests(ml: MockLogs, global = false) {
);
}
await builder.saveX();
return await builder.editedEntX();
return builder.editedEntX();
}),
);

Expand Down
4 changes: 2 additions & 2 deletions ts/src/graphql/query/edge_connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export class GraphQLEdgeConnection<
}

async queryTotalCount() {
return await this.query.queryRawCount();
return this.query.queryRawCount();
}

async queryEdges() {
Expand All @@ -116,7 +116,7 @@ export class GraphQLEdgeConnection<
// if nodes queried just return ents
// unlikely to query nodes and pageInfo so we just load this separately for now
async queryNodes() {
return await this.query.queryEnts();
return this.query.queryEnts();
}

private defaultPageInfo() {
Expand Down
2 changes: 1 addition & 1 deletion ts/src/graphql/tests/file_upload.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ afterAll(() => {
});

async function readStream(file): Promise<string> {
return await new Promise((resolve) => {
return new Promise((resolve) => {
const stream = file.createReadStream();
let data: string[] = [];
stream.on("data", function (chunk) {
Expand Down
2 changes: 1 addition & 1 deletion ts/src/scripts/custom_graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ async function readInputs(): Promise<{
nodes: string[];
nodesMap: Map<string, boolean>;
}> {
return await new Promise((resolve) => {
return new Promise((resolve) => {
const rl = readline.createInterface({
input: process.stdin,
// output: process.stdout,
Expand Down
8 changes: 4 additions & 4 deletions ts/src/testutils/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,11 +298,11 @@ export class SimpleBuilder<
}

async editedEnt(): Promise<T | null> {
return await this.orchestrator.editedEnt();
return this.orchestrator.editedEnt();
}

async editedEntX(): Promise<T> {
return await this.orchestrator.editedEntX();
return this.orchestrator.editedEntX();
}

async save(): Promise<void> {
Expand All @@ -314,11 +314,11 @@ export class SimpleBuilder<
}

async valid(): Promise<boolean> {
return await this.orchestrator.valid();
return this.orchestrator.valid();
}

async validX(): Promise<void> {
return await this.orchestrator.validX();
return this.orchestrator.validX();
}
}

Expand Down
6 changes: 3 additions & 3 deletions ts/src/testutils/db_mock.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ describe("ops", () => {
test("AND 2 ops", async () => {
await Promise.all(
[4, 8].map(async (id) => {
return await editRowForTest({
return editRowForTest({
tableName: "t",
fields: {
bar: "bar2",
Expand All @@ -594,7 +594,7 @@ describe("ops", () => {
test("AND 3 ops", async () => {
await Promise.all(
[4, 8].map(async (id) => {
return await editRowForTest({
return editRowForTest({
tableName: "t",
fields: {
bar: "bar2",
Expand Down Expand Up @@ -650,7 +650,7 @@ describe("ops", () => {
test("OR 4 ops", async () => {
await Promise.all(
[4, 8].map(async (id) => {
return await editRowForTest({
return editRowForTest({
tableName: "t",
fields: {
bar: "bar2",
Expand Down
4 changes: 2 additions & 2 deletions ts/src/testutils/ent-graphql-tests/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ export async function expectQueryFromRoot(
config: queryRootConfig,
...options: Option[] // TODO queries? expected values
): Promise<supertest.SuperTest<supertest.Test>> {
return await expectFromRoot(
return expectFromRoot(
{
...config,
queryPrefix: "query",
Expand Down Expand Up @@ -376,7 +376,7 @@ export async function expectMutation(
};
}

return await expectFromRoot(
return expectFromRoot(
{
...config,
args: args,
Expand Down
2 changes: 1 addition & 1 deletion ts/src/testutils/fake_data/fake_contact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export function getContactBuilder(viewer: Viewer, input: ContactCreateInput) {

export async function createContact(viewer: Viewer, input: ContactCreateInput) {
const builder = getContactBuilder(viewer, input);
return await builder.saveX();
return builder.saveX();
}

export const contactLoader = new ObjectLoaderFactory({
Expand Down
2 changes: 1 addition & 1 deletion ts/src/testutils/fake_data/fake_event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,5 +146,5 @@ export function getEventBuilder(viewer: Viewer, input: EventCreateInput) {

export async function createEvent(viewer: Viewer, input: EventCreateInput) {
const builder = getEventBuilder(viewer, input);
return await builder.saveX();
return builder.saveX();
}
4 changes: 2 additions & 2 deletions ts/src/testutils/fake_data/test_helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export async function createAllContacts(
},
);
await builder.saveX();
return await builder.editedEntX();
return builder.editedEntX();
}),
);
expect(contacts.length).toBe(userInputs.length);
Expand Down Expand Up @@ -325,7 +325,7 @@ export async function createTestEvent(
builder.orchestrator.addOutboundEdge(user.id, EdgeType.EventToHosts, "User");

await builder.saveX();
return await builder.editedEntX();
return builder.editedEntX();
}

export async function setupTempDB(global: boolean = false) {
Expand Down
2 changes: 1 addition & 1 deletion ts/src/testutils/fake_data/user_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ export class CustomEdge extends AssocEdge {
}

async loadUser(viewer: Viewer) {
return await FakeUser.load(viewer, this.id2);
return FakeUser.load(viewer, this.id2);
}
}

Expand Down
6 changes: 3 additions & 3 deletions ts/src/testutils/write.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export async function createRowForTest(
if (isSyncClient(client)) {
return createRowSync(client, options, suffix || "");
}
return await createRow(client, options, suffix || "");
return createRow(client, options, suffix || "");
} finally {
client.release();
}
Expand All @@ -47,7 +47,7 @@ export async function editRowForTest(options: EditRowOptions, suffix?: string) {
if (isSyncClient(client)) {
return editRowSync(client, options, suffix || "");
}
return await editRow(client, options, suffix);
return editRow(client, options, suffix);
} finally {
client.release();
}
Expand All @@ -63,7 +63,7 @@ export async function deleteRowsForTest(
if (isSyncClient(client)) {
return deleteRowsSync(client, options, cls);
}
return await deleteRows(client, options, cls);
return deleteRows(client, options, cls);
} finally {
client.release();
}
Expand Down