Skip to content

Commit da3d2bc

Browse files
authored
Update dependencies and such
* Upgrade XO and reformat * Update dev dependencies * Test with TypeScript 4.9 * Update dependencies * Pin latest node@18 for Volta * Use npm@9 * Rebuild lockfile * Select Node.js version from Volta pin in most CI jobs * Only pin npm when testing for lockfile churn; ensure npm@8 for Node.js 14
1 parent ffed948 commit da3d2bc

File tree

32 files changed

+903
-581
lines changed

32 files changed

+903
-581
lines changed

.github/workflows/ci.yml

+10-15
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ jobs:
2828
with:
2929
node-version: ${{ matrix.node-version }}
3030
cache: npm
31-
- name: Upgrade npm
32-
run: npm install --global npm@^8.18
31+
- name: Install npm@8 for Node.js 14
32+
if: matrix.node-version == '^14.19'
33+
run: npm install --global npm@^8
3334
- run: npm install --no-audit
3435
- run: npm run cover
3536
- uses: codecov/codecov-action@v2
@@ -42,15 +43,13 @@ jobs:
4243
runs-on: ubuntu-latest
4344
strategy:
4445
matrix:
45-
ts-version: [~4.7, ~4.8]
46+
ts-version: [~4.7, ~4.8, ~4.9]
4647
steps:
4748
- uses: actions/checkout@v3
4849
- uses: actions/setup-node@v3
4950
with:
50-
node-version: ^18
51+
node-version-file: package.json
5152
cache: npm
52-
- name: Upgrade npm
53-
run: npm install --global npm@^8.18
5453
- run: npm install --no-audit
5554
- run: npm i typescript@${TS_VERSION}
5655
env:
@@ -65,10 +64,10 @@ jobs:
6564
- uses: actions/checkout@v3
6665
- uses: actions/setup-node@v3
6766
with:
68-
node-version: ^18
67+
node-version-file: package.json
6968
cache: npm
70-
- name: Upgrade npm
71-
run: if [[ "$(npm -v)" != "8.18.0" ]]; then npm install --global npm@8.18.0; fi
69+
- name: Pin npm
70+
run: npm install --global npm@9.3.0
7271
- run: npm install --no-audit
7372
- name: Test package-lock for unexpected modifications
7473
run: |
@@ -87,9 +86,7 @@ jobs:
8786
- uses: actions/checkout@v3
8887
- uses: actions/setup-node@v3
8988
with:
90-
node-version: ^18
91-
- name: Upgrade npm
92-
run: npm install --global npm@^8.18
89+
node-version-file: package.json
9390
- run: npm install --no-package-lock --no-audit
9491
- run: npm run cover
9592

@@ -100,9 +97,7 @@ jobs:
10097
- uses: actions/checkout@v3
10198
- uses: actions/setup-node@v3
10299
with:
103-
node-version: ^18
100+
node-version-file: package.json
104101
cache: npm
105-
- name: Upgrade npm
106-
run: npm install --global npm@^8.18
107102
- run: npm install --no-audit
108103
- run: npx xo

entrypoints/eslint-plugin-helper.cjs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
'use strict';
2-
const path = require('path');
3-
const url = require('url');
4-
const v8 = require('v8');
5-
const {Worker} = require('worker_threads');
2+
const path = require('node:path');
3+
const url = require('node:url');
4+
const v8 = require('node:v8');
5+
const {Worker} = require('node:worker_threads');
66

77
const {
88
classify,

examples/endpoint-testing/test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use strict';
2-
const http = require('http');
2+
const http = require('node:http');
33

44
const test = require('ava');
55
const got = require('got');

lib/assert.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export class AssertionError extends Error {
5050
// use the values for custom diff views
5151
this.raw = options.raw;
5252

53-
this.savedError = options.savedError ? options.savedError : getErrorWithLongStackTrace();
53+
this.savedError = options.savedError || getErrorWithLongStackTrace();
5454
}
5555
}
5656

@@ -143,14 +143,17 @@ function validateExpectations(assertion, expectations, numberArgs) { // eslint-d
143143
case 'is':
144144
case 'message':
145145
case 'name':
146-
case 'code':
146+
case 'code': {
147147
continue;
148-
default:
148+
}
149+
150+
default: {
149151
throw new AssertionError({
150152
assertion,
151153
message: `The second argument to \`t.${assertion}()\` contains unexpected properties`,
152154
values: [formatWithLabel('Called with:', expectations)],
153155
});
156+
}
154157
}
155158
}
156159
}

lib/eslint-plugin-helper-worker.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const buildGlobs = ({conf, providers, projectDir, overrideExtensions, overrideFi
3333
cwd: projectDir,
3434
...normalizeGlobs({
3535
extensions,
36-
files: overrideFiles ? overrideFiles : conf.files,
36+
files: overrideFiles || conf.files,
3737
providers,
3838
}),
3939
};
@@ -69,5 +69,5 @@ const handleMessage = async ({projectDir, overrideExtensions, overrideFiles}) =>
6969
};
7070

7171
parentPort.on('message', handleMessage);
72-
handleMessage(workerData.firstMessage);
72+
handleMessage(workerData.firstMessage); // eslint-disable-line unicorn/prefer-top-level-await
7373
delete workerData.firstMessage;

lib/fork.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,11 @@ export default function loadFork(file, options, execArgv = process.execArgv) {
109109
}
110110

111111
switch (message.ava.type) {
112-
case 'ready-for-options':
112+
case 'ready-for-options': {
113113
send({type: 'options', options});
114114
break;
115+
}
116+
115117
case 'shared-worker-connect': {
116118
const {channelId, filename, initialData, port} = message.ava;
117119
emitter.emit('connectSharedWorker', {
@@ -125,11 +127,14 @@ export default function loadFork(file, options, execArgv = process.execArgv) {
125127
break;
126128
}
127129

128-
case 'ping':
130+
case 'ping': {
129131
send({type: 'pong'});
130132
break;
131-
default:
133+
}
134+
135+
default: {
132136
emitStateChange(message.ava);
137+
}
133138
}
134139
});
135140

lib/glob-helpers.cjs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
2-
const path = require('path');
3-
const process = require('process');
2+
const path = require('node:path');
3+
const process = require('node:process');
44

55
const ignoreByDefault = require('ignore-by-default');
66
const picomatch = require('picomatch');

lib/module-types.js

+22-8
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,28 @@ const requireTrueValue = value => {
66

77
const normalize = (extension, type, defaultModuleType) => {
88
switch (extension) {
9-
case 'cjs':
9+
case 'cjs': {
1010
requireTrueValue(type);
1111
return 'commonjs';
12-
case 'mjs':
12+
}
13+
14+
case 'mjs': {
1315
requireTrueValue(type);
1416
return 'module';
15-
case 'js':
17+
}
18+
19+
case 'js': {
1620
requireTrueValue(type);
1721
return defaultModuleType;
18-
default:
22+
}
23+
24+
default: {
1925
if (type !== 'commonjs' && type !== 'module') {
2026
throw new TypeError(`Module type for ’${extension}’ must be ’commonjs’ or ’module’`);
2127
}
2228

2329
return type;
30+
}
2431
}
2532
};
2633

@@ -37,17 +44,24 @@ const deriveFromArray = (extensions, defaultModuleType) => {
3744
const moduleTypes = {};
3845
for (const extension of extensions) {
3946
switch (extension) {
40-
case 'cjs':
47+
case 'cjs': {
4148
moduleTypes.cjs = 'commonjs';
4249
break;
43-
case 'mjs':
50+
}
51+
52+
case 'mjs': {
4453
moduleTypes.mjs = 'module';
4554
break;
46-
case 'js':
55+
}
56+
57+
case 'js': {
4758
moduleTypes.js = defaultModuleType;
4859
break;
49-
default:
60+
}
61+
62+
default: {
5063
moduleTypes[extension] = 'commonjs';
64+
}
5165
}
5266
}
5367

lib/now-and-timers.cjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use strict';
2-
const timers = require('timers');
2+
const timers = require('node:timers');
33

44
Object.assign(exports, timers);
55
exports.now = Date.now;

lib/plugin-support/shared-worker-loader.js

+6-7
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ let signalAvailable = () => {
166166
};
167167

168168
let fatal;
169-
loadFactory(workerData.filename).then(factory => {
169+
try {
170+
const factory = await loadFactory(workerData.filename);
170171
if (typeof factory !== 'function') {
171172
throw new TypeError(`Missing default factory function export for shared worker plugin at ${workerData.filename}`);
172173
}
@@ -236,14 +237,12 @@ loadFactory(workerData.filename).then(factory => {
236237
};
237238
},
238239
});
239-
}).catch(error => {
240-
if (fatal === undefined) {
241-
fatal = error;
242-
}
243-
}).finally(() => {
240+
} catch (error) {
241+
fatal = fatal ?? error;
242+
} finally {
244243
if (fatal !== undefined) {
245244
process.nextTick(() => {
246245
throw fatal;
247246
});
248247
}
249-
});
248+
}

lib/reporters/tap.js

+50-17
Original file line numberDiff line numberDiff line change
@@ -153,52 +153,78 @@ export default class TapReporter {
153153
const fileStats = this.stats && evt.testFile ? this.stats.byFile.get(evt.testFile) : null;
154154

155155
switch (evt.type) {
156-
case 'declared-test':
156+
case 'declared-test': {
157157
// Ignore
158158
break;
159-
case 'hook-failed':
159+
}
160+
161+
case 'hook-failed': {
160162
this.writeTest(evt, {passed: false, todo: false, skip: false});
161163
break;
162-
case 'hook-finished':
164+
}
165+
166+
case 'hook-finished': {
163167
this.writeComment(evt, {});
164168
break;
165-
case 'internal-error':
169+
}
170+
171+
case 'internal-error': {
166172
this.writeCrash(evt);
167173
break;
168-
case 'missing-ava-import':
174+
}
175+
176+
case 'missing-ava-import': {
169177
this.filesWithMissingAvaImports.add(evt.testFile);
170178
this.writeCrash(evt, `No tests found in ${this.relativeFile(evt.testFile)}, make sure to import "ava" at the top of your test file`);
171179
break;
172-
case 'process-exit':
180+
}
181+
182+
case 'process-exit': {
173183
this.writeProcessExit(evt);
174184
break;
175-
case 'selected-test':
185+
}
186+
187+
case 'selected-test': {
176188
if (evt.skip) {
177189
this.writeTest(evt, {passed: true, todo: false, skip: true});
178190
} else if (evt.todo) {
179191
this.writeTest(evt, {passed: false, todo: true, skip: false});
180192
}
181193

182194
break;
183-
case 'stats':
195+
}
196+
197+
case 'stats': {
184198
this.stats = evt.stats;
185199
break;
186-
case 'test-failed':
200+
}
201+
202+
case 'test-failed': {
187203
this.writeTest(evt, {passed: false, todo: false, skip: false});
188204
break;
189-
case 'test-passed':
205+
}
206+
207+
case 'test-passed': {
190208
this.writeTest(evt, {passed: true, todo: false, skip: false});
191209
break;
192-
case 'timeout':
210+
}
211+
212+
case 'timeout': {
193213
this.writeTimeout(evt);
194214
break;
195-
case 'uncaught-exception':
215+
}
216+
217+
case 'uncaught-exception': {
196218
this.writeCrash(evt);
197219
break;
198-
case 'unhandled-rejection':
220+
}
221+
222+
case 'unhandled-rejection': {
199223
this.writeCrash(evt);
200224
break;
201-
case 'worker-failed':
225+
}
226+
227+
case 'worker-failed': {
202228
if (!this.filesWithMissingAvaImports.has(evt.testFile)) {
203229
if (evt.nonZeroExitCode) {
204230
this.writeCrash(evt, `${this.relativeFile(evt.testFile)} exited with a non-zero exit code: ${evt.nonZeroExitCode}`);
@@ -208,7 +234,9 @@ export default class TapReporter {
208234
}
209235

210236
break;
211-
case 'worker-finished':
237+
}
238+
239+
case 'worker-finished': {
212240
if (!evt.forcedExit && !this.filesWithMissingAvaImports.has(evt.testFile)) {
213241
if (fileStats.declaredTests === 0) {
214242
this.writeCrash(evt, `No tests found in ${this.relativeFile(evt.testFile)}`);
@@ -218,12 +246,17 @@ export default class TapReporter {
218246
}
219247

220248
break;
249+
}
250+
221251
case 'worker-stderr':
222-
case 'worker-stdout':
252+
case 'worker-stdout': {
223253
this.stdStream.write(evt.chunk);
224254
break;
225-
default:
255+
}
256+
257+
default: {
226258
break;
259+
}
227260
}
228261
}
229262
}

0 commit comments

Comments
 (0)