Skip to content

Commit

Permalink
refactor: add no-return-await lint rule (denoland#4384)
Browse files Browse the repository at this point in the history
  • Loading branch information
bartlomieju committed Mar 16, 2020
1 parent 70434b5 commit 1edb20b
Show file tree
Hide file tree
Showing 18 changed files with 26 additions and 25 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
{ "argsIgnorePattern": "^_", "varsIgnorePattern": "^_" }
],
"@typescript-eslint/ban-ts-ignore": ["off"],
"@typescript-eslint/no-empty-function": ["off"]
"@typescript-eslint/no-empty-function": ["off"],
"no-return-await": "error"
},
"overrides": [
{
Expand Down
2 changes: 1 addition & 1 deletion cli/js/ops/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ export async function fetch(
zeroCopy = new Uint8Array(body.buffer, body.byteOffset, body.byteLength);
}

return await sendAsync("op_fetch", args, zeroCopy);
return sendAsync("op_fetch", args, zeroCopy);
}
4 changes: 2 additions & 2 deletions cli/js/ops/fs/make_temp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function makeTempDirSync(options: MakeTempOptions = {}): string {
export async function makeTempDir(
options: MakeTempOptions = {}
): Promise<string> {
return await sendAsync("op_make_temp_dir", options);
return sendAsync("op_make_temp_dir", options);
}

export function makeTempFileSync(options: MakeTempOptions = {}): string {
Expand All @@ -24,5 +24,5 @@ export function makeTempFileSync(options: MakeTempOptions = {}): string {
export async function makeTempFile(
options: MakeTempOptions = {}
): Promise<string> {
return await sendAsync("op_make_temp_file", options);
return sendAsync("op_make_temp_file", options);
}
2 changes: 1 addition & 1 deletion cli/js/ops/fs/open.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export async function open(
mode: OpenMode | undefined,
options: OpenOptions | undefined
): Promise<number> {
return await sendAsync("op_open", {
return sendAsync("op_open", {
path,
options,
mode
Expand Down
2 changes: 1 addition & 1 deletion cli/js/ops/fs/read_link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ export function readlinkSync(path: string): string {
}

export async function readlink(path: string): Promise<string> {
return await sendAsync("op_read_link", { path });
return sendAsync("op_read_link", { path });
}
2 changes: 1 addition & 1 deletion cli/js/ops/fs/realpath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ export function realpathSync(path: string): string {
}

export async function realpath(path: string): Promise<string> {
return await sendAsync("op_realpath", { path });
return sendAsync("op_realpath", { path });
}
2 changes: 1 addition & 1 deletion cli/js/ops/fs/seek.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ export async function seek(
offset: number,
whence: SeekMode
): Promise<number> {
return await sendAsync("op_seek", { rid, offset, whence });
return sendAsync("op_seek", { rid, offset, whence });
}
2 changes: 1 addition & 1 deletion cli/js/ops/fs_events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class FsEvents implements AsyncIterableIterator<FsEvent> {
}

async next(): Promise<IteratorResult<FsEvent>> {
return await sendAsync("op_fs_events_poll", {
return sendAsync("op_fs_events_poll", {
rid: this.rid
});
}
Expand Down
6 changes: 3 additions & 3 deletions cli/js/ops/net.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ interface AcceptResponse {
}

export async function accept(rid: number): Promise<AcceptResponse> {
return await sendAsync("op_accept", { rid });
return sendAsync("op_accept", { rid });
}

export interface ListenRequest {
Expand Down Expand Up @@ -75,7 +75,7 @@ export interface ConnectRequest {
}

export async function connect(args: ConnectRequest): Promise<ConnectResponse> {
return await sendAsync("op_connect", args);
return sendAsync("op_connect", args);
}

interface ReceiveResponse {
Expand All @@ -91,7 +91,7 @@ export async function receive(
rid: number,
zeroCopy: Uint8Array
): Promise<ReceiveResponse> {
return await sendAsync("op_receive", { rid }, zeroCopy);
return sendAsync("op_receive", { rid }, zeroCopy);
}

export interface SendRequest {
Expand Down
2 changes: 1 addition & 1 deletion cli/js/ops/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interface RunStatusResponse {
}

export async function runStatus(rid: number): Promise<RunStatusResponse> {
return await sendAsync("op_run_status", { rid });
return sendAsync("op_run_status", { rid });
}

interface RunRequest {
Expand Down
2 changes: 1 addition & 1 deletion cli/js/ops/signal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export function bindSignal(signo: number): { rid: number } {
}

export async function pollSignal(rid: number): Promise<{ done: boolean }> {
return await sendAsync("op_signal_poll", { rid });
return sendAsync("op_signal_poll", { rid });
}

export function unbindSignal(rid: number): void {
Expand Down
4 changes: 2 additions & 2 deletions cli/js/ops/tls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ interface ConnectTLSResponse {
export async function connectTLS(
args: ConnectTLSRequest
): Promise<ConnectTLSResponse> {
return await sendAsync("op_connect_tls", args);
return sendAsync("op_connect_tls", args);
}

interface AcceptTLSResponse {
Expand All @@ -44,7 +44,7 @@ interface AcceptTLSResponse {
}

export async function acceptTLS(rid: number): Promise<AcceptTLSResponse> {
return await sendAsync("op_accept_tls", { rid });
return sendAsync("op_accept_tls", { rid });
}

export interface ListenTLSRequest {
Expand Down
2 changes: 1 addition & 1 deletion cli/js/ops/worker_host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ export function hostPostMessage(id: number, data: Uint8Array): void {
}

export async function hostGetMessage(id: number): Promise<any> {
return await sendAsync("op_host_get_message", { id });
return sendAsync("op_host_get_message", { id });
}
2 changes: 1 addition & 1 deletion cli/js/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class Process {
}

async status(): Promise<ProcessStatus> {
return await runStatus(this.rid);
return runStatus(this.rid);
}

async output(): Promise<Uint8Array> {
Expand Down
4 changes: 2 additions & 2 deletions cli/js/tests/unit_test_runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,14 +312,14 @@ async function main(): Promise<void> {

// Master mode
if (args.master) {
return await masterRunnerMain(args.verbose, filter);
return masterRunnerMain(args.verbose, filter);
}

// Worker mode
if (args.worker) {
assertOrHelp(typeof args.addr === "string");
assertOrHelp(typeof args.perms === "string");
return await workerRunnerMain(args.addr, args.perms, filter);
return workerRunnerMain(args.addr, args.perms, filter);
}

// Running tests matching current process permissions
Expand Down
2 changes: 1 addition & 1 deletion cli/js/web/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ async function sendFetchReq(
headers: headerArray
};

return await opFetch(args, body);
return opFetch(args, body);
}

export async function fetch(
Expand Down
6 changes: 3 additions & 3 deletions core/examples/http_bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,20 +85,20 @@ function listen() {

/** Accepts a connection, returns rid. */
async function accept(rid) {
return await sendAsync(ops["accept"], rid);
return sendAsync(ops["accept"], rid);
}

/**
* Reads a packet from the rid, presumably an http request. data is ignored.
* Returns bytes read.
*/
async function read(rid, data) {
return await sendAsync(ops["read"], rid, data);
return sendAsync(ops["read"], rid, data);
}

/** Writes a fixed HTTP response to the socket rid. Returns bytes written. */
async function write(rid, data) {
return await sendAsync(ops["write"], rid, data);
return sendAsync(ops["write"], rid, data);
}

function close(rid) {
Expand Down
2 changes: 1 addition & 1 deletion std/http/file_server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ async function serveDir(
const fileUrl = posix.join(dirUrl, fileInfo.name ?? "");
if (fileInfo.name === "index.html" && fileInfo.isFile()) {
// in case index.html as dir...
return await serveFile(req, filePath);
return serveFile(req, filePath);
}
// Yuck!
let mode = null;
Expand Down

0 comments on commit 1edb20b

Please sign in to comment.