diff --git a/lib/routes/0xxx/index.ts b/lib/routes/0xxx/index.ts index 47d7be9a7f..f8d319b236 100644 --- a/lib/routes/0xxx/index.ts +++ b/lib/routes/0xxx/index.ts @@ -22,9 +22,7 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(response); const language = $('html').attr('lang') ?? 'en'; - let items: DataItem[] = []; - - items = $('table#home-table tr:not(.gore)') + let items: DataItem[] = $('table#home-table tr:not(.gore)') .slice(0, limit) .toArray() .map((el): Element => { diff --git a/lib/routes/10000link/info.ts b/lib/routes/10000link/info.ts index 6fa93593bf..bdffd3c32e 100644 --- a/lib/routes/10000link/info.ts +++ b/lib/routes/10000link/info.ts @@ -22,9 +22,7 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(response); const language = $('html').attr('lang') ?? 'zh'; - let items: DataItem[] = []; - - items = $('ul.l_newshot li dl.lhotnew2') + let items: DataItem[] = $('ul.l_newshot li dl.lhotnew2') .slice(0, limit) .toArray() .map((el): Element => { diff --git a/lib/routes/163/renjian.ts b/lib/routes/163/renjian.ts index 50d78180c9..c1f92c510a 100644 --- a/lib/routes/163/renjian.ts +++ b/lib/routes/163/renjian.ts @@ -1,7 +1,7 @@ import { load } from 'cheerio'; import iconv from 'iconv-lite'; -import type { Route } from '@/types'; +import type { DataItem, Route } from '@/types'; import cache from '@/utils/cache'; import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; @@ -55,7 +55,7 @@ async function handler(ctx) { const data = iconv.decode(response.data, 'gbk'); - let items = {}; + let items: DataItem[]; const urls = data.match(/url:"(.*)",/g); diff --git a/lib/routes/199it/index.tsx b/lib/routes/199it/index.tsx index 478c221c1a..de4747a76d 100644 --- a/lib/routes/199it/index.tsx +++ b/lib/routes/199it/index.tsx @@ -21,9 +21,7 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(response); const language = $('html').attr('lang') ?? 'zh-CN'; - let items: DataItem[] = []; - - items = $('article.newsplus') + let items: DataItem[] = $('article.newsplus') .slice(0, limit) .toArray() .map((el): Element => { diff --git a/lib/routes/21caijing/channel.ts b/lib/routes/21caijing/channel.ts index 4b06de223d..1678d0a89f 100644 --- a/lib/routes/21caijing/channel.ts +++ b/lib/routes/21caijing/channel.ts @@ -85,9 +85,7 @@ export const handler = async (ctx: Context): Promise => { }, }); - let items: DataItem[] = []; - - items = JSON.parse(response) + let items: DataItem[] = JSON.parse(response) .slice(0, limit) .map((item): DataItem => { const title: string = item.title; diff --git a/lib/routes/4gamers/category.ts b/lib/routes/4gamers/category.ts index 076131dc16..e2584f6994 100644 --- a/lib/routes/4gamers/category.ts +++ b/lib/routes/4gamers/category.ts @@ -33,10 +33,9 @@ async function handler(ctx) { const items = await Promise.all(list.map((item) => cache.tryGet(item.link, () => parseItem(item)))); - let categories = []; let categoryName = '最新消息'; if (!isLatest) { - categories = await getCategories(cache.tryGet); + const categories = await getCategories(cache.tryGet); categoryName = categories.find((c) => c.id === Number.parseInt(category)).name; } diff --git a/lib/routes/51cto/recommend.ts b/lib/routes/51cto/recommend.ts index d18858624e..1a5c218713 100644 --- a/lib/routes/51cto/recommend.ts +++ b/lib/routes/51cto/recommend.ts @@ -27,7 +27,6 @@ export const route: Route = { const pattern = /'(WTKkN|bOYDu|wyeCN)':\s*(\d+)/g; async function getFullcontent(item, cookie = '') { - let fullContent: null | string = null; const articleResponse = await ofetch(item.url, { headers: { cookie, @@ -35,7 +34,7 @@ async function getFullcontent(item, cookie = '') { }); const $ = load(articleResponse); - fullContent = new URL(item.url).host === 'ost.51cto.com' ? $('.posts-content').html() : $('article').html(); + const fullContent = new URL(item.url).host === 'ost.51cto.com' ? $('.posts-content').html() : $('article').html(); if (!fullContent && cookie === '') { // If fullContent is null and haven't tried to request with cookie, try to get fullContent with cookie diff --git a/lib/routes/6v123/index.ts b/lib/routes/6v123/index.ts index a6d3ec9e5a..ef0a69c95d 100644 --- a/lib/routes/6v123/index.ts +++ b/lib/routes/6v123/index.ts @@ -25,9 +25,7 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(iconv.decode(Buffer.from(response), encoding)); const language = $('html').attr('lang') ?? 'zh'; - let items: DataItem[] = []; - - items = $('ul.list li') + let items: DataItem[] = $('ul.list li') .slice(0, limit) .toArray() .map((el): Element => { diff --git a/lib/routes/aa1/60s.ts b/lib/routes/aa1/60s.ts index 597e999035..80ddbc6920 100644 --- a/lib/routes/aa1/60s.ts +++ b/lib/routes/aa1/60s.ts @@ -41,9 +41,7 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(targetResponse); const language = $('html').attr('lang') ?? 'zh'; - let items: DataItem[] = []; - - items = response.slice(0, limit).map((item): DataItem => { + const items: DataItem[] = response.slice(0, limit).map((item): DataItem => { const title: string = item.title?.rendered ?? item.title; const description: string | undefined = item.content.rendered; const pubDate: number | string = item.date_gmt; diff --git a/lib/routes/abc/index.ts b/lib/routes/abc/index.ts index 255367b0db..8ac465c92f 100644 --- a/lib/routes/abc/index.ts +++ b/lib/routes/abc/index.ts @@ -40,7 +40,7 @@ async function handler(ctx) { const rootUrl = 'https://www.abc.net.au'; const apiUrl = new URL('news-web/api/loader/channelrefetch', rootUrl).href; - let currentUrl = ''; + let currentUrl: string; let documentId; if (Number.isNaN(category)) { diff --git a/lib/routes/adquan/case-library.ts b/lib/routes/adquan/case-library.ts index b604c4a743..49bc280479 100644 --- a/lib/routes/adquan/case-library.ts +++ b/lib/routes/adquan/case-library.ts @@ -22,9 +22,7 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(response); const language = $('html').attr('lang') ?? 'zh-CN'; - let items: DataItem[] = []; - - items = $('div.article_1') + let items: DataItem[] = $('div.article_1') .slice(0, limit) .toArray() .map((el): Element => { diff --git a/lib/routes/adquan/index.ts b/lib/routes/adquan/index.ts index 706f904a9d..5a11ff58e4 100644 --- a/lib/routes/adquan/index.ts +++ b/lib/routes/adquan/index.ts @@ -22,9 +22,7 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(response); const language = $('html').attr('lang') ?? 'zh-CN'; - let items: DataItem[] = []; - - items = $('div.article_1') + let items: DataItem[] = $('div.article_1') .slice(0, limit) .toArray() .map((el): Element => { diff --git a/lib/routes/aflcio/blog.ts b/lib/routes/aflcio/blog.ts index ba9d30a3de..55fe585424 100644 --- a/lib/routes/aflcio/blog.ts +++ b/lib/routes/aflcio/blog.ts @@ -19,9 +19,7 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(response); const language = $('html').attr('lang') ?? 'en'; - let items: DataItem[] = []; - - items = $('article.article') + let items: DataItem[] = $('article.article') .slice(0, limit) .toArray() .map((el): Element => { diff --git a/lib/routes/amazfitwatchfaces/index.ts b/lib/routes/amazfitwatchfaces/index.ts index 1198f2fb83..d6c10fb11a 100644 --- a/lib/routes/amazfitwatchfaces/index.ts +++ b/lib/routes/amazfitwatchfaces/index.ts @@ -22,9 +22,7 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(response); const language = $('html').attr('lang') ?? 'en'; - let items: DataItem[] = []; - - items = $('div.wf-panel') + let items: DataItem[] = $('div.wf-panel') .slice(0, limit) .toArray() .map((el): Element => { diff --git a/lib/routes/apple/apps.ts b/lib/routes/apple/apps.ts index fc74125f9f..c9fd61023c 100644 --- a/lib/routes/apple/apps.ts +++ b/lib/routes/apple/apps.ts @@ -1,4 +1,4 @@ -import type { Route } from '@/types'; +import type { DataItem, Route } from '@/types'; import { ViewType } from '@/types'; import ofetch from '@/utils/ofetch'; import { parseDate } from '@/utils/parse-date'; @@ -116,8 +116,8 @@ async function handler(ctx) { const artistName = attributes.artistName; const platformAttributes = attributes.platformAttributes; - let items = []; - let title = ''; + let items: DataItem[] = []; + let title: string; let description = ''; let image = ''; diff --git a/lib/routes/apple/security-releases.ts b/lib/routes/apple/security-releases.ts index f3d3c7a27a..ff1a9d3f7d 100644 --- a/lib/routes/apple/security-releases.ts +++ b/lib/routes/apple/security-releases.ts @@ -27,9 +27,7 @@ export const handler = async (ctx: Context): Promise => { .toArray() .map((el) => $(el).text()); - let items: DataItem[] = []; - - items = $trEls + let items: DataItem[] = $trEls .slice(1, limit) .toArray() .map((el): Element => { diff --git a/lib/routes/asiafruitchina/categories.ts b/lib/routes/asiafruitchina/categories.ts index 42db49cdfb..157570857c 100644 --- a/lib/routes/asiafruitchina/categories.ts +++ b/lib/routes/asiafruitchina/categories.ts @@ -22,9 +22,7 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(response); const language = $('html').attr('lang') ?? 'zh-CN'; - let items: DataItem[] = []; - - items = $('div.listBlocks ul li') + let items: DataItem[] = $('div.listBlocks ul li') .slice(0, limit) .toArray() .map((el): Element => { diff --git a/lib/routes/asiafruitchina/news.ts b/lib/routes/asiafruitchina/news.ts index ec109a2ccb..9ae4752512 100644 --- a/lib/routes/asiafruitchina/news.ts +++ b/lib/routes/asiafruitchina/news.ts @@ -21,9 +21,7 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(response); const language = $('html').attr('lang') ?? 'zh-CN'; - let items: DataItem[] = []; - - items = $('div.listBlocks ul li') + let items: DataItem[] = $('div.listBlocks ul li') .slice(0, limit) .toArray() .map((el): Element => { diff --git a/lib/routes/augmentcode/blog.tsx b/lib/routes/augmentcode/blog.tsx index 1836d6598f..f8ad180f0b 100644 --- a/lib/routes/augmentcode/blog.tsx +++ b/lib/routes/augmentcode/blog.tsx @@ -40,9 +40,7 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(response); const language = $('html').attr('lang') ?? 'en'; - let items: DataItem[] = []; - - items = $('div[data-slot="card"]') + let items: DataItem[] = $('div[data-slot="card"]') .slice(0, limit) .toArray() .map((el): Element => { diff --git a/lib/routes/bangumi.tv/user/collections.tsx b/lib/routes/bangumi.tv/user/collections.tsx index e285d576a1..172ff8fa02 100644 --- a/lib/routes/bangumi.tv/user/collections.tsx +++ b/lib/routes/bangumi.tv/user/collections.tsx @@ -154,7 +154,7 @@ async function handler(ctx) { const typeName = typeNames[type] || ''; const subjectTypeName = subjectTypeNames[subjectType] || ''; - let descriptionFields = ''; + let descriptionFields: string; if (typeName && subjectTypeName) { descriptionFields = `${typeName}的${subjectTypeName}列表`; diff --git a/lib/routes/banshujiang/index.ts b/lib/routes/banshujiang/index.ts index dc983fe394..3393ad2027 100644 --- a/lib/routes/banshujiang/index.ts +++ b/lib/routes/banshujiang/index.ts @@ -22,9 +22,7 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(response); const language = $('html').attr('lang') ?? 'zh'; - let items: DataItem[] = []; - - items = $('ul.small-list li.row') + let items: DataItem[] = $('ul.small-list li.row') .slice(0, limit) .toArray() .map((el): Element => { diff --git a/lib/routes/banyuetan/index.ts b/lib/routes/banyuetan/index.ts index 25e7a94ca7..efcad0dd94 100644 --- a/lib/routes/banyuetan/index.ts +++ b/lib/routes/banyuetan/index.ts @@ -23,9 +23,7 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(response); const language = $('html').attr('lang') ?? 'zh'; - let items: DataItem[] = []; - - items = $('div.bty_tbtj_list ul.clearFix li') + let items: DataItem[] = $('div.bty_tbtj_list ul.clearFix li') .slice(0, limit) .toArray() .map((el): Element => { diff --git a/lib/routes/bbc/utils.tsx b/lib/routes/bbc/utils.tsx index a3760eefb3..266eb6d6bd 100644 --- a/lib/routes/bbc/utils.tsx +++ b/lib/routes/bbc/utils.tsx @@ -239,8 +239,6 @@ const renderVideo = (block: Block, index: number): JSX.Element | null => { let src: string | undefined; let sourceText: string | undefined; - let width: number | undefined; - let height: number | undefined; if (mediaMetadataBlock?.model?.imageUrl) { src = mediaMetadataBlock.model.imageUrl; @@ -254,7 +252,7 @@ const renderVideo = (block: Block, index: number): JSX.Element | null => { return null; } - return renderFigure(`video-${index}`, src, altText, width, height, caption, sourceText); + return renderFigure(`video-${index}`, src, altText, undefined, undefined, caption, sourceText); }; const renderMedia = (block: Block, index: number): JSX.Element | null => { diff --git a/lib/routes/bilibili/link-news.ts b/lib/routes/bilibili/link-news.ts index e3846aeda6..bd15493e8d 100644 --- a/lib/routes/bilibili/link-news.ts +++ b/lib/routes/bilibili/link-news.ts @@ -22,7 +22,7 @@ export const route: Route = { async function handler(ctx) { const product = ctx.req.param('product'); - let productTitle = ''; + let productTitle: string; switch (product) { case 'live': diff --git a/lib/routes/bilibili/live-area.ts b/lib/routes/bilibili/live-area.ts index ed5b0791e6..4fa7861c0b 100644 --- a/lib/routes/bilibili/live-area.ts +++ b/lib/routes/bilibili/live-area.ts @@ -26,7 +26,7 @@ async function handler(ctx) { const areaID = ctx.req.param('areaID'); const order = ctx.req.param('order'); - let orderTitle = ''; + let orderTitle: string; switch (order) { case 'live_time': orderTitle = '最新开播'; @@ -47,7 +47,7 @@ async function handler(ctx) { }); let parentTitle = ''; - let parentID = ''; + let parentID: string; let areaTitle = ''; let areaLink = ''; diff --git a/lib/routes/bilibili/live-search.ts b/lib/routes/bilibili/live-search.ts index ef7e7480e6..82b544fe71 100644 --- a/lib/routes/bilibili/live-search.ts +++ b/lib/routes/bilibili/live-search.ts @@ -27,7 +27,7 @@ async function handler(ctx) { const order = ctx.req.param('order'); const urlEncodedKey = encodeURIComponent(key); - let orderTitle = ''; + let orderTitle: string; switch (order) { case 'live_time': diff --git a/lib/routes/bilibili/partion-ranking.ts b/lib/routes/bilibili/partion-ranking.ts index 1b160d1673..3401482443 100644 --- a/lib/routes/bilibili/partion-ranking.ts +++ b/lib/routes/bilibili/partion-ranking.ts @@ -1,4 +1,4 @@ -import type { Route } from '@/types'; +import type { DataItem, Route } from '@/types'; import got from '@/utils/got'; import utils from './utils'; @@ -43,11 +43,8 @@ async function handler(ctx) { const responseApi = `https://api.bilibili.com/x/web-interface/newlist?ps=15&rid=${tid}&_=${Date.now()}`; const response = await got_ins.get(responseApi); - const items = []; let name = '未知'; - let list = {}; - - list = response.data.data.archives; + const list = response.data.data.archives; if (list && list[0] && list[0].tname) { name = list[0].tname; } @@ -58,16 +55,13 @@ async function handler(ctx) { const HotRankResponse = await got_ins.get(HotRankResponseApi); const hotlist = HotRankResponse.data.result; - for (let item of hotlist) { - item = { - title: item.title, - description: utils.renderUGCDescription(embed, item.pic, `${item.description} - ${item.tag}`, item.id, undefined, item.bvid), - pubDate: new Date(item.pubdate).toUTCString(), - link: item.pubdate > utils.bvidTime && item.bvid ? `https://www.bilibili.com/video/${item.bvid}` : `https://www.bilibili.com/video/av${item.id}`, - author: item.author, - }; - items.push(item); - } + const items: DataItem[] = hotlist.map((item) => ({ + title: item.title, + description: utils.renderUGCDescription(embed, item.pic, `${item.description} - ${item.tag}`, item.id, undefined, item.bvid), + pubDate: new Date(item.pubdate).toUTCString(), + link: item.pubdate > utils.bvidTime && item.bvid ? `https://www.bilibili.com/video/${item.bvid}` : `https://www.bilibili.com/video/av${item.id}`, + author: item.author, + })); return { title: `bilibili ${name} 最热视频`, diff --git a/lib/routes/bilibili/ranking.ts b/lib/routes/bilibili/ranking.ts index 20f4aec24d..7c9f5d3452 100644 --- a/lib/routes/bilibili/ranking.ts +++ b/lib/routes/bilibili/ranking.ts @@ -193,7 +193,7 @@ function getAPI(isNumericRid: boolean, rid: string | number) { const ridEnglish = zone[1].english; let apiBase = 'https://api.bilibili.com/x/web-interface/ranking/v2'; - let apiParams = ''; + let apiParams: string; switch (ridType) { case 'x/rid': diff --git a/lib/routes/bilibili/wasm-exec.ts b/lib/routes/bilibili/wasm-exec.ts index 7cfb8a02f4..05dc96f70a 100644 --- a/lib/routes/bilibili/wasm-exec.ts +++ b/lib/routes/bilibili/wasm-exec.ts @@ -319,7 +319,7 @@ // func resetMemoryDataView() 'runtime.resetMemoryDataView': (sp) => { - // eslint-disable-next-line @typescript-eslint/no-unused-vars + // eslint-disable-next-line @typescript-eslint/no-unused-vars, no-useless-assignment sp >>>= 0; this.mem = new DataView(this._inst.exports.mem.buffer); }, diff --git a/lib/routes/biquge/index.ts b/lib/routes/biquge/index.ts index 1160970c9d..15985aee1d 100644 --- a/lib/routes/biquge/index.ts +++ b/lib/routes/biquge/index.ts @@ -60,7 +60,7 @@ async function handler(ctx) { .map((item) => { item = $(item); - let link = ''; + let link: string; const url = item.attr('href'); if (url.startsWith('http')) { link = url; diff --git a/lib/routes/bse/index.ts b/lib/routes/bse/index.ts index 77e0b44217..64435b249c 100644 --- a/lib/routes/bse/index.ts +++ b/lib/routes/bse/index.ts @@ -1,4 +1,4 @@ -import type { Route } from '@/types'; +import type { DataItem, Route } from '@/types'; import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; import timezone from '@/utils/timezone'; @@ -185,7 +185,7 @@ async function handler(ctx) { const data = JSON.parse(response.data.match(/null\(\[({.*})]\)/)[1]); - let items = []; + let items: DataItem[]; switch (type) { case '/info/listse': diff --git a/lib/routes/bt0/util.ts b/lib/routes/bt0/util.ts index dfcd8d7203..9892befcb4 100644 --- a/lib/routes/bt0/util.ts +++ b/lib/routes/bt0/util.ts @@ -19,7 +19,7 @@ async function doGot(num, host, link) { throw new Error('api error'); } cookieJar.setCookieSync(match[1], host); - return doGot(++num, host, link); + return doGot(num + 1, host, link); } return data; } diff --git a/lib/routes/bullionvault/gold-news.ts b/lib/routes/bullionvault/gold-news.ts index f4986b4c24..86a624f798 100644 --- a/lib/routes/bullionvault/gold-news.ts +++ b/lib/routes/bullionvault/gold-news.ts @@ -20,9 +20,7 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(response); const language = $('html').attr('lang') ?? 'en'; - let items: DataItem[] = []; - - items = $('section#block-bootstrap-views-block-latest-articles-block div.media, div.gold-news-content table tr') + let items: DataItem[] = $('section#block-bootstrap-views-block-latest-articles-block div.media, div.gold-news-content table tr') .slice(0, limit) .toArray() .map((el): Element => { diff --git a/lib/routes/cast/index.ts b/lib/routes/cast/index.ts index 887283ca4d..0411914547 100644 --- a/lib/routes/cast/index.ts +++ b/lib/routes/cast/index.ts @@ -1,6 +1,6 @@ import { load } from 'cheerio'; -import type { Route } from '@/types'; +import type { DataItem, Route } from '@/types'; import cache from '@/utils/cache'; import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; @@ -88,7 +88,7 @@ async function handler(ctx) { const $ = load(indexData); - let items: any[] = []; + let items: DataItem[]; // 新闻-视频首页特殊处理 if (column === 'xw' && subColumn === 'SP' && !category) { diff --git a/lib/routes/cbndata/information.ts b/lib/routes/cbndata/information.ts index 08bc5b5b50..aad1a06eb8 100644 --- a/lib/routes/cbndata/information.ts +++ b/lib/routes/cbndata/information.ts @@ -29,9 +29,7 @@ export const handler = async (ctx: Context): Promise => { }, }); - let items: DataItem[] = []; - - items = response.data.slice(0, limit).map((item): DataItem => { + let items: DataItem[] = response.data.slice(0, limit).map((item): DataItem => { const title: string = item.title; const image: string | undefined = item.image; const description: string | undefined = renderDescription({ diff --git a/lib/routes/ccagm/index.ts b/lib/routes/ccagm/index.ts index 2a95b397fa..1eaf3d35ec 100644 --- a/lib/routes/ccagm/index.ts +++ b/lib/routes/ccagm/index.ts @@ -21,9 +21,7 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(response); const language = $('html').attr('lang') ?? 'zh'; - let items: DataItem[] = []; - - items = $('ul.news_list li a') + let items: DataItem[] = $('ul.news_list li a') .slice(0, limit) .toArray() .map((el): Element => { diff --git a/lib/routes/cccmc/index.ts b/lib/routes/cccmc/index.ts index b134289e43..92441a0bb5 100644 --- a/lib/routes/cccmc/index.ts +++ b/lib/routes/cccmc/index.ts @@ -20,11 +20,9 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(response); const language = $('html').attr('lang') ?? 'zh-CN'; - let items: DataItem[] = []; - const regex = /\{url:'(.*)',title:'(.*)',time:'(.*)'\},/g; - items = + let items: DataItem[] = response .match(regex) ?.slice(0, limit) diff --git a/lib/routes/ccg/index.ts b/lib/routes/ccg/index.ts index 4fa5559455..0594be8879 100644 --- a/lib/routes/ccg/index.ts +++ b/lib/routes/ccg/index.ts @@ -22,9 +22,7 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(response); const language = $('html').attr('lang') ?? 'zh'; - let items: DataItem[] = []; - - items = $('ul.huodong-list li') + let items: DataItem[] = $('ul.huodong-list li') .slice(0, limit) .toArray() .map((el): Element => { diff --git a/lib/routes/cde/xxgk.tsx b/lib/routes/cde/xxgk.tsx index 0d858d0cec..c770309252 100644 --- a/lib/routes/cde/xxgk.tsx +++ b/lib/routes/cde/xxgk.tsx @@ -81,7 +81,7 @@ async function handler(ctx) { }); const items = data.data.records.map((item) => { - let description = ''; + let description: string; switch (category) { case 'priorityApproval': description = renderToString(); diff --git a/lib/routes/chinadaily/language.ts b/lib/routes/chinadaily/language.ts index b3f256fd62..47dc17388b 100644 --- a/lib/routes/chinadaily/language.ts +++ b/lib/routes/chinadaily/language.ts @@ -23,9 +23,7 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(response); const language = $('html').attr('lang') ?? 'zh-CN'; - let items: DataItem[] = []; - - items = $('div.gy_box, ul.content_list li') + let items: DataItem[] = $('div.gy_box, ul.content_list li') .slice(0, limit) .toArray() .map((el): Element => { diff --git a/lib/routes/chinaratings/credit-research.ts b/lib/routes/chinaratings/credit-research.ts index 9f18b23676..4ccb5ae9ff 100644 --- a/lib/routes/chinaratings/credit-research.ts +++ b/lib/routes/chinaratings/credit-research.ts @@ -20,9 +20,7 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(response); const language = 'zh-CN'; - let items: DataItem[] = []; - - items = $('div.contRight ul.list li') + let items: DataItem[] = $('div.contRight ul.list li') .slice(0, limit) .toArray() .map((el): Element => { diff --git a/lib/routes/chongdiantou/index.ts b/lib/routes/chongdiantou/index.ts index 36c91c288d..ec3f636f78 100644 --- a/lib/routes/chongdiantou/index.ts +++ b/lib/routes/chongdiantou/index.ts @@ -1,6 +1,6 @@ import { load } from 'cheerio'; -import type { Route } from '@/types'; +import type { DataItem, Route } from '@/types'; import cache from '@/utils/cache'; import ofetch from '@/utils/ofetch'; @@ -23,7 +23,7 @@ export const route: Route = { async function handler() { const response = await ofetch('https://www.chongdiantou.com/nice-json/front-end/home-load-more'); - let items = []; + let items: DataItem[]; items = response.data.map((item) => ({ title: item.title, diff --git a/lib/routes/chsi/hotnews.ts b/lib/routes/chsi/hotnews.ts index 316ab02af2..e0d54ea8c1 100644 --- a/lib/routes/chsi/hotnews.ts +++ b/lib/routes/chsi/hotnews.ts @@ -41,7 +41,7 @@ async function handler() { let itemUrl = ''; itemUrl = path.startsWith('http') ? path : host + path; return cache.tryGet(itemUrl, async () => { - let description = ''; + let description: string; let itemDate; if (path) { const result = await got(itemUrl); diff --git a/lib/routes/chsi/kydt.ts b/lib/routes/chsi/kydt.ts index b590fdaa26..830fbee1b0 100644 --- a/lib/routes/chsi/kydt.ts +++ b/lib/routes/chsi/kydt.ts @@ -46,7 +46,7 @@ async function handler() { const path = item.find('a').attr('href'); const itemUrl = path.startsWith('http') ? path : host + path; return cache.tryGet(itemUrl, async () => { - let description = ''; + let description: string; if (!path.startsWith('https://') && !path.startsWith('http://')) { const result = await got(itemUrl); const $ = load(result.data); diff --git a/lib/routes/chsi/kyzx.ts b/lib/routes/chsi/kyzx.ts index 824ceb163d..8b35906979 100644 --- a/lib/routes/chsi/kyzx.ts +++ b/lib/routes/chsi/kyzx.ts @@ -53,7 +53,7 @@ async function handler(ctx) { let itemUrl = ''; itemUrl = path.startsWith('http') ? path : host + path; return cache.tryGet(itemUrl, async () => { - let description = ''; + let description: string; if (itemUrl) { const result = await got(itemUrl); const $ = load(result.data); diff --git a/lib/routes/cnljxh/index.ts b/lib/routes/cnljxh/index.ts index 24930df3d7..6cc695cd3f 100644 --- a/lib/routes/cnljxh/index.ts +++ b/lib/routes/cnljxh/index.ts @@ -20,9 +20,7 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(response); const language = $('html').attr('lang') ?? 'zh'; - let items: DataItem[] = []; - - items = $('div.main_left ul li') + let items: DataItem[] = $('div.main_left ul li') .slice(0, limit) .toArray() .map((el): Element => { diff --git a/lib/routes/copymanga/comic.tsx b/lib/routes/copymanga/comic.tsx index 67321cc65a..d57e16e155 100644 --- a/lib/routes/copymanga/comic.tsx +++ b/lib/routes/copymanga/comic.tsx @@ -41,7 +41,7 @@ async function handler(ctx) { const chapterArray = await cache.tryGet( strBaseUrl, async () => { - let bHasNextPage = false; + let bHasNextPage: boolean; let chapters = []; let iReqOffSet = 0; diff --git a/lib/routes/costar/press-releases.ts b/lib/routes/costar/press-releases.ts index adb7154ea9..7afabf862f 100644 --- a/lib/routes/costar/press-releases.ts +++ b/lib/routes/costar/press-releases.ts @@ -20,9 +20,7 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(response); const language = $('html').attr('lang') ?? 'en'; - let items: DataItem[] = []; - - items = $('div.views-row article') + let items: DataItem[] = $('div.views-row article') .slice(0, limit) .toArray() .map((el): Element => { diff --git a/lib/routes/dbaplus/new.ts b/lib/routes/dbaplus/new.ts index d8d75f8d9c..2aa195e8a0 100644 --- a/lib/routes/dbaplus/new.ts +++ b/lib/routes/dbaplus/new.ts @@ -23,9 +23,7 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(response); const language = $('html').attr('lang') ?? 'zh'; - let items: DataItem[] = []; - - items = $('ul.media-list li.media') + let items: DataItem[] = $('ul.media-list li.media') .slice(0, limit) .toArray() .map((el): Element => { diff --git a/lib/routes/deepl/blog.ts b/lib/routes/deepl/blog.ts index 41419f934f..0fb408d85b 100644 --- a/lib/routes/deepl/blog.ts +++ b/lib/routes/deepl/blog.ts @@ -22,9 +22,7 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(response); const language = $('html').attr('lang') ?? lang; - let items: DataItem[] = []; - - items = $('h4, h6') + let items: DataItem[] = $('h4, h6') .slice(0, limit) .toArray() .map((el): Element => { diff --git a/lib/routes/dgtle/util.ts b/lib/routes/dgtle/util.ts index a9a83f77b1..0eaf19610f 100644 --- a/lib/routes/dgtle/util.ts +++ b/lib/routes/dgtle/util.ts @@ -17,9 +17,7 @@ const md = MarkdownIt({ const baseUrl = 'https://www.dgtle.com'; const ProcessItems = async (limit: number, dataList: any): Promise => { - let items: DataItem[] = []; - - items = dataList.slice(0, limit).map((item): DataItem => { + let items: DataItem[] = dataList.slice(0, limit).map((item): DataItem => { const title: string = item.title || item.content; const image: string | undefined = item.cover; const description: string | undefined = renderDescription({ diff --git a/lib/routes/dgtle/video.ts b/lib/routes/dgtle/video.ts index da8ce22d2e..1cb7c441c7 100644 --- a/lib/routes/dgtle/video.ts +++ b/lib/routes/dgtle/video.ts @@ -25,9 +25,7 @@ export const handler = async (ctx: Context): Promise => { const response = await ofetch(apiUrl); - let items: DataItem[] = []; - - items = response.data.list.slice(0, limit).map((item): DataItem => { + let items: DataItem[] = response.data.list.slice(0, limit).map((item): DataItem => { const title: string = item.title; const image: string | undefined = item.cover?.split(/\?/)?.[0]; const description: string | undefined = renderDescription({ diff --git a/lib/routes/dhu/jiaowu/news.ts b/lib/routes/dhu/jiaowu/news.ts index 14b1efe76d..898278ac8c 100644 --- a/lib/routes/dhu/jiaowu/news.ts +++ b/lib/routes/dhu/jiaowu/news.ts @@ -60,7 +60,7 @@ async function handler(ctx) { return await cache.tryGet(url, async () => { // fetch article content // some contents are only available for internal network - let description = ''; + let description: string; try { const { data: response } = await got(url); const $ = load(response); diff --git a/lib/routes/dhu/xxgk/news.ts b/lib/routes/dhu/xxgk/news.ts index 36c52a9319..fc98fd30c6 100644 --- a/lib/routes/dhu/xxgk/news.ts +++ b/lib/routes/dhu/xxgk/news.ts @@ -51,7 +51,7 @@ async function handler() { return await cache.tryGet(url, async () => { // fetch article content // some contents are only available for internal network - let description = ''; + let description: string; try { const { data: response } = await got(url); const $ = load(response); diff --git a/lib/routes/diariofruticola/filtro.ts b/lib/routes/diariofruticola/filtro.ts index 79fcbdc1eb..b52d577946 100644 --- a/lib/routes/diariofruticola/filtro.ts +++ b/lib/routes/diariofruticola/filtro.ts @@ -21,9 +21,7 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(response); const language = $('html').attr('lang') ?? 'es'; - let items: DataItem[] = []; - - items = $('div#printableArea a.text-dark') + let items: DataItem[] = $('div#printableArea a.text-dark') .slice(0, limit) .toArray() .map((el): Element => { diff --git a/lib/routes/digitalpolicyalert/activity-tracker.ts b/lib/routes/digitalpolicyalert/activity-tracker.ts index 0eda4f5bdd..ad8042148b 100644 --- a/lib/routes/digitalpolicyalert/activity-tracker.ts +++ b/lib/routes/digitalpolicyalert/activity-tracker.ts @@ -40,9 +40,7 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(targetResponse); const language = $('html').attr('lang') ?? 'en'; - let items: DataItem[] = []; - - items = response.results.slice(0, limit).map((item): DataItem => { + const items: DataItem[] = response.results.slice(0, limit).map((item): DataItem => { const title: string = item.title; const description: string | undefined = item.latest_event?.description ?? undefined; const pubDate: number | string = item.latest_event?.date; diff --git a/lib/routes/douban/channel/subject.ts b/lib/routes/douban/channel/subject.ts index 1b0ff5eaff..240895c8e5 100644 --- a/lib/routes/douban/channel/subject.ts +++ b/lib/routes/douban/channel/subject.ts @@ -45,7 +45,7 @@ async function handler(ctx) { const channel_name = channel_info_response.data.title; const data = response.data.modules[nav].payload.subjects; - let nav_name = ''; + let nav_name: string; switch (nav) { case '0': diff --git a/lib/routes/douban/channel/topic.ts b/lib/routes/douban/channel/topic.ts index 3b285f6cac..c91dbf5cbe 100644 --- a/lib/routes/douban/channel/topic.ts +++ b/lib/routes/douban/channel/topic.ts @@ -45,7 +45,7 @@ async function handler(ctx) { const channel_name = channel_info_response.data.title; const data = response.data.items; - let nav_name = ''; + let nav_name: string; switch (nav) { case 'hot': diff --git a/lib/routes/duozhi/index.ts b/lib/routes/duozhi/index.ts index f5c1aef220..82275da229 100644 --- a/lib/routes/duozhi/index.ts +++ b/lib/routes/duozhi/index.ts @@ -23,9 +23,7 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(response); const language = $('html').attr('lang') ?? 'zh'; - let items: DataItem[] = []; - - items = $('div.post-item') + let items: DataItem[] = $('div.post-item') .slice(0, limit) .toArray() .map((el): Element => { diff --git a/lib/routes/dytt/index.ts b/lib/routes/dytt/index.ts index 3a58a5a5ce..d62cccaabb 100644 --- a/lib/routes/dytt/index.ts +++ b/lib/routes/dytt/index.ts @@ -26,9 +26,7 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(iconv.decode(Buffer.from(response), 'gb2312')); const language = $('html').attr('lang') ?? 'zh-CN'; - let items: DataItem[] = []; - - items = $('div.co_content8 ul table') + let items: DataItem[] = $('div.co_content8 ul table') .slice(0, limit) .toArray() .map((el): Element => { diff --git a/lib/routes/eastmoney/utils.ts b/lib/routes/eastmoney/utils.ts index 6d040d8e32..ab3078cfa6 100644 --- a/lib/routes/eastmoney/utils.ts +++ b/lib/routes/eastmoney/utils.ts @@ -1,5 +1,5 @@ function getRatingChangeStr(ratingChange) { - let ratingChangeName = ''; + let ratingChangeName: string; switch (String(ratingChange)) { case '0': ratingChangeName = '调高'; diff --git a/lib/routes/eeo/kuaixun.ts b/lib/routes/eeo/kuaixun.ts index f6b2802b67..28cf67b811 100644 --- a/lib/routes/eeo/kuaixun.ts +++ b/lib/routes/eeo/kuaixun.ts @@ -34,9 +34,7 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(targetResponse); const language = $('html').attr('lang') ?? 'en'; - let items: DataItem[] = []; - - items = response.data.slice(0, limit).map((item): DataItem => { + let items: DataItem[] = response.data.slice(0, limit).map((item): DataItem => { const title: string = item.title; const description: string | undefined = renderDescription({ intro: item.description, diff --git a/lib/routes/expats/czech-news.ts b/lib/routes/expats/czech-news.ts index 2cbcb13cdb..766d38a122 100644 --- a/lib/routes/expats/czech-news.ts +++ b/lib/routes/expats/czech-news.ts @@ -20,9 +20,7 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(response); const language = $('html').attr('lang') ?? 'en'; - let items: DataItem[] = []; - - items = $('div.main h3 a') + let items: DataItem[] = $('div.main h3 a') .slice(0, limit) .toArray() .map((el): Element => { diff --git a/lib/routes/fangchan/list.tsx b/lib/routes/fangchan/list.tsx index 2d61e2def3..a36ddfae4c 100644 --- a/lib/routes/fangchan/list.tsx +++ b/lib/routes/fangchan/list.tsx @@ -31,9 +31,7 @@ export const handler = async (ctx: Context): Promise => { }, }); - let items: DataItem[] = []; - - items = response.data.slice(0, limit).map((item): DataItem => { + let items: DataItem[] = response.data.slice(0, limit).map((item): DataItem => { const title: string = item.title; const description: string = renderToString(item.zhaiyao ?
{item.zhaiyao}
: null); const pubDate: number | string = item.createtime; diff --git a/lib/routes/fantia/search.ts b/lib/routes/fantia/search.ts index 945e031b23..fe28e53814 100644 --- a/lib/routes/fantia/search.ts +++ b/lib/routes/fantia/search.ts @@ -1,5 +1,5 @@ import { config } from '@/config'; -import type { Route } from '@/types'; +import type { DataItem, Route } from '@/types'; import { ViewType } from '@/types'; import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; @@ -163,7 +163,7 @@ async function handler(ctx) { }, }); - let items = {}; + let items: DataItem[]; switch (type) { case 'fanclubs': diff --git a/lib/routes/flyert/creditcard.ts b/lib/routes/flyert/creditcard.ts index 4ff98ade60..8ac5e9a5d6 100644 --- a/lib/routes/flyert/creditcard.ts +++ b/lib/routes/flyert/creditcard.ts @@ -58,7 +58,7 @@ export const route: Route = { async function handler(ctx) { const bank = ctx.req.param('bank'); const target = `${host}/forum-${bank}-1.html`; - let bankname = ''; + let bankname: string; switch (bank) { case 'creditcard': diff --git a/lib/routes/gamer/gnn-index.ts b/lib/routes/gamer/gnn-index.ts index fcfbe7f018..b17b26abaa 100644 --- a/lib/routes/gamer/gnn-index.ts +++ b/lib/routes/gamer/gnn-index.ts @@ -55,7 +55,7 @@ export const route: Route = { async function handler(ctx) { const category = ctx.req.param('category'); - let url = ''; + let url: string; let categoryName = ''; const categoryTable = { 1: 'PC', @@ -126,7 +126,7 @@ async function handler(ctx) { async (item) => { item.description = await cache.tryGet(item.link, async () => { const response = await got.get(item.link); - let component = ''; + let component: string; const urlReg = /window\.lazySizesConfig/g; let pubInfo; diff --git a/lib/routes/gaoyu/blog.ts b/lib/routes/gaoyu/blog.ts index 56b7cd30cc..3e25b019ed 100644 --- a/lib/routes/gaoyu/blog.ts +++ b/lib/routes/gaoyu/blog.ts @@ -29,9 +29,7 @@ export const handler = async (ctx: Context): Promise => { }, ]; - let items: DataItem[] = []; - - items = $('a.flex-col') + let items: DataItem[] = $('a.flex-col') .slice(0, limit) .toArray() .map((el): Element => { diff --git a/lib/routes/gcores/util.ts b/lib/routes/gcores/util.ts index a18b16bf36..ef1b2c7045 100644 --- a/lib/routes/gcores/util.ts +++ b/lib/routes/gcores/util.ts @@ -31,9 +31,7 @@ const processItems = async (limit: number, query: any, apiUrl: string, targetUrl const included = response.included; const data = [...response.data, ...included].filter((item) => types.has(item.type)); - let items: DataItem[] = []; - - items = data?.slice(0, limit).map((item): DataItem => { + const items: DataItem[] = data?.slice(0, limit).map((item): DataItem => { const attributes = item.attributes; const relationships = item.relationships; diff --git a/lib/routes/github/eventapi.ts b/lib/routes/github/eventapi.ts index 20a0dec6a5..4caaafdbc9 100644 --- a/lib/routes/github/eventapi.ts +++ b/lib/routes/github/eventapi.ts @@ -22,9 +22,9 @@ export const eventTypeMapping: Record = { function formatEventItem(event: any) { const { id, type, actor, repo, payload, created_at } = event; - let title = ''; - let description = ''; - let link = ''; + let title: string; + let description: string; + let link: string; switch (type) { case 'PushEvent': { diff --git a/lib/routes/gov/cn/news/index.ts b/lib/routes/gov/cn/news/index.ts index 510ec2fd94..924f93cf6a 100644 --- a/lib/routes/gov/cn/news/index.ts +++ b/lib/routes/gov/cn/news/index.ts @@ -33,7 +33,7 @@ async function handler(ctx) { const originDomain = 'https://www.gov.cn'; let url = ''; let title = ''; - let list = ''; + let list: string; switch (uid) { case 'bm': url = `${originDomain}/lianbo/bumen/index.htm`; diff --git a/lib/routes/gov/csrc/news.tsx b/lib/routes/gov/csrc/news.tsx index 4e70801550..4bded27f63 100644 --- a/lib/routes/gov/csrc/news.tsx +++ b/lib/routes/gov/csrc/news.tsx @@ -1,7 +1,7 @@ import { load } from 'cheerio'; import { renderToString } from 'hono/jsx/dom/server'; -import type { Route } from '@/types'; +import type { DataItem, Route } from '@/types'; import cache from '@/utils/cache'; import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; @@ -23,8 +23,8 @@ async function handler(ctx) { const channelId = $('meta[name="channelid"]').attr('content'); - let data, - out = []; + let data; + let out: DataItem[]; if (channelId) { data = await got(`${baseUrl}/searchList/${channelId}`, { searchParams: { diff --git a/lib/routes/gov/customs/list.ts b/lib/routes/gov/customs/list.ts index d28d20200c..cf39609925 100644 --- a/lib/routes/gov/customs/list.ts +++ b/lib/routes/gov/customs/list.ts @@ -39,7 +39,7 @@ export const route: Route = { async function handler(ctx) { const { gchannel = 'paimai' } = ctx.req.param(); - let channelName = ''; + let channelName: string; let link = ''; switch (gchannel) { diff --git a/lib/routes/gov/general/general.ts b/lib/routes/gov/general/general.ts index fe65e569b8..7766acb8ab 100644 --- a/lib/routes/gov/general/general.ts +++ b/lib/routes/gov/general/general.ts @@ -105,8 +105,8 @@ const gdgov = async (info, ctx) => { const currentUrl = `${rootUrl}/${pathname}`; let $ = ''; - let name = ''; - let list = ''; + let name: string; + let list: string; // 判断是否处于特殊目录 if (pathname.startsWith('gkmlpt')) { title_element = undefined; @@ -149,7 +149,7 @@ const gdgov = async (info, ctx) => { } const lists = list.map((i, item) => { - let link = ''; + let link: string; if (pathname.startsWith('gkmlpt')) { link = i.url; @@ -198,16 +198,13 @@ const gdgov = async (info, ctx) => { const content = load(res); // 获取来源 - let author = ''; - author = author_element === undefined ? content('meta[name="ContentSource"]').attr('content') : content(author_element).text().trim().match(author_match)[1].trim().replaceAll(/(-*$)/g, ''); + const author = author_element === undefined ? content('meta[name="ContentSource"]').attr('content') : content(author_element).text().trim().match(author_match)[1].trim().replaceAll(/(-*$)/g, ''); // 获取发布时间 - let pubDate = ''; - pubDate = pubDate_element === undefined ? content('meta[name="PubDate"]').attr('content') : content(pubDate_element).text().trim().match(pubDate_match)[1].trim().replaceAll(/(-*$)/g, ''); + const pubDate = pubDate_element === undefined ? content('meta[name="PubDate"]').attr('content') : content(pubDate_element).text().trim().match(pubDate_match)[1].trim().replaceAll(/(-*$)/g, ''); // 获取标题 - let title = ''; - title = title_element === undefined ? content('meta[name="ArticleTitle"]').attr('content') : content(title_element).text().trim().match(title_match)[1]; + const title = title_element === undefined ? content('meta[name="ArticleTitle"]').attr('content') : content(title_element).text().trim().match(title_match)[1]; // 获取正文 const description_content = description_element.split(',').filter((item) => item !== ''); for (let index = 0; index < description_content.length; index++) { diff --git a/lib/routes/gov/maoming/maoming.ts b/lib/routes/gov/maoming/maoming.ts index bde7c1822f..84a0a4c106 100644 --- a/lib/routes/gov/maoming/maoming.ts +++ b/lib/routes/gov/maoming/maoming.ts @@ -16,14 +16,14 @@ async function handler(ctx) { .filter((item) => item !== ''); let pathstartat = 0; let defaultPath = ''; - let list_element = ''; + let list_element: string; let list_include = 'site'; - let title_element = ''; + let title_element: string; let title_match = '(.*)'; - let description_element = ''; - let authorisme = ''; - let pubDate_element = ''; - let pubDate_match = ''; + let description_element: string; + let authorisme: string; + let pubDate_element: string; + let pubDate_match: string; // let pubDate_format = undefined; switch (path[1]) { case 'www': diff --git a/lib/routes/gov/maonan/maonan.ts b/lib/routes/gov/maonan/maonan.ts index bbdb67c191..6363972180 100644 --- a/lib/routes/gov/maonan/maonan.ts +++ b/lib/routes/gov/maonan/maonan.ts @@ -30,8 +30,8 @@ export const route: Route = { }; async function handler(ctx) { - let id = ''; - let name = ''; + let id: string; + let name: string; switch (ctx.req.param('category')) { case 'zwgk': diff --git a/lib/routes/gov/mee/nnsa.ts b/lib/routes/gov/mee/nnsa.ts index a03e555967..0f1db35d87 100644 --- a/lib/routes/gov/mee/nnsa.ts +++ b/lib/routes/gov/mee/nnsa.ts @@ -21,9 +21,7 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(response); const language = $('html').attr('lang') ?? 'zh'; - let items: DataItem[] = []; - - items = $('a.cjcx_biaob, ul#div li a') + let items: DataItem[] = $('a.cjcx_biaob, ul#div li a') .slice(0, limit) .toArray() .map((el): Element => { diff --git a/lib/routes/gov/moa/gjs.ts b/lib/routes/gov/moa/gjs.ts index 45b7b1ad0b..56c65dabcc 100644 --- a/lib/routes/gov/moa/gjs.ts +++ b/lib/routes/gov/moa/gjs.ts @@ -21,9 +21,7 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(response); const language = $('html').attr('lang') ?? 'zh-CN'; - let items: DataItem[] = []; - - items = $('ul#div li') + let items: DataItem[] = $('ul#div li') .slice(0, limit) .toArray() .map((el): Element => { diff --git a/lib/routes/gov/moa/moa.ts b/lib/routes/gov/moa/moa.ts index 3460037170..cf86e6fcfa 100644 --- a/lib/routes/gov/moa/moa.ts +++ b/lib/routes/gov/moa/moa.ts @@ -247,7 +247,7 @@ function dealLink(element, url) { // host 不同的是外部文章,outside // url 里带 govpublic 的都是公示文章,govpublic // 其他的都算普通文章,normal - let pageType = null; + let pageType: string; if (host === hostUrlObj.host) { pageType = href.includes('gk') || href.includes('govpublic') ? 'govpublic' : 'normal'; } else { diff --git a/lib/routes/gov/mot/index.ts b/lib/routes/gov/mot/index.ts index da2416e164..7c9b58aa0c 100644 --- a/lib/routes/gov/mot/index.ts +++ b/lib/routes/gov/mot/index.ts @@ -20,9 +20,7 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(response); const language = $('html').attr('lang') ?? 'zh'; - let items: DataItem[] = []; - - items = $('div.tab-pane a') + let items: DataItem[] = $('div.tab-pane a') .slice(0, limit) .toArray() .map((el): Element => { diff --git a/lib/routes/gov/suzhou/news.ts b/lib/routes/gov/suzhou/news.ts index e370c9f138..ccab64c84e 100644 --- a/lib/routes/gov/suzhou/news.ts +++ b/lib/routes/gov/suzhou/news.ts @@ -58,10 +58,10 @@ export const route: Route = { async function handler(ctx) { const rootUrl = 'https://www.suzhou.gov.cn'; const uid = ctx.req.param('uid'); - let url = ''; - let title = ''; + let url: string; + let title: string; let apiUrl = ''; - let items = []; + let items: DataItem[]; switch (uid) { case 'szyw': case 'news': diff --git a/lib/routes/gov/zhengce/govall.ts b/lib/routes/gov/zhengce/govall.ts index f39868276b..3afc233d72 100644 --- a/lib/routes/gov/zhengce/govall.ts +++ b/lib/routes/gov/zhengce/govall.ts @@ -71,7 +71,7 @@ async function handler(ctx) { const items = await Promise.all( list.map((item) => cache.tryGet(item.link, async () => { - let description = ''; + let description: string; try { const contentData = await got(item.link); const $ = load(contentData.data); diff --git a/lib/routes/grainoil/category.ts b/lib/routes/grainoil/category.ts index 54e6be4e91..3e862b855c 100644 --- a/lib/routes/grainoil/category.ts +++ b/lib/routes/grainoil/category.ts @@ -20,9 +20,7 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(response); const language = $('html').attr('lang') ?? 'zh-CN'; - let items: DataItem[] = []; - - items = $('div.m_listpagebox ol li a') + let items: DataItem[] = $('div.m_listpagebox ol li a') .slice(0, limit) .toArray() .map((el): Element => { diff --git a/lib/routes/hafu/utils.tsx b/lib/routes/hafu/utils.tsx index bfe3e8376a..224119be40 100644 --- a/lib/routes/hafu/utils.tsx +++ b/lib/routes/hafu/utils.tsx @@ -35,7 +35,7 @@ export default parseList; async function tryGetFullText(href, link, type) { let articleData = ''; - let description = ''; + let description: string; // for some unexpected href link try { const articleRes = await got(link); @@ -97,7 +97,7 @@ async function ggtzParse(ctx, $) { const result = await cache.tryGet(link, async () => { const { articleData, description } = await tryGetFullText(href, link, 'ggtz'); let author = ''; - let pubDate = ''; + let pubDate: string; if (typeof articleData === 'function') { const header = articleData('h1').next().text(); const index = header.indexOf('日期'); @@ -176,7 +176,7 @@ async function zsjycParse(ctx, $) { const result = await cache.tryGet(link, async () => { const { articleData, description } = await tryGetFullText(href, link, 'zsjyc'); - let pubDate = ''; + let pubDate: string; if (typeof articleData === 'function') { const date = articleData('span[class=timestyle127702]').text(); pubDate = parseDate(date, 'YYYY-MM-DD HH:mm'); diff --git a/lib/routes/hit/hitgs.ts b/lib/routes/hit/hitgs.ts index a38c24934d..6828262d92 100644 --- a/lib/routes/hit/hitgs.ts +++ b/lib/routes/hit/hitgs.ts @@ -22,9 +22,7 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(response); const language = $('html').attr('lang') ?? 'zh'; - let items: DataItem[] = []; - - items = $('li.news, div.tbt17') + let items: DataItem[] = $('li.news, div.tbt17') .slice(0, limit) .toArray() .map((el): Element => { diff --git a/lib/routes/hlju/news.ts b/lib/routes/hlju/news.ts index 82e17b54f8..16f667f20a 100644 --- a/lib/routes/hlju/news.ts +++ b/lib/routes/hlju/news.ts @@ -100,7 +100,7 @@ async function handler(ctx) { // 提取文章内容 - 只使用主要内容选择器 const content = $detail('.v_news_content'); - let description = ''; + let description: string; if (content.length > 0) { // 清理内容 diff --git a/lib/routes/hongkong/chp.ts b/lib/routes/hongkong/chp.ts index 98d4c6ab09..04de3eac81 100644 --- a/lib/routes/hongkong/chp.ts +++ b/lib/routes/hongkong/chp.ts @@ -71,7 +71,7 @@ async function handler(ctx) { }); const list = JSON.parse(response.data.match(/"data":(\[{.*}])}/)[1]).map((item) => { - let link = ''; + let link: string; if (item.UrlPath_en) { link = item[`UrlPath_${language}`].includes('http') ? item[`UrlPath_${language}`] : `${rootUrl}${item[`UrlPath_${language}`]}`; diff --git a/lib/routes/huitun/xiaohongshu.ts b/lib/routes/huitun/xiaohongshu.ts index 1c7b586b29..f16ed870c6 100644 --- a/lib/routes/huitun/xiaohongshu.ts +++ b/lib/routes/huitun/xiaohongshu.ts @@ -55,7 +55,7 @@ async function handler(ctx) { const notes = note_data.extData.list; const items = await Promise.all( notes.map(async (item) => { - let desc = ''; + let desc: string; switch (item.type) { case 'normal': desc = `

`; diff --git a/lib/routes/hupu/utils.ts b/lib/routes/hupu/utils.ts index d0363658d2..dadc17d837 100644 --- a/lib/routes/hupu/utils.ts +++ b/lib/routes/hupu/utils.ts @@ -15,7 +15,7 @@ export function extractNextData(html: string, url?: string): T { try { return JSON.parse(scriptMatch[1]) as T; } catch (error) { - throw new Error(`Failed to parse __NEXT_DATA__ JSON: ${error instanceof Error ? error.message : String(error)}`); + throw new Error(`Failed to parse __NEXT_DATA__ JSON: ${error instanceof Error ? error.message : String(error)}`, { cause: error }); } } diff --git a/lib/routes/indianexpress/section.ts b/lib/routes/indianexpress/section.ts index d58b9a184c..8e553fda77 100644 --- a/lib/routes/indianexpress/section.ts +++ b/lib/routes/indianexpress/section.ts @@ -40,9 +40,7 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(targetResponse); const language = $('html').attr('lang') ?? 'en'; - let items: DataItem[] = []; - - items = response.slice(0, limit).map((item): DataItem => { + const items: DataItem[] = response.slice(0, limit).map((item): DataItem => { const title: string = item.title?.rendered ?? item.title; const description: string | undefined = item.content.rendered; const pubDate: number | string = item.date_gmt; diff --git a/lib/routes/instagram/common-utils.ts b/lib/routes/instagram/common-utils.ts index d780500619..25bd4ab7a2 100644 --- a/lib/routes/instagram/common-utils.ts +++ b/lib/routes/instagram/common-utils.ts @@ -9,7 +9,7 @@ const renderItems = (items) => // Content const summary = item.caption?.text ?? ''; - let description = ''; + let description: string; switch (productType) { case 'carousel_container': { const images = item.carousel_media.map((i) => ({ diff --git a/lib/routes/instagram/web-api/utils.ts b/lib/routes/instagram/web-api/utils.ts index 560df81725..c099630a58 100644 --- a/lib/routes/instagram/web-api/utils.ts +++ b/lib/routes/instagram/web-api/utils.ts @@ -154,7 +154,7 @@ const renderGuestItems = (items) => { const type = node.__typename; const summary = node.edge_media_to_caption.edges[0]?.node.text ?? ''; - let description = ''; + let description: string; switch (type) { // carousel, can include GraphVideo and GraphImage case 'GraphSidecar': diff --git a/lib/routes/investor/index.ts b/lib/routes/investor/index.ts index b1b2755339..b87edcb23b 100644 --- a/lib/routes/investor/index.ts +++ b/lib/routes/investor/index.ts @@ -20,9 +20,7 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(response); const language = $('html').attr('lang') ?? 'zh'; - let items: DataItem[] = []; - - items = $('div.right_content_item a') + let items: DataItem[] = $('div.right_content_item a') .slice(0, limit) .toArray() .map((el): Element => { diff --git a/lib/routes/iqiyi/album.tsx b/lib/routes/iqiyi/album.tsx index 319f78b0ab..ec0157f365 100644 --- a/lib/routes/iqiyi/album.tsx +++ b/lib/routes/iqiyi/album.tsx @@ -45,7 +45,7 @@ async function handler(ctx) { } let pos = 1; - let hasMore = false; + let hasMore: boolean; let epgs = []; do { const { diff --git a/lib/routes/iresearch/report.ts b/lib/routes/iresearch/report.ts index 2fc2a1075d..9eb20031c9 100644 --- a/lib/routes/iresearch/report.ts +++ b/lib/routes/iresearch/report.ts @@ -230,9 +230,7 @@ export const handler = async (ctx: Context): Promise => { }, }); - let items: DataItem[] = []; - - items = response.List.slice(0, limit).map((item): DataItem => { + let items: DataItem[] = response.List.slice(0, limit).map((item): DataItem => { const title: string = item.reportname ?? (() => { diff --git a/lib/routes/jornada/index.ts b/lib/routes/jornada/index.ts index 30703d43c0..05644df1e2 100644 --- a/lib/routes/jornada/index.ts +++ b/lib/routes/jornada/index.ts @@ -1,4 +1,4 @@ -import type { Route } from '@/types'; +import type { DataItem, Route } from '@/types'; import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; @@ -65,7 +65,7 @@ async function handler(ctx) { const response = await got(url); const data = response.data; - let items = {}; + let items: DataItem[]; if (category) { const newsFilteredByCategory = data.filter((item) => item.category === categories[category]); diff --git a/lib/routes/juejin/pins.ts b/lib/routes/juejin/pins.ts index dc9187a959..86a0fcb407 100644 --- a/lib/routes/juejin/pins.ts +++ b/lib/routes/juejin/pins.ts @@ -37,8 +37,8 @@ async function handler(ctx) { '6824710203112423437': '树洞一下', }; - let url = ''; - let json = {}; + let url: string; + let json: Record; if (/^\d+$/.test(type)) { url = `https://api.juejin.cn/recommend_api/v1/short_msg/topic`; json = { id_type: 4, sort_type: 500, cursor: '0', limit: 20, topic_id: type }; diff --git a/lib/routes/kemono/index.tsx b/lib/routes/kemono/index.tsx index e6571ad739..18fec7103c 100644 --- a/lib/routes/kemono/index.tsx +++ b/lib/routes/kemono/index.tsx @@ -412,6 +412,6 @@ async function handler(ctx) { item: items, }; } catch (error) { - throw new Error(`Failed to fetch data from Kemono: ${error instanceof Error ? error.message : 'Unknown error'}`); + throw new Error(`Failed to fetch data from Kemono: ${error instanceof Error ? error.message : 'Unknown error'}`, { cause: error }); } } diff --git a/lib/routes/kiro/blog.ts b/lib/routes/kiro/blog.ts index 1c17a77814..c7b516b6dd 100644 --- a/lib/routes/kiro/blog.ts +++ b/lib/routes/kiro/blog.ts @@ -19,9 +19,7 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(response); const language = $('html').attr('lang') ?? 'en'; - let items: DataItem[] = []; - - items = $('main a.group') + let items: DataItem[] = $('main a.group') .slice(0, limit) .toArray() .map((el): Element => { diff --git a/lib/routes/kiro/changelog.ts b/lib/routes/kiro/changelog.ts index c76e50fd71..8565b40515 100644 --- a/lib/routes/kiro/changelog.ts +++ b/lib/routes/kiro/changelog.ts @@ -19,9 +19,7 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(response); const language = $('html').attr('lang') ?? 'en'; - let items: DataItem[] = []; - - items = $('a.block') + let items: DataItem[] = $('a.block') .slice(0, limit) .toArray() .map((el): Element => { diff --git a/lib/routes/koyso/index.tsx b/lib/routes/koyso/index.tsx index 5e9fd534f5..a038f6a39a 100644 --- a/lib/routes/koyso/index.tsx +++ b/lib/routes/koyso/index.tsx @@ -38,9 +38,7 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(response); const language = $('html').attr('lang') ?? 'en'; - let items: DataItem[] = []; - - items = $('a.game_item') + let items: DataItem[] = $('a.game_item') .slice(0, limit) .toArray() .map((el): Element => { diff --git a/lib/routes/kpopping/kpics.ts b/lib/routes/kpopping/kpics.ts index 328f366b1a..428132b0d0 100644 --- a/lib/routes/kpopping/kpics.ts +++ b/lib/routes/kpopping/kpics.ts @@ -22,9 +22,7 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(response); const language = $('html').attr('lang') ?? 'en'; - let items: DataItem[] = []; - - items = $('div.pics div.matrix div.cell') + let items: DataItem[] = $('div.pics div.matrix div.cell') .slice(0, limit) .toArray() .map((el): Element => { diff --git a/lib/routes/kpopping/news.ts b/lib/routes/kpopping/news.ts index 770e529fe6..822ee81b34 100644 --- a/lib/routes/kpopping/news.ts +++ b/lib/routes/kpopping/news.ts @@ -23,9 +23,7 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(response); const language = $('html').attr('lang') ?? 'en'; - let items: DataItem[] = []; - - items = $('section.news-list-item') + let items: DataItem[] = $('section.news-list-item') .slice(0, limit) .toArray() .map((el): Element => { diff --git a/lib/routes/liquipedia/dota2-matches.ts b/lib/routes/liquipedia/dota2-matches.ts index 90b7cc0692..8e406daacf 100644 --- a/lib/routes/liquipedia/dota2-matches.ts +++ b/lib/routes/liquipedia/dota2-matches.ts @@ -45,7 +45,7 @@ async function handler(ctx) { link: url, item: list?.toArray().map((item) => { item = $(item); - let message = ''; + let message: string; if (item.attr('style') === 'background:rgb(240, 255, 240)') { message = '胜'; } else if (item.attr('style') === 'background:rgb(249, 240, 242)') { diff --git a/lib/routes/ltaaa/article.ts b/lib/routes/ltaaa/article.ts index 66c2ce872b..bb2a6c67f5 100644 --- a/lib/routes/ltaaa/article.ts +++ b/lib/routes/ltaaa/article.ts @@ -21,9 +21,7 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(response); const language = $('html').attr('lang') ?? 'zh-CN'; - let items: DataItem[] = []; - - items = $('ul.wlist li') + let items: DataItem[] = $('ul.wlist li') .slice(0, limit) .toArray() .map((el): Element => { diff --git a/lib/routes/mail/imap.ts b/lib/routes/mail/imap.ts index 5ba9e0159d..d5b0475006 100644 --- a/lib/routes/mail/imap.ts +++ b/lib/routes/mail/imap.ts @@ -48,7 +48,7 @@ async function handler(ctx) { try { await client.connect(); } catch (error) { - throw new Error(error.responseText); + throw new Error(error.responseText, { cause: error }); } /** diff --git a/lib/routes/mathpix/blog.tsx b/lib/routes/mathpix/blog.tsx index a43b200c72..651c68074e 100644 --- a/lib/routes/mathpix/blog.tsx +++ b/lib/routes/mathpix/blog.tsx @@ -33,9 +33,7 @@ export const handler = async (ctx: Context): Promise => { } }); - let items: DataItem[] = []; - - items = $('li.articles__item') + let items: DataItem[] = $('li.articles__item') .slice(0, limit) .toArray() .map((el): Element => { diff --git a/lib/routes/maven/central.ts b/lib/routes/maven/central.ts index b5a1717c9d..c6a1a66348 100644 --- a/lib/routes/maven/central.ts +++ b/lib/routes/maven/central.ts @@ -72,7 +72,7 @@ async function handler(ctx) { } } catch (error: any) { if (error?.response?.status === 404) { - throw new Error(`Could not find component for ${group}:${artifact}: metadata not found`); + throw new Error(`Could not find component for ${group}:${artifact}: metadata not found`, { cause: error }); } throw error; } diff --git a/lib/routes/mercari/util.tsx b/lib/routes/mercari/util.tsx index 9de7a2000a..e8d885605a 100644 --- a/lib/routes/mercari/util.tsx +++ b/lib/routes/mercari/util.tsx @@ -285,7 +285,7 @@ const fetchFromMercari = async function fetchFromMercari(url: string, data: a try { return await ofetch(url, options); } catch (error) { - throw new Error(`API request failed: ${error}`); + throw new Error(`API request failed: ${error}`, { cause: error }); } }; diff --git a/lib/routes/miniflux/entry.ts b/lib/routes/miniflux/entry.ts index 0090796f86..b2511d5394 100644 --- a/lib/routes/miniflux/entry.ts +++ b/lib/routes/miniflux/entry.ts @@ -1,6 +1,6 @@ import { config } from '@/config'; import ConfigNotFoundError from '@/errors/types/config-not-found'; -import type { Data, Route } from '@/types'; +import type { Data, DataItem, Route } from '@/types'; import got from '@/utils/got'; export const route: Route = { @@ -131,7 +131,7 @@ async function handler(ctx) { const entriesID = []; const feedsName = []; - const articles = []; + const articles: DataItem[] = []; // MiniFlux will only preserve the *first* valid filter option // for each parameter, in order to matching the default behavior @@ -162,28 +162,16 @@ async function handler(ctx) { const feedsList = [feedsID.split('&')].flat(); if (limit && queryLimit) { - if (limit < queryLimit) { - queryLimit = limit * feedsList.length; - } else { + if (limit >= queryLimit) { const eachLimit = Number.parseInt(queryLimit / feedsList.length); - if (eachLimit) { - limit = eachLimit; - } else { - limit = 1; - queryLimit = feedsList.length; - } + limit = eachLimit || 1; } parameters += `&limit=${limit}`; } else if (limit) { parameters += `&limit=${limit}`; } else if (queryLimit) { const eachLimit = Number.parseInt(queryLimit / feedsList.length); - if (eachLimit) { - limit = eachLimit; - } else { - limit = 1; - queryLimit = feedsList.length; - } + limit = eachLimit || 1; parameters += `&limit=${limit}`; } @@ -267,7 +255,7 @@ async function handler(ctx) { }); const entries = response.data.entries; - const articles = []; + const articles: DataItem[] = []; for (const entry of entries) { entriesID.push(entry.id); let entryTitle = entry.title; diff --git a/lib/routes/misskey/utils.tsx b/lib/routes/misskey/utils.tsx index 11b66ae821..189d7740b1 100644 --- a/lib/routes/misskey/utils.tsx +++ b/lib/routes/misskey/utils.tsx @@ -56,7 +56,7 @@ const parseNotes = (data: MisskeyNote[], site: string, simplifyAuthor: boolean = reply: item.reply, }); - let title = ''; + let title: string; if (isReply && item.reply) { const replyToHost = item.reply.user.host ?? site; const replyToAuthor = simplifyAuthor ? item.reply.user.name : `${item.reply.user.name} (${item.reply.user.username}@${replyToHost})`; diff --git a/lib/routes/modrinth/versions.tsx b/lib/routes/modrinth/versions.tsx index 15eab1f379..4ff061ace6 100644 --- a/lib/routes/modrinth/versions.tsx +++ b/lib/routes/modrinth/versions.tsx @@ -140,7 +140,7 @@ async function handler(ctx: Context) { }; } catch (error: any) { if (error?.response?.statusCode === 404) { - throw new Error(`${error.message}: Project ${id} not found`); + throw new Error(`${error.message}: Project ${id} not found`, { cause: error }); } throw error; } diff --git a/lib/routes/musikguru/news.ts b/lib/routes/musikguru/news.ts index a98b390e67..4bdd53b8fb 100644 --- a/lib/routes/musikguru/news.ts +++ b/lib/routes/musikguru/news.ts @@ -22,9 +22,7 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(response); const language = $('html').attr('lang') ?? 'de'; - let items: DataItem[] = []; - - items = $('section') + let items: DataItem[] = $('section') .eq(1) .find('div.card') .slice(0, limit) diff --git a/lib/routes/mycard520/news.ts b/lib/routes/mycard520/news.ts index 1e850e21e5..256f32d21d 100644 --- a/lib/routes/mycard520/news.ts +++ b/lib/routes/mycard520/news.ts @@ -20,11 +20,9 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(response); const language = $('html').attr('lang') ?? 'zh-TW'; - let items: DataItem[] = []; - $('div.page_numbers').remove(); - items = $('div#tab1 ul li') + let items: DataItem[] = $('div#tab1 ul li') .slice(0, limit) .toArray() .map((el): Element => { diff --git a/lib/routes/neea/jlpt.ts b/lib/routes/neea/jlpt.ts index e43520e35c..ee42e625b8 100644 --- a/lib/routes/neea/jlpt.ts +++ b/lib/routes/neea/jlpt.ts @@ -19,9 +19,7 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(response); const language = $('html').attr('lang') ?? 'zh-CN'; - let items: DataItem[] = []; - - items = $('div.indexcontent a') + let items: DataItem[] = $('div.indexcontent a') .slice(0, limit) .toArray() .map((el): Element => { diff --git a/lib/routes/nikkei/cn/index.ts b/lib/routes/nikkei/cn/index.ts index 4489347f71..36defa883f 100644 --- a/lib/routes/nikkei/cn/index.ts +++ b/lib/routes/nikkei/cn/index.ts @@ -2,7 +2,7 @@ import { load } from 'cheerio'; import Parser from 'rss-parser'; import { config } from '@/config'; -import type { Route } from '@/types'; +import type { DataItem, Route } from '@/types'; import cache from '@/utils/cache'; import { getSubPath } from '@/utils/common-utils'; import got from '@/utils/got'; @@ -63,7 +63,7 @@ export const route: Route = { }; async function handler(ctx) { - let language = ''; + let language: string; let path = getSubPath(ctx); if (/^\/cn\/(cn|zh)/.test(path)) { @@ -81,8 +81,8 @@ async function handler(ctx) { let officialFeed; - let items = [], - $; + let items: DataItem[]; + let $; if (isOfficialRSS) { officialFeed = await parser.parseURL(currentUrl); diff --git a/lib/routes/nikkei/news.tsx b/lib/routes/nikkei/news.tsx index 701638da3b..ef28bd5441 100644 --- a/lib/routes/nikkei/news.tsx +++ b/lib/routes/nikkei/news.tsx @@ -29,14 +29,13 @@ export const route: Route = { async function handler(ctx) { const baseUrl = 'https://www.nikkei.com'; const { category, article_type = 'paid' } = ctx.req.param(); - let url = ''; - url = category === 'news' ? `${baseUrl}/news/category/` : `${baseUrl}/${category}/archive/`; + const url = category === 'news' ? `${baseUrl}/news/category/` : `${baseUrl}/${category}/archive/`; const response = await got(url); const data = response.data; const $ = load(data); - let categoryName = ''; + let categoryName: string; const listSelector = $('[class^="container_"] [class^="default_"]:has(article)'); const paidSelector = 'img[class^="icon_"]'; diff --git a/lib/routes/nintendo/utils.ts b/lib/routes/nintendo/utils.ts index e515fdb805..ef570d1e68 100644 --- a/lib/routes/nintendo/utils.ts +++ b/lib/routes/nintendo/utils.ts @@ -13,7 +13,7 @@ import { renderEshopCnDescription } from './templates/eshop-cn'; dayjs.extend(localizedFormat); function nuxtReader(data) { - let nuxt = {}; + let nuxt: Record; try { const dom = new JSDOM(data, { runScripts: 'dangerously', diff --git a/lib/routes/notefolio/search.tsx b/lib/routes/notefolio/search.tsx index 6cf26f560b..9388ed96b3 100644 --- a/lib/routes/notefolio/search.tsx +++ b/lib/routes/notefolio/search.tsx @@ -182,7 +182,7 @@ async function handler(ctx) { } // 时间范围 if (time !== 'all' && ['one-day', 'week', 'month', 'three-month'].includes(time)) { - let startTime = ''; + let startTime: string; const endTime = dayjs().endOf('d').format('YYYY-MM-DDTHH:mm:ss.SSS'); // 过去24小时-day 最近一周-week 最近一个月-month 最近三个月three-month diff --git a/lib/routes/nowcoder/hots.ts b/lib/routes/nowcoder/hots.ts index 7160f82f7c..14b1366f03 100644 --- a/lib/routes/nowcoder/hots.ts +++ b/lib/routes/nowcoder/hots.ts @@ -33,7 +33,7 @@ async function handler(ctx) { const limit = Number.parseInt(ctx.req.query('limit') ?? '20', 10); const size = Number.isFinite(limit) && limit > 0 ? limit : 20; - let link = ''; + let link: string; if (type === '1') { link = `https://gw-c.nowcoder.com/api/sparta/subject/hot-subject?limit=${size}&_=${Date.now()}&t=`; const responseBody = (await got.get(link)).data; diff --git a/lib/routes/nyc/mayors-office-news.ts b/lib/routes/nyc/mayors-office-news.ts index af1b5782e9..159592d653 100644 --- a/lib/routes/nyc/mayors-office-news.ts +++ b/lib/routes/nyc/mayors-office-news.ts @@ -117,7 +117,7 @@ Categories } // Description - let description = ''; + let description: string; description = types ? toTitleCase(cleanedTypes) : 'News'; if (categories) { diff --git a/lib/routes/oncc/money18.ts b/lib/routes/oncc/money18.ts index 391506af7b..369add4d23 100644 --- a/lib/routes/oncc/money18.ts +++ b/lib/routes/oncc/money18.ts @@ -1,7 +1,7 @@ import { load } from 'cheerio'; import dayjs from 'dayjs'; -import type { Route } from '@/types'; +import type { DataItem, Route } from '@/types'; import cache from '@/utils/cache'; import got from '@/utils/got'; import { parseDate } from '@/utils/parse-date'; @@ -54,11 +54,11 @@ async function handler(ctx) { const toApiUrl = (date) => `${rootUrl}/cnt/utf8/content/${date}/articleList/list_${id}_all.js`; - let apiUrl = id === 'ipo' ? ipoApiUrl : id === 'industry' ? industryApiUrl : toApiUrl(dayjs().format('YYYYMMDD')), - hasArticle = false, - items = [], - i = 0, - response; + let apiUrl = id === 'ipo' ? ipoApiUrl : id === 'industry' ? industryApiUrl : toApiUrl(dayjs().format('YYYYMMDD')); + let hasArticle = false; + let items: DataItem[]; + let i = 0; + let response; /* eslint-disable no-await-in-loop */ diff --git a/lib/routes/ornl/all-news.ts b/lib/routes/ornl/all-news.ts index cd0ea8b682..63d4bd566b 100644 --- a/lib/routes/ornl/all-news.ts +++ b/lib/routes/ornl/all-news.ts @@ -21,9 +21,7 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(response); const language = $('html').attr('lang') ?? 'en'; - let items: DataItem[] = []; - - items = $('div.view-rows-main div.list-item-wrapper') + let items: DataItem[] = $('div.view-rows-main div.list-item-wrapper') .slice(0, limit) .toArray() .map((el): Element => { diff --git a/lib/routes/oschina/column.ts b/lib/routes/oschina/column.ts index e3d78545fe..de8ce4b519 100644 --- a/lib/routes/oschina/column.ts +++ b/lib/routes/oschina/column.ts @@ -24,9 +24,7 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(response); const language: string = $('html').attr('lang') ?? 'zh-CN'; - let items: DataItem[] = []; - - items = $('div.news-item') + let items: DataItem[] = $('div.news-item') .slice(0, limit) .toArray() .map((el): Element => { diff --git a/lib/routes/oschina/event.ts b/lib/routes/oschina/event.ts index 13f8e9e852..65eab66a26 100644 --- a/lib/routes/oschina/event.ts +++ b/lib/routes/oschina/event.ts @@ -31,9 +31,7 @@ export const handler = async (ctx: Context): Promise => { const $target: CheerioAPI = load(targetResponse); const language = $target('html').attr('lang') ?? 'zh-CN'; - let items: DataItem[] = []; - - items = $('div.event-item') + let items: DataItem[] = $('div.event-item') .slice(0, limit) .toArray() .map((el): Element => { diff --git a/lib/routes/oshwhub/explore.ts b/lib/routes/oshwhub/explore.ts index d97c50b687..19776ea9e1 100644 --- a/lib/routes/oshwhub/explore.ts +++ b/lib/routes/oshwhub/explore.ts @@ -70,9 +70,7 @@ export const handler = async (ctx: Context): Promise => { }, }); - let items: DataItem[] = []; - - items = response.result.lists.slice(0, limit).map((item): DataItem => { + let items: DataItem[] = response.result.lists.slice(0, limit).map((item): DataItem => { const title: string = item.name; const image: string | undefined = item.thumb?.startsWith('https:') ? item.thumb : `https:${item.thumb}`; const description: string | undefined = renderDescription({ diff --git a/lib/routes/picnob.info/user.ts b/lib/routes/picnob.info/user.ts index d9fc359b99..4160f53ca4 100644 --- a/lib/routes/picnob.info/user.ts +++ b/lib/routes/picnob.info/user.ts @@ -42,7 +42,7 @@ export const route: Route = { const renderVideo = (video, poster) => ``; const renderImage = (src) => ``; const renderDescription = (type: Post['postType'], item: Post | Story) => { - let media = ''; + let media: string; switch (type) { case 'carousel': media = item.albumItems diff --git a/lib/routes/pikabu/utils.ts b/lib/routes/pikabu/utils.ts index db1cc27f5b..c279a2ef76 100644 --- a/lib/routes/pikabu/utils.ts +++ b/lib/routes/pikabu/utils.ts @@ -19,7 +19,7 @@ const fixVideo = (element) => { .attr('style') .match(/url\((.+)\);/)[1]; const dataType = element.attr('data-type'); - let videoHtml = ''; + let videoHtml: string; if (dataType === 'video') { const videoId = element.attr('data-source').match(/\/embed\/(.+)$/)[1]; diff --git a/lib/routes/pingwest/user.ts b/lib/routes/pingwest/user.ts index 0cdd51c9cc..3fe00a1a8e 100644 --- a/lib/routes/pingwest/user.ts +++ b/lib/routes/pingwest/user.ts @@ -71,7 +71,7 @@ async function handler(ctx) { }); const $ = load(response.data.data.list); - let item = []; + let item: DataItem[]; const needFullText = option === 'fulltext'; switch (type) { case 'article': diff --git a/lib/routes/pixelstech/index.ts b/lib/routes/pixelstech/index.ts index 8fa99f4814..254566ad4f 100644 --- a/lib/routes/pixelstech/index.ts +++ b/lib/routes/pixelstech/index.ts @@ -22,9 +22,7 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(response); const language = $('html').attr('lang') ?? 'en'; - let items: DataItem[] = []; - - items = $('div.feed-item') + let items: DataItem[] = $('div.feed-item') .slice(0, limit) .toArray() .map((el): Element => { diff --git a/lib/routes/pixiv/novel-api/content/utils.ts b/lib/routes/pixiv/novel-api/content/utils.ts index b440798dd3..ef5ec5629f 100644 --- a/lib/routes/pixiv/novel-api/content/utils.ts +++ b/lib/routes/pixiv/novel-api/content/utils.ts @@ -131,6 +131,6 @@ export async function parseNovelContent(content: string, images: Record => { const $: CheerioAPI = load(response); const language = $('html').attr('lang') ?? 'en'; - let items: DataItem[] = []; - - items = $('table.views-table tbody tr') + let items: DataItem[] = $('table.views-table tbody tr') .slice(0, limit) .toArray() .map((el): Element => { diff --git a/lib/routes/psyche/utils.ts b/lib/routes/psyche/utils.ts index 08f35f6b04..c8dc72f17b 100644 --- a/lib/routes/psyche/utils.ts +++ b/lib/routes/psyche/utils.ts @@ -26,8 +26,8 @@ function format(article) { const type = article.type.toLowerCase(); let block = ''; - let banner = ''; - let authorsBio = ''; + let banner: string; + let authorsBio: string; switch (type) { case 'film': @@ -89,8 +89,7 @@ const getData = async (list) => { }) ); - let authors = ''; - authors = article.type === 'film' ? article.creditsShort : article.authors.map((author) => author.name).join(', '); + const authors: string = article.type === 'film' ? article.creditsShort : article.authors.map((author) => author.name).join(', '); item.description = capture.html(); item.author = authors; diff --git a/lib/routes/python/release.ts b/lib/routes/python/release.ts index d34555abbc..e55b104533 100644 --- a/lib/routes/python/release.ts +++ b/lib/routes/python/release.ts @@ -19,9 +19,7 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(response); const language = $('html').attr('lang') ?? 'en'; - let items: DataItem[] = []; - - items = $('div.active-release-list-widget ol.list-row-container li') + let items: DataItem[] = $('div.active-release-list-widget ol.list-row-container li') .slice(0, limit) .toArray() .map((el): Element => { diff --git a/lib/routes/qdu/houqin.ts b/lib/routes/qdu/houqin.ts index 2303edb7d2..d8b3adf746 100644 --- a/lib/routes/qdu/houqin.ts +++ b/lib/routes/qdu/houqin.ts @@ -48,7 +48,6 @@ async function handler() { const path = item.find('a').attr('href'); const itemUrl = base + path; return cache.tryGet(itemUrl, async () => { - let description = ''; const result = await got(itemUrl); const $ = load(result.data); if ( @@ -69,7 +68,7 @@ async function handler() { 8 ); } - description = $('.v_news_content').html().trim(); + const description = $('.v_news_content').html()?.trim(); return { title: itemTitle, diff --git a/lib/routes/qdu/jwc.ts b/lib/routes/qdu/jwc.ts index b79f98abdf..9c9714efd0 100644 --- a/lib/routes/qdu/jwc.ts +++ b/lib/routes/qdu/jwc.ts @@ -49,7 +49,7 @@ async function handler() { let itemUrl = ''; itemUrl = path.startsWith('http') ? path : base + path; return cache.tryGet(itemUrl, async () => { - let description = ''; + let description: string; if (path.startsWith('http')) { description = itemTitle; } else { diff --git a/lib/routes/qlu/notice.ts b/lib/routes/qlu/notice.ts index 7609557929..476efdc6ea 100644 --- a/lib/routes/qlu/notice.ts +++ b/lib/routes/qlu/notice.ts @@ -49,7 +49,7 @@ async function handler() { const path = item.find('.news_title').children().attr('href'); const itemUrl = path.startsWith('https') ? path : host + path; return cache.tryGet(itemUrl, async () => { - let description = ''; + let description: string; if (path.startsWith('https')) { description = itemTitle; } else { diff --git a/lib/routes/qq/lol/news.ts b/lib/routes/qq/lol/news.ts index 80dcc36b5a..7bec8ca1b0 100644 --- a/lib/routes/qq/lol/news.ts +++ b/lib/routes/qq/lol/news.ts @@ -34,9 +34,7 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(iconv.decode(Buffer.from(targetResponse), 'gbk')); const language = $('html').attr('lang') ?? 'zh-CN'; - let items: DataItem[] = []; - - items = response.data.result.slice(0, limit).map((item): DataItem => { + let items: DataItem[] = response.data.result.slice(0, limit).map((item): DataItem => { const title: string = item.sTitle; const pubDate: number | string = item.sCreated; const linkUrl: string | undefined = item.iDocID ? `${item.iVideoId ? 'v/v2' : 'news'}/detail.shtml?docid=${item.iDocID}` : undefined; diff --git a/lib/routes/qq/pd/guild.ts b/lib/routes/qq/pd/guild.ts index 9bbfddcf74..a56733d7bb 100644 --- a/lib/routes/qq/pd/guild.ts +++ b/lib/routes/qq/pd/guild.ts @@ -56,7 +56,7 @@ async function handler(ctx: Context): Promise { } const sortType = sortMap[sort]; - let url = ''; + let url: string; let body = {}; let headers = {}; diff --git a/lib/routes/qq/pd/utils.ts b/lib/routes/qq/pd/utils.ts index 988b1b5c0d..9ebdf4abc1 100644 --- a/lib/routes/qq/pd/utils.ts +++ b/lib/routes/qq/pd/utils.ts @@ -37,7 +37,7 @@ function parseText(text: string, props: FeedFontProps | undefined): string { } function parseDataItem(item: FeedPatternData, texts: string[], images: { [id: string]: FeedImage }): string { - let imageId = ''; + let imageId: string; switch (patternTypeMap[item.type] || undefined) { case 'text': return parseText(texts.shift() ?? '', item.props); diff --git a/lib/routes/raspberrypi/magazine.ts b/lib/routes/raspberrypi/magazine.ts index 666abd7779..9490a0d845 100644 --- a/lib/routes/raspberrypi/magazine.ts +++ b/lib/routes/raspberrypi/magazine.ts @@ -21,11 +21,9 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(response); const language = $('html').attr('lang') ?? 'en'; - let items: DataItem[] = []; - const author: DataItem['author'] = $('meta[property="og:site_name"]').attr('content'); - items = $('div.o-grid--equal div.o-grid__col') + let items: DataItem[] = $('div.o-grid--equal div.o-grid__col') .slice(0, limit) .toArray() .map((el): Element => { diff --git a/lib/routes/rockthejvm/articles.ts b/lib/routes/rockthejvm/articles.ts index a75dc0df63..68a2d6df81 100644 --- a/lib/routes/rockthejvm/articles.ts +++ b/lib/routes/rockthejvm/articles.ts @@ -23,9 +23,7 @@ export const handler = async (ctx: Context): Promise => { $('footer').remove(); - let items: DataItem[] = []; - - items = $('h2') + let items: DataItem[] = $('h2') .slice(0, limit) .toArray() .map((el): Element => { diff --git a/lib/routes/samrdprc/index.ts b/lib/routes/samrdprc/index.ts index 38da5cd8ab..eca84611e4 100644 --- a/lib/routes/samrdprc/index.ts +++ b/lib/routes/samrdprc/index.ts @@ -20,9 +20,7 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(response); const language = $('html').attr('lang') ?? 'zh'; - let items: DataItem[] = []; - - items = $('div.boxl_ul ul li') + let items: DataItem[] = $('div.boxl_ul ul li') .slice(0, limit) .toArray() .map((el): Element => { diff --git a/lib/routes/sass/gs/index.ts b/lib/routes/sass/gs/index.ts index c3ea0e9ebf..4bda148e53 100644 --- a/lib/routes/sass/gs/index.ts +++ b/lib/routes/sass/gs/index.ts @@ -48,7 +48,7 @@ async function handler(ctx) { const itemUrl = path.startsWith('http') ? path : host + path; return cache.tryGet(itemUrl, async () => { - let description = ''; + let description: string; if (itemUrl) { const result = await got(itemUrl); const $ = load(result.data); diff --git a/lib/routes/sciencedirect/call-for-paper.tsx b/lib/routes/sciencedirect/call-for-paper.tsx index d43200ef0d..f1903b0b46 100644 --- a/lib/routes/sciencedirect/call-for-paper.tsx +++ b/lib/routes/sciencedirect/call-for-paper.tsx @@ -42,7 +42,7 @@ async function handler(ctx) { try { data = JSON.parse(JSON.parse(scriptJSON)); } catch (error: any) { - throw new Error(`Failed to parse embedded script JSON: ${error.message}`); + throw new Error(`Failed to parse embedded script JSON: ${error.message}`, { cause: error }); } const cfpList = data?.callsForPapers?.list || []; diff --git a/lib/routes/scientificamerican/podcast.ts b/lib/routes/scientificamerican/podcast.ts index 6a65d41537..b4d24e6c3a 100644 --- a/lib/routes/scientificamerican/podcast.ts +++ b/lib/routes/scientificamerican/podcast.ts @@ -24,9 +24,7 @@ export const handler = async (ctx: Context): Promise => { const data: string | undefined = response.match(/window\.__DATA__=JSON\.parse\(`(.*?)`\)/)?.[1]; const parsedData = data ? JSON.parse(data.replaceAll('\\\\', '\\')) : undefined; - let items: DataItem[] = []; - - items = parsedData + let items: DataItem[] = parsedData ? parsedData.initialData.props.results.slice(0, limit).map((item): DataItem => { const title: string = item.title; const image: string | undefined = item.image_url; diff --git a/lib/routes/scoop/apps.tsx b/lib/routes/scoop/apps.tsx index e5e9dc32de..6d7cefa875 100644 --- a/lib/routes/scoop/apps.tsx +++ b/lib/routes/scoop/apps.tsx @@ -92,9 +92,7 @@ export const handler = async (ctx: Context): Promise => { }, }); - let items: DataItem[] = []; - - items = response.value.slice(0, limit).map((item): DataItem => { + const items: DataItem[] = response.value.slice(0, limit).map((item): DataItem => { const repositorySplits: string[] = item.Metadata.Repository.split(/\//); const repositoryName: string = repositorySplits.slice(-2).join('/'); const title = `${item.Name} ${item.Version} in ${repositoryName}`; diff --git a/lib/routes/scpta/news.ts b/lib/routes/scpta/news.ts index 90003dab1f..1a8696e912 100644 --- a/lib/routes/scpta/news.ts +++ b/lib/routes/scpta/news.ts @@ -68,7 +68,7 @@ async function handler(ctx) { const items = await Promise.all( list.map((item) => cache.tryGet(item.link, async () => { - let description = ''; + let description: string; try { const contentResponse = await got(item.link); const content = load(contentResponse.data); diff --git a/lib/routes/sdo/ff14risingstones/utils.tsx b/lib/routes/sdo/ff14risingstones/utils.tsx index 0d937660a2..8839437e19 100644 --- a/lib/routes/sdo/ff14risingstones/utils.tsx +++ b/lib/routes/sdo/ff14risingstones/utils.tsx @@ -159,7 +159,7 @@ export async function generateDynamicFeeds(dynamics: UserDynamic[]) { let title = `${dynamic.character_name}@${dynamic.group_name} ${dynamic.mask_content}`; let link: string | undefined; let description: string | undefined; - let detail: PostDetail | DutiesPartyDetail | FreeCompanyPartyDetail | NoviceNetworkParty | null = null; + let detail: PostDetail | DutiesPartyDetail | FreeCompanyPartyDetail | NoviceNetworkParty | null; switch (dynamic.from) { case DynamicSource.Post: diff --git a/lib/routes/sega/pjsekai.ts b/lib/routes/sega/pjsekai.ts index 3e164b46c8..3bcf376602 100644 --- a/lib/routes/sega/pjsekai.ts +++ b/lib/routes/sega/pjsekai.ts @@ -35,8 +35,8 @@ async function handler() { const posts = response.data || []; const list = await Promise.all( posts.map(async (post) => { - let link = ''; - let description = ''; + let link: string; + let description: string; const guid = post.displayOrder.toString() + post.id.toString(); // 双ID if (post.path.startsWith('information/')) { // information 公告 diff --git a/lib/routes/semiconductors/index.ts b/lib/routes/semiconductors/index.ts index 3790a62bdb..3fc271130d 100644 --- a/lib/routes/semiconductors/index.ts +++ b/lib/routes/semiconductors/index.ts @@ -22,9 +22,7 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(response); const language = $('html').attr('lang') ?? 'en'; - let items: DataItem[] = []; - - items = $('div.col-sm-8') + let items: DataItem[] = $('div.col-sm-8') .slice(0, limit) .toArray() .map((el): Element => { diff --git a/lib/routes/setn/index.ts b/lib/routes/setn/index.ts index 952012c7d2..e89573d4ba 100644 --- a/lib/routes/setn/index.ts +++ b/lib/routes/setn/index.ts @@ -120,7 +120,7 @@ async function handler(ctx) { const content = load(detailResponse.data); - let head = {}; + let head: Record; try { head = JSON.parse(content('script[type="application/ld+json"]').first().text()); } catch { diff --git a/lib/routes/sspai/series-update.ts b/lib/routes/sspai/series-update.ts index 62f8638a28..c57a9ee5e5 100644 --- a/lib/routes/sspai/series-update.ts +++ b/lib/routes/sspai/series-update.ts @@ -34,7 +34,7 @@ async function handler(ctx) { const items = await Promise.all( response.data.data.map(async (item) => { - let description = ''; + let description: string; if (item.probation) { const res = await got(`https://sspai.com/api/v1/article/info/get?id=${item.id}&view=second&support_webp=true`); description = res.data.data.body; diff --git a/lib/routes/stcn/index.ts b/lib/routes/stcn/index.ts index 9fd2a955e8..9f9b2b20d4 100644 --- a/lib/routes/stcn/index.ts +++ b/lib/routes/stcn/index.ts @@ -21,9 +21,7 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(response); const language = $('html').attr('lang') ?? 'zh-CN'; - let items: DataItem[] = []; - - items = $('ul.infinite-list li') + let items: DataItem[] = $('ul.infinite-list li') .slice(0, limit) .toArray() .map((el): Element => { diff --git a/lib/routes/stcn/kx.ts b/lib/routes/stcn/kx.ts index e3766fc82c..d580f65bd3 100644 --- a/lib/routes/stcn/kx.ts +++ b/lib/routes/stcn/kx.ts @@ -30,9 +30,7 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(targetResponse); const language = $('html').attr('lang') ?? 'zh-CN'; - let items: DataItem[] = []; - - items = response.data.slice(0, limit).map((item): DataItem => { + let items: DataItem[] = response.data.slice(0, limit).map((item): DataItem => { const title: string = item.title; const description: string = item.content; const pubDate: number | string = item.time; diff --git a/lib/routes/stcn/rank.ts b/lib/routes/stcn/rank.ts index 6671db552e..9ad5abc95d 100644 --- a/lib/routes/stcn/rank.ts +++ b/lib/routes/stcn/rank.ts @@ -30,9 +30,7 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(targetResponse); const language = $('html').attr('lang') ?? 'zh-CN'; - let items: DataItem[] = []; - - items = response.data.slice(0, limit).map((item): DataItem => { + let items: DataItem[] = response.data.slice(0, limit).map((item): DataItem => { const title: string = item.title; const linkUrl: string | undefined = item.url; diff --git a/lib/routes/surfshark/blog.ts b/lib/routes/surfshark/blog.ts index bf95e8c50b..bc3de6db6d 100644 --- a/lib/routes/surfshark/blog.ts +++ b/lib/routes/surfshark/blog.ts @@ -31,9 +31,7 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(response); const language = $('html').attr('lang') ?? 'en'; - let items: DataItem[] = []; - - items = $('div.dg-article-single-card') + let items: DataItem[] = $('div.dg-article-single-card') .slice(0, limit) .toArray() .map((el): Element => { diff --git a/lib/routes/taobao/mysql.ts b/lib/routes/taobao/mysql.ts index e516ddaa00..b545430bd2 100644 --- a/lib/routes/taobao/mysql.ts +++ b/lib/routes/taobao/mysql.ts @@ -19,10 +19,9 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(response); const language = $('html').attr('lang') ?? 'zh'; - let items: DataItem[] = []; let count = 0; - items = await Promise.all( + let items: DataItem[] = await Promise.all( $('h3 a.main') .toArray() .map(async (monthlyEl): Promise => { diff --git a/lib/routes/tencent/news/coronavirus/data.tsx b/lib/routes/tencent/news/coronavirus/data.tsx index cfec69ede6..392a04c89d 100644 --- a/lib/routes/tencent/news/coronavirus/data.tsx +++ b/lib/routes/tencent/news/coronavirus/data.tsx @@ -25,12 +25,8 @@ async function handler(ctx) { const nationalData = areaTree?.[0]; const provinceList = nationalData?.children; - let todayConfirm = 0; - let totalNowConfirm = 0; - let totalConfirm = 0; - let totalDead = 0; - let coronavirusData = {}; - let placeName = ''; + let coronavirusData: Record; + let placeName: string; if (!province || province === '中国' || province === '全国') { // 没有传参则取全国 @@ -51,10 +47,10 @@ async function handler(ctx) { if (!coronavirusData) { throw new InvalidParameterError(`未找到 ${placeName} 的疫情数据,请检查输入的省市名称是否正确`); } - todayConfirm = coronavirusData.today?.confirm; - totalNowConfirm = coronavirusData.total?.nowConfirm; - totalConfirm = coronavirusData.total?.confirm; - totalDead = coronavirusData.total?.dead; + const todayConfirm = coronavirusData.today?.confirm; + const totalNowConfirm = coronavirusData.total?.nowConfirm; + const totalConfirm = coronavirusData.total?.confirm; + const totalDead = coronavirusData.total?.dead; const pubDate = parseDate(coronavirusData.total?.mtime || lastUpdateTime); const title = `${placeName} - 腾讯新闻 - 新型冠状病毒肺炎疫情实时追踪`; diff --git a/lib/routes/tencent/qq/sdk/changelog.ts b/lib/routes/tencent/qq/sdk/changelog.ts index 6ff1a0ca20..bd4fc26156 100644 --- a/lib/routes/tencent/qq/sdk/changelog.ts +++ b/lib/routes/tencent/qq/sdk/changelog.ts @@ -25,8 +25,8 @@ export const route: Route = { async function handler(ctx) { const platform = ctx.req.param('platform'); - let title = ''; - let link = ''; + let title: string; + let link: string; if (platform === 'iOS') { title = 'iOS SDK 历史变更'; link = 'https://wiki.connect.qq.com/ios_sdk历史变更'; diff --git a/lib/routes/thebrain/blog.tsx b/lib/routes/thebrain/blog.tsx index 1d8588207d..85a882ddc1 100644 --- a/lib/routes/thebrain/blog.tsx +++ b/lib/routes/thebrain/blog.tsx @@ -21,9 +21,7 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(response); const language = $('html').attr('lang') ?? 'en'; - let items: DataItem[] = []; - - items = $('div.blog-row') + let items: DataItem[] = $('div.blog-row') .slice(0, limit) .toArray() .map((el): Element => { diff --git a/lib/routes/tidb/blog.ts b/lib/routes/tidb/blog.ts index 0001a58638..c62845f2ee 100644 --- a/lib/routes/tidb/blog.ts +++ b/lib/routes/tidb/blog.ts @@ -87,9 +87,7 @@ export const handler = async (ctx: Context): Promise => { }, }); - let items: DataItem[] = []; - - items = response.pageProps.blogs.content.slice(0, limit).map((item): DataItem => { + let items: DataItem[] = response.pageProps.blogs.content.slice(0, limit).map((item): DataItem => { const title: string = item.title; const description: string | undefined = item.summary; const pubDate: number | string = item.publishedAt; diff --git a/lib/routes/tju/cic/index.ts b/lib/routes/tju/cic/index.ts index 6ce3a999b7..21e80d4ef5 100644 --- a/lib/routes/tju/cic/index.ts +++ b/lib/routes/tju/cic/index.ts @@ -104,9 +104,8 @@ async function handler(ctx) { case 'tju-cic': case 'in-site': return cache.tryGet(item.link, async () => { - let detailResponse = null; try { - detailResponse = await got(item.link); + const detailResponse = await got(item.link); const content = load(detailResponse.data); item.pubDate = timezone(parseDate(content('.news_info > span').first().text(), 'YYYY年MM月DD日 HH:mm'), +8); content('.news_tit').remove(); diff --git a/lib/routes/tju/news/index.ts b/lib/routes/tju/news/index.ts index e5d0b116fa..a90598c58e 100644 --- a/lib/routes/tju/news/index.ts +++ b/lib/routes/tju/news/index.ts @@ -116,10 +116,9 @@ async function handler(ctx) { case 'tju-news': case 'in-site': return cache.tryGet(item.link, async () => { - let detailResponse = null; try { delete item.type; - detailResponse = await got(item.link); + const detailResponse = await got(item.link); const content = load(detailResponse.data); item.pubDate = timezone( parseDate( diff --git a/lib/routes/tju/oaa/index.ts b/lib/routes/tju/oaa/index.ts index 90e9420c4c..ea1da97f1b 100644 --- a/lib/routes/tju/oaa/index.ts +++ b/lib/routes/tju/oaa/index.ts @@ -110,9 +110,8 @@ async function handler(ctx) { case 'tju-oaa': case 'in-site': return cache.tryGet(item.link, async () => { - let detailResponse = null; try { - detailResponse = await got(item.link); + const detailResponse = await got(item.link); const content = load(detailResponse.data); item.description = content('.v_news_content').html(); } catch { diff --git a/lib/routes/tju/yzb/index.ts b/lib/routes/tju/yzb/index.ts index 8f7f6147d0..e383912409 100644 --- a/lib/routes/tju/yzb/index.ts +++ b/lib/routes/tju/yzb/index.ts @@ -114,9 +114,8 @@ async function handler(ctx) { case 'tju-yzb': case 'in-site': return cache.tryGet(item.link, async () => { - let detailResponse = null; try { - detailResponse = await got(item.link, { responseType: 'buffer' }); + const detailResponse = await got(item.link, { responseType: 'buffer' }); const content = load(iconv.decode(detailResponse.data, 'gbk')); content('.font_18_b').remove(); content('.font_grey_en').remove(); diff --git a/lib/routes/tmtpost/util.ts b/lib/routes/tmtpost/util.ts index 14290bb318..622e5d9f33 100644 --- a/lib/routes/tmtpost/util.ts +++ b/lib/routes/tmtpost/util.ts @@ -29,9 +29,7 @@ const processItems = async (limit: number, query: Record, apiUrl: s const $: CheerioAPI = load(targetResponse); const language = $('html').attr('lang') ?? 'zh-CN'; - let items: DataItem[] = []; - - items = response.data.slice(0, limit).map((item): DataItem => { + let items: DataItem[] = response.data.slice(0, limit).map((item): DataItem => { const title: string = item.title; const description: string = renderDescription({ intro: item.summary, diff --git a/lib/routes/twitter/utils.ts b/lib/routes/twitter/utils.ts index 179a1458c9..45b05d422b 100644 --- a/lib/routes/twitter/utils.ts +++ b/lib/routes/twitter/utils.ts @@ -4,7 +4,7 @@ import { fallback, queryToBoolean, queryToInteger } from '@/utils/readable-socia const getQueryParams = (url) => Object.fromEntries(new URL(url).searchParams.entries()); const getOriginalImg = (url) => { // https://greasyfork.org/zh-CN/scripts/2312-resize-image-on-open-image-in-new-tab/code#n150 - let m = null; + let m: RegExpMatchArray | null; if ((m = url.match(/^(https?:\/\/\w+\.twimg\.com\/media\/[^/:]+)\.(jpg|jpeg|gif|png|bmp|webp)(:\w+)?$/i))) { let format = m[2]; if (m[2] === 'jpeg') { diff --git a/lib/routes/twreporter/fetch-article.ts b/lib/routes/twreporter/fetch-article.ts index 450407635b..7a16cc8d5b 100644 --- a/lib/routes/twreporter/fetch-article.ts +++ b/lib/routes/twreporter/fetch-article.ts @@ -17,7 +17,7 @@ export default async function fetch(slug: string) { } // For `photography`, if it exists - let photographers = ''; + let photographers: string; if (post.photographers) { photographers = post.photographers .map((photographer) => { diff --git a/lib/routes/uraaka-joshi/uraaka-joshi-user.ts b/lib/routes/uraaka-joshi/uraaka-joshi-user.ts index 51933cbd90..aa7cad586a 100644 --- a/lib/routes/uraaka-joshi/uraaka-joshi-user.ts +++ b/lib/routes/uraaka-joshi/uraaka-joshi-user.ts @@ -50,7 +50,7 @@ async function handler(ctx) { } }); - let html = ''; + let html: string; try { await page.goto(link, { waitUntil: 'domcontentloaded', diff --git a/lib/routes/uraaka-joshi/uraaka-joshi.ts b/lib/routes/uraaka-joshi/uraaka-joshi.ts index e10b6ab8a4..1aef1cf8d7 100644 --- a/lib/routes/uraaka-joshi/uraaka-joshi.ts +++ b/lib/routes/uraaka-joshi/uraaka-joshi.ts @@ -38,7 +38,7 @@ async function handler() { } }); - let html = ''; + let html: string; try { await page.goto(link, { waitUntil: 'domcontentloaded', diff --git a/lib/routes/ustc/eeis.ts b/lib/routes/ustc/eeis.ts index f0f29b98d3..720ac4746c 100644 --- a/lib/routes/ustc/eeis.ts +++ b/lib/routes/ustc/eeis.ts @@ -71,7 +71,7 @@ async function handler(ctx) { const items = await Promise.all( list.map((item) => cache.tryGet(item.link, async () => { - let desc = ''; + let desc: string; try { const response = await got(item.link); desc = load(response.data)('div.wp_articlecontent').html(); diff --git a/lib/routes/ustc/gs.ts b/lib/routes/ustc/gs.ts index 4db48abd31..6b88fa1577 100644 --- a/lib/routes/ustc/gs.ts +++ b/lib/routes/ustc/gs.ts @@ -70,7 +70,7 @@ async function handler(ctx) { items = await Promise.all( items.map((item) => cache.tryGet(item.link, async () => { - let desc = ''; + let desc: string; try { const response = await got(item.link); desc = load(response.data)('article.article').html(); diff --git a/lib/routes/ustc/math.ts b/lib/routes/ustc/math.ts index 4b216dd9f1..d95b8dc01e 100644 --- a/lib/routes/ustc/math.ts +++ b/lib/routes/ustc/math.ts @@ -74,7 +74,7 @@ async function handler(ctx) { items = await Promise.all( items.map((item) => cache.tryGet(item.link, async () => { - let desc = ''; + let desc: string; try { const response = await got(item.link); desc = load(response.data)('div.wp_articlecontent').html(); diff --git a/lib/routes/ustc/scms.ts b/lib/routes/ustc/scms.ts index 0195aad6c2..da9bfef35c 100644 --- a/lib/routes/ustc/scms.ts +++ b/lib/routes/ustc/scms.ts @@ -77,7 +77,7 @@ async function handler(ctx) { items = await Promise.all( items.map((item) => cache.tryGet(item.link, async () => { - let desc = ''; + let desc: string; try { const response = await got(item.link); desc = load(response.data)('div.wp_articlecontent').html(); diff --git a/lib/routes/ustc/sist.ts b/lib/routes/ustc/sist.ts index bd9a0e4a50..2246674f2e 100644 --- a/lib/routes/ustc/sist.ts +++ b/lib/routes/ustc/sist.ts @@ -71,7 +71,7 @@ async function handler(ctx) { items = await Promise.all( items.map((item) => cache.tryGet(item.link, async () => { - let desc = ''; + let desc: string; try { const response = await got(item.link); desc = load(response.data)('div.wp_articlecontent').html(); diff --git a/lib/routes/wainao/topics.tsx b/lib/routes/wainao/topics.tsx index 0383f03312..1d935b9f3a 100644 --- a/lib/routes/wainao/topics.tsx +++ b/lib/routes/wainao/topics.tsx @@ -50,9 +50,7 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(targetResponse); const language = $('html').attr('lang') ?? 'zh-CN'; - let items: DataItem[] = []; - - items = response.content_elements + const items: DataItem[] = response.content_elements .slice(0, limit) .map((item): DataItem => { const title: string = item.headlines.basic; diff --git a/lib/routes/wdfxw/bookfree.tsx b/lib/routes/wdfxw/bookfree.tsx index 9a6c78ddfc..417baad910 100644 --- a/lib/routes/wdfxw/bookfree.tsx +++ b/lib/routes/wdfxw/bookfree.tsx @@ -21,9 +21,7 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(response); const language = $('meta[http-equiv="Content-Language"]').attr('content') ?? 'zh-cn'; - let items: DataItem[] = []; - - items = $('ul.camWholeBoxUl li') + let items: DataItem[] = $('ul.camWholeBoxUl li') .slice(0, limit) .toArray() .map((el): Element => { diff --git a/lib/routes/weibo/search/hot.tsx b/lib/routes/weibo/search/hot.tsx index f2b1042ab3..25abbc8163 100644 --- a/lib/routes/weibo/search/hot.tsx +++ b/lib/routes/weibo/search/hot.tsx @@ -3,7 +3,7 @@ import { raw } from 'hono/html'; import { renderToString } from 'hono/jsx/dom/server'; import { config } from '@/config'; -import type { Route } from '@/types'; +import type { DataItem, Route } from '@/types'; import { ViewType } from '@/types'; import cache from '@/utils/cache'; import got from '@/utils/got'; @@ -72,7 +72,7 @@ async function handler(ctx) { return _r; }); - let resultItems = null; + let resultItems: DataItem[]; if (ctx.req.param('fulltext') === 'fulltext') { const cardslist = data.cards[0].card_group; // Topic List diff --git a/lib/routes/whu/rsgis.ts b/lib/routes/whu/rsgis.ts index f9966ce0a7..c1cb00755d 100644 --- a/lib/routes/whu/rsgis.ts +++ b/lib/routes/whu/rsgis.ts @@ -255,7 +255,7 @@ export const route: Route = { `, handler: async (ctx: Context) => { const { type = 'index', sub = 'all' } = ctx.req.param(); - let itemList: DataItem[] = []; + let itemList: DataItem[]; switch (type) { case 'index': itemList = await handleIndex(); diff --git a/lib/routes/wikipedia/current-events.ts b/lib/routes/wikipedia/current-events.ts index c10ec147f5..8ae433d945 100644 --- a/lib/routes/wikipedia/current-events.ts +++ b/lib/routes/wikipedia/current-events.ts @@ -398,7 +398,7 @@ async function handler(ctx) { }; } catch (error) { const message = error instanceof Error ? error.message : String(error); - throw new Error(`Failed to fetch Wikipedia current events: ${message}`); + throw new Error(`Failed to fetch Wikipedia current events: ${message}`, { cause: error }); } } function determineDates(includeToday: any) { diff --git a/lib/routes/x410/news.ts b/lib/routes/x410/news.ts index 6f41f719f1..ed6b84f751 100644 --- a/lib/routes/x410/news.ts +++ b/lib/routes/x410/news.ts @@ -21,9 +21,7 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(response); const language = $('html').attr('lang') ?? 'en'; - let items: DataItem[] = []; - - items = $('article.post') + let items: DataItem[] = $('article.post') .slice(0, limit) .toArray() .map((el): Element => { diff --git a/lib/routes/xbmu/academic.ts b/lib/routes/xbmu/academic.ts index 797852af12..d824e55b44 100644 --- a/lib/routes/xbmu/academic.ts +++ b/lib/routes/xbmu/academic.ts @@ -70,7 +70,7 @@ const handler: Route['handler'] = async () => { id: 'https://rsshub.app/xbmu/academic', }; } catch (error) { - throw new Error(`Error fetching academic information: ${error}`); + throw new Error(`Error fetching academic information: ${error}`, { cause: error }); } }; diff --git a/lib/routes/xbmu/announcement.ts b/lib/routes/xbmu/announcement.ts index 5c5ff50e3d..8fcd834b59 100644 --- a/lib/routes/xbmu/announcement.ts +++ b/lib/routes/xbmu/announcement.ts @@ -70,7 +70,7 @@ const handler: Route['handler'] = async () => { id: 'https://rsshub.app/xbmu/announcement', }; } catch (error) { - throw new Error(`Error fetching announcements: ${error}`); + throw new Error(`Error fetching announcements: ${error}`, { cause: error }); } }; diff --git a/lib/routes/xianbao/index.ts b/lib/routes/xianbao/index.ts index 20864188f7..fc77de5efa 100644 --- a/lib/routes/xianbao/index.ts +++ b/lib/routes/xianbao/index.ts @@ -64,7 +64,7 @@ export const route: Route = { async function handler(ctx) { const categoryParam = ctx.req.param() || { category: 'latest' }; - let urlPath = ''; + let urlPath: string; const category = categoryParam.category || 'latest'; diff --git a/lib/routes/xjtu/zs.ts b/lib/routes/xjtu/zs.ts index 49bbb81f7d..edf32ef009 100644 --- a/lib/routes/xjtu/zs.ts +++ b/lib/routes/xjtu/zs.ts @@ -21,9 +21,7 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(response); const language = $('html').attr('lang') ?? 'zh'; - let items: DataItem[] = []; - - items = $('section.TextList ul li') + let items: DataItem[] = $('section.TextList ul li') .slice(0, limit) .toArray() .map((el): Element => { diff --git a/lib/routes/yamibo/utils.ts b/lib/routes/yamibo/utils.ts index 354cda6512..437d5d14a1 100644 --- a/lib/routes/yamibo/utils.ts +++ b/lib/routes/yamibo/utils.ts @@ -79,7 +79,7 @@ export async function fetchThread( }; } } - return await fetchThread(tid, options, ++retry); + return await fetchThread(tid, options, retry + 1); } return { diff --git a/lib/routes/ynet/list.ts b/lib/routes/ynet/list.ts index 35fd9c9646..fb92d0ed35 100644 --- a/lib/routes/ynet/list.ts +++ b/lib/routes/ynet/list.ts @@ -62,9 +62,7 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(response); const language = $('html').attr('lang') ?? 'zh'; - let items: DataItem[] = []; - - items = $('li.cfix') + let items: DataItem[] = $('li.cfix') .slice(0, limit) .toArray() .map((el): Element => { diff --git a/lib/routes/yuque/utils.ts b/lib/routes/yuque/utils.ts index 58d719964b..44f4f4953a 100644 --- a/lib/routes/yuque/utils.ts +++ b/lib/routes/yuque/utils.ts @@ -2,7 +2,7 @@ const card2Html = (elem, link) => { const name = elem.attr('name'); const data = elem.attr('value')?.split('data:')[1]?.replace('undefined', ''); const value = JSON.parse(decodeURIComponent(data || '[]')); - let html = ''; + let html: string; switch (name) { case 'board': case 'emoji': diff --git a/lib/routes/zhibo8/more.ts b/lib/routes/zhibo8/more.ts index 3a8f678185..9d57a993c8 100644 --- a/lib/routes/zhibo8/more.ts +++ b/lib/routes/zhibo8/more.ts @@ -46,10 +46,10 @@ async function handler(ctx) { const rootUrl = 'https://news.zhibo8.cc'; - let list, - apiUrl = '', - currentUrl = '', - response; + let list; + let apiUrl: string; + let currentUrl: string; + let response; if (category === 'nba' || category === 'zuqiu') { currentUrl = `${rootUrl}/${category}/more.htm`; diff --git a/lib/routes/zhihu/topic.ts b/lib/routes/zhihu/topic.ts index da7fb17326..3ced96358b 100644 --- a/lib/routes/zhihu/topic.ts +++ b/lib/routes/zhihu/topic.ts @@ -62,7 +62,7 @@ async function handler(ctx) { const items = response.data.map(({ target: item }) => { const type = item.type; let title = ''; - let description = ''; + let description: string; let link = ''; let pubDate: Date; let author = ''; diff --git a/lib/routes/zhihu/xhu/collection.ts b/lib/routes/zhihu/xhu/collection.ts index 66495d08eb..b1f82e52c9 100644 --- a/lib/routes/zhihu/xhu/collection.ts +++ b/lib/routes/zhihu/xhu/collection.ts @@ -60,8 +60,8 @@ async function handler(ctx) { const link = item.url; const author = item.author.name; const pubDate = parseDate(item.collect_time * 1000); - let title = ''; - let description = ''; + let title: string; + let description: string; // This API gets only article, answer and pin, not zvideo switch (item.type) { diff --git a/lib/routes/zhihu/xhu/topic.ts b/lib/routes/zhihu/xhu/topic.ts index 3fa7a44ee3..74d9121ee7 100644 --- a/lib/routes/zhihu/xhu/topic.ts +++ b/lib/routes/zhihu/xhu/topic.ts @@ -49,11 +49,11 @@ async function handler(ctx) { link, item: listRes.map(({ target: item }) => { const type = item.type; - let title = ''; - let description = ''; - let link = ''; - let pubDate = new Date(); - let author = ''; + let title: string; + let description: string; + let link: string; + let pubDate: Date; + let author: string; switch (type) { case 'answer': diff --git a/lib/routes/zhihu/xhu/zhuanlan.ts b/lib/routes/zhihu/xhu/zhuanlan.ts index b31f35d913..849f056102 100644 --- a/lib/routes/zhihu/xhu/zhuanlan.ts +++ b/lib/routes/zhihu/xhu/zhuanlan.ts @@ -67,9 +67,9 @@ async function handler(ctx) { description = $.html(); } - let title = ''; - let link = ''; - let author = ''; + let title: string; + let link: string; + let author: string; let pubDate; // The xhu api only get items of type article. diff --git a/lib/routes/zhihu/zhuanlan.ts b/lib/routes/zhihu/zhuanlan.ts index 8ae250a839..d100d28539 100644 --- a/lib/routes/zhihu/zhuanlan.ts +++ b/lib/routes/zhihu/zhuanlan.ts @@ -83,9 +83,9 @@ async function handler(ctx) { } $('img').css('max-width', '100%'); - let title = ''; - let link = ''; - let author = ''; + let title: string; + let link: string; + let author: string; let pubDate: Date; switch (item.type) { diff --git a/lib/routes/zsxq/utils.ts b/lib/routes/zsxq/utils.ts index 570e27854d..00e08fcf5f 100644 --- a/lib/routes/zsxq/utils.ts +++ b/lib/routes/zsxq/utils.ts @@ -19,7 +19,7 @@ export async function customFetch>(path: s } // sometimes the request will fail with code 1059, retry will solve the problem if (code === 1059 && retryCount < 3) { - return customFetch(path, ++retryCount); + return customFetch(path, retryCount + 1); } throw new Error('something wrong'); } diff --git a/scripts/workflow/test-route/identify.mjs b/scripts/workflow/test-route/identify.mjs index 6d7b4990cf..ffb7f8e81e 100644 --- a/scripts/workflow/test-route/identify.mjs +++ b/scripts/workflow/test-route/identify.mjs @@ -10,7 +10,7 @@ export default async function identify({ github, context, core }, body, number, const bodyNoCmts = body?.replaceAll(//g, ''); const m = bodyNoCmts?.match(/```routes\s+([\S\s]*?)```/); core.debug(`match: ${m}`); - let routes = null; + let routes; const issueFacts = { owner: context.repo.owner,