Skip to content

Commit

Permalink
Use prettier with no config (#580)
Browse files Browse the repository at this point in the history
  • Loading branch information
scotttrinh committed May 4, 2023
1 parent ea04f85 commit 9c4daff
Show file tree
Hide file tree
Showing 175 changed files with 2,780 additions and 2,872 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ jobs:
run: |
yarn lint
- name: Check format
run: |
yarn run format:check
- name: ESLint (ignore failures for now)
run: |
yarn eslint || echo "ESLint still failing... Fine for now!"
Expand Down
9 changes: 0 additions & 9 deletions .prettierrc

This file was deleted.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"scripts": {
"lint": "tslint 'packages/*/src/**/*.ts'",
"eslint": "eslint 'packages/*/src/**/*.ts'",
"format": "prettier --write 'src/**/*.ts' 'test/**/*.ts'",
"format:check": "prettier --check 'packages/*/src/**/*.ts' 'packages/*/test/**/*.ts'",
"format": "prettier --write 'packages/*/src/**/*.ts' 'packages/*/test/**/*.ts'",
"generate": "yarn workspace @edgedb/generate generate"
}
}
30 changes: 15 additions & 15 deletions packages/driver/src/adapter.deno.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {process} from "https://deno.land/std@0.177.0/node/process.ts";
import { process } from "https://deno.land/std@0.177.0/node/process.ts";
import {
crypto,
toHashString
toHashString,
} from "https://deno.land/std@0.177.0/crypto/mod.ts";

import path from "https://deno.land/std@0.177.0/node/path.ts";
Expand All @@ -10,14 +10,14 @@ import * as fs from "https://deno.land/std@0.177.0/node/fs/promises.ts";
import EventEmitter from "https://deno.land/std@0.177.0/node/events.ts";
import util from "https://deno.land/std@0.177.0/node/util.ts";

export {path, process, util, fs};
export { path, process, util, fs };

export async function readFileUtf8(...pathParts: string[]): Promise<string> {
return await Deno.readTextFile(path.join(...pathParts));
}

export function hasFSReadPermission(): boolean {
return Deno.permissions.querySync({name: "read"}).state === "granted";
return Deno.permissions.querySync({ name: "read" }).state === "granted";
}

export async function readDir(path: string) {
Expand All @@ -34,11 +34,11 @@ export async function readDir(path: string) {

export async function walk(
path: string,
params?: {match?: RegExp[]; skip?: RegExp[]}
params?: { match?: RegExp[]; skip?: RegExp[] }
) {
const {match, skip} = params || {};
const { match, skip } = params || {};
await _fs.ensureDir(path);
const entries = _fs.walk(path, {match, skip});
const entries = _fs.walk(path, { match, skip });
const files: string[] = [];
for await (const e of entries) {
if (!e.isFile) {
Expand Down Expand Up @@ -136,7 +136,7 @@ async function toArray(iter: AsyncIterable<unknown>) {
// }
// }

export async function input(message = "", _params?: {silent?: boolean}) {
export async function input(message = "", _params?: { silent?: boolean }) {

Check warning on line 139 in packages/driver/src/adapter.deno.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 16, 1.4)

'_params' is defined but never used

Check warning on line 139 in packages/driver/src/adapter.deno.ts

View workflow job for this annotation

GitHub Actions / test (16, ubuntu-latest, stable)

'_params' is defined but never used

Check warning on line 139 in packages/driver/src/adapter.deno.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 16, nightly)

'_params' is defined but never used

Check warning on line 139 in packages/driver/src/adapter.deno.ts

View workflow job for this annotation

GitHub Actions / test (14, ubuntu-latest, stable)

'_params' is defined but never used

Check warning on line 139 in packages/driver/src/adapter.deno.ts

View workflow job for this annotation

GitHub Actions / test (18, ubuntu-latest, stable)

'_params' is defined but never used

Check warning on line 139 in packages/driver/src/adapter.deno.ts

View workflow job for this annotation

GitHub Actions / test (macos-latest, 16, stable)

'_params' is defined but never used
const buf = new Uint8Array(1024);
await Deno.stdout.write(new TextEncoder().encode(message));
const n = <number>await Deno.stdin.read(buf);
Expand All @@ -156,8 +156,8 @@ export namespace net {
// typing when (if?) this becomes stable
const opts: any =

Check warning on line 157 in packages/driver/src/adapter.deno.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 16, 1.4)

Unexpected any. Specify a different type

Check warning on line 157 in packages/driver/src/adapter.deno.ts

View workflow job for this annotation

GitHub Actions / test (16, ubuntu-latest, stable)

Unexpected any. Specify a different type

Check warning on line 157 in packages/driver/src/adapter.deno.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 16, nightly)

Unexpected any. Specify a different type

Check warning on line 157 in packages/driver/src/adapter.deno.ts

View workflow job for this annotation

GitHub Actions / test (14, ubuntu-latest, stable)

Unexpected any. Specify a different type

Check warning on line 157 in packages/driver/src/adapter.deno.ts

View workflow job for this annotation

GitHub Actions / test (18, ubuntu-latest, stable)

Unexpected any. Specify a different type

Check warning on line 157 in packages/driver/src/adapter.deno.ts

View workflow job for this annotation

GitHub Actions / test (macos-latest, 16, stable)

Unexpected any. Specify a different type
typeof port === "string"
? {transport: "unix", path: port}
: {port, hostname};
? { transport: "unix", path: port }
: { port, hostname };

const conn = Deno.connect(opts);

Expand Down Expand Up @@ -240,13 +240,13 @@ export namespace net {
constructor(pconn: Promise<Deno.Conn>) {
super();
pconn
.then(conn => {
.then((conn) => {
this._conn = conn;
this._reader = conn;
this.emit("connect");
this.resume();
})
.catch(e => {
.catch((e) => {
this.emit("error", e);
});
}
Expand All @@ -267,7 +267,7 @@ export namespace tls {
port: options.port,
hostname: options.host,
alpnProtocols: options.ALPNProtocols,
caCerts: typeof options.ca === "string" ? [options.ca] : options.ca
caCerts: typeof options.ca === "string" ? [options.ca] : options.ca,
});

return new TLSSocket(conn);
Expand Down Expand Up @@ -295,15 +295,15 @@ export namespace tls {
constructor(pconn: Promise<Deno.TlsConn>) {
super();
pconn
.then(async conn => {
.then(async (conn) => {
const handshake = await conn.handshake();
this._alpnProtocol = handshake.alpnProtocol;
this._conn = conn;
this._reader = conn;
this.emit("secureConnect");
this.resume();
})
.catch(e => {
.catch((e) => {
this.emit("error", e);
});
}
Expand Down
30 changes: 15 additions & 15 deletions packages/driver/src/adapter.node.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
import * as crypto from "crypto";
import {promises as fs} from "fs";
import { promises as fs } from "fs";
import * as net from "net";
import * as os from "os";
import * as path from "path";
import * as tls from "tls";

import process from "process";
import * as readline from "readline";
import {Writable} from "stream";
import { Writable } from "stream";

export {path, net, fs, tls, process};
export { path, net, fs, tls, process };

export async function readFileUtf8(...pathParts: string[]): Promise<string> {
return await fs.readFile(path.join(...pathParts), {encoding: "utf8"});
return await fs.readFile(path.join(...pathParts), { encoding: "utf8" });
}

export function hasFSReadPermission(): boolean {
return true;
}

export function watch(dir: string) {
return fs.watch(dir, {recursive: true});
return fs.watch(dir, { recursive: true });
}

export async function readDir(pathString: string) {
Expand All @@ -33,22 +33,22 @@ export function hashSHA1toHex(msg: string): string {

export async function walk(
dir: string,
params?: {match?: RegExp[]; skip?: RegExp[]}
params?: { match?: RegExp[]; skip?: RegExp[] }
): Promise<string[]> {
const {match, skip = []} = params || {};
const { match, skip = [] } = params || {};

try {
await fs.access(dir);
} catch (err) {
return [];
}
const dirents = await fs.readdir(dir, {withFileTypes: true});
const dirents = await fs.readdir(dir, { withFileTypes: true });
const files = await Promise.all(
dirents.map(dirent => {
dirents.map((dirent) => {
const fspath = path.resolve(dir, dirent.name);
if (skip) {
// at least one skip pattern matches
if (skip.some(re => re.test(fspath))) {
if (skip.some((re) => re.test(fspath))) {
return [];
}
}
Expand All @@ -57,7 +57,7 @@ export async function walk(
}
if (match) {
// at least one match pattern matches
if (!match.some(re => re.test(fspath))) {
if (!match.some((re) => re.test(fspath))) {
return [];
}
}
Expand All @@ -80,7 +80,7 @@ export async function exists(filepath: string): Promise<boolean> {

export function input(
message: string,
params?: {silent?: boolean}
params?: { silent?: boolean }
): Promise<string> {
let silent = false;

Expand All @@ -93,16 +93,16 @@ export function input(
) {
if (!silent) process.stdout.write(chunk, encoding);
callback();
}
},
})
: process.stdout;
const rl = readline.createInterface({
input: process.stdin,
output
output,
});

return new Promise((resolve, rej) => {

Check warning on line 104 in packages/driver/src/adapter.node.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 16, 1.4)

'rej' is defined but never used

Check warning on line 104 in packages/driver/src/adapter.node.ts

View workflow job for this annotation

GitHub Actions / test (16, ubuntu-latest, stable)

'rej' is defined but never used

Check warning on line 104 in packages/driver/src/adapter.node.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 16, nightly)

'rej' is defined but never used

Check warning on line 104 in packages/driver/src/adapter.node.ts

View workflow job for this annotation

GitHub Actions / test (14, ubuntu-latest, stable)

'rej' is defined but never used

Check warning on line 104 in packages/driver/src/adapter.node.ts

View workflow job for this annotation

GitHub Actions / test (18, ubuntu-latest, stable)

'rej' is defined but never used

Check warning on line 104 in packages/driver/src/adapter.node.ts

View workflow job for this annotation

GitHub Actions / test (macos-latest, 16, stable)

'rej' is defined but never used
rl.question(message, val => {
rl.question(message, (val) => {
rl.close();
resolve(val);
});
Expand Down
6 changes: 3 additions & 3 deletions packages/driver/src/adapter.shared.deno.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {crypto} from "https://deno.land/std@0.177.0/crypto/mod.ts";
import { crypto } from "https://deno.land/std@0.177.0/crypto/mod.ts";

export async function randomBytes(size: number): Promise<Uint8Array> {
const buf = new Uint8Array(size);
Expand All @@ -21,7 +21,7 @@ export async function HMAC(
key,
{
name: "HMAC",
hash: {name: "SHA-256"}
hash: { name: "SHA-256" },
},
false,
["sign"]
Expand All @@ -35,7 +35,7 @@ export function getEnv(envName: string, required = false): string | undefined {
if (!required) {
const state = Deno.permissions.querySync({
name: "env",
variable: envName
variable: envName,
}).state;
if (state !== "granted") {
return undefined;
Expand Down
4 changes: 2 additions & 2 deletions packages/driver/src/adapter.shared.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ if (typeof crypto === "undefined") {
key,
{
name: "HMAC",
hash: {name: "SHA-256"}
hash: { name: "SHA-256" },
},
false,
["sign"]
Expand All @@ -58,7 +58,7 @@ if (typeof crypto === "undefined") {
};
}

export {randomBytes, H, HMAC};
export { randomBytes, H, HMAC };

export function getEnv(
envName: string,
Expand Down
43 changes: 19 additions & 24 deletions packages/driver/src/baseClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,29 @@
* limitations under the License.
*/

import type {Duration} from "./datatypes/datetime";
import {CodecsRegistry} from "./codecs/registry";
import type { Duration } from "./datatypes/datetime";
import { CodecsRegistry } from "./codecs/registry";
import {

Check failure on line 21 in packages/driver/src/baseClient.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 16, 1.4)

All imports in the declaration are only used as types. Use `import type`

Check failure on line 21 in packages/driver/src/baseClient.ts

View workflow job for this annotation

GitHub Actions / test (16, ubuntu-latest, stable)

All imports in the declaration are only used as types. Use `import type`

Check failure on line 21 in packages/driver/src/baseClient.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 16, nightly)

All imports in the declaration are only used as types. Use `import type`

Check failure on line 21 in packages/driver/src/baseClient.ts

View workflow job for this annotation

GitHub Actions / test (14, ubuntu-latest, stable)

All imports in the declaration are only used as types. Use `import type`

Check failure on line 21 in packages/driver/src/baseClient.ts

View workflow job for this annotation

GitHub Actions / test (18, ubuntu-latest, stable)

All imports in the declaration are only used as types. Use `import type`

Check failure on line 21 in packages/driver/src/baseClient.ts

View workflow job for this annotation

GitHub Actions / test (macos-latest, 16, stable)

All imports in the declaration are only used as types. Use `import type`
ConnectArgumentsParser,
ConnectConfig,
NormalizedConnectConfig
NormalizedConnectConfig,
} from "./conUtils";
import * as errors from "./errors";
import {Cardinality, Executor, OutputFormat, QueryArgs} from "./ifaces";
import { Cardinality, Executor, OutputFormat, QueryArgs } from "./ifaces";

Check failure on line 27 in packages/driver/src/baseClient.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 16, 1.4)

Imports "Executor" and "QueryArgs" are only used as types

Check failure on line 27 in packages/driver/src/baseClient.ts

View workflow job for this annotation

GitHub Actions / test (16, ubuntu-latest, stable)

Imports "Executor" and "QueryArgs" are only used as types

Check failure on line 27 in packages/driver/src/baseClient.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 16, nightly)

Imports "Executor" and "QueryArgs" are only used as types

Check failure on line 27 in packages/driver/src/baseClient.ts

View workflow job for this annotation

GitHub Actions / test (14, ubuntu-latest, stable)

Imports "Executor" and "QueryArgs" are only used as types

Check failure on line 27 in packages/driver/src/baseClient.ts

View workflow job for this annotation

GitHub Actions / test (18, ubuntu-latest, stable)

Imports "Executor" and "QueryArgs" are only used as types

Check failure on line 27 in packages/driver/src/baseClient.ts

View workflow job for this annotation

GitHub Actions / test (macos-latest, 16, stable)

Imports "Executor" and "QueryArgs" are only used as types
import {

Check failure on line 28 in packages/driver/src/baseClient.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 16, 1.4)

Imports "RetryOptions", "Session", "SimpleRetryOptions", "SimpleTransactionOptions" and "TransactionOptions" are only used as types

Check failure on line 28 in packages/driver/src/baseClient.ts

View workflow job for this annotation

GitHub Actions / test (16, ubuntu-latest, stable)

Imports "RetryOptions", "Session", "SimpleRetryOptions", "SimpleTransactionOptions" and "TransactionOptions" are only used as types

Check failure on line 28 in packages/driver/src/baseClient.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 16, nightly)

Imports "RetryOptions", "Session", "SimpleRetryOptions", "SimpleTransactionOptions" and "TransactionOptions" are only used as types

Check failure on line 28 in packages/driver/src/baseClient.ts

View workflow job for this annotation

GitHub Actions / test (14, ubuntu-latest, stable)

Imports "RetryOptions", "Session", "SimpleRetryOptions", "SimpleTransactionOptions" and "TransactionOptions" are only used as types

Check failure on line 28 in packages/driver/src/baseClient.ts

View workflow job for this annotation

GitHub Actions / test (18, ubuntu-latest, stable)

Imports "RetryOptions", "Session", "SimpleRetryOptions", "SimpleTransactionOptions" and "TransactionOptions" are only used as types

Check failure on line 28 in packages/driver/src/baseClient.ts

View workflow job for this annotation

GitHub Actions / test (macos-latest, 16, stable)

Imports "RetryOptions", "Session", "SimpleRetryOptions", "SimpleTransactionOptions" and "TransactionOptions" are only used as types
Options,
RetryOptions,
Session,
SimpleRetryOptions,
SimpleTransactionOptions,
TransactionOptions
TransactionOptions,
} from "./options";
import Event from "./primitives/event";
import {LifoQueue} from "./primitives/queues";
import {BaseRawConnection} from "./baseConn";
import {ConnectWithTimeout, retryingConnect} from "./retry";
import {Transaction} from "./transaction";
import {sleep} from "./utils";
import { LifoQueue } from "./primitives/queues";
import { BaseRawConnection } from "./baseConn";

Check failure on line 38 in packages/driver/src/baseClient.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 16, 1.4)

All imports in the declaration are only used as types. Use `import type`

Check failure on line 38 in packages/driver/src/baseClient.ts

View workflow job for this annotation

GitHub Actions / test (16, ubuntu-latest, stable)

All imports in the declaration are only used as types. Use `import type`

Check failure on line 38 in packages/driver/src/baseClient.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 16, nightly)

All imports in the declaration are only used as types. Use `import type`

Check failure on line 38 in packages/driver/src/baseClient.ts

View workflow job for this annotation

GitHub Actions / test (14, ubuntu-latest, stable)

All imports in the declaration are only used as types. Use `import type`

Check failure on line 38 in packages/driver/src/baseClient.ts

View workflow job for this annotation

GitHub Actions / test (18, ubuntu-latest, stable)

All imports in the declaration are only used as types. Use `import type`

Check failure on line 38 in packages/driver/src/baseClient.ts

View workflow job for this annotation

GitHub Actions / test (macos-latest, 16, stable)

All imports in the declaration are only used as types. Use `import type`
import { ConnectWithTimeout, retryingConnect } from "./retry";

Check failure on line 39 in packages/driver/src/baseClient.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 16, 1.4)

Import "ConnectWithTimeout" is only used as types

Check failure on line 39 in packages/driver/src/baseClient.ts

View workflow job for this annotation

GitHub Actions / test (16, ubuntu-latest, stable)

Import "ConnectWithTimeout" is only used as types

Check failure on line 39 in packages/driver/src/baseClient.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 16, nightly)

Import "ConnectWithTimeout" is only used as types

Check failure on line 39 in packages/driver/src/baseClient.ts

View workflow job for this annotation

GitHub Actions / test (14, ubuntu-latest, stable)

Import "ConnectWithTimeout" is only used as types

Check failure on line 39 in packages/driver/src/baseClient.ts

View workflow job for this annotation

GitHub Actions / test (18, ubuntu-latest, stable)

Import "ConnectWithTimeout" is only used as types

Check failure on line 39 in packages/driver/src/baseClient.ts

View workflow job for this annotation

GitHub Actions / test (macos-latest, 16, stable)

Import "ConnectWithTimeout" is only used as types
import { Transaction } from "./transaction";
import { sleep } from "./utils";

export class ClientConnectionHolder {
private _pool: BaseClientPool;
Expand Down Expand Up @@ -126,7 +126,7 @@ export class ClientConnectionHolder {
try {
result = await Promise.race([
action(transaction),
transaction._waitForConnAbort()
transaction._waitForConnAbort(),
]);
try {
await transaction._commit();
Expand Down Expand Up @@ -225,12 +225,7 @@ export class ClientConnectionHolder {
}

async queryJSON(query: string, args?: QueryArgs): Promise<string> {
return this.retryingFetch(
query,
args,
OutputFormat.JSON,
Cardinality.MANY
);
return this.retryingFetch(query, args, OutputFormat.JSON, Cardinality.MANY);
}

async querySingle(query: string, args?: QueryArgs): Promise<any> {
Expand Down Expand Up @@ -293,7 +288,7 @@ export abstract class BaseClientPool {
this._userConcurrency = options.concurrency ?? null;
this._suggestedConcurrency = null;
this._closing = null;
this._connectConfig = {...options};
this._connectConfig = { ...options };

this._resizeHolderPool();
}
Expand All @@ -314,11 +309,11 @@ export abstract class BaseClientPool {
}
}

_getStats(): {openConnections: number; queueLength: number} {
_getStats(): { openConnections: number; queueLength: number } {
return {
queueLength: this._queue.pending,
openConnections: this._holders.filter(holder => holder.connectionOpen)
.length
openConnections: this._holders.filter((holder) => holder.connectionOpen)
.length,
};
}

Expand Down Expand Up @@ -445,7 +440,7 @@ export abstract class BaseClientPool {

try {
await Promise.all(
this._holders.map(connectionHolder =>
this._holders.map((connectionHolder) =>
connectionHolder._waitUntilReleasedAndClose()
)
);
Expand Down Expand Up @@ -532,7 +527,7 @@ export class Client implements Executor {
return new Client(this.pool, this.options.withSession(session));
}

withModuleAliases(aliases: {[name: string]: string}) {
withModuleAliases(aliases: { [name: string]: string }) {
return new Client(
this.pool,
this.options.withSession(this.options.session.withModuleAliases(aliases))
Expand All @@ -544,7 +539,7 @@ export class Client implements Executor {
return new Client(this.pool, this.options.withSession(newConfig));
}

withGlobals(globals: {[name: string]: any}): Client {
withGlobals(globals: { [name: string]: any }): Client {
return new Client(
this.pool,
this.options.withSession(this.options.session.withGlobals(globals))
Expand Down

0 comments on commit 9c4daff

Please sign in to comment.