Skip to content

Commit b15df53

Browse files
authored
Update dependencies & other general maintenance
* Upgrade XO * Update TypeScript-related dependencies — Don't upgrade @sindresorhus/tsconfig to v6 since it requires TS 5.5 and we test with 5.2. * Update dev dependencies * Update dependencies * Rebuild lockfile * Upgrade CodeCov action * Update reporter log instructions and remove deprecation warnings * Make Node.js 22.6 the recommended development version * Remove Node.js 21 from the engines list: It's no longer maintained by Node.js itself, see also <https://github.com/avajs/ava/blob/main/docs/support-statement.md>.
1 parent f8bf00c commit b15df53

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+2464
-3602
lines changed

.github/workflows/ci.yml

+4-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
strategy:
1616
fail-fast: false
1717
matrix:
18-
node-version: [^18.18, ^20.8, ^21, ^22]
18+
node-version: [^18.18, ^20.8, ^22]
1919
os: [ubuntu-latest, windows-latest, macos-latest]
2020
steps:
2121
- uses: actions/checkout@v4
@@ -31,17 +31,18 @@ jobs:
3131
- run: npm install --no-audit
3232
- run: ./scripts/ci.sh
3333
shell: bash
34-
- uses: codecov/codecov-action@v3
34+
- uses: codecov/codecov-action@v4
3535
with:
3636
files: coverage/lcov.info
3737
name: ${{ matrix.os }}/${{ matrix.node-version }}
38+
token: ${{ secrets.CODECOV_TOKEN }}
3839

3940
typescript:
4041
name: TypeScript compatibility
4142
runs-on: ubuntu-latest
4243
strategy:
4344
matrix:
44-
ts-version: [~5.2, ~5.3]
45+
ts-version: [~5.2, ~5.3, ~5.4, ~5.5]
4546
steps:
4647
- uses: actions/checkout@v4
4748
- uses: actions/setup-node@v4

.xo-config.cjs

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ module.exports = {
3636
files: '**/*.d.*(c|m)ts',
3737
rules: {
3838
'import/extensions': 'off',
39+
'n/file-extension-in-import': 'off',
3940
},
4041
},
4142
{
@@ -91,6 +92,7 @@ module.exports = {
9192
rules: {
9293
'import/no-anonymous-default-export': 'off',
9394
'n/prefer-global/process': 'off',
95+
'promise/prefer-await-to-then': 'off',
9496
'unicorn/error-message': 'off',
9597
},
9698
},

docs/support-statement.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ AVA supports the latest release of any major version that [is supported by Node.
88

99
When we drop support for an LTS-covered major version we will bump AVA's major version number.
1010

11-
We will drop support for odd-numbered Node.js versions (e.g. `11` or `13`) *without* bumping AVA's major version number.
11+
We will drop support for odd-numbered Node.js versions (e.g. `21` or `23`) *without* bumping AVA's major version number.
1212

1313
We try to avoid *accidentally* dropping support for non-latest Node.js releases. If such breakage does occur we'll accept pull requests to restore functionality. We might decide to deprecate the offending AVA release and bump AVA's major version number instead.
1414

examples/endpoint-testing/app.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
module.exports = (request, response) => {
3+
const app = (request, response) => {
44
if (request.url === '/user') {
55
response.setHeader('Content-Type', 'application/json');
66
response.end(JSON.stringify({email: '[email protected]'}));
@@ -9,3 +9,5 @@ module.exports = (request, response) => {
99
response.end();
1010
}
1111
};
12+
13+
module.exports = app;

lib/assert.js

+15-6
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ export class Assertions {
423423
retval = fn();
424424
if (isPromise(retval)) {
425425
// Here isPromise() checks if something is "promise like". Cast to an actual promise.
426-
Promise.resolve(retval).catch(noop);
426+
Promise.resolve(retval).catch(noop); // eslint-disable-line promise/prefer-await-to-then
427427
throw fail(new AssertionError(message, {
428428
assertion: 't.throws()',
429429
formattedDetails: [formatWithLabel('Function returned a promise. Use `t.throwsAsync()` instead:', retval)],
@@ -462,7 +462,10 @@ export class Assertions {
462462
try {
463463
assertMessage(message, 't.throwsAsync()');
464464
} catch (error) {
465-
Promise.resolve(thrower).catch(noop);
465+
try {
466+
await thrower;
467+
} catch {}
468+
466469
throw error;
467470
}
468471

@@ -476,15 +479,18 @@ export class Assertions {
476479
try {
477480
expectations = validateExpectations('t.throwsAsync()', expectations, args.length, experiments);
478481
} catch (error) {
479-
Promise.resolve(thrower).catch(noop);
482+
try {
483+
await thrower;
484+
} catch {}
485+
480486
throw fail(error);
481487
}
482488

483489
const handlePromise = async (promise, wasReturned) => {
484490
// Record the stack before it gets lost in the promise chain.
485491
const assertionStack = getAssertionStack();
486492
// Handle "promise like" objects by casting to a real Promise.
487-
const intermediate = Promise.resolve(promise).then(value => {
493+
const intermediate = Promise.resolve(promise).then(value => { // eslint-disable-line promise/prefer-await-to-then
488494
throw failPending(new AssertionError(message, {
489495
assertion: 't.throwsAsync()',
490496
assertionStack,
@@ -568,7 +574,10 @@ export class Assertions {
568574
try {
569575
assertMessage(message, 't.notThrowsAsync()');
570576
} catch (error) {
571-
Promise.resolve(nonThrower).catch(noop);
577+
try {
578+
await nonThrower;
579+
} catch {}
580+
572581
throw error;
573582
}
574583

@@ -583,7 +592,7 @@ export class Assertions {
583592
// Create an error object to record the stack before it gets lost in the promise chain.
584593
const assertionStack = getAssertionStack();
585594
// Handle "promise like" objects by casting to a real Promise.
586-
const intermediate = Promise.resolve(promise).then(noop, error => {
595+
const intermediate = Promise.resolve(promise).then(noop, error => { // eslint-disable-line promise/prefer-await-to-then
587596
throw failPending(new AssertionError(message, {
588597
assertion: 't.notThrowsAsync()',
589598
assertionStack,

lib/eslint-plugin-helper-worker.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,9 @@ const buildGlobs = ({conf, providers, projectDir, overrideExtensions, overrideFi
4141

4242
const resolveGlobs = async (projectDir, overrideExtensions, overrideFiles) => {
4343
if (!configCache.has(projectDir)) {
44-
configCache.set(projectDir, loadConfig({resolveFrom: projectDir}).then(async ({config: conf}) => {
45-
const providers = await collectProviders({conf, projectDir});
46-
return {conf, providers};
47-
}));
44+
const {config: conf} = await loadConfig({resolveFrom: projectDir});
45+
const providers = await collectProviders({conf, projectDir});
46+
configCache.set(projectDir, {conf, providers});
4847
}
4948

5049
const {conf, providers} = await configCache.get(projectDir);

lib/plugin-support/shared-workers.js

+9-4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ const waitForAvailable = async worker => {
1616
}
1717
};
1818

19+
const waitForError = async worker => {
20+
const [error] = await events.once(worker, 'error');
21+
return tagWorkerError(error);
22+
};
23+
1924
function launchWorker(filename, initialData) {
2025
if (launchedWorkers.has(filename)) {
2126
return launchedWorkers.get(filename);
@@ -34,7 +39,7 @@ function launchWorker(filename, initialData) {
3439
const launched = {
3540
statePromises: {
3641
available: waitForAvailable(worker),
37-
error: events.once(worker, 'error').then(([error]) => tagWorkerError(error)),
42+
error: waitForError(worker),
3843
},
3944
exited: false,
4045
worker,
@@ -79,7 +84,7 @@ export async function observeWorkerProcess(fork, runStatus) {
7984
}
8085
};
8186

82-
fork.promise.finally(() => {
87+
fork.promise.finally(() => { // eslint-disable-line promise/prefer-await-to-then
8388
removeAllInstances();
8489
});
8590

@@ -94,7 +99,7 @@ export async function observeWorkerProcess(fork, runStatus) {
9499
}
95100
};
96101

97-
launched.statePromises.error.then(error => {
102+
launched.statePromises.error.then(error => { // eslint-disable-line promise/prefer-await-to-then
98103
launched.worker.off('message', handleWorkerMessage);
99104
removeAllInstances();
100105
runStatus.emitStateChange({type: 'shared-worker-error', err: serializeError(error)});
@@ -113,7 +118,7 @@ export async function observeWorkerProcess(fork, runStatus) {
113118
port,
114119
}, [port]);
115120

116-
fork.promise.finally(() => {
121+
fork.promise.finally(() => { // eslint-disable-line promise/prefer-await-to-then
117122
launched.worker.postMessage({
118123
type: 'deregister-test-worker',
119124
id: fork.threadId,

lib/runner.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ export default class Runner extends Emittery {
489489

490490
// Note that the hooks and tests always begin running asynchronously.
491491
const beforePromise = this.runHooks(this.tasks.before, contextRef);
492-
const serialPromise = beforePromise.then(beforeHooksOk => {
492+
const serialPromise = beforePromise.then(beforeHooksOk => { // eslint-disable-line promise/prefer-await-to-then
493493
// Don't run tests if a `before` hook failed.
494494
if (!beforeHooksOk) {
495495
return false;
@@ -511,7 +511,7 @@ export default class Runner extends Emittery {
511511
return this.runTest(task, contextRef.copy());
512512
}, true);
513513
});
514-
const concurrentPromise = Promise.all([beforePromise, serialPromise]).then(async ([beforeHooksOk, serialOk]) => {
514+
const concurrentPromise = Promise.all([beforePromise, serialPromise]).then(async ([beforeHooksOk, serialOk]) => { // eslint-disable-line promise/prefer-await-to-then
515515
// Don't run tests if a `before` hook failed, or if `failFast` is enabled
516516
// and a previous serial test failed.
517517
if (!beforeHooksOk || (!serialOk && this.failFast)) {

lib/test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ export default class Test {
590590
};
591591

592592
promise
593-
.catch(error => {
593+
.catch(error => { // eslint-disable-line promise/prefer-await-to-then
594594
if (this.testFailure !== null && error === this.testFailure) {
595595
return;
596596
}
@@ -607,7 +607,7 @@ export default class Test {
607607
}));
608608
}
609609
})
610-
.then(() => resolve(this.finish()));
610+
.then(() => resolve(this.finish())); // eslint-disable-line promise/prefer-await-to-then
611611
});
612612
}
613613

lib/watcher.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ async function * plan({api, filter, globs, projectDir, providers, stdin, abortSi
7272
};
7373

7474
// Begin a file trace in the background.
75-
fileTracer.update(findTests(cwdAndGlobs).then(testFiles => testFiles.map(path => ({
75+
fileTracer.update(findTests(cwdAndGlobs).then(testFiles => testFiles.map(path => ({ // eslint-disable-line promise/prefer-await-to-then
7676
path: nodePath.relative(projectDir, path),
7777
isTest: true,
7878
exists: true,
@@ -187,7 +187,7 @@ async function * plan({api, filter, globs, projectDir, providers, stdin, abortSi
187187
// If the file tracer is still analyzing dependencies, wait for that to
188188
// complete.
189189
if (fileTracer.busy !== null) {
190-
fileTracer.busy.then(() => debounce.refresh());
190+
fileTracer.busy.then(() => debounce.refresh()); // eslint-disable-line promise/prefer-await-to-then
191191
takeCoverageForSelfTests?.();
192192
return;
193193
}
@@ -526,7 +526,7 @@ class FileTracer {
526526
}
527527

528528
update(changes) {
529-
const current = this.#update(changes).finally(() => {
529+
const current = this.#update(changes).finally(() => { // eslint-disable-line promise/prefer-await-to-then
530530
if (this.#pendingTrace === current) {
531531
this.#pendingTrace = null;
532532
this.#updateRunning = new Promise(resolve => {

lib/worker/base.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {mkdir} from 'node:fs/promises';
22
import {createRequire} from 'node:module';
3-
import {join as joinPath, resolve as resolvePath} from 'node:path';
3+
import path from 'node:path';
44
import process from 'node:process';
55
import {pathToFileURL} from 'node:url';
66
import {workerData} from 'node:worker_threads';
@@ -89,7 +89,7 @@ const run = async options => {
8989

9090
refs.runnerChain = runner.chain;
9191

92-
channel.peerFailed.then(() => {
92+
channel.peerFailed.then(() => { // eslint-disable-line promise/prefer-await-to-then
9393
runner.interrupt();
9494
});
9595

@@ -187,7 +187,7 @@ const run = async options => {
187187

188188
// Try to load the module as a file, relative to the project directory.
189189
// Match load() behavior.
190-
const fullPath = resolvePath(projectDir, ref);
190+
const fullPath = path.resolve(projectDir, ref);
191191
try {
192192
for (const extension of extensionsToLoadAsModules) {
193193
if (fullPath.endsWith(`.${extension}`)) {
@@ -208,9 +208,9 @@ const run = async options => {
208208

209209
let importFromProject = async ref => {
210210
// Do not use the cacheDir since it's not guaranteed to be inside node_modules.
211-
const avaCacheDir = joinPath(projectDir, 'node_modules', '.cache', 'ava');
211+
const avaCacheDir = path.join(projectDir, 'node_modules', '.cache', 'ava');
212212
await mkdir(avaCacheDir, {recursive: true});
213-
const stubPath = joinPath(avaCacheDir, 'import-from-project.mjs');
213+
const stubPath = path.join(avaCacheDir, 'import-from-project.mjs');
214214
await writeFileAtomic(stubPath, 'export const importFromProject = ref => import(ref);\n');
215215
({importFromProject} = await import(pathToFileURL(stubPath)));
216216
return importFromProject(ref);

lib/worker/channel.cjs

+3-3
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,9 @@ function registerSharedWorker(filename, initialData) {
158158
// The attaching of message listeners will cause the port to be referenced by
159159
// Node.js. In order to keep track, explicitly reference before attaching.
160160
sharedWorkerHandle.ref();
161-
const ready = selectAvaMessage(ourPort, 'ready').then(() => {
161+
const ready = selectAvaMessage(ourPort, 'ready').then(() => { // eslint-disable-line promise/prefer-await-to-then
162162
currentlyAvailable = error === null;
163-
}).finally(() => {
163+
}).finally(() => { // eslint-disable-line promise/prefer-await-to-then
164164
// Once ready, it's up to user code to subscribe to messages, which (see
165165
// below) causes us to reference the port.
166166
sharedWorkerHandle.unref();
@@ -170,7 +170,7 @@ function registerSharedWorker(filename, initialData) {
170170

171171
// Errors are received over the test worker channel, not the message port
172172
// dedicated to the shared worker.
173-
events.once(channelEmitter, 'shared-worker-error').then(() => {
173+
events.once(channelEmitter, 'shared-worker-error').then(() => { // eslint-disable-line promise/prefer-await-to-then
174174
unsubscribe();
175175
sharedWorkerHandle.forceUnref();
176176
error = new Error('The shared worker is no longer available');

0 commit comments

Comments
 (0)