Skip to content

Commit 01e3bec

Browse files
committed
fix: move fetch to node-builtins && add more tests
Signed-off-by: 唯然 <[email protected]>
1 parent 3a54507 commit 01e3bec

File tree

3 files changed

+57
-9
lines changed

3 files changed

+57
-9
lines changed

lib/rules/no-unsupported-features/es-builtins.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -601,9 +601,6 @@ const traceMap = {
601601
trace: { [READ]: { supported: ["0.10.0"] } },
602602
warn: { [READ]: { supported: ["0.10.0"] } },
603603
},
604-
fetch: {
605-
[READ]: { supported: ["18.0.0"] },
606-
},
607604
queueMicrotask: {
608605
[READ]: { supported: ["11.0.0"] },
609606
},

lib/rules/no-unsupported-features/node-builtins.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ const traceMap = {
3131
paths: { [READ]: { supported: ["8.9.0"] } },
3232
},
3333
},
34+
fetch: {
35+
[READ]: { supported: ["18.0.0"] },
36+
},
3437
},
3538
modules: NodeBuiltinModules,
3639
}

tests/lib/rules/no-unsupported-features/node-builtins.js

Lines changed: 54 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5305,12 +5305,6 @@ new RuleTester({ languageOptions: { sourceType: "module" } }).run(
53055305
node: { version: "12.11.0" },
53065306
},
53075307
},
5308-
5309-
// https://github.com/eslint-community/eslint-plugin-n/issues/253
5310-
{
5311-
code: `fetch("/api/xxx");`,
5312-
settings: { node: { version: ">=18.2.0" } },
5313-
},
53145308
],
53155309
invalid: [
53165310
{
@@ -5373,5 +5367,59 @@ new RuleTester({ languageOptions: { sourceType: "module" } }).run(
53735367
},
53745368
],
53755369
},
5370+
5371+
//----------------------------------------------------------------------
5372+
// fetch
5373+
//----------------------------------------------------------------------
5374+
{
5375+
valid: [
5376+
{
5377+
code: `fetch("/api/xxx");`,
5378+
options: [{ version: ">=18.2.0" }],
5379+
},
5380+
{
5381+
code: `fetch("/api/xxx");`,
5382+
options: [{ version: ">=18.0.0" }],
5383+
},
5384+
{
5385+
code: `fetch("/api/xxx");`,
5386+
options: [{ version: "^18.0.0" }],
5387+
},
5388+
{
5389+
code: `fetch("/api/xxx");`,
5390+
options: [{ version: ">18.0.0" }],
5391+
},
5392+
{
5393+
code: `fetch("/api/xxx");`,
5394+
options: [{ version: ">=19.0.0" }],
5395+
},
5396+
{
5397+
code: `fetch("/api/xxx");`,
5398+
options: [{ version: ">19.0.0" }],
5399+
},
5400+
],
5401+
invalid: [
5402+
{
5403+
code: `fetch("/api/xxx");`,
5404+
options: [{ version: ">=17.0.0" }],
5405+
errors: [{ messageId: "not-supported-till" }],
5406+
},
5407+
{
5408+
code: `fetch("/api/xxx");`,
5409+
options: [{ version: "^17.0.0" }],
5410+
errors: [{ messageId: "not-supported-till" }],
5411+
},
5412+
{
5413+
code: `fetch("/api/xxx");`,
5414+
options: [{ version: "^17.2.0" }],
5415+
errors: [{ messageId: "not-supported-till" }],
5416+
},
5417+
{
5418+
code: `fetch("/api/xxx");`,
5419+
options: [{ version: "^17.2.0||18.x" }],
5420+
errors: [{ messageId: "not-supported-till" }],
5421+
},
5422+
],
5423+
},
53765424
])
53775425
)

0 commit comments

Comments
 (0)