Skip to content
Open
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
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

35 changes: 0 additions & 35 deletions .eslintrc

This file was deleted.

66 changes: 66 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { defineConfig, globalIgnores } from "eslint/config";
import typescriptEslint from "@typescript-eslint/eslint-plugin";
import prettier from "eslint-plugin-prettier";
import globals from "globals";
import tsParser from "@typescript-eslint/parser";
import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
});

export default defineConfig([globalIgnores([
"**/node_modules",
"**/coverage",
"packages/*/dist",
"packages/pg-protocol/dist/**/*",
"packages/pg-query-stream/dist/**/*",
]), {
extends: compat.extends("eslint:recommended", "plugin:prettier/recommended", "prettier"),

plugins: {
"@typescript-eslint": typescriptEslint,
prettier,
},

languageOptions: {
globals: {
...globals.node,
...globals.mocha,
},

parser: tsParser,
ecmaVersion: 2017,
sourceType: "module",
},

rules: {
"@typescript-eslint/no-unused-vars": ["error", {
args: "none",
caughtErrors: "none",
varsIgnorePattern: "^_$",
}],

// handled by @typescript-eslint/no-unused-vars
"no-unused-vars": "off",

"no-var": "error",
"prefer-const": "error",
"no-constant-condition": ["error", {
checkLoops: "all"
}]
},
}, {
files: ["**/*.ts", "**/*.mts", "**/*.cts", "**/*.tsx"],

rules: {
"no-undef": "off",
},
}]);
11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,18 @@
"lint": "eslint --cache 'packages/**/*.{js,ts,tsx}'"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^7.0.0",
"@typescript-eslint/parser": "^6.17.0",
"eslint": "^8.56.0",
"@eslint/eslintrc": "^3.3.5",
"@eslint/js": "^10.0.1",
"@typescript-eslint/eslint-plugin": "^8.58.0",
"@typescript-eslint/parser": "^8.58.0",
"eslint": "^10.2.1",
"eslint-config-prettier": "^10.1.2",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^5.1.2",
"lerna": "^3.19.0",
"prettier": "3.0.3",
"typescript": "^4.0.3"
"typescript": "^6.0.3",
"@types/node": "^16"
},
"prettier": {
"semi": false,
Expand Down
2 changes: 1 addition & 1 deletion packages/pg-cloudflare/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"license": "MIT",
"devDependencies": {
"ts-node": "^8.5.4",
"typescript": "^4.0.3"
"typescript": "^6.0.3"
},
"exports": {
".": {
Expand Down
7 changes: 5 additions & 2 deletions packages/pg-cloudflare/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SocketOptions, Socket, TlsOptions } from 'cloudflare:sockets' // eslint-disable-line
import { SocketOptions, Socket, TlsOptions } from 'cloudflare:sockets'
import { EventEmitter } from 'events'

/**
Expand Down Expand Up @@ -153,7 +153,10 @@ const debug = false

function dump(data: unknown) {
if (data instanceof Uint8Array || data instanceof ArrayBuffer) {
const hex = Buffer.from(data).toString('hex')
// workaround https://github.com/microsoft/TypeScript/issues/63447
const buf = data instanceof Uint8Array ? Buffer.from(data) : Buffer.from(data)

const hex = buf.toString('hex')
const str = new TextDecoder().decode(data)
return `\n>>> STR: "${str.replace(/\n/g, '\\n')}"\n>>> HEX: ${hex}\n`
} else {
Expand Down
9 changes: 5 additions & 4 deletions packages/pg-cloudflare/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@
"moduleResolution": "node16",
"sourceMap": true,
"outDir": "dist",
"rootDir": "./src",
"incremental": true,
"baseUrl": ".",
"declaration": true,
"paths": {
"*": [
"node_modules/*",
"src/types/*"
"./node_modules/*",
"./src/types/*"
]
}
},
"types": ["node"]
},
"include": [
"src/**/*"
Expand Down
2 changes: 1 addition & 1 deletion packages/pg-connection-string/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"mocha": "^11.7.5",
"nyc": "^15",
"tsx": "^4.19.4",
"typescript": "^4.0.3"
"typescript": "^6.0.3"
},
"files": [
"index.js",
Expand Down
4 changes: 2 additions & 2 deletions packages/pg-protocol/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
"devDependencies": {
"@types/chai": "^4.2.7",
"@types/mocha": "^10.0.10",
"@types/node": "^12.12.21",
"@types/node": "^16",
"chai": "^4.2.0",
"chunky": "^0.0.0",
"mocha": "^11.7.5",
"ts-node": "^8.5.4",
"typescript": "^4.0.3"
"typescript": "^6.0.3"
},
"scripts": {
"test": "mocha dist/**/*.test.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/pg-protocol/src/buffer-reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export class BufferReader {
private buffer: Buffer = Buffer.allocUnsafe(0)

// TODO(bmc): support non-utf8 encoding?
private encoding: string = 'utf-8'
private encoding: BufferEncoding = 'utf-8'

constructor(private offset: number = 0) {}

Expand Down
12 changes: 8 additions & 4 deletions packages/pg-protocol/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,19 @@
"moduleResolution": "node16",
"sourceMap": true,
"outDir": "dist",
"rootDir": "./src",
"incremental": true,
"baseUrl": ".",
"declaration": true,
"paths": {
"*": [
"node_modules/*",
"src/types/*"
"./node_modules/*",
"./src/types/*"
]
}
},
"types": [
"node",
"mocha"
]
},
"include": [
"src/**/*"
Expand Down
6 changes: 3 additions & 3 deletions packages/pg-query-stream/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@
"devDependencies": {
"@types/chai": "^4.2.13",
"@types/mocha": "^10.0.10",
"@types/node": "^14.0.0",
"@types/node": "^16.0.0",
"@types/pg": "^7.14.5",
"JSONStream": "~1.3.5",
"concat-stream": "~1.0.1",
"eslint-plugin-promise": "^7.2.1",
"eslint-plugin-promise": "^7.3.0",
"mocha": "^11.7.5",
"pg": "^8.20.0",
"stream-spec": "~0.3.5",
"ts-node": "^8.5.4",
"typescript": "^4.0.3"
"typescript": "^6.0.3"
},
"peerDependencies": {
"pg": "^8"
Expand Down
2 changes: 1 addition & 1 deletion packages/pg-query-stream/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"sourceMap": true,
"pretty": true,
"outDir": "dist",
"rootDir": "./src",
"incremental": true,
"baseUrl": ".",
"declaration": true,
"types": [
"node",
Expand Down
2 changes: 1 addition & 1 deletion packages/pg/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"bluebird": "3.7.2",
"co": "4.6.0",
"pg-copy-streams": "0.3.0",
"typescript": "^4.0.3",
"typescript": "^6.0.3",
"vitest": "~3.0.9",
"wrangler": "^3.x"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ if (NODE_MAJOR_VERSION >= 16) {
} catch (e) {
const stack = e.stack
if (!e.stack.includes('innerFunction') || !e.stack.includes('outerFunction')) {
throw Error('async stack trace does not contain wanted values: ' + stack)
throw Error('async stack trace does not contain wanted values: ' + stack, { cause: e })
}
}
})
Expand All @@ -44,7 +44,7 @@ if (NODE_MAJOR_VERSION >= 16) {
} catch (e) {
const stack = e.stack
if (!e.stack.includes('innerFunction') || !e.stack.includes('outerFunction')) {
throw Error('async stack trace does not contain wanted values: ' + stack)
throw Error('async stack trace does not contain wanted values: ' + stack, { cause: e })
}
}
})
Expand Down
Loading
Loading