Skip to content

Commit 199b8c6

Browse files
committed
chore: refresh dev tooling stack (plan#2)
1 parent 09077ba commit 199b8c6

11 files changed

Lines changed: 2020 additions & 1921 deletions

File tree

.eslintignore

Lines changed: 0 additions & 6 deletions
This file was deleted.

.eslintrc.yml

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,31 @@ env:
33
node: true
44
es6: true
55

6+
ignorePatterns:
7+
- node_modules/*
8+
- build/*
9+
- coverage/*
10+
- example/*
11+
612
parser: '@typescript-eslint/parser'
713

814
parserOptions:
9-
ecmaVersion: 9
15+
ecmaVersion: 2022
1016
project: './tsconfig.json'
1117

1218
extends:
13-
- standard
14-
- prettier
15-
- prettier/standard
16-
- plugin:eslint-comments/recommended
19+
- eslint:recommended
1720
- plugin:@typescript-eslint/recommended
18-
- prettier/@typescript-eslint
21+
- plugin:@typescript-eslint/stylistic
22+
- plugin:eslint-comments/recommended
23+
- plugin:prettier/recommended
1924

2025
plugins:
2126
- eslint-comments
22-
- prettier
2327
- '@typescript-eslint'
2428

2529
rules:
26-
prettier/prettier: error
2730
camelcase: warn
28-
standard/no-callback-literal: off
2931
'@typescript-eslint/no-unused-vars':
3032
- warn
3133
- args: none
@@ -37,5 +39,11 @@ rules:
3739
ignoreReadBeforeAssign: false
3840
'@typescript-eslint/explicit-function-return-type': off
3941
'@typescript-eslint/no-var-requires': off
40-
'@typescript-eslint/interface-name-prefix': off
4142
'@typescript-eslint/ban-ts-comment': off
43+
'@typescript-eslint/no-explicit-any': off
44+
'@typescript-eslint/consistent-type-definitions': off
45+
'@typescript-eslint/consistent-indexed-object-style': off
46+
'@typescript-eslint/no-require-imports': off
47+
48+
# TODO(agent): migrate to the flat eslint.config.js format so we can drop the
49+
# ESLINT_USE_FLAT_CONFIG shim once TypeScript rules are fully modernized.

.husky/commit-msg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
[ "${HUSKY-}" = "0" ] && exit 0
3+
4+
npx commitlint --edit "$1"

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
[ "${HUSKY-}" = "0" ] && exit 0
3+
4+
yarn lint-staged

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99
- Drop Node 12, 14, 16 support
1010
- Add Node 20, 22, 24 support
1111
- Clarify compatibility guarantees: require Node >=18.19.0, acknowledge Node 18/20/22/24 LTS plus MongoDB server 4.4-8.0, limit the mongodb peer dependency range to >=5 <8, and expand CI to cover every Node/driver/server combination (drivers 5.x-7.x, servers 4.4-8.0).
12+
- Refresh developer tooling: bump TypeScript (5.9), Ava (6.x), ESLint (9.x), Prettier (3.x), Husky (9), lint-staged (16), commitlint (20), ts-node (10.9), TypeDoc (0.28), and the @types/* packages so the repo matches modern Node 18+ environments.
1213

1314
## [5.1.0] - 2023-10-14
1415

docs/PLANS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22
- Bring the published compatibility story in sync with reality: engines.node still only asserts >=18.12.0, MongoDB is capped to <7, and the README claims MongoDB server 3.6+ (EOL for years) while also saying “mongodb is not a peer dependency” even though it now is (package.json:56-63, README.md:45-55). Bump the
33
engine floor so the metadata and docs explicitly cover the currently maintained Node LTS releases (18, 20, 22, 24), extend the peer range to cover MongoDB driver >=5 and <8 plus server 4.4-8.0 (and add corresponding tests), and fix the user-facing docs/badges so consumers aren't misled.
44
- [done 2025-11-15] Refine compatibility statements + CI matrix for Node 18/20/22/24, MongoDB server 4.4-8.0, driver >=5<8 (agent: Codex)
5+
- TODO(agent): drop src/types/async-disposable.d.ts once tsconfig enables the built-in esnext.disposable lib and the shim is redundant.
56
- Refresh the tooling stack: virtually every dev dependency is from 2020 (TypeScript 4.0, Ava 3, ESLint 7, Husky 4, Prettier 2, commitlint 11, etc.), which misses hundreds of bug fixes and no longer understands Node 20/22 typings (package.json:67-107). Plan an across-the-board upgrade (TS ≥5.6, Ava 6, ESLint 9,
67
Prettier 3, Husky 9/Lint‑Staged 15, latest @types/*) and run yarn dedupe afterwards.
8+
- [done 2025-11-15] Upgrade TS/AVA/ESLint/prettier/husky stacks while keeping Node 18 compatibility (agent: Codex)
9+
- TODO(agent): migrate from .eslintrc.yml to an eslint.config.js flat config so ESLINT_USE_FLAT_CONFIG shim can be removed.
710
- Examples and fixtures lag far behind: the sample app still consumes connect-mongo@^4.4.0, forces MongoDB 3.6 via Yarn resolutions, and docker-compose.yaml spins up Mongo 4.4 (example/package.json:12-23, docker-compose.yaml:1-11). Update those to your current major, exercise Mongo server 7+, and document SRV/TLS
811
flows so contributors can reproduce issues without pinning to obsolete builds.
912
- Modernize packaging: you only emit CommonJS (main + typings) yet advertise a non-existent build/module artifact and lack an exports map or dual entry points (package.json:5-8, 28-33, 109-118). Add a build:module/Rollup step (or at least exports: { ".": { "require": "./build/main/index.js", "import": "./build/main/

package.json

Lines changed: 31 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@
3030
"build:main": "tsc -p tsconfig.json",
3131
"fix": "run-s fix:*",
3232
"fix:prettier": "prettier \"src/**/*.ts\" --write",
33-
"fix:lint": "eslint --cache src --ext .ts --fix",
33+
"fix:lint": "cross-env ESLINT_USE_FLAT_CONFIG=false eslint --cache src --ext .ts --fix",
3434
"test": "run-s build test:*",
35-
"test:lint": "eslint --cache src --ext .ts",
35+
"test:lint": "cross-env ESLINT_USE_FLAT_CONFIG=false eslint --cache src --ext .ts",
3636
"test:prettier": "prettier \"src/**/*.ts\" --list-different",
3737
"test:unit": "nyc ava",
3838
"check-cli": "run-s test diff-integration-tests check-integration-tests",
@@ -46,12 +46,13 @@
4646
"cov:send": "run-s cov:lcov && codecov",
4747
"cov:check": "nyc report && nyc check-coverage",
4848
"doc": "run-s doc:html && open-cli build/docs/index.html",
49-
"doc:html": "typedoc src/ --exclude **/*.spec.ts --target ES6 --mode file --out build/docs",
50-
"doc:json": "typedoc src/ --exclude **/*.spec.ts --target ES6 --mode file --json build/docs/typedoc.json",
49+
"doc:html": "typedoc --entryPointStrategy expand --entryPoints src --exclude **/*.spec.ts --out build/docs",
50+
"doc:json": "typedoc --entryPointStrategy expand --entryPoints src --exclude **/*.spec.ts --json build/docs/typedoc.json",
5151
"doc:publish": "gh-pages -m \"[ci skip] Updates\" -d build/docs",
5252
"version": "standard-version",
5353
"reset-hard": "git clean -dfx && git reset --hard && yarn",
54-
"prepare-release": "run-s reset-hard test cov:check doc:html version doc:publish"
54+
"prepare-release": "run-s reset-hard test cov:check doc:html version doc:publish",
55+
"prepare": "husky"
5556
},
5657
"engines": {
5758
"node": ">=18.19.0"
@@ -65,46 +66,41 @@
6566
"kruptein": "^3.0.0"
6667
},
6768
"devDependencies": {
68-
"@ava/typescript": "^1.1.1",
69-
"@commitlint/cli": "^11.0.0",
70-
"@commitlint/config-conventional": "^11.0.0",
69+
"@ava/typescript": "^6.0.0",
70+
"@commitlint/cli": "^20.1.0",
71+
"@commitlint/config-conventional": "^20.0.0",
7172
"@istanbuljs/nyc-config-typescript": "^1.0.1",
72-
"@types/debug": "^4.1.7",
73-
"@types/express": "^4.17.13",
74-
"@types/express-session": "^1.17.4",
75-
"@types/node": "^14.14.20",
76-
"@types/supertest": "^2.0.10",
77-
"@typescript-eslint/eslint-plugin": "^4.12.0",
78-
"@typescript-eslint/parser": "^4.12.0",
79-
"ava": "^3.12.1",
73+
"@types/debug": "^4.1.12",
74+
"@types/express": "^4.17.21",
75+
"@types/express-session": "^1.18.2",
76+
"@types/node": "^24.10.1",
77+
"@types/supertest": "^6.0.3",
78+
"@typescript-eslint/eslint-plugin": "^8.46.4",
79+
"@typescript-eslint/parser": "^8.46.4",
80+
"ava": "^6.4.1",
8081
"codecov": "^3.5.0",
8182
"cspell": "^4.1.0",
8283
"cz-conventional-changelog": "^3.3.0",
83-
"eslint": "^7.17.0",
84-
"eslint-config-prettier": "^7.1.0",
85-
"eslint-config-prettier-standard": "^3.0.1",
86-
"eslint-config-standard": "^16.0.2",
84+
"eslint": "^9.39.1",
85+
"eslint-config-prettier": "^10.1.8",
8786
"eslint-plugin-eslint-comments": "^3.2.0",
88-
"eslint-plugin-import": "^2.22.1",
89-
"eslint-plugin-node": "^11.1.0",
90-
"eslint-plugin-prettier": "^3.3.1",
91-
"eslint-plugin-promise": "^4.2.1",
92-
"eslint-plugin-standard": "^5.0.0",
87+
"eslint-plugin-prettier": "^5.5.4",
9388
"express": "^4.17.1",
9489
"express-session": "^1.17.1",
9590
"gh-pages": "^3.1.0",
96-
"husky": "4",
97-
"lint-staged": "^10.5.4",
91+
"husky": "^9.1.7",
92+
"lint-staged": "^16.2.6",
9893
"mongodb": "^6.21.0",
9994
"npm-run-all": "^4.1.5",
10095
"nyc": "^15.1.0",
10196
"open-cli": "^6.0.1",
102-
"prettier": "^2.2.1",
97+
"prettier": "^3.6.2",
10398
"standard-version": "^9.0.0",
10499
"supertest": "^6.1.3",
105-
"ts-node": "^9.0.0",
106-
"typedoc": "^0.19.0",
107-
"typescript": "^4.0.2"
100+
"ts-node": "^10.9.2",
101+
"typedoc": "^0.28.14",
102+
"typescript": "^5.9.3",
103+
"cross-env": "^10.1.0"
108104
},
109105
"files": [
110106
"build/main",
@@ -122,7 +118,8 @@
122118
"typescript": {
123119
"rewritePaths": {
124120
"src/": "build/main/"
125-
}
121+
},
122+
"compile": false
126123
},
127124
"files": [
128125
"!build/module/**",
@@ -145,15 +142,9 @@
145142
"**/*.spec.js"
146143
]
147144
},
148-
"husky": {
149-
"hooks": {
150-
"pre-commit": "lint-staged",
151-
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
152-
}
153-
},
154145
"lint-staged": {
155-
"*.{js,ts}": [
156-
"eslint --fix"
146+
"**/*.{ts,js}": [
147+
"cross-env ESLINT_USE_FLAT_CONFIG=false eslint --cache --fix"
157148
]
158149
},
159150
"packageManager": "yarn@1.22.22+sha1.ac34549e6aa8e7ead463a7407e1c7390f61a6610"

src/lib/MongoStore.spec.ts

Lines changed: 66 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -87,44 +87,71 @@ test.serial('basic operation flow', async (t) => {
8787
t.is(await storePromise.length(), 0)
8888
})
8989

90-
test.serial.cb('set and listen to event', (t) => {
90+
test.serial('set and listen to event', async (t) => {
9191
;({ store, storePromise } = createStoreHelper())
92-
let orgSession = makeData()
9392
const sid = 'test-set-event'
94-
store.set(sid, orgSession)
95-
orgSession = JSON.parse(JSON.stringify(orgSession))
96-
store.on('set', (sessionId) => {
97-
t.is(sessionId, sid)
98-
store.get(sid, (err, session) => {
99-
t.is(err, null)
100-
t.is(typeof session, 'object')
101-
t.deepEqual(session, orgSession)
102-
t.end()
93+
const orgSession = makeData()
94+
const expectedSession = JSON.parse(JSON.stringify(orgSession))
95+
96+
const waitForSet = new Promise<void>((resolve, reject) => {
97+
store.once('set', async (sessionId) => {
98+
try {
99+
t.is(sessionId, sid)
100+
const session = await storePromise.get(sid)
101+
t.truthy(session)
102+
t.is(typeof session, 'object')
103+
t.deepEqual(session, expectedSession)
104+
resolve()
105+
} catch (err) {
106+
reject(err)
107+
}
103108
})
104109
})
110+
111+
await storePromise.set(sid, orgSession)
112+
await waitForSet
105113
})
106114

107-
test.serial.cb('set and listen to create event', (t) => {
115+
test.serial('set and listen to create event', async (t) => {
108116
;({ store, storePromise } = createStoreHelper())
109-
const orgSession = makeData()
110117
const sid = 'test-create-event'
111-
store.set(sid, orgSession)
112-
store.on('create', (sessionId) => {
113-
t.is(sessionId, sid)
114-
t.end()
118+
const orgSession = makeData()
119+
120+
const waitForCreate = new Promise<void>((resolve, reject) => {
121+
store.once('create', (sessionId) => {
122+
try {
123+
t.is(sessionId, sid)
124+
resolve()
125+
} catch (err) {
126+
reject(err)
127+
}
128+
})
115129
})
130+
131+
await storePromise.set(sid, orgSession)
132+
await waitForCreate
116133
})
117134

118-
test.serial.cb('set and listen to update event', (t) => {
135+
test.serial('set and listen to update event', async (t) => {
119136
;({ store, storePromise } = createStoreHelper())
120-
const orgSession = makeData()
121137
const sid = 'test-update-event'
122-
store.set(sid, orgSession)
123-
store.set(sid, { ...orgSession, foo: 'new-bar' } as SessionData)
124-
store.on('update', (sessionId) => {
125-
t.is(sessionId, sid)
126-
t.end()
138+
const orgSession = makeData()
139+
140+
await storePromise.set(sid, orgSession)
141+
142+
const waitForUpdate = new Promise<void>((resolve, reject) => {
143+
store.once('update', (sessionId) => {
144+
try {
145+
t.is(sessionId, sid)
146+
resolve()
147+
} catch (err) {
148+
reject(err)
149+
}
150+
})
127151
})
152+
153+
await storePromise.set(sid, { ...orgSession, foo: 'new-bar' } as SessionData)
154+
await waitForUpdate
128155
})
129156

130157
test.serial('set with no stringify', async (t) => {
@@ -146,17 +173,25 @@ test.serial('set with no stringify', async (t) => {
146173
t.is(await storePromise.length(), 0)
147174
})
148175

149-
test.serial.cb('test destory event', (t) => {
176+
test.serial('test destory event', async (t) => {
150177
;({ store, storePromise } = createStoreHelper())
151178
const orgSession = makeData()
152179
const sid = 'test-destory-event'
153-
store.on('destroy', (sessionId) => {
154-
t.is(sessionId, sid)
155-
t.end()
156-
})
157-
storePromise.set(sid, orgSession).then(() => {
158-
store.destroy(sid)
180+
181+
const waitForDestroy = new Promise<void>((resolve, reject) => {
182+
store.once('destroy', (sessionId) => {
183+
try {
184+
t.is(sessionId, sid)
185+
resolve()
186+
} catch (err) {
187+
reject(err)
188+
}
189+
})
159190
})
191+
192+
await storePromise.set(sid, orgSession)
193+
await storePromise.destroy(sid)
194+
await waitForDestroy
160195
})
161196

162197
test.serial('test set default TTL', async (t) => {

0 commit comments

Comments
 (0)