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

Replace tslint with typescript-eslint #1030

Merged
merged 15 commits into from
May 29, 2024
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
19 changes: 0 additions & 19 deletions .eslintrc.cjs

This file was deleted.

38 changes: 38 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import eslint from "@eslint/js";
import tseslint from "typescript-eslint";

export default tseslint.config(
eslint.configs.recommended,
...tseslint.configs.recommended,
...tseslint.configs.stylistic,
{
files: ["packages/*/src/**/*.ts"],
languageOptions: {
parser: tseslint.parser,
// parserOptions: {
// project: true,
// },
},
rules: {
"@typescript-eslint/no-unnecessary-type-constraint": "warn",
// Svelte doesn't correctly compile if imports of the generated /modules
// aren't imported as 'import type' in other parts of the generated
// querybuilder, so set this option to ensure we always do that
"@typescript-eslint/consistent-type-imports": "error",
"@typescript-eslint/no-namespace": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-empty-function": "warn",
"@typescript-eslint/ban-ts-comment": "warn",
"no-empty-function": "off",
"@typescript-eslint/class-literal-property-style": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{ argsIgnorePattern: "^_", varsIgnorePattern: "^_" },
],
// some stylistic rules results with errors, turn them off for now
"@typescript-eslint/consistent-indexed-object-style": "off",
"@typescript-eslint/consistent-type-definitions": "off",
"@typescript-eslint/no-empty-interface": "off",
},
}
);
6 changes: 6 additions & 0 deletions integration-tests/lts/deno/deno.lock
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@
"https://deno.land/std@0.177.0/types.d.ts": "220ed56662a0bd393ba5d124aa6ae2ad36a00d2fcbc0e8666a65f4606aaa9784",
"https://deno.land/std@0.208.0/assert/assert.ts": "9a97dad6d98c238938e7540736b826440ad8c1c1e54430ca4c4e623e585607ee",
"https://deno.land/std@0.208.0/assert/assertion_error.ts": "4d0bde9b374dfbcbe8ac23f54f567b77024fb67dbb1906a852d67fe050d42f56",
"https://deno.land/std@0.208.0/collections/_utils.ts": "5114abc026ddef71207a79609b984614e66a63a4bda17d819d56b0e72c51527e",
"https://deno.land/std@0.208.0/collections/deep_merge.ts": "9db788ba56cb05b65c77166b789e58e125dff159b7f41bf4d19dc1cba19ecb8b",
"https://deno.land/std@0.208.0/fs/_util.ts": "fbf57dcdc9f7bc8128d60301eece608246971a7836a3bb1e78da75314f08b978",
"https://deno.land/std@0.208.0/fs/copy.ts": "ca19e4837965914471df38fbd61e16f9e8adfe89f9cffb0c83615c83ea3fc2bf",
"https://deno.land/std@0.208.0/fs/empty_dir.ts": "7fba29ef2d03f3503cd512616efc0535984cf1bbe7ca9d098e8b4d0d88910120",
Expand Down Expand Up @@ -329,6 +331,10 @@
"https://deno.land/std@0.208.0/path/windows/separator.ts": "ae21f27015f10510ed1ac4a0ba9c4c9c967cbdd9d9e776a3e4967553c397bd5d",
"https://deno.land/std@0.208.0/path/windows/to_file_url.ts": "8e9ea9e1ff364aa06fa72999204229952d0a279dbb876b7b838b2b2fea55cce3",
"https://deno.land/std@0.208.0/path/windows/to_namespaced_path.ts": "e0f4d4a5e77f28a5708c1a33ff24360f35637ba6d8f103d19661255ef7bfd50d",
"https://deno.land/std@0.208.0/toml/_parser.ts": "63d68503fc4e22dcc6b677126765e67fe570e62c86199874efd8b6c976dc2679",
"https://deno.land/std@0.208.0/toml/mod.ts": "b7127578e29155a91a45991e098a5478e6c61d0a4fbd2a99fd08b9043cab2ba1",
"https://deno.land/std@0.208.0/toml/parse.ts": "e900bafdf35d802519842a303e07a62ea5282186960b3474e8083509ab1c7f0d",
"https://deno.land/std@0.208.0/toml/stringify.ts": "be8c9182353f80234cf296ca26d4e605b4672e35a2aa0648cc942b5605d4bc1d",
"https://deno.land/std@0.97.0/fmt/colors.ts": "db22b314a2ae9430ae7460ce005e0a7130e23ae1c999157e3bb77cf55800f7e4",
"https://deno.land/std@0.97.0/testing/_diff.ts": "961eaf6d9f5b0a8556c9d835bbc6fa74f5addd7d3b02728ba7936ff93364f7a3",
"https://deno.land/std@0.97.0/testing/asserts.ts": "341292d12eebc44be4c3c2ca101ba8b6b5859cef2fa69d50c217f9d0bfbcfd1f",
Expand Down
16 changes: 6 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,15 @@
],
"packageManager": "yarn@1.22.19",
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^5.60.1",
"@typescript-eslint/parser": "^5.60.1",
"eslint": "^8.43.0",
"eslint-config-prettier": "^8.8.0",
"@eslint/js": "^9.2.0",
"eslint": "^9.2.0",
"prettier": "^2.8.8",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0",
"tslint-plugin-prettier": "^2.3.0",
"typescript": "^5.4.5"
"typescript": "^5.4.5",
"typescript-eslint": "^7.8.0"
},
"scripts": {
"lint": "tslint 'packages/*/src/**/*.ts'",
"eslint": "eslint 'packages/*/src/**/*.ts'",
"lint": "eslint --quiet 'packages/*/src/**/*.ts'",
"lint:fix": "eslint 'packages/*/src/**/*.ts' --fix",
"format:check": "prettier --check 'packages/*/src/**/*.(mts|ts)' 'packages/*/test/**/*.ts'",
"format": "prettier --write 'packages/*/src/**/*.(mts|ts)' 'packages/*/test/**/*.ts'",
"generate": "yarn workspace @edgedb/generate generate"
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-nextjs/src/pages/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export class NextPagesClientAuth extends NextAuthHelpers {
}

async function apiRequest(url: string, _data: any) {
let data: { [key: string]: any };
let data: Record<string, any>;
if (_data instanceof FormData) {
data = {};
for (const [key, val] of _data.entries()) {
Expand Down
6 changes: 1 addition & 5 deletions packages/auth-nextjs/src/pages/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,7 @@ export default function createNextPagesServerAuth(
const sessionCache = new WeakMap<any, NextAuthSession>();

export class NextPagesAuth extends NextAuth {
getSession(req: {
cookies: Partial<{
[key: string]: string;
}>;
}) {
getSession(req: { cookies: Partial<Record<string, string>> }) {
const session =
sessionCache.get(req) ??
new NextAuthSession(
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-remix/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export class RemixServerAuth extends RemixClientAuth {
params,
}: {
request: Request;
params: { [key: string]: string | undefined };
params: Record<string, string | undefined>;
}) => {
const path = params["*"];
if (!path) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
import { redirect } from "next/navigation";
import { auth } from "@/edgedb";
import type { TokenData } from "@edgedb/auth-core";

export const { GET, POST } = auth.createAuthRouteHandlers({
async onBuiltinUICallback({ error, tokenData, provider, isSignUp }) {
async onBuiltinUICallback({
error,
tokenData,
isSignUp,
}: {
error?: Error;
tokenData?: TokenData;
isSignUp?: boolean;
}) {
if (error) {
console.error("sign in failed", error);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import type { NextApiRequest, NextApiResponse } from "next";

import { auth } from "@/edgedb";

type Data = {
interface Data {
name: string;
identity: any;
};
}

export default async function handler(
req: NextApiRequest,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
import type { NextApiRequest, NextApiResponse } from "next";

type Data = {
interface Data {
name: string;
};
}

export default function handler(
req: NextApiRequest,
Expand Down
9 changes: 4 additions & 5 deletions packages/create/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ export async function copyTemplateFiles(
vars[filepath].push({ varname, value });
}
return vars;
}, {} as { [filepath: string]: { varname: string; value: string }[] }) ??
{},
}, {} as Record<string, { varname: string; value: string }[]>) ?? {},
});
}

Expand All @@ -53,11 +52,11 @@ async function _walkDir(
_dest: string,
untaggedSource: string,
opts: Omit<CopyTemplateFilesOpts, "injectVars"> & {
injectVars: { [filepath: string]: { varname: string; value: string }[] };
injectVars: Record<string, { varname: string; value: string }[]>;
}
) {
const files: { [filename: string]: { entry: Dirent; tags: string[] }[] } = {};
const dirs: { [dirname: string]: { entry: Dirent; tags: string[] }[] } = {};
const files: Record<string, { entry: Dirent; tags: string[] }[]> = {};
const dirs: Record<string, { entry: Dirent; tags: string[] }[]> = {};
for (const entry of await fs.readdir(source, { withFileTypes: true })) {
const parts = entry.name.split(".");
const name = [
Expand Down
4 changes: 2 additions & 2 deletions packages/driver/src/adapter.crypto.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { CryptoUtils } from "./utils";
let cryptoUtils: CryptoUtils;

if (typeof crypto === "undefined") {
// tslint:disable-next-line:no-var-requires
// eslint-disable-next-line @typescript-eslint/no-var-requires
const nodeCrypto = require("crypto");

cryptoUtils = {
Expand Down Expand Up @@ -32,7 +32,7 @@ if (typeof crypto === "undefined") {
},
};
} else {
// tslint:disable-next-line:no-var-requires
// eslint-disable-next-line @typescript-eslint/no-var-requires
cryptoUtils = require("./browserCrypto").default;
}

Expand Down
8 changes: 5 additions & 3 deletions packages/driver/src/adapter.deno.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export function homeDir(): string {
export async function input(message = "", _params?: { silent?: boolean }) {
const buf = new Uint8Array(1024);
await Deno.stdout.write(new TextEncoder().encode(message));
const n = <number>await Deno.stdin.read(buf);
const n = (await Deno.stdin.read(buf)) as number;
return new TextDecoder().decode(buf.subarray(0, n)).trim();
}

Expand All @@ -162,6 +162,7 @@ export namespace net {

export const isIP = _isIP;

// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
export declare interface Socket {
on(eventName: "error", listener: (e: any) => void): this;
on(eventName: "connect", listener: () => void): this;
Expand Down Expand Up @@ -234,6 +235,7 @@ export namespace net {
}
}

// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
export class Socket extends BaseSocket<Deno.Conn> {
constructor(pconn: Promise<Deno.Conn>) {
super();
Expand Down Expand Up @@ -272,8 +274,8 @@ export namespace tls {
}

export function checkServerIdentity(
hostname: string,
cert: Object
_hostname: string,
_cert: object
): Error | undefined {
return undefined;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/driver/src/adapter.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export function input(
): Promise<string> {
let silent = false;

const output = !!params?.silent
const output = params?.silent
? new Writable({
write(
chunk: any,
Expand All @@ -102,7 +102,7 @@ export function input(
output,
});

return new Promise((resolve, rej) => {
return new Promise((resolve) => {
rl.question(message, (val) => {
rl.close();
resolve(val);
Expand Down
5 changes: 1 addition & 4 deletions packages/driver/src/adapter.shared.node.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
export function getEnv(
envName: string,
required: boolean = false
): string | undefined {
export function getEnv(envName: string, _required = false): string | undefined {
return process.env[envName];
}
25 changes: 15 additions & 10 deletions packages/driver/src/baseClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,32 @@

import type { Duration } from "./datatypes/datetime";
import { CodecsRegistry } from "./codecs/registry";
import {
import type {
ConnectArgumentsParser,
ConnectConfig,
NormalizedConnectConfig,
ResolvedConnectConfigReadonly,
} from "./conUtils";
import * as errors from "./errors";
import { Cardinality, Executor, OutputFormat, QueryArgs } from "./ifaces";
import {
Options,
type Executor,
type QueryArgs,
Cardinality,
OutputFormat,
} from "./ifaces";
import type {
RetryOptions,
Session,
SimpleRetryOptions,
SimpleTransactionOptions,
TransactionOptions,
} from "./options";
import { Options } from "./options";
import Event from "./primitives/event";
import { LifoQueue } from "./primitives/queues";
import { BaseRawConnection } from "./baseConn";
import { ConnectWithTimeout, retryingConnect } from "./retry";
import type { BaseRawConnection } from "./baseConn";
import type { ConnectWithTimeout } from "./retry";
import { retryingConnect } from "./retry";
import { util } from "./reflection/util";
import { Transaction } from "./transaction";
import { sleep } from "./utils";
Expand Down Expand Up @@ -121,7 +127,7 @@ export class ClientConnectionHolder {
action: (transaction: Transaction) => Promise<T>
): Promise<T> {
let result: T | void;
for (let iteration = 0; true; ++iteration) {
for (let iteration = 0; ; ++iteration) {
const transaction = await Transaction._startTransaction(this);

let commitFailed = false;
Expand Down Expand Up @@ -173,7 +179,7 @@ export class ClientConnectionHolder {
expectedCardinality: Cardinality
): Promise<any> {
let result: any;
for (let iteration = 0; true; ++iteration) {
for (let iteration = 0; ; ++iteration) {
const conn = await this._getConnection();
try {
result = await conn.fetch(
Expand Down Expand Up @@ -438,7 +444,6 @@ export abstract class BaseClientPool {
);

const warningTimeoutId = setTimeout(() => {
// tslint:disable-next-line: no-console
console.warn(
"Client.close() is taking over 60 seconds to complete. " +
"Check if you have any unreleased connections left."
Expand Down Expand Up @@ -534,7 +539,7 @@ export class Client implements Executor {
return new Client(this.pool, this.options.withSession(session));
}

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

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