Skip to content

Commit 9372225

Browse files
committed
Merge branch 'master' into add-support-for-include-unused-variables-option
2 parents d36f715 + 39d0901 commit 9372225

13 files changed

+177
-79
lines changed

.eslintrc.json

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

.github/workflows/ci.yml

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,50 @@
11
name: CI
22
on: [push, workflow_dispatch]
33
jobs:
4+
prettier:
5+
name: Prettier
6+
runs-on: ubuntu-latest
7+
steps:
8+
- uses: actions/checkout@v5
9+
- uses: actions/setup-node@v4
10+
with:
11+
node-version: latest
12+
- run: npm install
13+
- run: node --run prettier
14+
eslint:
15+
name: ESLint
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v5
19+
- uses: actions/setup-node@v4
20+
with:
21+
node-version: latest
22+
- run: npm install
23+
- run: node --run eslint
24+
types:
25+
name: Types
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: actions/checkout@v5
29+
- uses: actions/setup-node@v4
30+
with:
31+
node-version: latest
32+
- run: npm install
33+
- run: node --run types
434
test:
5-
name: Test with Node.js v${{ matrix.node }} and ${{ matrix.os }}
6-
runs-on: ${{ matrix.os }}
35+
name: Test
736
strategy:
837
matrix:
938
os: [ubuntu-latest, macos-latest]
10-
node: ["18", "20", "21"]
39+
node: [20, 22, 24]
40+
runs-on: ${{ matrix.os }}
1141
steps:
12-
- uses: actions/checkout@v4
13-
- name: Setup Node.js v${{ matrix.node }}
14-
uses: actions/setup-node@v3
42+
- uses: actions/checkout@v5
43+
- uses: actions/setup-node@v4
1544
with:
1645
node-version: ${{ matrix.node }}
17-
- name: npm install and test
18-
run: npm install-test
46+
- run: npm install
47+
- run: npm run test
48+
if: matrix.node < 22
49+
- run: node --run test
50+
if: matrix.node >= 22

changelog.md

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,29 @@
11
# apollo-upload-client changelog
22

3+
## Next
4+
5+
### Major
6+
7+
- Updated Node.js support to `^20.9.0 || >=22.0.0`.
8+
- Use the TypeScript v5.5+ JSDoc tag `@import` to import types in modules.
9+
- Updated dev dependencies, some of which require newer Node.js versions than previously supported.
10+
11+
### Patch
12+
13+
- Updated the package scripts:
14+
- Reordered and renamed scripts.
15+
- Replaced `npm run` with `node --run`.
16+
- Updated GitHub Actions CI config:
17+
- Run checks in separate jobs.
18+
- Removed custom step names.
19+
- Updated `actions/checkout` to v5.
20+
- Updated `actions/setup-node` to v4.
21+
- Replaced `npm run` with `node --run`.
22+
- Run tests with Node.js v20, v22, v24.
23+
- Enabled the TypeScript compiler options `noUnusedLocals` and `noUnusedParameters`.
24+
- Migrated to the ESLint v9 CLI and “flat” config.
25+
- In tests, removed the no longer needed polyfill for the global `File`.
26+
327
## 18.0.1
428

529
### Patch
@@ -15,7 +39,6 @@
1539
- Updated Node.js support to `^18.15.0 || >=20.4.0`.
1640
- Updated the [`@apollo/client`](https://npm.im/@apollo/client) peer dependency to `^3.8.0`.
1741
- Updated the [`extract-files`](http://npm.im/extract-files) dependency to v13.
18-
1942
- React Native is no longer supported out of the box.
2043

2144
The class `ReactNativeFile` is no longer exported, or matched by the function `isExtractableFile`.
@@ -64,7 +87,6 @@
6487
Types published in [`@types/apollo-upload-client`](https://npm.im/@types/apollo-upload-client) should no longer be used.
6588

6689
Projects must configure TypeScript to use types from the ECMAScript modules that have a `// @ts-check` comment:
67-
6890
- [`compilerOptions.allowJs`](https://www.typescriptlang.org/tsconfig#allowJs) should be `true`.
6991
- [`compilerOptions.maxNodeModuleJsDepth`](https://www.typescriptlang.org/tsconfig#maxNodeModuleJsDepth) should be reasonably large, e.g. `10`.
7092
- [`compilerOptions.module`](https://www.typescriptlang.org/tsconfig#module) should be `"node16"` or `"nodenext"`.

createUploadLink.mjs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
// @ts-check
22

3+
/**
4+
* @import { DefaultContext } from "@apollo/client/core/types.js"
5+
* @import {
6+
* Printer
7+
* } from "@apollo/client/link/http/selectHttpOptionsAndBody.js"
8+
*/
9+
310
import { ApolloLink } from "@apollo/client/link/core/ApolloLink.js";
411
import { createSignalIfSupported } from "@apollo/client/link/http/createSignalIfSupported.js";
512
import { parseAndCheckHttpResponse } from "@apollo/client/link/http/parseAndCheckHttpResponse.js";
@@ -49,9 +56,8 @@ import isExtractableFile from "./isExtractableFile.mjs";
4956
* Customizes how extracted files are appended to the
5057
* [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData)
5158
* instance. Defaults to {@linkcode formDataAppendFile}.
52-
* @param {import("@apollo/client/link/http/selectHttpOptionsAndBody.js").Printer} [options.print]
53-
* Prints the GraphQL query or mutation AST to a string for transport.
54-
* Defaults to {@linkcode defaultPrinter}.
59+
* @param {Printer} [options.print] Prints the GraphQL query or mutation AST to
60+
* a string for transport. Defaults to {@linkcode defaultPrinter}.
5561
* @param {typeof fetch} [options.fetch] [`fetch`](https://fetch.spec.whatwg.org)
5662
* implementation. Defaults to the {@linkcode fetch} global.
5763
* @param {RequestInit} [options.fetchOptions] `fetch` options; overridden by
@@ -104,7 +110,7 @@ export default function createUploadLink({
104110
return new ApolloLink((operation) => {
105111
const context =
106112
/**
107-
* @type {import("@apollo/client/core/types.js").DefaultContext & {
113+
* @type {DefaultContext & {
108114
* clientAwareness?: {
109115
* name?: string,
110116
* version?: string,

createUploadLink.test.mjs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// @ts-check
22

3-
import "./test/polyfillFile.mjs";
4-
53
import { deepEqual, deepStrictEqual, ok, strictEqual } from "node:assert";
64
import { describe, it } from "node:test";
75

eslint.config.mjs

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
// @ts-check
2+
3+
/** @import { Linter } from "eslint" */
4+
5+
import eslintJs from "@eslint/js";
6+
import eslintPluginOptimalModules from "eslint-plugin-optimal-modules";
7+
import eslintPluginSimpleImportSort from "eslint-plugin-simple-import-sort";
8+
import globals from "globals";
9+
10+
/**
11+
* Globs for ESM files.
12+
* @satisfies {Array<string>}
13+
*/
14+
const globsEsm = ["**/**.mjs"];
15+
16+
/**
17+
* Globs for CJS files.
18+
* @satisfies {Array<string>}
19+
*/
20+
const globsCjs = ["**/**.cjs", "**/**.js"];
21+
22+
/**
23+
* Globs for all JavaScript files.
24+
* @satisfies {Array<string>}
25+
*/
26+
const globsJs = [...globsEsm, ...globsCjs];
27+
28+
/**
29+
* ESLint configuration.
30+
* @satisfies {Array<Linter.Config>}
31+
*/
32+
const eslintConfig = [
33+
{
34+
files: globsJs,
35+
...eslintJs.configs.recommended,
36+
},
37+
{
38+
files: globsJs,
39+
rules: {
40+
"arrow-body-style": "error",
41+
"object-shorthand": "error",
42+
strict: "error",
43+
},
44+
},
45+
{
46+
files: globsEsm,
47+
languageOptions: {
48+
globals: {
49+
...globals.nodeBuiltin,
50+
...globals.browser,
51+
},
52+
},
53+
plugins: {
54+
"simple-import-sort": eslintPluginSimpleImportSort,
55+
},
56+
rules: {
57+
"simple-import-sort/imports": "error",
58+
"simple-import-sort/exports": "error",
59+
},
60+
},
61+
{
62+
files: globsEsm,
63+
...eslintPluginOptimalModules.configs.recommended,
64+
},
65+
{
66+
files: globsCjs,
67+
languageOptions: {
68+
sourceType: "commonjs",
69+
globals: globals.node,
70+
},
71+
},
72+
];
73+
74+
export default eslintConfig;

formDataAppendFile.mjs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
// @ts-check
22

3+
/** @import { ExtractableFile } from "./isExtractableFile.mjs" */
4+
35
/**
46
* The default implementation for the function `createUploadLink` option
57
* `formDataAppendFile` that uses the standard {@linkcode FormData.append}
68
* method.
79
* @param {FormData} formData Form data to append the specified file to.
810
* @param {string} fieldName Field name for the file.
9-
* @param {import("./isExtractableFile.mjs").ExtractableFile} file File to
10-
* append.
11+
* @param {ExtractableFile} file File to append.
1112
*/
1213
export default function formDataAppendFile(formData, fieldName, file) {
1314
"name" in file

formDataAppendFile.test.mjs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// @ts-check
22

3-
import "./test/polyfillFile.mjs";
4-
53
import { ok, strictEqual } from "node:assert";
64
import { describe, it } from "node:test";
75

isExtractableFile.mjs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
// @ts-check
22

3+
/**
4+
* @import {
5+
* ExtractableFile as ExtractFilesExtractableFile
6+
* } from "extract-files/isExtractableFile.mjs"
7+
*/
8+
39
export { default } from "extract-files/isExtractableFile.mjs";
410

511
/**
612
* An extractable file.
7-
* @typedef {import(
8-
* "extract-files/isExtractableFile.mjs"
9-
* ).ExtractableFile} ExtractableFile
13+
* @typedef {ExtractFilesExtractableFile} ExtractableFile
1014
*/

jsconfig.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
"maxNodeModuleJsDepth": 10,
44
"module": "nodenext",
55
"noEmit": true,
6+
"noUnusedLocals": true,
7+
"noUnusedParameters": true,
68
"strict": true
79
},
810
"typeAcquisition": {

0 commit comments

Comments
 (0)