Skip to content

Commit 2d0c85a

Browse files
committed
chore: format
1 parent ccdb6d7 commit 2d0c85a

9 files changed

+64
-56
lines changed

Diff for: .eslintrc

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
{
2-
"extends": ["eslint-config-unjs"],
2+
"extends": [
3+
"eslint-config-unjs"
4+
],
35
"rules": {
46
"no-undef": 0,
57
"unicorn/consistent-destructuring": 0,
6-
"unicorn/no-await-expression-member": 0
8+
"unicorn/no-await-expression-member": 0,
9+
"unicorn/prefer-top-level-await": 0
710
}
811
}

Diff for: examples/body.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import { $fetch } from 'ofetch'
1+
import { $fetch } from "ofetch";
22

33
async function main() {
4-
const response = await $fetch<string>('https://api.github.com/markdown', {
5-
method: 'POST',
4+
const response = await $fetch<string>("https://api.github.com/markdown", {
5+
method: "POST",
66
// To provide a body, we need to use the `body` option and just use an object.
77
body: {
8-
text: 'UnJS is **awesome**!\n\nCheck out their [website](https://unjs.io).',
8+
text: "UnJS is **awesome**!\n\nCheck out their [website](https://unjs.io).",
99
},
10-
}) // Be careful, we use the GitHub API.
10+
}); // Be careful, we use the GitHub API.
1111

12-
console.log(response)
12+
console.log(response);
1313
}
1414

15-
main().catch(console.error)
15+
main().catch(console.error);

Diff for: examples/error-handling.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import { $fetch } from "ofetch"
1+
import { $fetch } from "ofetch";
22

33
async function main() {
44
try {
55
await $fetch("https://api.github.com", {
6-
method: 'POST'
7-
})
6+
method: "POST",
7+
});
88
} catch (error) {
9-
console.log(error.data) // This allow us to get the error body.
9+
console.log(error.data); // This allow us to get the error body.
1010
}
1111
}
1212

13-
main().catch(console.error)
13+
main().catch(console.error);

Diff for: examples/first-request.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { $fetch } from "ofetch"
1+
import { $fetch } from "ofetch";
22

33
async function main() {
4-
const data = await $fetch("https://ungh.cc/repos/unjs/ofetch")
4+
const data = await $fetch("https://ungh.cc/repos/unjs/ofetch");
55

6-
console.log(data)
6+
console.log(data);
77
}
88

9-
main().catch(console.error)
9+
main().catch(console.error);

Diff for: examples/headers.ts

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
import { $fetch } from 'ofetch'
1+
import { $fetch } from "ofetch";
22

33
async function main() {
4-
const response = await $fetch('https://api.github.com/gists', {
5-
method: 'POST',
4+
const response = await $fetch("https://api.github.com/gists", {
5+
method: "POST",
66
headers: {
77
Authorization: `token ${process.env.GH_TOKEN}`,
88
},
99
body: {
10-
description: 'This is a gist created by ofetch.',
10+
description: "This is a gist created by ofetch.",
1111
public: true,
1212
files: {
13-
'unjs.txt': {
14-
content: 'UnJS is awesome!',
15-
}
16-
}
17-
}
18-
}) // Be careful, we use the GitHub API directly.
13+
"unjs.txt": {
14+
content: "UnJS is awesome!",
15+
},
16+
},
17+
},
18+
}); // Be careful, we use the GitHub API directly.
1919

20-
console.log(response.url)
20+
console.log(response.url);
2121
}
2222

23-
main().catch(console.error)
23+
main().catch(console.error);

Diff for: examples/methods.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { $fetch } from 'ofetch'
1+
import { $fetch } from "ofetch";
22

33
async function main() {
4-
const response = await $fetch('https://api.github.com/gists', {
5-
method: 'POST',
6-
}) // Be careful, we use the GitHub API directly.
4+
const response = await $fetch("https://api.github.com/gists", {
5+
method: "POST",
6+
}); // Be careful, we use the GitHub API directly.
77

8-
console.log(response)
8+
console.log(response);
99
}
1010

11-
main().catch(console.error)
11+
main().catch(console.error);

Diff for: examples/query-string.ts

+11-8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1-
import { $fetch } from "ofetch"
1+
import { $fetch } from "ofetch";
22

33
async function main() {
4-
const response = await $fetch('https://api.github.com/repos/unjs/ofetch/tags', {
5-
query: {
6-
per_page: 2,
7-
},
8-
}) // Be careful, we use the GitHub API directly.
4+
const response = await $fetch(
5+
"https://api.github.com/repos/unjs/ofetch/tags",
6+
{
7+
query: {
8+
per_page: 2,
9+
},
10+
}
11+
); // Be careful, we use the GitHub API directly.
912

10-
console.log(response)
13+
console.log(response);
1114
}
1215

13-
main().catch(console.error)
16+
main().catch(console.error);

Diff for: examples/type-safety.ts

+11-9
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
import { $fetch } from "ofetch"
1+
import { $fetch } from "ofetch";
22

33
interface Repo {
4-
id: number
5-
name: string
6-
repo: string
7-
description: string
8-
stars: number
4+
id: number;
5+
name: string;
6+
repo: string;
7+
description: string;
8+
stars: number;
99
}
1010

1111
async function main() {
12-
const { repo } = await $fetch<{ repo: Repo }>("https://ungh.cc/repos/unjs/ofetch")
12+
const { repo } = await $fetch<{ repo: Repo }>(
13+
"https://ungh.cc/repos/unjs/ofetch"
14+
);
1315

14-
console.log(`The repo ${repo.name} has ${repo.stars} stars.`) // The repo object is now strongly typed.
16+
console.log(`The repo ${repo.name} has ${repo.stars} stars.`); // The repo object is now strongly typed.
1517
}
1618

17-
main().catch(console.error)
19+
main().catch(console.error);

Diff for: package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@
6262
"scripts": {
6363
"build": "unbuild",
6464
"dev": "vitest",
65-
"lint": "eslint --ext .ts . && prettier -c src test playground",
66-
"lint:fix": "eslint --fix --ext .ts . && prettier -w src test playground",
65+
"lint": "eslint --ext .ts . && prettier -c src test playground examples",
66+
"lint:fix": "eslint --fix --ext .ts . && prettier -w src test playground examples",
6767
"prepack": "pnpm build",
6868
"play": "jiti playground/index.ts",
6969
"release": "pnpm test && changelogen --release && npm publish && git push --follow-tags",
@@ -92,4 +92,4 @@
9292
"vitest": "^0.34.3"
9393
},
9494
"packageManager": "[email protected]"
95-
}
95+
}

0 commit comments

Comments
 (0)