Skip to content

Commit e8a4976

Browse files
authored
Update all the things
* Test lockfile using npm 7.23 * Workflow updates * Update codecov action * Cache npm dependencies * Simplify checkout * Bump minimal Node.js versions These should allow us to add features over AVA 4's lifetime using newly available Node.js APIs. * Update dev dependencies * Update to TypeScript 4.4 and latest tsd * Upgrade XO and reformat * Update dependencies * Rebuild lockfile * Run XO with Node.js 16 It fails on older Node.js versions.
1 parent e96b82d commit e8a4976

File tree

210 files changed

+8852
-11486
lines changed

Some content is hidden

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

210 files changed

+8852
-11486
lines changed

.github/workflows/ci.yml

+14-20
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,10 @@ jobs:
1515
strategy:
1616
fail-fast: false
1717
matrix:
18-
node-version: [^12.22, ^14.15, ^16]
18+
node-version: [^12.22, ^14.17, ^16.4]
1919
os: [ubuntu-latest, windows-latest]
2020
steps:
2121
- uses: actions/checkout@v2
22-
with:
23-
fetch-depth: 1
2422
- name: Enable symlinks
2523
if: matrix.os == 'windows-latest'
2624
run: |
@@ -29,31 +27,31 @@ jobs:
2927
- uses: actions/setup-node@v2
3028
with:
3129
node-version: ${{ matrix.node-version }}
30+
cache: npm
3231
- name: Upgrade npm
3332
run: npm install --global npm@7
34-
- run: npm ci --no-audit
33+
- run: npm install --no-audit
3534
- run: npm run cover
36-
- uses: codecov/codecov-action@v1
35+
- uses: codecov/codecov-action@v2
3736
with:
38-
file: coverage/lcov.info
37+
files: coverage/lcov.info
3938
name: ${{ matrix.os }}/${{ matrix.node-version }}
4039

4140
typescript:
4241
name: TypeScript compatibility
4342
runs-on: ubuntu-latest
4443
strategy:
4544
matrix:
46-
ts-version: [~4.2]
45+
ts-version: [~4.4]
4746
steps:
4847
- uses: actions/checkout@v2
49-
with:
50-
fetch-depth: 1
5148
- uses: actions/setup-node@v2
5249
with:
5350
node-version: ^12.22
51+
cache: npm
5452
- name: Upgrade npm
5553
run: npm install --global npm@7
56-
- run: npm ci --no-audit
54+
- run: npm install --no-audit
5755
- run: npm i typescript@${TS_VERSION}
5856
env:
5957
TS_VERSION: ${{ matrix.ts-version }}
@@ -65,14 +63,13 @@ jobs:
6563
runs-on: ubuntu-latest
6664
steps:
6765
- uses: actions/checkout@v2
68-
with:
69-
fetch-depth: 1
7066
- uses: actions/setup-node@v2
7167
with:
7268
node-version: ^12.22
69+
cache: npm
7370
- name: Upgrade npm
74-
run: if [[ "$(npm -v)" != "7.11" ]]; then npm install --global npm@7.11; fi
75-
- run: npm ci --no-audit
71+
run: if [[ "$(npm -v)" != "7.23" ]]; then npm install --global npm@7.23; fi
72+
- run: npm install --no-audit
7673
- name: Test package-lock for unexpected modifications
7774
run: |
7875
npm -v
@@ -88,8 +85,6 @@ jobs:
8885
runs-on: ubuntu-latest
8986
steps:
9087
- uses: actions/checkout@v2
91-
with:
92-
fetch-depth: 1
9388
- uses: actions/setup-node@v2
9489
with:
9590
node-version: ^12.22
@@ -103,12 +98,11 @@ jobs:
10398
runs-on: ubuntu-latest
10499
steps:
105100
- uses: actions/checkout@v2
106-
with:
107-
fetch-depth: 1
108101
- uses: actions/setup-node@v2
109102
with:
110-
node-version: ^12.22
103+
node-version: ^16.4
104+
cache: npm
111105
- name: Upgrade npm
112106
run: npm install --global npm@7
113-
- run: npm ci
107+
- run: npm install --no-audit
114108
- run: npx xo

.xo-config.json

+20-18
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
"examples/typescript-*/**/*.ts"
88
],
99
"rules": {
10-
"import/no-anonymous-default-export": "off",
11-
"import/no-mutable-exports": "off",
1210
"import/order": [
1311
"error",
1412
{
@@ -19,8 +17,7 @@
1917
}
2018
],
2119
"import/newline-after-import": "error",
22-
"node/no-unsupported-features/es-syntax": "off",
23-
"no-use-extend-native/no-use-extend-native": "off"
20+
"unicorn/require-post-message-target-origin": "off"
2421
},
2522
"overrides": [
2623
{
@@ -39,21 +36,28 @@
3936
}
4037
},
4138
{
42-
"files": "test-{d,tap}/**/*.ts",
39+
"files": "{test,test-{d,tap}}/**/*.ts",
4340
"rules": {
4441
"@typescript-eslint/explicit-function-return-type": "off",
4542
"@typescript-eslint/no-empty-function": "off",
43+
"@typescript-eslint/no-unsafe-assignment": "off",
4644
"@typescript-eslint/no-unsafe-call": "off",
4745
"@typescript-eslint/no-unsafe-member-access": "off",
4846
"@typescript-eslint/no-unsafe-return": "off",
4947
"@typescript-eslint/no-unused-vars": "off",
50-
"@typescript-eslint/prefer-readonly-parameter-types": "off",
51-
"import/extensions": "off",
52-
"no-unused-vars": "off"
48+
"@typescript-eslint/prefer-readonly-parameter-types": "off"
5349
}
5450
},
5551
{
56-
"files": "test-tap/**/*.js",
52+
"files": "{test,test-{d,tap}}/**",
53+
"rules": {
54+
"import/no-anonymous-default-export": "off",
55+
"node/prefer-global/buffer": "off",
56+
"node/prefer-global/process": "off"
57+
}
58+
},
59+
{
60+
"files": "test-tap/**",
5761
"rules": {
5862
"promise/prefer-await-to-then": "off",
5963
"unicorn/error-message": "off",
@@ -62,20 +66,18 @@
6266
}
6367
},
6468
{
65-
"files": [
66-
"test-tap/fixture/**",
67-
"test/**/fixtures/**"
68-
],
69+
"files": "test/macros/fixtures/macros.js",
6970
"rules": {
70-
"ava/no-todo-test": "off",
71-
"import/no-extraneous-dependencies": "off",
72-
"import/no-unresolved": "off"
71+
"ava/no-identical-title": "off"
7372
}
7473
},
7574
{
76-
"files": "test/macros/fixtures/macros.js",
75+
"files": [
76+
"examples/**",
77+
"test/snapshot-*/fixtures/**"
78+
],
7779
"rules": {
78-
"ava/no-identical-title": "off"
80+
"unicorn/prefer-module": "off"
7981
}
8082
},
8183
{

ava.config.cjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
// installed "test-ava" version.
44
module.exports = {
55
files: ['test/**', '!test/**/{fixtures,helpers}/**'],
6-
ignoredByWatcher: ['{coverage,docs,media,test-d,test-tap}/**']
6+
ignoredByWatcher: ['{coverage,docs,media,test-d,test-tap}/**'],
77
};

docs/recipes/typescript.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Translations: [Español](https://github.com/avajs/ava-docs/blob/master/es_ES/doc
44

55
AVA comes bundled with a TypeScript definition file. This allows developers to leverage TypeScript for writing tests.
66

7-
This guide assumes you've already set up TypeScript for your project. Note that AVA 3's definition expects at least version 3.7.5. AVA 4 will require at least version 4.2.
7+
This guide assumes you've already set up TypeScript for your project. Note that AVA 3's definition expects at least version 3.7.5. AVA 4 will require at least version 4.4.
88

99
## Enabling AVA's support for TypeScript test files
1010

entrypoints/eslint-plugin-helper.cjs

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const {
1010
isHelperish,
1111
matches,
1212
normalizeFileForMatching,
13-
normalizePatterns
13+
normalizePatterns,
1414
} = require('../lib/glob-helpers.cjs');
1515

1616
const MAX_DATA_LENGTH_EXCLUSIVE = 100 * 1024; // Allocate 100 KiB to exchange globs.
@@ -32,15 +32,15 @@ const resolveGlobsSync = (projectDir, overrideExtensions, overrideFiles) => {
3232
workerData: {
3333
dataBuffer,
3434
syncBuffer,
35-
firstMessage: {projectDir, overrideExtensions, overrideFiles}
36-
}
35+
firstMessage: {projectDir, overrideExtensions, overrideFiles},
36+
},
3737
});
3838
worker.unref();
3939
} else {
4040
worker.postMessage({projectDir, overrideExtensions, overrideFiles});
4141
}
4242

43-
const synchronize = Atomics.wait(sync, 0, 0, 10000);
43+
const synchronize = Atomics.wait(sync, 0, 0, 10_000);
4444
if (synchronize === 'timed-out') {
4545
throw new Error('Timed out resolving AVA configuration');
4646
}
@@ -100,7 +100,7 @@ function load(projectDir, overrides) {
100100
// Add the first extension. If multiple extensions are available, assume
101101
// patterns are not biased to any particular extension.
102102
return classifyForESLint(`${importPath}.${globs.extensions[0]}`);
103-
}
103+
},
104104
});
105105
helperCache.set(cacheKey, helper);
106106
return helper;

examples/endpoint-testing/test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const test = require('ava');
55
const got = require('got');
66
const listen = require('test-listen');
77

8-
const app = require('./app');
8+
const app = require('./app.js');
99

1010
test.before(async t => {
1111
t.context.server = http.createServer(app);

examples/macros/test.js

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
'use strict';
21
const test = require('ava');
32

43
const {sum} = require('.');

examples/timeouts/index.js

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

3-
const delay = ms => {
4-
return new Promise(resolve => {
5-
setTimeout(resolve, ms);
6-
});
7-
};
3+
const delay = ms => new Promise(resolve => {
4+
setTimeout(resolve, ms);
5+
});
86

97
exports.fetchUsers = async () => {
108
await delay(50);
@@ -14,8 +12,8 @@ exports.fetchUsers = async () => {
1412
id: 1,
1513
firstName: 'Ava',
1614
name: 'Rocks',
17-
18-
}
15+
16+
},
1917
];
2018
};
2119

@@ -26,8 +24,8 @@ exports.fetchPosts = async userId => {
2624
{
2725
id: 1,
2826
userId,
29-
message: 'AVA Rocks 🚀'
30-
}
27+
message: 'AVA Rocks 🚀',
28+
},
3129
];
3230
};
3331

@@ -37,6 +35,6 @@ exports.createPost = async message => {
3735
return {
3836
id: 2,
3937
userId: 1,
40-
message
38+
message,
4139
};
4240
};

examples/timeouts/test.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ test('retrieve users', async t => {
1313
id: 1,
1414
firstName: 'Ava',
1515
name: 'Rocks',
16-
17-
}
16+
17+
},
1818
]);
1919
});
2020

@@ -27,8 +27,8 @@ test('retrieve posts', async t => {
2727
{
2828
id: 1,
2929
userId: 1,
30-
message: 'AVA Rocks 🚀'
31-
}
30+
message: 'AVA Rocks 🚀',
31+
},
3232
]);
3333
});
3434

@@ -38,6 +38,6 @@ test('create post', async t => {
3838
t.deepEqual(post, {
3939
id: 2,
4040
userId: 1,
41-
message: 'I love 🦄 and 🌈'
41+
message: 'I love 🦄 and 🌈',
4242
});
4343
});

lib/api.js

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import fs from 'fs';
2-
import os from 'os';
3-
import path from 'path';
1+
import fs from 'node:fs';
2+
import os from 'node:os';
3+
import path from 'node:path';
4+
import process from 'node:process';
45

56
import arrify from 'arrify';
67
import chunkd from 'chunkd';
@@ -126,7 +127,7 @@ export default class Api extends Emittery {
126127
selectedFiles = filter.length === 0 ? testFiles : globs.applyTestFileFilter({
127128
cwd: this.options.projectDir,
128129
filter: filter.map(({pattern}) => pattern),
129-
testFiles
130+
testFiles,
130131
});
131132
}
132133
} catch (error) {
@@ -165,7 +166,7 @@ export default class Api extends Emittery {
165166
previousFailures: runtimeOptions.previousFailures || 0,
166167
runOnlyExclusive: runtimeOptions.runOnlyExclusive === true,
167168
runVector: runtimeOptions.runVector || 0,
168-
status: runStatus
169+
status: runStatus,
169170
});
170171

171172
if (setupOrGlobError) {
@@ -230,7 +231,7 @@ export default class Api extends Emittery {
230231
lineNumbers,
231232
recordNewSnapshots: !isCi,
232233
// If we're looking for matches, run every single test process in exclusive-only mode
233-
runOnlyExclusive: apiOptions.match.length > 0 || runtimeOptions.runOnlyExclusive === true
234+
runOnlyExclusive: apiOptions.match.length > 0 || runtimeOptions.runOnlyExclusive === true,
234235
};
235236

236237
if (runtimeOptions.updateSnapshots) {
@@ -282,9 +283,9 @@ export default class Api extends Emittery {
282283
return this._cacheDir;
283284
}
284285

285-
const cacheDir = this.options.cacheEnabled === false ?
286-
fs.mkdtempSync(`${tempDir}${path.sep}`) :
287-
this._getLocalCacheDir();
286+
const cacheDir = this.options.cacheEnabled === false
287+
? fs.mkdtempSync(`${tempDir}${path.sep}`)
288+
: this._getLocalCacheDir();
288289

289290
// Ensure cacheDir exists
290291
fs.mkdirSync(cacheDir, {recursive: true});

0 commit comments

Comments
 (0)