Skip to content

Commit

Permalink
This works
Browse files Browse the repository at this point in the history
  • Loading branch information
diksipav committed May 24, 2024
1 parent c04f591 commit ced2695
Show file tree
Hide file tree
Showing 22 changed files with 44 additions and 60 deletions.
5 changes: 5 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ export default tseslint.config(
"error",
{ argsIgnorePattern: "^_", varsIgnorePattern: "^_" },
],
//
"@typescript-eslint/adjacent-overload-signatures": "error",
"@typescript-eslint/array-type": "error",
"@typescript-eslint/ban-tslint-comment": "error",
"@typescript-eslint/consistent-generic-constructors": "error",
},
}
);
3 changes: 1 addition & 2 deletions packages/driver/src/baseClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -444,8 +444,7 @@ export abstract class BaseClientPool {
);

const warningTimeoutId = setTimeout(() => {
// tslint:disable-next-line: no-console
console.warn(
console.warn(
"Client.close() is taking over 60 seconds to complete. " +
"Check if you have any unreleased connections left."
);
Expand Down
14 changes: 6 additions & 8 deletions packages/driver/src/baseConn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ export class BaseRawConnection {

private _parseDataMessages(
codec: ICodec,
result: Array<any> | WriteBuffer
result: any[] | WriteBuffer
): void {
const frb = ReadBuffer.alloc();
const $D = chars.$D;
Expand Down Expand Up @@ -427,10 +427,8 @@ export class BaseRawConnection {
this._parseHeaders();
this.buffer.finishMessage();

/* tslint:disable */
console.info("SERVER MESSAGE", severity, code, message);
/* tslint:enable */

console.info("SERVER MESSAGE", severity, code, message);

break;
}

Expand Down Expand Up @@ -683,7 +681,7 @@ export class BaseRawConnection {
args: QueryArgs,
inCodec: ICodec,
outCodec: ICodec,
result: Array<any> | WriteBuffer
result: any[] | WriteBuffer
): Promise<void> {
const wb = new WriteMessageBuffer();
wb.beginMessage(chars.$E)
Expand Down Expand Up @@ -755,7 +753,7 @@ export class BaseRawConnection {
expectedCardinality: Cardinality,
inCodec: ICodec,
outCodec: ICodec,
result: Array<any> | WriteBuffer
result: any[] | WriteBuffer
): Promise<void> {
const expectOne =
expectedCardinality === Cardinality.ONE ||
Expand Down Expand Up @@ -1039,7 +1037,7 @@ export class BaseRawConnection {
state: Session,
inCodec: ICodec,
outCodec: ICodec,
result: Array<any> | WriteBuffer,
result: any[] | WriteBuffer,
capabilitiesFlags: number = RESTRICTED_CAPABILITIES,
options?: QueryOptions
): Promise<void> {
Expand Down
2 changes: 1 addition & 1 deletion packages/driver/src/codecs/datetime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export class LocalTimeCodec extends ScalarCodec implements ICodec {
}
}

const unencodableDurationFields: Array<keyof Duration> = [
const unencodableDurationFields: (keyof Duration)[] = [
"years",
"months",
"weeks",
Expand Down
3 changes: 1 addition & 2 deletions packages/driver/src/conUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -577,8 +577,7 @@ async function parseConnectDsnAndArgs(
let port: string | undefined = getEnv("EDGEDB_PORT");
if (resolvedConfig._port === null && port?.startsWith("tcp://")) {
// EDGEDB_PORT is set by 'docker --link' so ignore and warn
// tslint:disable-next-line: no-console
console.warn(
console.warn(
`EDGEDB_PORT in 'tcp://host:port' format, so will be ignored`
);
port = undefined;
Expand Down
1 change: 0 additions & 1 deletion packages/driver/src/errors/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
* limitations under the License.
*/

/* tslint:disable */

import { EdgeDBError } from "./base";
import * as tags from "./tags";
Expand Down
2 changes: 1 addition & 1 deletion packages/driver/src/primitives/buffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ export class WriteMessageBuffer {

const entries = Object.entries(headers).filter(
([_, value]) => value !== undefined
) as Array<[keyof typeof LegacyHeaderCodes, string | Uint8Array]>;
) as [keyof typeof LegacyHeaderCodes, string | Uint8Array][];
this.buffer.writeUInt16(entries.length);
for (const [code, value] of entries) {
this.buffer.writeUInt16(LegacyHeaderCodes[code]);
Expand Down
6 changes: 3 additions & 3 deletions packages/driver/src/primitives/queues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
import { InternalClientError } from "../errors";

export class LifoQueue<T> {
private _promises: Array<Promise<T>>;
private _resolvers: Array<(t: T) => void>;
private _rejecters: Array<(err: Error) => void>;
private _promises: Promise<T>[];
private _resolvers: ((t: T) => void)[];
private _rejecters: ((err: Error) => void)[];

constructor() {
this._resolvers = [];
Expand Down
2 changes: 1 addition & 1 deletion packages/driver/src/reflection/analyzeQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export const defaultCodecGenerators: CodecGeneratorMap = new Map([
]);

export const generateTsObject = (
fields: Array<Parameters<typeof generateTsObjectField>[0]>,
fields: Parameters<typeof generateTsObjectField>[0][],
ctx: CodecGeneratorContext
) => {
const properties = fields.map((field) => generateTsObjectField(field, ctx));
Expand Down
3 changes: 1 addition & 2 deletions packages/driver/src/reflection/queries/casts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ export const casts = async (cxn: Executor, params?: { debug?: boolean }) => {
assignableByMap[type] = reachableFrom(type, assignmentCastsByTarget);
}

// tslint:disable:no-console
if (params?.debug === true) {
if (params?.debug === true) {
console.log(`\nIMPLICIT`);
for (const [fromId, castArr] of Object.entries(implicitCastMap)) {
console.log(
Expand Down
25 changes: 12 additions & 13 deletions packages/driver/src/reflection/queries/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export type Pointer = {
is_computed: boolean;
is_readonly: boolean;
has_default: boolean;
pointers: ReadonlyArray<Pointer> | null;
pointers: readonly Pointer[] | null;
};

export type Backlink = Pointer & {
Expand All @@ -39,20 +39,20 @@ export type TypeProperties<T extends TypeKind> = {
export type ScalarType = TypeProperties<"scalar"> & {
is_abstract: boolean;
is_seq: boolean;
bases: ReadonlyArray<{ id: UUID }>;
enum_values: ReadonlyArray<string> | null;
bases: readonly { id: UUID }[];
enum_values: readonly string[] | null;
material_id: UUID | null;
cast_type?: UUID;
};

export type ObjectType = TypeProperties<"object"> & {
is_abstract: boolean;
bases: ReadonlyArray<{ id: UUID }>;
union_of: ReadonlyArray<{ id: UUID }>;
intersection_of: ReadonlyArray<{ id: UUID }>;
pointers: ReadonlyArray<Pointer>;
backlinks: ReadonlyArray<Backlink>;
backlink_stubs: ReadonlyArray<Backlink>;
bases: readonly { id: UUID }[];
union_of: readonly { id: UUID }[];
intersection_of: readonly { id: UUID }[];
pointers: readonly Pointer[];
backlinks: readonly Backlink[];
backlink_stubs: readonly Backlink[];
exclusives: { [k: string]: Pointer }[];
};

Expand All @@ -62,10 +62,10 @@ export type ArrayType = TypeProperties<"array"> & {
};

export type TupleType = TypeProperties<"tuple"> & {
tuple_elements: ReadonlyArray<{
tuple_elements: readonly {
name: string;
target_id: UUID;
}>;
}[];
is_abstract: boolean;
};

Expand Down Expand Up @@ -247,8 +247,7 @@ export async function getTypes(
`;

const _types: Type[] = JSON.parse(await cxn.queryJSON(QUERY));
// tslint:disable-next-line
if (debug) console.log(JSON.stringify(_types, null, 2));
if (debug) console.log(JSON.stringify(_types, null, 2));

// remap types
for (const type of _types) {
Expand Down
6 changes: 2 additions & 4 deletions packages/driver/src/retry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,13 @@ export async function retryingConnect(
`\n`
);
}
// tslint:disable-next-line: no-console
console.warn(...logMsg);
console.warn(...logMsg);
}
} else {
throw e;
}
} else {
// tslint:disable-next-line: no-console
console.error("Unexpected connection error:", e);
console.error("Unexpected connection error:", e);
throw e; // this shouldn't happen
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/generate/src/builders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ type ImportParams = {
};
type ExportParams = { modes?: Mode[] };

const allModes: Set<Mode> = new Set(["dts", "js", "ts"]);
const allModes = new Set<Mode>(["dts", "js", "ts"]);
class BuilderImportsExports {
constructor(
public imports: Set<Import> = new Set<Import>(),
Expand Down
1 change: 0 additions & 1 deletion packages/generate/src/commandutil.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env node

// tslint:disable:no-console
import { adapter } from "edgedb";
import { type Target, exitWithError } from "./genutil";

Expand Down
5 changes: 1 addition & 4 deletions packages/generate/src/edgeql-js.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// tslint:disable:no-console

import { $, adapter, type Client } from "edgedb";
import { type CommandOptions, isTTY, promptBoolean } from "./commandutil";
Expand All @@ -18,7 +17,6 @@ import { generateSetImpl } from "./edgeql-js/generateSetImpl";

const { path, fs, readFileUtf8, exists, walk } = adapter;

// tslint:disable-next-line
export const configFileHeader = `// EdgeDB query builder`;

export type GeneratorParams = {
Expand Down Expand Up @@ -89,8 +87,7 @@ export async function generateQueryBuilder(params: {

const dir = new DirBuilder();

// tslint:disable-next-line
console.log(`Introspecting database schema...`);
console.log(`Introspecting database schema...`);

const [types, scalars, casts, functions, operators, globals, version] =
await Promise.all([
Expand Down
3 changes: 1 addition & 2 deletions packages/generate/src/edgeql-js/generateObjectTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,7 @@ export const generateObjectTypes = (params: GeneratorParams) => {
body.writeln([
dts`declare `,
...frag`const ${literal}`,
// tslint:disable-next-line
t`: $.$expr_PathNode<$.TypeSet<${ref}, $.Cardinality.${typeCard}>, null> `,
t`: $.$expr_PathNode<$.TypeSet<${ref}, $.Cardinality.${typeCard}>, null> `,
r`= _.syntax.$PathNode($.$toSet(${ref}, $.Cardinality.${typeCard}), null);`,
]);
body.nl();
Expand Down
3 changes: 1 addition & 2 deletions packages/generate/src/genutil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -469,8 +469,7 @@ export type GeneratorParams = {
};

export function exitWithError(message: string): never {
// tslint:disable-next-line
console.error(message);
console.error(message);
adapter.exit(1);
throw new Error();
}
Expand Down
4 changes: 1 addition & 3 deletions packages/generate/src/interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// tslint:disable:no-console
import type { CommandOptions } from "./commandutil";
import { headerComment } from "./genutil";
import { $, adapter, type Client } from "edgedb";
Expand Down Expand Up @@ -41,8 +40,7 @@ export async function runInterfacesGenerator(params: {

const dir = new DirBuilder();

// tslint:disable-next-line
console.log(`Introspecting database schema...`);
console.log(`Introspecting database schema...`);
const types = await $.introspect.types(client);

const generatorParams = {
Expand Down
3 changes: 1 addition & 2 deletions packages/generate/src/syntax/group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ export type $expr_Group<
ObjectType<
"std::FreeObject",
{
// tslint:disable-next-line
[k in keyof Mods["by"]]: Mods["by"][k]["__element__"] extends ObjectType
[k in keyof Mods["by"]]: Mods["by"][k]["__element__"] extends ObjectType
? never
: PropertyDesc<
Mods["by"][k]["__element__"],
Expand Down
3 changes: 1 addition & 2 deletions packages/generate/src/syntax/path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ export interface PathParent<
export type $linkPropify<Root extends ObjectTypeSet> = Root extends {
__parent__: PathParent<infer Parent, infer L>;
}
? // tslint:disable-next-line
Parent["__element__"]["__pointers__"][L] extends LinkDesc<
? Parent["__element__"]["__pointers__"][L] extends LinkDesc<
any,
any,
infer LinkProps,
Expand Down
5 changes: 2 additions & 3 deletions packages/generate/src/syntax/toEdgeQL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ function walkExprTree(
// this prevents recurring grouping elements from being walked twice
// this way, these won't get pulled into with blocks,
// which is good because they need to be rendered in `using`
const seen: Set<any> = new Set();
const seen = new Set<any>();
if (!seen.has(expr)) {
childExprs.push(...walkExprTree(groupExpr, expr, ctx));
seen.add(expr);
Expand Down Expand Up @@ -1279,8 +1279,7 @@ function shapeToEdgeQL(
for (const key in shape) {
if (!Object.prototype.hasOwnProperty.call(shape, key)) continue;
if (seen.has(key)) {
// tslint:disable-next-line
console.warn(`Invalid: duplicate key "${key}"`);
console.warn(`Invalid: duplicate key "${key}"`);
continue;
}
seen.add(key);
Expand Down
3 changes: 1 addition & 2 deletions packages/generate/src/syntax/typesystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ export type scalarTypeWithConstructor<
S extends ScalarType,
ExtraTsTypes = never
> = S & {
// tslint:disable-next-line
<T extends S["__tstype__"] | ExtraTsTypes>(val: T): $expr_Literal<
<T extends S["__tstype__"] | ExtraTsTypes>(val: T): $expr_Literal<
Omit<S, "__tsconsttype__"> & {
__tsconsttype__: T extends S["__tstype__"] ? T : S["__tstype__"];
}
Expand Down

0 comments on commit ced2695

Please sign in to comment.