Skip to content

Commit 1017ef6

Browse files
azuclaude
andauthored
refactor: remove node-fetch and fs-extra dependencies (#161)
Replace node-fetch with native fetch API and remove unused fs-extra dependency. The native fetch API is now available in Node.js 18+ and provides the same functionality. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Claude <[email protected]>
1 parent 198c52c commit 1017ef6

File tree

3 files changed

+2
-126
lines changed

3 files changed

+2
-126
lines changed

package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,8 @@
4040
"trailingComma": "none"
4141
},
4242
"dependencies": {
43-
"fs-extra": "^8.1.0",
4443
"get-url-origin": "^1.0.1",
4544
"minimatch": "^3.0.4",
46-
"node-fetch": "^2.6.0",
4745
"p-memoize": "^3.1.0",
4846
"p-queue": "^6.2.0",
4947
"textlint-rule-helper": "^2.2.4"
@@ -54,7 +52,6 @@
5452
"@types/minimatch": "^5.1.2",
5553
"@types/mocha": "^10.0.0",
5654
"@types/node": "^24.3.0",
57-
"@types/node-fetch": "^2.6.2",
5855
"lint-staged": "^16.1.5",
5956
"mocha": "^11.7.1",
6057
"prettier": "^3.6.2",

pnpm-lock.yaml

Lines changed: 0 additions & 116 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/no-dead-link.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { RuleHelper } from "textlint-rule-helper";
2-
import fetch, { RequestInit } from "node-fetch";
32
import URL from "url";
43
import fs from "fs/promises";
54
import minimatch from "minimatch";
@@ -109,10 +108,6 @@ const createFetchWithRuleDefaults = (ruleOptions: Options) => {
109108
const { host } = URL.parse(uri);
110109
return fetch(uri, {
111110
...fetchOptions,
112-
// Disable gzip compression in Node.js
113-
// to avoid the zlib's "unexpected end of file" error
114-
// https://github.com/request/request/issues/2045
115-
compress: false,
116111
// Some website require UserAgent and Accept header
117112
// to avoid ECONNRESET error
118113
// https://github.com/textlint-rule/textlint-rule-no-dead-link/issues/111
@@ -168,11 +163,11 @@ const createCheckAliveURL = (ruleOptions: Options) => {
168163
maxRetryCount: number = 3,
169164
currentRetryCount: number = 0
170165
): Promise<AliveFunctionReturn> {
171-
const opts: RequestInit = {
166+
const opts = {
172167
method,
173168
// Use `manual` redirect behaviour to get HTTP redirect status code
174169
// and see what kind of redirect is occurring
175-
redirect: "manual"
170+
redirect: "manual" as RequestRedirect
176171
};
177172
try {
178173
const res = await fetchWithDefaults(uri, opts);

0 commit comments

Comments
 (0)