From 7aaf94705e2ae157c83bbabda9207b19757757e2 Mon Sep 17 00:00:00 2001 From: Tony Date: Fri, 23 Oct 2026 06:11:54 +0800 Subject: [PATCH] style: replace .contents().remove() with .empty() --- .oxlintrc.json | 4 ---- lib/routes/game-wisdom/index.ts | 2 +- lib/routes/skysports/news.ts | 2 +- lib/routes/tencent/qq/sdk/changelog.ts | 2 +- 4 files changed, 3 insertions(+), 7 deletions(-) diff --git a/.oxlintrc.json b/.oxlintrc.json index c6fd167b69..59a12bf0e2 100644 --- a/.oxlintrc.json +++ b/.oxlintrc.json @@ -606,10 +606,6 @@ "selector": "CallExpression[callee.property.name='clone'][arguments.length=0]:not([callee.object.name=/^(request|response|req|res)$/])", "message": "Usage of .clone() in cheerio is not allowed." }, - { - "selector": "CallExpression[callee.property.name='empty'][arguments.length=0]", - "message": "Usage of .empty() in cheerio is not allowed." - }, { "selector": "CallExpression[callee.property.name='toArray'] MemberExpression[object.callee.property.name='map']", "message": "Use .toArray() before .map()." diff --git a/lib/routes/game-wisdom/index.ts b/lib/routes/game-wisdom/index.ts index 0bc3e24044..ad4a0e55a7 100644 --- a/lib/routes/game-wisdom/index.ts +++ b/lib/routes/game-wisdom/index.ts @@ -35,7 +35,7 @@ const parseArticle = async (link: string, excerpt?: string): Promise { $(el).replaceWith($('
').append($(el).contents())); }); diff --git a/lib/routes/skysports/news.ts b/lib/routes/skysports/news.ts index 3b8c7bedcd..a62fe1268c 100644 --- a/lib/routes/skysports/news.ts +++ b/lib/routes/skysports/news.ts @@ -95,7 +95,7 @@ async function handler(ctx) { const video = content(element); const poster = copyNodes(video.find('.sdc-site-video__poster img').first()); const caption = copyNodes(video.find('.sdc-site-video__caption').first()); - video.contents().remove(); + video.empty(); video.append(poster, caption); }); diff --git a/lib/routes/tencent/qq/sdk/changelog.ts b/lib/routes/tencent/qq/sdk/changelog.ts index 79acc9d071..6417b1ab26 100644 --- a/lib/routes/tencent/qq/sdk/changelog.ts +++ b/lib/routes/tencent/qq/sdk/changelog.ts @@ -103,6 +103,6 @@ function copyContent(selection: Cheerio, $: CheerioAPI): C return $(nodes); } function clearContent(selection: Cheerio): Cheerio { - selection.contents().remove(); + selection.empty(); return selection; }