diff --git a/eslint.config.mjs b/eslint.config.mjs index 9839ce29b26a51..5352672f9e9263 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -29,7 +29,7 @@ export default [ { ignores: ['**/coverage', '**/.vscode', '**/docker-compose.yml', '!.github', 'assets/build', 'lib/routes-deprecated', 'lib/router.js', '**/babel.config.js', 'scripts/docker/minify-docker.js', 'dist', 'dist-lib'], }, - ...compat.extends('eslint:recommended', 'plugin:yml/recommended', 'plugin:@typescript-eslint/recommended'), + ...compat.extends('eslint:recommended', 'plugin:yml/recommended', 'plugin:@typescript-eslint/recommended', 'plugin:@typescript-eslint/stylistic'), n.configs['flat/recommended-script'], unicorn.configs.recommended, { @@ -147,8 +147,16 @@ export default [ 'require-await': 'error', // typescript + '@typescript-eslint/array-type': ['error', { default: 'array-simple' }], + '@typescript-eslint/ban-ts-comment': 'off', + '@typescript-eslint/consistent-indexed-object-style': 'off', // stylistic + '@typescript-eslint/consistent-type-definitions': 'off', // stylistic + '@typescript-eslint/no-empty-function': 'off', // stylistic && tests '@typescript-eslint/no-explicit-any': 'off', + + '@typescript-eslint/no-inferrable-types': ['error', { ignoreParameters: true, ignoreProperties: true }], + '@typescript-eslint/no-var-requires': 'off', '@typescript-eslint/no-unused-expressions': [ @@ -167,6 +175,8 @@ export default [ }, ], + '@typescript-eslint/prefer-for-of': 'error', + // unicorn 'unicorn/consistent-function-scoping': 'warn', 'unicorn/explicit-length-check': 'off', @@ -184,6 +194,7 @@ export default [ 'unicorn/no-array-sort': 'warn', 'unicorn/no-await-expression-member': 'off', 'unicorn/no-empty-file': 'warn', + 'unicorn/no-for-loop': 'off', 'unicorn/no-hex-escape': 'warn', 'unicorn/no-null': 'off', 'unicorn/no-object-as-default-parameter': 'warn', diff --git a/lib/registry.ts b/lib/registry.ts index 0d7b5ca3b3dfe9..452cdd2b649bb6 100644 --- a/lib/registry.ts +++ b/lib/registry.ts @@ -223,13 +223,13 @@ for (const namespace in namespaces) { continue; } - const sortedRoutes = Object.entries(namespaceData.apiRoutes) as [ + const sortedRoutes = Object.entries(namespaceData.apiRoutes) as Array<[ string, APIRoute & { location: string; module?: () => Promise<{ apiRoute: APIRoute }>; }, - ][]; + ]>; for (const [path, routeData] of sortedRoutes) { const wrappedHandler: Handler = async (ctx) => { diff --git a/lib/routes-deprecated/lolapp/article.js b/lib/routes-deprecated/lolapp/article.js index 0128ec67b71353..3eff4f9fc01089 100644 --- a/lib/routes-deprecated/lolapp/article.js +++ b/lib/routes-deprecated/lolapp/article.js @@ -10,8 +10,8 @@ module.exports = async (ctx) => { const name = data[0].feedNews.footer.source; const newData = []; let pubDate = []; - for (const [i, datum] of data.entries()) { - newData[i] = datum.feedNews.body; + for (let i = 0; i < data.length; i++) { + newData[i] = data[i].feedNews.body; newData[i].link = 'https://mlol.qt.qq.com/go/mlol_news/varcache_article?is_lqt=true&docid=' + newData[i].commentID; pubDate[i] = getPublishedDate(newData[i].link); } diff --git a/lib/routes.test.ts b/lib/routes.test.ts index fc32ad7dc3fa4b..f1da8dc8dd2e38 100644 --- a/lib/routes.test.ts +++ b/lib/routes.test.ts @@ -51,7 +51,7 @@ async function checkRSS(response) { checkDate(parsed.lastBuildDate); // check items - const guids: (string | undefined)[] = []; + const guids: Array = []; for (const item of parsed.items) { expect(item).toEqual(expect.any(Object)); expect(item.title).toEqual(expect.any(String)); diff --git a/lib/routes/0xxx/index.ts b/lib/routes/0xxx/index.ts index cc690d8979e5ec..47d7be9a7f230a 100644 --- a/lib/routes/0xxx/index.ts +++ b/lib/routes/0xxx/index.ts @@ -15,7 +15,7 @@ export const handler = async (ctx: Context): Promise => { const { filter } = ctx.req.param(); const limit: number = Number.parseInt(ctx.req.query('limit') ?? '100', 10); - const baseUrl: string = 'https://0xxx.ws'; + const baseUrl = 'https://0xxx.ws'; const targetUrl: string = new URL(filter ? `?${filter}` : '', baseUrl).href; const response = await ofetch(targetUrl); diff --git a/lib/routes/10000link/info.ts b/lib/routes/10000link/info.ts index da095db3b0d1b4..6fa93593bfa99e 100644 --- a/lib/routes/10000link/info.ts +++ b/lib/routes/10000link/info.ts @@ -15,7 +15,7 @@ export const handler = async (ctx: Context): Promise => { const { category = 'newslists', id } = ctx.req.param(); const limit: number = Number.parseInt(ctx.req.query('limit') ?? '30', 10); - const baseUrl: string = 'https://info.10000link.com'; + const baseUrl = 'https://info.10000link.com'; const targetUrl: string = new URL(`${category}.aspx${id ? `?chid=${id}` : ''}`, baseUrl).href; const response = await ofetch(targetUrl); @@ -109,7 +109,7 @@ export const handler = async (ctx: Context): Promise => { ) ).filter((_): _ is DataItem => true); - const author: string = '10000万联网'; + const author = '10000万联网'; const title: string = $('h1').contents().first().text(); return { diff --git a/lib/routes/121/weather-live.tsx b/lib/routes/121/weather-live.tsx index d576045d8d239e..63e58678181032 100644 --- a/lib/routes/121/weather-live.tsx +++ b/lib/routes/121/weather-live.tsx @@ -27,8 +27,8 @@ const renderDescription = (description, images) => export const handler = async (ctx: Context): Promise => { const limit: number = Number.parseInt(ctx.req.query('limit') ?? '100', 10); - const baseUrl: string = 'https://tf.121.com.cn'; - const imgBaseUrl: string = 'https://wx.121.com.cn'; + const baseUrl = 'https://tf.121.com.cn'; + const imgBaseUrl = 'https://wx.121.com.cn'; const targetUrl: string = new URL('web/weatherLive/', baseUrl).href; const apiUrl: string = new URL('weather/weibo/message.js', baseUrl).href; @@ -52,7 +52,7 @@ export const handler = async (ctx: Context): Promise => { ); const pubDate: number | string = item.DDatetime; const linkUrl: string | undefined = targetUrl; - const guid: string = `121-${title}-${pubDate}`; + const guid = `121-${title}-${pubDate}`; const image: string | undefined = item.Img?.length > 0 ? new URL(`WeChat/data/weiweb/images/lwspic/${item.Img[0]}`, imgBaseUrl).href : undefined; const updated: number | string = pubDate; diff --git a/lib/routes/199it/index.tsx b/lib/routes/199it/index.tsx index f6716883bb0340..478c221c1aaead 100644 --- a/lib/routes/199it/index.tsx +++ b/lib/routes/199it/index.tsx @@ -14,7 +14,7 @@ export const handler = async (ctx: Context): Promise => { const { category = 'newly' } = ctx.req.param(); const limit: number = Number.parseInt(ctx.req.query('limit') ?? '30', 10); - const baseUrl: string = 'https://www.199it.com'; + const baseUrl = 'https://www.199it.com'; const targetUrl: string = new URL(category, baseUrl).href; const response = await ofetch(targetUrl); diff --git a/lib/routes/21caijing/channel.ts b/lib/routes/21caijing/channel.ts index e7738cbccf3070..4b06de223d8453 100644 --- a/lib/routes/21caijing/channel.ts +++ b/lib/routes/21caijing/channel.ts @@ -45,9 +45,9 @@ export const handler = async (ctx: Context): Promise => { const { name = '热点' } = ctx.req.param(); const limit: number = Number.parseInt(ctx.req.query('limit') ?? '30', 10); - const domain: string = 'm.21jingji.com'; - const baseUrl: string = `https://${domain}`; - const staticBaseUrl: string = 'https://static.21jingji.com'; + const domain = 'm.21jingji.com'; + const baseUrl = `https://${domain}`; + const staticBaseUrl = 'https://static.21jingji.com'; const menuUrl: string = new URL('m/webMenu.json', staticBaseUrl).href; const menuResponse = await ofetch(menuUrl); @@ -97,7 +97,7 @@ export const handler = async (ctx: Context): Promise => { const authors: DataItem['author'] = [...new Set([item.mp?.name, item.author, item.editor, item.source].filter(Boolean))].map((name) => ({ name, })); - const guid: string = `21jingji-${item.id}`; + const guid = `21jingji-${item.id}`; const image: string | undefined = item.image ?? item.thumb ?? item.listthumb; const updated: number | string = item.updatetime; diff --git a/lib/routes/5eplay/utils.ts b/lib/routes/5eplay/utils.ts index 1e50b25fd159f1..595eb2227197af 100644 --- a/lib/routes/5eplay/utils.ts +++ b/lib/routes/5eplay/utils.ts @@ -16,11 +16,10 @@ const getAcwScV2ByArg1 = (arg1) => { const unsbox = function (str: string) { const code = [15, 35, 29, 24, 33, 16, 1, 38, 10, 9, 19, 31, 40, 27, 22, 23, 25, 13, 6, 11, 39, 18, 20, 8, 14, 21, 32, 26, 2, 30, 7, 4, 17, 5, 3, 28, 34, 37, 12, 36]; const res: string[] = []; - // eslint-disable-next-line unicorn/no-for-loop for (let i = 0; i < str.length; i++) { const cur = str[i]; - for (const [j, element] of code.entries()) { - if (element === i + 1) { + for (let j = 0; j < code.length; j++) { + if (code[j] === i + 1) { res[j] = cur; } } diff --git a/lib/routes/6v123/index.ts b/lib/routes/6v123/index.ts index 12c02661d087c6..a6d3ec9e5af328 100644 --- a/lib/routes/6v123/index.ts +++ b/lib/routes/6v123/index.ts @@ -14,9 +14,9 @@ export const handler = async (ctx: Context): Promise => { const { category = 'dy' } = ctx.req.param(); const limit: number = Number.parseInt(ctx.req.query('limit') ?? '25', 10); - const encoding: string = 'gb2312'; + const encoding = 'gb2312'; - const baseUrl: string = 'https://www.hao6v.me'; + const baseUrl = 'https://www.hao6v.me'; const targetUrl: string = new URL(category.startsWith('gvod') ? `${category}.html` : category, baseUrl).href; const response = await ofetch(targetUrl, { @@ -39,7 +39,7 @@ export const handler = async (ctx: Context): Promise => { .text() .replaceAll(/(\[|\])/g, ''); const linkUrl: string | undefined = $el.find('a').attr('href'); - const guid: string = `${linkUrl}#${title}`; + const guid = `${linkUrl}#${title}`; const upDatedStr: string | undefined = pubDateStr; const processedItem: DataItem = { @@ -101,7 +101,7 @@ export const handler = async (ctx: Context): Promise => { const enclosureUrl: string | undefined = $enclosureEl.attr('href'); if (enclosureUrl) { - const enclosureType: string = 'application/x-bittorrent'; + const enclosureType = 'application/x-bittorrent'; const enclosureTitle: string = $enclosureEl.text(); processedItem = { diff --git a/lib/routes/aa1/60s.ts b/lib/routes/aa1/60s.ts index af7e98264dcd43..597e9990358284 100644 --- a/lib/routes/aa1/60s.ts +++ b/lib/routes/aa1/60s.ts @@ -12,7 +12,7 @@ export const handler = async (ctx: Context): Promise => { const limit: number = Number.parseInt(ctx.req.query('limit') ?? '100', 10); const apiSlug = 'wp-json/wp/v2'; - const baseUrl: string = 'https://60s.aa1.cn'; + const baseUrl = 'https://60s.aa1.cn'; const apiUrl = new URL(`${apiSlug}/posts`, baseUrl).href; const apiSearchUrl = new URL(`${apiSlug}/categories`, baseUrl).href; diff --git a/lib/routes/adquan/case-library.ts b/lib/routes/adquan/case-library.ts index d1525069ada77f..b604c4a74372af 100644 --- a/lib/routes/adquan/case-library.ts +++ b/lib/routes/adquan/case-library.ts @@ -15,7 +15,7 @@ import { renderDescription } from './templates/description'; export const handler = async (ctx: Context): Promise => { const limit: number = Number.parseInt(ctx.req.query('limit') ?? '24', 10); - const baseUrl: string = 'https://www.adquan.com'; + const baseUrl = 'https://www.adquan.com'; const targetUrl: string = new URL('case_library/index', baseUrl).href; const response = await ofetch(targetUrl); diff --git a/lib/routes/adquan/index.ts b/lib/routes/adquan/index.ts index 646ed6008feabb..706f904a9d8072 100644 --- a/lib/routes/adquan/index.ts +++ b/lib/routes/adquan/index.ts @@ -15,7 +15,7 @@ import { renderDescription } from './templates/description'; export const handler = async (ctx: Context): Promise => { const limit: number = Number.parseInt(ctx.req.query('limit') ?? '30', 10); - const baseUrl: string = 'https://www.adquan.com'; + const baseUrl = 'https://www.adquan.com'; const targetUrl: string = baseUrl; const response = await ofetch(targetUrl); diff --git a/lib/routes/aflcio/blog.ts b/lib/routes/aflcio/blog.ts index 1e824792a38491..ba9d30a3de4c3e 100644 --- a/lib/routes/aflcio/blog.ts +++ b/lib/routes/aflcio/blog.ts @@ -12,7 +12,7 @@ import { parseDate } from '@/utils/parse-date'; export const handler = async (ctx: Context): Promise => { const limit: number = Number.parseInt(ctx.req.query('limit') ?? '5', 10); - const baseUrl: string = 'https://aflcio.org'; + const baseUrl = 'https://aflcio.org'; const targetUrl: string = new URL('blog', baseUrl).href; const response = await ofetch(targetUrl); diff --git a/lib/routes/ali213/news.ts b/lib/routes/ali213/news.ts index 53a454f5364fa4..0520769bab236c 100644 --- a/lib/routes/ali213/news.ts +++ b/lib/routes/ali213/news.ts @@ -16,7 +16,7 @@ export const handler = async (ctx: Context): Promise => { const { category = 'new' } = ctx.req.param(); const limit: number = Number.parseInt(ctx.req.query('limit') ?? '30', 10); - const rootUrl: string = 'https://www.ali213.net'; + const rootUrl = 'https://www.ali213.net'; const targetUrl: string = new URL(`news/${category.endsWith('/') ? category : `${category}/`}`, rootUrl).href; const response = await ofetch(targetUrl); diff --git a/lib/routes/ali213/zl.ts b/lib/routes/ali213/zl.ts index 23e6839bbce748..16a1234e3ede15 100644 --- a/lib/routes/ali213/zl.ts +++ b/lib/routes/ali213/zl.ts @@ -15,8 +15,8 @@ export const handler = async (ctx: Context): Promise => { const { category } = ctx.req.param(); const limit: number = Number.parseInt(ctx.req.query('limit') ?? '1', 10); - const rootUrl: string = 'https://www.ali213.net'; - const apiRootUrl: string = 'https://mp.ali213.net'; + const rootUrl = 'https://www.ali213.net'; + const apiRootUrl = 'https://mp.ali213.net'; const targetUrl: string = new URL(`/news/zl/${category ? (category.endsWith('/') ? category : `${category}/`) : ''}`, rootUrl).href; const apiUrl: string = new URL('ajax/newslist', apiRootUrl).href; @@ -37,7 +37,7 @@ export const handler = async (ctx: Context): Promise => { const description: string = renderDescription({ intro: item.GuideRead ?? '', }); - const guid: string = `ali213-zl-${item.ID}`; + const guid = `ali213-zl-${item.ID}`; const image: string | undefined = item.PicPath ? `https:${item.PicPath}` : undefined; const author: DataItem['author'] = item.xiaobian; diff --git a/lib/routes/amazfitwatchfaces/index.ts b/lib/routes/amazfitwatchfaces/index.ts index 1d6591b8343478..1198f2fb83ce59 100644 --- a/lib/routes/amazfitwatchfaces/index.ts +++ b/lib/routes/amazfitwatchfaces/index.ts @@ -15,7 +15,7 @@ export const handler = async (ctx: Context): Promise => { const { device, sort, searchParams } = ctx.req.param(); const limit: number = Number.parseInt(ctx.req.query('limit') ?? '30', 10); - const baseUrl: string = 'https://amazfitwatchfaces.com'; + const baseUrl = 'https://amazfitwatchfaces.com'; const targetUrl: string = new URL(`${device}/${sort}${searchParams ? `?${searchParams}` : ''}`, baseUrl).href; const response = await ofetch(targetUrl); diff --git a/lib/routes/anytxt/release-notes.ts b/lib/routes/anytxt/release-notes.ts index 951d75d48a8777..32901623dfa9c5 100644 --- a/lib/routes/anytxt/release-notes.ts +++ b/lib/routes/anytxt/release-notes.ts @@ -11,7 +11,7 @@ import { parseDate } from '@/utils/parse-date'; export const handler = async (ctx: Context): Promise => { const limit: number = Number.parseInt(ctx.req.query('limit') ?? '30', 10); - const baseUrl: string = 'https://anytxt.net'; + const baseUrl = 'https://anytxt.net'; const targetUrl: string = new URL('download/', baseUrl).href; const response = await ofetch(targetUrl); diff --git a/lib/routes/app-sales/index.ts b/lib/routes/app-sales/index.ts index 3b19daba01c725..28d590e9a4c364 100644 --- a/lib/routes/app-sales/index.ts +++ b/lib/routes/app-sales/index.ts @@ -21,7 +21,7 @@ export const handler = async (ctx: Context): Promise => { }); const $: CheerioAPI = load(response); const language = $('html').attr('lang') ?? 'en'; - const selector: string = 'div.card-panel'; + const selector = 'div.card-panel'; const items: DataItem[] = await fetchItems($, selector, targetUrl, country, limit); diff --git a/lib/routes/app-sales/util.tsx b/lib/routes/app-sales/util.tsx index 76657fa51e4c60..4f5c2e08ce4403 100644 --- a/lib/routes/app-sales/util.tsx +++ b/lib/routes/app-sales/util.tsx @@ -6,7 +6,7 @@ import { renderToString } from 'hono/jsx/dom/server'; import type { DataItem } from '@/types'; import ofetch from '@/utils/ofetch'; -const baseUrl: string = 'https://www.app-sales.net'; +const baseUrl = 'https://www.app-sales.net'; const renderDescription = ({ images, appName, @@ -20,7 +20,7 @@ const renderDescription = ({ priceDisco, linkUrl, }: { - images?: { alt?: string; src?: string }[]; + images?: Array<{ alt?: string; src?: string }>; appName?: string; appDev?: string; appNote?: string; @@ -150,7 +150,7 @@ const processItems = ($: CheerioAPI, selector: string): DataItem[] => const isHot: boolean = $el.hasClass('sale-hot'); const isFree: boolean = priceNew?.toLocaleUpperCase() === 'FREE'; - const title: string = `${appName} ${formatPriceChangeTag(priceOld, priceNew, priceDisco)}`; + const title = `${appName} ${formatPriceChangeTag(priceOld, priceNew, priceDisco)}`; const image: string | undefined = $el.find('div.app-icon img').attr('src'); const linkUrl: string | undefined = $el.find('div.sale-list-action a').attr('href'); const description: string | undefined = renderDescription({ diff --git a/lib/routes/apple/security-releases.ts b/lib/routes/apple/security-releases.ts index 48b9a2432897e1..f3d3c7a27a4854 100644 --- a/lib/routes/apple/security-releases.ts +++ b/lib/routes/apple/security-releases.ts @@ -15,7 +15,7 @@ export const handler = async (ctx: Context): Promise => { const { language = 'en-us' } = ctx.req.param(); const limit: number = Number.parseInt(ctx.req.query('limit') ?? '30', 10); - const baseUrl: string = 'https://support.apple.com'; + const baseUrl = 'https://support.apple.com'; const targetUrl: string = new URL(`${language}/100100`, baseUrl).href; const response = await ofetch(targetUrl); diff --git a/lib/routes/artstation/templates/description.tsx b/lib/routes/artstation/templates/description.tsx index 6153da1df3fcd0..26c322e4e18941 100644 --- a/lib/routes/artstation/templates/description.tsx +++ b/lib/routes/artstation/templates/description.tsx @@ -7,11 +7,11 @@ type DescriptionData = { src?: string; title?: string; }; - assets?: { + assets?: Array<{ asset_type?: string; player_embedded?: string; image_url?: string; - }[]; + }>; }; const ArtstationDescription = ({ description, image, assets }: DescriptionData) => ( diff --git a/lib/routes/asiafruitchina/categories.ts b/lib/routes/asiafruitchina/categories.ts index d3dcf7440d2ca1..42db49cdfb55af 100644 --- a/lib/routes/asiafruitchina/categories.ts +++ b/lib/routes/asiafruitchina/categories.ts @@ -15,7 +15,7 @@ export const handler = async (ctx: Context): Promise => { const { category = 'all' } = ctx.req.param(); const limit: number = Number.parseInt(ctx.req.query('limit') ?? '10', 10); - const baseUrl: string = 'https://asiafruitchina.net'; + const baseUrl = 'https://asiafruitchina.net'; const targetUrl: string = new URL(`categories?gspx=${category}`, baseUrl).href; const response = await ofetch(targetUrl); diff --git a/lib/routes/asiafruitchina/news.ts b/lib/routes/asiafruitchina/news.ts index bcd19804df10d3..ec109a2ccbebc9 100644 --- a/lib/routes/asiafruitchina/news.ts +++ b/lib/routes/asiafruitchina/news.ts @@ -14,7 +14,7 @@ import { renderDescription } from './templates/description'; export const handler = async (ctx: Context): Promise => { const limit: number = Number.parseInt(ctx.req.query('limit') ?? '30', 10); - const baseUrl: string = 'https://asiafruitchina.net'; + const baseUrl = 'https://asiafruitchina.net'; const targetUrl: string = new URL('category/news', baseUrl).href; const response = await ofetch(targetUrl); diff --git a/lib/routes/asmr-200/type.ts b/lib/routes/asmr-200/type.ts index 8036204afd1222..0961c9deda650b 100644 --- a/lib/routes/asmr-200/type.ts +++ b/lib/routes/asmr-200/type.ts @@ -21,54 +21,54 @@ export interface Work { duration: number; has_subtitle: boolean; id: number; - language_editions: { + language_editions: Array<{ display_order: number; edition_id: number; edition_type: string; label: string; lang: string; workno: string; - }[]; + }>; mainCoverUrl: string; name: string; nsfw: boolean; original_workno: null | string; - other_language_editions_in_db: { + other_language_editions_in_db: Array<{ id: number; is_original: boolean; lang: string; source_id: string; source_type: string; title: string; - }[]; + }>; playlistStatus: any; price: number; rank: - | { + | Array<{ category: string; rank: number; rank_date: string; term: string; - }[] + }> | null; rate_average_2dp: number | number; rate_count: number; - rate_count_detail: { + rate_count_detail: Array<{ count: number; ratio: number; review_point: number; - }[]; + }>; release: string; review_count: number; samCoverUrl: string; source_id: string; source_type: string; source_url: string; - tags: { + tags: Array<{ i18n: any; id: number; name: string; - }[]; + }>; category: string; thumbnailCoverUrl: string; title: string; @@ -87,10 +87,10 @@ export interface Work { translation_bonus_langs: string[]; }; userRating: null; - vas: { + vas: Array<{ id: string; name: string; - }[]; + }>; cv: string; work_attributes: string; } diff --git a/lib/routes/augmentcode/blog.tsx b/lib/routes/augmentcode/blog.tsx index a730faa54bc9d5..1836d6598f232e 100644 --- a/lib/routes/augmentcode/blog.tsx +++ b/lib/routes/augmentcode/blog.tsx @@ -33,7 +33,7 @@ const renderDescription = ({ images, description }: { images?: DescriptionImage[ export const handler = async (ctx: Context): Promise => { const limit: number = Number.parseInt(ctx.req.query('limit') ?? '50', 10); - const baseUrl: string = 'https://augmentcode.com'; + const baseUrl = 'https://augmentcode.com'; const targetUrl: string = new URL('blog', baseUrl).href; const response = await ofetch(targetUrl); diff --git a/lib/routes/azul/packages.ts b/lib/routes/azul/packages.ts index 4a9ce21faf41d3..c8ecf5080d4985 100644 --- a/lib/routes/azul/packages.ts +++ b/lib/routes/azul/packages.ts @@ -9,8 +9,8 @@ import ofetch from '@/utils/ofetch'; export const handler = async (ctx: Context): Promise => { const limit: number = Number.parseInt(ctx.req.query('limit') ?? '30', 10); - const baseUrl: string = 'https://www.azul.com'; - const apiBaseUrl: string = 'https://api.azul.com'; + const baseUrl = 'https://www.azul.com'; + const apiBaseUrl = 'https://api.azul.com'; const targetUrl: string = new URL('downloads', baseUrl).href; const apiUrl: string = new URL('metadata/v1/zulu/packages', apiBaseUrl).href; @@ -30,13 +30,13 @@ export const handler = async (ctx: Context): Promise => { }); const items: DataItem[] = response.slice(0, limit).map((item): DataItem => { - const javaVersion: string = `${item.java_version.join('.')}+${item.openjdk_build_number}`; + const javaVersion = `${item.java_version.join('.')}+${item.openjdk_build_number}`; const distroVersion: string = item.distro_version.join('.'); - const title: string = `[${javaVersion}] (${distroVersion}) ${item.name}`; + const title = `[${javaVersion}] (${distroVersion}) ${item.name}`; const linkUrl: string | undefined = item.download_url; const categories: string[] = [item.os, item.arch, item.java_package_type, item.archive_type, item.abi, ...(item.javafx_bundled ? ['javafx'] : []), ...(item.crac_supported ? ['crac'] : [])]; - const guid: string = `azul-${item.name}`; + const guid = `azul-${item.name}`; let processedItem: DataItem = { title, diff --git a/lib/routes/azurlane/news.ts b/lib/routes/azurlane/news.ts index c3a4c6745896ae..a0b38daab70a65 100644 --- a/lib/routes/azurlane/news.ts +++ b/lib/routes/azurlane/news.ts @@ -40,7 +40,7 @@ const handler: Route['handler'] = async (ctx) => { const ja: Route['handler'] = async (ctx) => { const { type = '0' } = ctx.req.param(); - const response = await ofetch<{ data: { rows: { id: number; content: string; title: string; publishTime: number }[] } }>('https://www.azurlane.jp/api/news/list', { + const response = await ofetch<{ data: { rows: Array<{ id: number; content: string; title: string; publishTime: number }> } }>('https://www.azurlane.jp/api/news/list', { query: { type, index: 1, diff --git a/lib/routes/baai/hub.ts b/lib/routes/baai/hub.ts index 93877d157c2783..e0a39473c331ae 100644 --- a/lib/routes/baai/hub.ts +++ b/lib/routes/baai/hub.ts @@ -51,7 +51,7 @@ async function handler(ctx) { if (tagId) { const tagsData = await getTagsData(); - const tag = (tagsData as Record[]).find((tag) => tag.id === tagId); + const tag = (tagsData as Array>).find((tag) => tag.id === tagId); if (tag) { title = tag.title; description = tag.description; diff --git a/lib/routes/bandisoft/history.ts b/lib/routes/bandisoft/history.ts index 620a0568bdf1d7..397c1ceec6039e 100644 --- a/lib/routes/bandisoft/history.ts +++ b/lib/routes/bandisoft/history.ts @@ -130,19 +130,19 @@ export const handler = async (ctx: Context): Promise => { const { id = 'bandizip', language = 'en' } = ctx.req.param(); const limit: number = Number.parseInt(ctx.req.query('limit') ?? '500', 10); - const validIds: Set = new Set(idOptions.map((option) => option.value)); + const validIds = new Set(idOptions.map((option) => option.value)); if (!validIds.has(id)) { throw new Error(`Invalid id: ${id}. Allowed values are: ${[...validIds].join(', ')}`); } - const validLanguages: Set = new Set(languageOptions.map((option) => option.value)); + const validLanguages = new Set(languageOptions.map((option) => option.value)); if (!validLanguages.has(language)) { throw new Error(`Invalid language: ${language}. Allowed values are: ${[...validLanguages].join(', ')}`); } - const baseUrl: string = `https://${language}.bandisoft.com`; + const baseUrl = `https://${language}.bandisoft.com`; const targetUrl: string = new URL(`${id}/history/`, baseUrl).href; const response = await ofetch(targetUrl); @@ -163,7 +163,7 @@ export const handler = async (ctx: Context): Promise => { const description: string | undefined = $el.find('ul.cell3').html() ?? undefined; const linkUrl: string = targetUrl; - const guid: string = `bandisoft-${id}-${language}-${version}`; + const guid = `bandisoft-${id}-${language}-${version}`; const upDatedStr: string | undefined = pubDateStr; const processedItem: DataItem = { diff --git a/lib/routes/banshujiang/index.ts b/lib/routes/banshujiang/index.ts index acf26a51d56dad..dc983fe3943e78 100644 --- a/lib/routes/banshujiang/index.ts +++ b/lib/routes/banshujiang/index.ts @@ -15,7 +15,7 @@ export const handler = async (ctx: Context): Promise => { const { category } = ctx.req.param(); const limit: number = Number.parseInt(ctx.req.query('limit') ?? '20', 10); - const baseUrl: string = 'http://banshujiang.cn'; + const baseUrl = 'http://banshujiang.cn'; const targetUrl: string = new URL(`${category ? 'e_books' : `category/${category}`}/page/1`, baseUrl).href; const response = await ofetch(targetUrl); diff --git a/lib/routes/banyuetan/index.ts b/lib/routes/banyuetan/index.ts index 829bfe24c1a692..25e7a94ca77c06 100644 --- a/lib/routes/banyuetan/index.ts +++ b/lib/routes/banyuetan/index.ts @@ -16,7 +16,7 @@ export const handler = async (ctx: Context): Promise => { const { id = 'jinritan' } = ctx.req.param(); const limit: number = Number.parseInt(ctx.req.query('limit') ?? '30', 10); - const baseUrl: string = 'http://www.banyuetan.org'; + const baseUrl = 'http://www.banyuetan.org'; const targetUrl: string = new URL(`byt/${id}/index.html`, baseUrl).href; const response = await ofetch(targetUrl); diff --git a/lib/routes/bilibili/cache.ts b/lib/routes/bilibili/cache.ts index cbacd15e757f2f..85f5cbc7be15a1 100644 --- a/lib/routes/bilibili/cache.ts +++ b/lib/routes/bilibili/cache.ts @@ -35,7 +35,7 @@ const getCookie = (disableConfig = false) => { } const key = 'bili-cookie'; return cache.tryGet(key, async () => { - let waitForRequest: Promise = new Promise((resolve) => { + let waitForRequest = new Promise((resolve) => { resolve(''); }); const { destory } = await getPuppeteerPage('https://space.bilibili.com/1/dynamic', { diff --git a/lib/routes/bilibili/dynamic.ts b/lib/routes/bilibili/dynamic.ts index c5adbaac4e9afc..85c48effee30a3 100644 --- a/lib/routes/bilibili/dynamic.ts +++ b/lib/routes/bilibili/dynamic.ts @@ -129,11 +129,11 @@ const getIframe = (data?: Modules, embed: boolean = true) => { }; const getImgs = (data?: Modules) => { - const imgUrls: { + const imgUrls: Array<{ url: string; width?: number; height?: number; - }[] = []; + }> = []; const major = data?.module_dynamic?.major; if (!major) { return ''; diff --git a/lib/routes/bilibili/followings-dynamic.ts b/lib/routes/bilibili/followings-dynamic.ts index 5bdda1f5d7bb4f..87940965512632 100644 --- a/lib/routes/bilibili/followings-dynamic.ts +++ b/lib/routes/bilibili/followings-dynamic.ts @@ -105,14 +105,14 @@ async function handler(ctx) { let imgs = ''; // 动态图片 if (data.pictures) { - for (let i = 0; i < data.pictures.length; i++) { - imgs += ``; + for (const pic of data.pictures) { + imgs += ``; } } // 专栏封面 if (data.image_urls) { - for (let i = 0; i < data.image_urls.length; i++) { - imgs += ``; + for (const url of data.image_urls) { + imgs += ``; } } // 视频封面 diff --git a/lib/routes/bluearchive/news.ts b/lib/routes/bluearchive/news.ts index 42415851ab0446..4013d1137c7033 100644 --- a/lib/routes/bluearchive/news.ts +++ b/lib/routes/bluearchive/news.ts @@ -41,7 +41,7 @@ const handler: Route['handler'] = async (ctx) => { const ja: Route['handler'] = async (ctx) => { const { type = '0' } = ctx.req.param(); - const data = await ofetch<{ data: { rows: { id: number; content: string; summary: string; publishTime: number }[] } }, 'json'>('https://api-web.bluearchive.jp/api/news/list', { + const data = await ofetch<{ data: { rows: Array<{ id: number; content: string; summary: string; publishTime: number }> } }, 'json'>('https://api-web.bluearchive.jp/api/news/list', { query: { typeId: type, pageNum: 16, diff --git a/lib/routes/bookwalker/search.tsx b/lib/routes/bookwalker/search.tsx index ba545a9c94da44..5eb1f8cf8aea71 100644 --- a/lib/routes/bookwalker/search.tsx +++ b/lib/routes/bookwalker/search.tsx @@ -12,7 +12,7 @@ export const handler = async (ctx: Context): Promise => { const { filter = 'order=sell_desc' } = ctx.req.param(); const limit: number = Number.parseInt(ctx.req.query('limit') ?? '24', 10); - const baseUrl: string = 'https://www.bookwalker.com.tw'; + const baseUrl = 'https://www.bookwalker.com.tw'; const targetUrl: string = new URL(`search?${filter}`, baseUrl).href; const response = await ofetch(targetUrl); @@ -29,7 +29,7 @@ export const handler = async (ctx: Context): Promise => { const price: string = $el.find('h5.bprice').text(); const authorStr: string = $el.find('h5.booknamesub').text().trim(); - const title: string = `${name} - ${authorStr} ${price}`; + const title = `${name} - ${authorStr} ${price}`; const image: string | undefined = $el .find('img') .attr('data-src') diff --git a/lib/routes/bullionvault/gold-news.ts b/lib/routes/bullionvault/gold-news.ts index f3dc7e9f8d4bc8..f4986b4c246c1b 100644 --- a/lib/routes/bullionvault/gold-news.ts +++ b/lib/routes/bullionvault/gold-news.ts @@ -13,7 +13,7 @@ export const handler = async (ctx: Context): Promise => { const { category } = ctx.req.param(); const limit: number = Number.parseInt(ctx.req.query('limit') ?? '30', 10); - const baseUrl: string = 'https://bullionvault.com'; + const baseUrl = 'https://bullionvault.com'; const targetUrl: string = new URL(`gold-news${category ? `/${category}` : ''}`, baseUrl).href; const response = await ofetch(targetUrl); diff --git a/lib/routes/cara/types.ts b/lib/routes/cara/types.ts index 7d3aea28a023c3..5207f884accd25 100644 --- a/lib/routes/cara/types.ts +++ b/lib/routes/cara/types.ts @@ -10,36 +10,36 @@ export interface UserNextData { } export interface PortfolioResponse { - data: { + data: Array<{ url: string; postId: string; imageNum: number; - }[]; + }>; } export interface PortfolioDetailResponse { data: { createdAt: string; - images: { + images: Array<{ src: string; isCoverImg: boolean; - }[]; + }>; title: string; content: string; }; } export interface PostsResponse { - data: { + data: Array<{ name: string; photo: string; createdAt: string; - images: { + images: Array<{ src: string; isCoverImg: boolean; - }[]; + }>; id: string; title: string; content: string; - }[]; + }>; } diff --git a/lib/routes/cbndata/information.ts b/lib/routes/cbndata/information.ts index 43f8a6d4a2774a..08bc5b5b507e41 100644 --- a/lib/routes/cbndata/information.ts +++ b/lib/routes/cbndata/information.ts @@ -14,7 +14,7 @@ export const handler = async (ctx: Context): Promise => { const { id = 'all' } = ctx.req.param(); const limit: number = Number.parseInt(ctx.req.query('limit') ?? '50', 10); - const baseUrl: string = 'https://www.cbndata.com'; + const baseUrl = 'https://www.cbndata.com'; const targetUrl: string = new URL(`information?tag_id=${id}`, baseUrl).href; const apiUrl: string = new URL('api/v3/informations', baseUrl).href; @@ -47,7 +47,7 @@ export const handler = async (ctx: Context): Promise => { const pubDate: number | string = item.date; const linkUrl: string | undefined = item.id ? `information/${item.id}` : undefined; const categories: string[] = item.tags; - const guid: string = `cbndata-information-${item.id}`; + const guid = `cbndata-information-${item.id}`; const updated: number | string = pubDate; const processedItem: DataItem = { @@ -108,7 +108,7 @@ export const handler = async (ctx: Context): Promise => { avatar: undefined, }, ]; - const guid: string = `cbndata-information-${data.id}`; + const guid = `cbndata-information-${data.id}`; const image: string | undefined = data.thumbnail_url; const updated: number | string = pubDate; @@ -140,7 +140,7 @@ export const handler = async (ctx: Context): Promise => { ); const tag: string = response.home_tags.find((t: { id: number; name: string }) => String(t.id) === id)?.name ?? ''; - const title: string = `${tag ? `${tag}-` : ''}${$('title').text().trim()}`; + const title = `${tag ? `${tag}-` : ''}${$('title').text().trim()}`; return { title, diff --git a/lib/routes/ccagm/index.ts b/lib/routes/ccagm/index.ts index 6716b23477a252..2a95b397fa99d7 100644 --- a/lib/routes/ccagm/index.ts +++ b/lib/routes/ccagm/index.ts @@ -14,7 +14,7 @@ export const handler = async (ctx: Context): Promise => { const { category = 'association-news' } = ctx.req.param(); const limit: number = Number.parseInt(ctx.req.query('limit') ?? '10', 10); - const baseUrl: string = 'http://www.ccagm.org.cn'; + const baseUrl = 'http://www.ccagm.org.cn'; const targetUrl: string = new URL(category, baseUrl).href; const response = await ofetch(targetUrl); diff --git a/lib/routes/cccmc/index.ts b/lib/routes/cccmc/index.ts index fae13256b21e8f..b134289e43b9ba 100644 --- a/lib/routes/cccmc/index.ts +++ b/lib/routes/cccmc/index.ts @@ -13,7 +13,7 @@ export const handler = async (ctx: Context): Promise => { const { category = 'ywgg/tzgg' } = ctx.req.param(); const limit: number = Number.parseInt(ctx.req.query('limit') ?? '15', 10); - const baseUrl: string = 'https://www.cccmc.org.cn'; + const baseUrl = 'https://www.cccmc.org.cn'; const targetUrl: string = new URL(category.endsWith('/') ? category : `${category}/`, baseUrl).href; const response = await ofetch(targetUrl); @@ -22,7 +22,7 @@ export const handler = async (ctx: Context): Promise => { let items: DataItem[] = []; - const regex: RegExp = /\{url:'(.*)',title:'(.*)',time:'(.*)'\},/g; + const regex = /\{url:'(.*)',title:'(.*)',time:'(.*)'\},/g; items = response diff --git a/lib/routes/ccg/index.ts b/lib/routes/ccg/index.ts index 6d86a9016761fc..4fa5559455bb60 100644 --- a/lib/routes/ccg/index.ts +++ b/lib/routes/ccg/index.ts @@ -15,7 +15,7 @@ export const handler = async (ctx: Context): Promise => { const { category = 'news' } = ctx.req.param(); const limit: number = Number.parseInt(ctx.req.query('limit') ?? '7', 10); - const baseUrl: string = 'http://www.ccg.org.cn'; + const baseUrl = 'http://www.ccg.org.cn'; const targetUrl: string = new URL(category, baseUrl).href; const response = await ofetch(targetUrl); diff --git a/lib/routes/cfr/types.ts b/lib/routes/cfr/types.ts index c81cc58a2997d0..c83f258314d9a3 100644 --- a/lib/routes/cfr/types.ts +++ b/lib/routes/cfr/types.ts @@ -1,6 +1,6 @@ export interface LinkData { '@context': string; - '@graph': { + '@graph': Array<{ '@type': string; headline: string; name: string; @@ -18,13 +18,13 @@ export interface LinkData { name: string; url: string; }; - }[]; + }>; } export interface VideoSetup { techOrder: string[]; - sources: { + sources: Array<{ type: string; src: string; - }[]; + }>; } diff --git a/lib/routes/cfr/utils.ts b/lib/routes/cfr/utils.ts index 662b4e8e991899..b9dadd7ccd44ca 100644 --- a/lib/routes/cfr/utils.ts +++ b/lib/routes/cfr/utils.ts @@ -232,7 +232,7 @@ function parseDefault($): DataItem { function parseLinkData($: CheerioAPI) { try { - const data = (JSON.parse($('script[type="application/ld+json"]').text()))['@graph'][0]; + const data = (JSON.parse($('script[type="application/ld+json"]').text()) as LinkData)['@graph'][0]; return { title: data.name, diff --git a/lib/routes/chinacdc/index.ts b/lib/routes/chinacdc/index.ts index b03b8b823d5c21..35216afb37765c 100644 --- a/lib/routes/chinacdc/index.ts +++ b/lib/routes/chinacdc/index.ts @@ -15,7 +15,7 @@ export const handler = async (ctx: Context): Promise => { const { category = 'zxyw' } = ctx.req.param(); const limit: number = Number.parseInt(ctx.req.query('limit') ?? '11', 10); - const rootUrl: string = 'https://www.chinacdc.cn'; + const rootUrl = 'https://www.chinacdc.cn'; const targetUrl: string = new URL(category.endsWith('/') ? category : `${category}/`, rootUrl).href; const response = await ofetch(targetUrl); diff --git a/lib/routes/chinadaily/language.ts b/lib/routes/chinadaily/language.ts index 7bddbd8279b6d1..b3f256fd62714c 100644 --- a/lib/routes/chinadaily/language.ts +++ b/lib/routes/chinadaily/language.ts @@ -16,7 +16,7 @@ export const handler = async (ctx: Context): Promise => { const { category = 'thelatest' } = ctx.req.param(); const limit: number = Number.parseInt(ctx.req.query('limit') ?? '30', 10); - const baseUrl: string = 'https://language.chinadaily.com.cn'; + const baseUrl = 'https://language.chinadaily.com.cn'; const targetUrl: string = new URL(category, baseUrl).href; const response = await ofetch(targetUrl); diff --git a/lib/routes/chinaratings/credit-research.ts b/lib/routes/chinaratings/credit-research.ts index 5b2506ad796e16..9f18b236767d25 100644 --- a/lib/routes/chinaratings/credit-research.ts +++ b/lib/routes/chinaratings/credit-research.ts @@ -13,7 +13,7 @@ export const handler = async (ctx: Context): Promise => { const { category = 'Industry/Comment' } = ctx.req.param(); const limit: number = Number.parseInt(ctx.req.query('limit') ?? '15', 10); - const baseUrl: string = 'https://www.chinaratings.com.cn'; + const baseUrl = 'https://www.chinaratings.com.cn'; const targetUrl: string = new URL(`CreditResearch/${category.endsWith('/') ? category : `${category}/`}`, baseUrl).href; const response = await ofetch(targetUrl); diff --git a/lib/routes/chocolatey/packages.ts b/lib/routes/chocolatey/packages.ts index a7bc4001787085..5276a12d0a65b2 100644 --- a/lib/routes/chocolatey/packages.ts +++ b/lib/routes/chocolatey/packages.ts @@ -11,7 +11,7 @@ import { parseDate } from '@/utils/parse-date'; export const handler = async (ctx: Context): Promise => { const { id } = ctx.req.param(); - const baseUrl: string = 'https://community.chocolatey.org'; + const baseUrl = 'https://community.chocolatey.org'; const targetUrl: string = new URL(`packages/${id}`, baseUrl).href; const response = await ofetch(targetUrl); @@ -33,7 +33,7 @@ export const handler = async (ctx: Context): Promise => { avatar: $authorEl.attr('src'), }; }); - const guid: string = `chocolatey-${title}`; + const guid = `chocolatey-${title}`; const image: string | undefined = $('div.package-logo img').attr('src') ? new URL($('div.package-logo img').attr('src') as string, baseUrl).href : undefined; const upDatedStr: string | undefined = pubDateStr; diff --git a/lib/routes/chuapp/chuapp.ts b/lib/routes/chuapp/chuapp.ts index 6ffd5d28e107d3..7b472c9e4b5d24 100644 --- a/lib/routes/chuapp/chuapp.ts +++ b/lib/routes/chuapp/chuapp.ts @@ -108,7 +108,7 @@ async function handler(ctx: Context): Promise { link: $(element).attr('href'), })); - const processedItems: Promise[] = articles + const processedItems: Array> = articles .filter((article: RawArticle): article is ValidArticle => isValidArticle(article)) .map((article: ValidArticle) => { if (article.link.startsWith('/')) { diff --git a/lib/routes/cloudflarestatus/index.tsx b/lib/routes/cloudflarestatus/index.tsx index 630e00ff6ebba1..12d2ff4c228eb4 100644 --- a/lib/routes/cloudflarestatus/index.tsx +++ b/lib/routes/cloudflarestatus/index.tsx @@ -13,7 +13,7 @@ import { parseDate } from '@/utils/parse-date'; export const handler = async (ctx: Context): Promise => { const limit: number = Number.parseInt(ctx.req.query('limit') ?? '100', 10); - const baseUrl: string = 'https://www.cloudflarestatus.com'; + const baseUrl = 'https://www.cloudflarestatus.com'; const response = await ofetch(baseUrl); const $: CheerioAPI = load(response); @@ -32,7 +32,7 @@ export const handler = async (ctx: Context): Promise => { const type: string = $el.find('strong').first().text(); const text: string = $el.find('span.whitespace-pre-wrap').first().text(); - const title: string = `${type ? `${type} - ` : ''}${text}`; + const title = `${type ? `${type} - ` : ''}${text}`; const description: string | undefined = renderToString( <> {actualTitle ?

{actualTitle}

: null} diff --git a/lib/routes/cnljxh/index.ts b/lib/routes/cnljxh/index.ts index 24ca1cc2e679b9..24930df3d76931 100644 --- a/lib/routes/cnljxh/index.ts +++ b/lib/routes/cnljxh/index.ts @@ -13,7 +13,7 @@ export const handler = async (ctx: Context): Promise => { const { category = 'news', id = '10' } = ctx.req.param(); const limit: number = Number.parseInt(ctx.req.query('limit') ?? '20', 10); - const baseUrl: string = 'https://www.cnljxh.org.cn'; + const baseUrl = 'https://www.cnljxh.org.cn'; const targetUrl: string = new URL(`${category}/?classid=${id}`, baseUrl).href; const response = await ofetch(targetUrl); diff --git a/lib/routes/cool18/index.ts b/lib/routes/cool18/index.ts index 6f8007a8a3ff2b..6f4b5d7043137b 100644 --- a/lib/routes/cool18/index.ts +++ b/lib/routes/cool18/index.ts @@ -51,7 +51,7 @@ async function handler(ctx: Context) { const $ = load(response); - const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 20; + const limit = ctx.req.query('limit') ? Number.parseInt((ctx.req.query('limit') as string)) : 20; const list = type === 'home' diff --git a/lib/routes/coolbuy/index.tsx b/lib/routes/coolbuy/index.tsx index 8770c527e9d873..0c33ba8ad7a66c 100644 --- a/lib/routes/coolbuy/index.tsx +++ b/lib/routes/coolbuy/index.tsx @@ -10,8 +10,8 @@ import ofetch from '@/utils/ofetch'; export const handler = async (ctx: Context): Promise => { const limit: number = Number.parseInt(ctx.req.query('limit') ?? '50', 10); - const baseUrl: string = 'https://coolbuy.com'; - const imageBaseUrl: string = 'https://mcache.ifanr.cn'; + const baseUrl = 'https://coolbuy.com'; + const imageBaseUrl = 'https://mcache.ifanr.cn'; const apiUrl: string = new URL('api/v1.4/product_preview', baseUrl).href; const response = await ofetch(apiUrl, { @@ -77,7 +77,7 @@ export const handler = async (ctx: Context): Promise => { ); const linkUrl: string | undefined = item.visit_url; - const guid: string = `coolbuy-${item.id}#${item.price}`; + const guid = `coolbuy-${item.id}#${item.price}`; const processedItem: DataItem = { title, diff --git a/lib/routes/costar/press-releases.ts b/lib/routes/costar/press-releases.ts index b0572fc5e37f12..adb7154ea9262c 100644 --- a/lib/routes/costar/press-releases.ts +++ b/lib/routes/costar/press-releases.ts @@ -13,7 +13,7 @@ export const handler = async (ctx: Context): Promise => { const { filter } = ctx.req.param(); const limit: number = Number.parseInt(ctx.req.query('limit') ?? '10', 10); - const baseUrl: string = 'https://www.costar.com'; + const baseUrl = 'https://www.costar.com'; const targetUrl: string = new URL(`products/benchmark/resources/press-releases${filter ? `?${filter}` : ''}`, baseUrl).href; const response = await ofetch(targetUrl); diff --git a/lib/routes/ctinews/topic.ts b/lib/routes/ctinews/topic.ts index 90536389f87278..ec1d4b745febfe 100644 --- a/lib/routes/ctinews/topic.ts +++ b/lib/routes/ctinews/topic.ts @@ -71,7 +71,7 @@ async function handler(ctx) { ]; const seen = new Set(); - const dedupedList: { title?: string; link?: string }[] = []; + const dedupedList: Array<{ title?: string; link?: string }> = []; for (const item of list) { const link = item.link || ''; if (seen.has(link)) { diff --git a/lib/routes/cursor/changelog.ts b/lib/routes/cursor/changelog.ts index b52f3d30ce8fe7..c9b9e03639a3e5 100644 --- a/lib/routes/cursor/changelog.ts +++ b/lib/routes/cursor/changelog.ts @@ -11,7 +11,7 @@ import { parseDate } from '@/utils/parse-date'; export const handler = async (ctx: Context): Promise => { const limit: number = Number.parseInt(ctx.req.query('limit') ?? '100', 10); - const baseUrl: string = 'https://cursor.com'; + const baseUrl = 'https://cursor.com'; const targetUrl: string = new URL('changelog', baseUrl).href; const response = await ofetch(targetUrl, { @@ -28,7 +28,7 @@ export const handler = async (ctx: Context): Promise => { .map((el): DataItem => { const $el: Cheerio = $(el); - let version: string = ''; + let version = ''; let pubDateStr: string | undefined; $el.find('div').each((_, div) => { @@ -47,7 +47,7 @@ export const handler = async (ctx: Context): Promise => { const title: string = version ? `[${version}] ${titleText}` : titleText; const linkUrl: string | undefined = linkEl.attr('href'); - const guid: string = `cursor-changelog-${version || 'unknown'}`; + const guid = `cursor-changelog-${version || 'unknown'}`; const upDatedStr: string | undefined = pubDateStr; const $h2El = $el.find('h2').first(); diff --git a/lib/routes/daum/potplayer.ts b/lib/routes/daum/potplayer.ts index d682f96817c1e2..653c5800461021 100644 --- a/lib/routes/daum/potplayer.ts +++ b/lib/routes/daum/potplayer.ts @@ -9,7 +9,7 @@ export const handler = async (ctx: Context): Promise => { const { lang } = ctx.req.param(); const limit: number = Number.parseInt(ctx.req.query('limit') ?? '500', 10); - const baseUrl: string = 'https://t1.daumcdn.net'; + const baseUrl = 'https://t1.daumcdn.net'; const targetUrl: string = new URL(`potplayer/PotPlayer/v4/Update2/Update${lang ?? ''}.html`, baseUrl).href; const response: string = await ofetch(targetUrl); @@ -29,7 +29,7 @@ export const handler = async (ctx: Context): Promise => { const headerLine: string | undefined = match[2].trim(); const description: string | undefined = match[4].trim()?.replaceAll(/(\s[+-])/g, '
$1'); - let version: string = 'N/A'; + let version = 'N/A'; let pubDateStr: string | undefined = undefined; // Regex to extract version (e.g., [1.4.20199] or [250514]) @@ -56,7 +56,7 @@ export const handler = async (ctx: Context): Promise => { } } - const guid: string = `potplayer-${lang}-${version}`; + const guid = `potplayer-${lang}-${version}`; const processedItem: DataItem = { title: version, diff --git a/lib/routes/dbaplus/new.ts b/lib/routes/dbaplus/new.ts index 4eace458fd299d..d8d75f8d9cd1ba 100644 --- a/lib/routes/dbaplus/new.ts +++ b/lib/routes/dbaplus/new.ts @@ -16,7 +16,7 @@ export const handler = async (ctx: Context): Promise => { const { id = '9' } = ctx.req.param(); const limit: number = Number.parseInt(ctx.req.query('limit') ?? '30', 10); - const baseUrl: string = 'https://dbaplus.cn'; + const baseUrl = 'https://dbaplus.cn'; const targetUrl: string = new URL(`news-${id}-1.html`, baseUrl).href; const response = await ofetch(targetUrl); diff --git a/lib/routes/deepin/thread.ts b/lib/routes/deepin/thread.ts index 5c7ec627565015..606c41ad98186b 100644 --- a/lib/routes/deepin/thread.ts +++ b/lib/routes/deepin/thread.ts @@ -34,13 +34,13 @@ export const route: Route = { }; interface ThreadIndexResult { - ThreadIndex: { + ThreadIndex: Array<{ id: number; subject: string; created_at: string; user: { nickname: string }; forum: { name: string }; - }[]; + }>; } interface ThreadInfoResult { data: { diff --git a/lib/routes/deepl/blog.ts b/lib/routes/deepl/blog.ts index c828101d5b0be8..41419f934ffec4 100644 --- a/lib/routes/deepl/blog.ts +++ b/lib/routes/deepl/blog.ts @@ -15,7 +15,7 @@ export const handler = async (ctx: Context): Promise => { const { lang = 'en' } = ctx.req.param(); const limit: number = Number.parseInt(ctx.req.query('limit') ?? '30', 10); - const baseUrl: string = 'https://www.deepl.com'; + const baseUrl = 'https://www.deepl.com'; const targetUrl: string = new URL(`${lang}/blog`, baseUrl).href; const response = await ofetch(targetUrl); diff --git a/lib/routes/dgtle/util.ts b/lib/routes/dgtle/util.ts index 98b4f34ec8f196..a9a83f77b1773e 100644 --- a/lib/routes/dgtle/util.ts +++ b/lib/routes/dgtle/util.ts @@ -14,7 +14,7 @@ const md = MarkdownIt({ linkify: true, }); -const baseUrl: string = 'https://www.dgtle.com'; +const baseUrl = 'https://www.dgtle.com'; const ProcessItems = async (limit: number, dataList: any): Promise => { let items: DataItem[] = []; @@ -43,7 +43,7 @@ const ProcessItems = async (limit: number, dataList: any): Promise = avatar: item.user?.avatar_path ?? item.avatar_path, }, ]; - const guid: string = `dgtle-${item.id}`; + const guid = `dgtle-${item.id}`; const updated: number | string = pubDate; const processedItem: DataItem = { @@ -142,7 +142,7 @@ const ProcessFeedItems = (limit: number, dataList: any, $: CheerioAPI): DataItem avatar: item.avatar_path, }, ]; - const guid: string = `dgtle-${item.id}`; + const guid = `dgtle-${item.id}`; const image: string | undefined = item.imgs_url?.[0]; const updated: number | string = item.updated_at ?? pubDate; @@ -174,10 +174,10 @@ const ProcessFeedItems = (limit: number, dataList: any, $: CheerioAPI): DataItem continue; } - const medium: string = 'image'; + const medium = 'image'; const count: number = Object.values(acc).filter((m) => m.medium === medium).length + 1; - const key: string = `${medium}${count}`; + const key = `${medium}${count}`; acc[key] = { url, diff --git a/lib/routes/dgtle/video.ts b/lib/routes/dgtle/video.ts index 933077166d7b1f..da8ce22d2eb361 100644 --- a/lib/routes/dgtle/video.ts +++ b/lib/routes/dgtle/video.ts @@ -15,7 +15,7 @@ import { renderDescription } from './templates/description'; export const handler = async (ctx: Context): Promise => { const limit: number = Number.parseInt(ctx.req.query('limit') ?? '18', 10); - const baseUrl: string = 'https://www.dgtle.com'; + const baseUrl = 'https://www.dgtle.com'; const targetUrl: string = new URL('video', baseUrl).href; const apiUrl: string = new URL('video/list/1', baseUrl).href; @@ -49,7 +49,7 @@ export const handler = async (ctx: Context): Promise => { avatar: item.author.avatar_path?.split(/\?/)?.[0], }, ]; - const guid: string = `dgtle-${item.id}`; + const guid = `dgtle-${item.id}`; const processedItem: DataItem = { title, diff --git a/lib/routes/diariofruticola/filtro.ts b/lib/routes/diariofruticola/filtro.ts index a81dd31c108513..79fcbdc1eb4637 100644 --- a/lib/routes/diariofruticola/filtro.ts +++ b/lib/routes/diariofruticola/filtro.ts @@ -14,7 +14,7 @@ export const handler = async (ctx: Context): Promise => { const { filter } = ctx.req.param(); const limit: number = Number.parseInt(ctx.req.query('limit') ?? '30', 10); - const baseUrl: string = 'https://diariofruticola.cl'; + const baseUrl = 'https://diariofruticola.cl'; const targetUrl: string = new URL(`filtro/${filter}`, baseUrl).href; const response = await ofetch(targetUrl); diff --git a/lib/routes/digitalpolicyalert/activity-tracker.ts b/lib/routes/digitalpolicyalert/activity-tracker.ts index 06ef0167c107de..0eda4f5bddd868 100644 --- a/lib/routes/digitalpolicyalert/activity-tracker.ts +++ b/lib/routes/digitalpolicyalert/activity-tracker.ts @@ -27,8 +27,8 @@ export const handler = async (ctx: Context): Promise => { const limit: number = Number.parseInt(ctx.req.query('limit') ?? '30', 10); const params: URLSearchParams = createSearchParams(filters, limit); - const baseUrl: string = 'https://digitalpolicyalert.org'; - const apiBaseUrl: string = 'https://api.globaltradealert.org'; + const baseUrl = 'https://digitalpolicyalert.org'; + const apiBaseUrl = 'https://api.globaltradealert.org'; const targetUrl: string = new URL(`activity-tracker?${params.toString()}`, baseUrl).href; const apiUrl: string = new URL('dpa/intervention', apiBaseUrl).href; diff --git a/lib/routes/douyin/types.ts b/lib/routes/douyin/types.ts index 645c1b92097f4d..b7ec1b68b5eff1 100644 --- a/lib/routes/douyin/types.ts +++ b/lib/routes/douyin/types.ts @@ -183,7 +183,7 @@ interface Music { prevent_download: boolean; unshelve_countries: null; prevent_item_download_status: number; - external_song_info: false[]; + external_song_info: Array; preview_start_time: number; preview_end_time: number; is_commerce_music: boolean; @@ -191,7 +191,7 @@ interface Music { audition_duration: number; shoot_duration: number; reason_type: number; - artists: false[]; + artists: Array; lyric_short_position: null; mute_share: boolean; tag_list: null; @@ -447,16 +447,16 @@ interface LogPb { } interface SuggestWords { - suggest_words: { - words: { + suggest_words: Array<{ + words: Array<{ word: string; word_id: string; info: string; - }[]; + }>; scene: string; icon_url: string; hint_text: string; - }[]; + }>; } interface CommentPermissionInfo { @@ -661,7 +661,7 @@ interface Aweme { comment_list: null; author_user_id: number; publish_plus_alienation: PublishPlusAlienation; - geofencing: false[]; + geofencing: Array; enable_comment_sticker_rec: boolean; xigua_base_info: XiguaBaseInfo; region: string; @@ -669,7 +669,7 @@ interface Aweme { ref_voice_modify_id_list: null; collect_stat: number; label_top_text: null; - promotions: false[]; + promotions: Array; group_id: string; prevent_download: boolean; nickname_position: null; @@ -720,11 +720,11 @@ interface Aweme { relation_labels: null; mark_largely_following: boolean; impression_data: { - group_id_list_a: false[]; - group_id_list_b: false[]; + group_id_list_a: Array; + group_id_list_b: Array; similar_id_list_a: number[] | null; similar_id_list_b: number[] | null; - group_id_list_c: false[]; + group_id_list_c: Array; }; boost_status: number; authentication_token: string; diff --git a/lib/routes/duozhi/index.ts b/lib/routes/duozhi/index.ts index 22646a90c409d8..96a322bfb6b6c6 100644 --- a/lib/routes/duozhi/index.ts +++ b/lib/routes/duozhi/index.ts @@ -16,7 +16,7 @@ export const handler = async (ctx: Context): Promise => { const { category } = ctx.req.param(); const limit: number = Number.parseInt(ctx.req.query('limit') ?? '30', 10); - const baseUrl: string = 'http://www.duozhi.com'; + const baseUrl = 'http://www.duozhi.com'; const targetUrl: string = new URL(category && category.endsWith('/') ? category : category ? `${category}/` : '', baseUrl).href; const response = await ofetch(targetUrl); diff --git a/lib/routes/dxy/types.ts b/lib/routes/dxy/types.ts index 40c221f638273a..94b217471e9e59 100644 --- a/lib/routes/dxy/types.ts +++ b/lib/routes/dxy/types.ts @@ -111,7 +111,7 @@ interface Post { postPerm: PostPerm; showStatus: boolean; postUser: PostUser; - hintInfos: false[]; + hintInfos: Array; isDisableRepost: boolean; tagInfos: TagInfo[]; isVoteActivityPost: boolean; @@ -140,7 +140,7 @@ interface SpecialAdmin { enterpriseStatus: boolean; identificationTitle: string; blueVip: boolean; - talentBoard: false[]; + talentBoard: Array; userTitle: UserTitle; enterpriseName: string; } @@ -169,7 +169,7 @@ export interface SpecialBoardDetail { pushStatus: boolean; specialAdmins: SpecialAdmin[]; isContribute: boolean; - post: false[]; + post: Array; isOpenPostEntrance: boolean; } diff --git a/lib/routes/dytt/index.ts b/lib/routes/dytt/index.ts index 4ce35c6f3d1129..3a58a5a5cee827 100644 --- a/lib/routes/dytt/index.ts +++ b/lib/routes/dytt/index.ts @@ -11,8 +11,8 @@ import ofetch from '@/utils/ofetch'; import { parseDate } from '@/utils/parse-date'; import timezone from '@/utils/timezone'; -const domain: string = 'www.dydytt.net'; -const baseUrl: string = `https://${domain}`; +const domain = 'www.dydytt.net'; +const baseUrl = `https://${domain}`; export const handler = async (ctx: Context): Promise => { const { category = 'gndy/dyzz' } = ctx.req.param(); @@ -101,7 +101,7 @@ export const handler = async (ctx: Context): Promise => { const enclosureUrl: string | undefined = $enclosureEl.attr('href'); if (enclosureUrl) { - const enclosureType: string = 'application/x-bittorrent'; + const enclosureType = 'application/x-bittorrent'; const enclosureTitle: string = $enclosureEl.text(); processedItem = { diff --git a/lib/routes/eeo/kuaixun.ts b/lib/routes/eeo/kuaixun.ts index cb141920351cd6..f6b2802b67284d 100644 --- a/lib/routes/eeo/kuaixun.ts +++ b/lib/routes/eeo/kuaixun.ts @@ -14,8 +14,8 @@ import { renderDescription } from './templates/description'; export const handler = async (ctx: Context): Promise => { const limit: number = Number.parseInt(ctx.req.query('limit') ?? '50', 10); - const baseUrl: string = 'https://www.eeo.com.cn'; - const apiUrl: string = 'https://app.eeo.com.cn'; + const baseUrl = 'https://www.eeo.com.cn'; + const apiUrl = 'https://app.eeo.com.cn'; const targetUrl: string = new URL('kuaixun/', baseUrl).href; const response = await ofetch(apiUrl, { diff --git a/lib/routes/eventbrite/events.ts b/lib/routes/eventbrite/events.ts index f9c99ef7c771a6..13a3b0677aaa9c 100644 --- a/lib/routes/eventbrite/events.ts +++ b/lib/routes/eventbrite/events.ts @@ -126,9 +126,9 @@ interface EventbriteEvent { url: string; }; summary: string; - tags: { + tags: Array<{ display_name: string; - }[]; + }>; image: { url: string; original: { diff --git a/lib/routes/expats/czech-news.ts b/lib/routes/expats/czech-news.ts index 4c51a4836888c1..2cbcb13cdb4aaf 100644 --- a/lib/routes/expats/czech-news.ts +++ b/lib/routes/expats/czech-news.ts @@ -13,7 +13,7 @@ export const handler = async (ctx: Context): Promise => { const { category = 'daily-news' } = ctx.req.param(); const limit: number = Number.parseInt(ctx.req.query('limit') ?? '30', 10); - const baseUrl: string = 'https://www.expats.cz'; + const baseUrl = 'https://www.expats.cz'; const targetUrl: string = new URL(`czech-news/${category}`, baseUrl).href; const response = await ofetch(targetUrl); diff --git a/lib/routes/famitsu/types.ts b/lib/routes/famitsu/types.ts index 234008d7b5f997..7bddde13b31ada 100644 --- a/lib/routes/famitsu/types.ts +++ b/lib/routes/famitsu/types.ts @@ -42,11 +42,11 @@ export interface ArticleDetail { name_ja: string; }; description: string; - content: { + content: Array<{ page_no: number; contents: Content[]; text: string; - }[]; + }>; mainCategories: Category; publishedAt: string; subCategories: Category[]; @@ -63,7 +63,7 @@ export interface ArticleDetail { offset: number; page: number; limit: number; - results: { + results: Array<{ id: string; article_type: string; main_category_ids: string[]; @@ -91,27 +91,27 @@ export interface ArticleDetail { tweet_id: string; game_ids: string[]; author_ids: string[]; - }[]; + }>; }; - authors: { + authors: Array<{ id: number; icon_url: string; name_ja: string; description: string; relate_urls: any[]; - }[]; + }>; redirectUrl: string; copyright: string; - relatedLinks: { + relatedLinks: Array<{ title: string; description: null; url: string; article: any[]; - }[]; + }>; isToc: boolean; - items: { + items: Array<{ status: string; item_id: string; item_type: string; - }[]; + }>; } diff --git a/lib/routes/fanbox/types.ts b/lib/routes/fanbox/types.ts index 027a9e1c3337e5..cb447ef06118d8 100644 --- a/lib/routes/fanbox/types.ts +++ b/lib/routes/fanbox/types.ts @@ -10,12 +10,12 @@ export interface UserInfoResponse { hasAdultContent: boolean; coverImageUrl: string; profileLinks: string[]; - profileItems: { + profileItems: Array<{ id: string; type: string; serviceProvider: string; videoId: string; - }[]; + }>; isFollowed: boolean; isSupported: boolean; isStopped: boolean; @@ -60,7 +60,7 @@ export interface PostItem { interface BasicPost { commentCount: number; commentList: { - items: { + items: Array<{ body: string; createdDatetime: string; id: string; @@ -68,7 +68,7 @@ interface BasicPost { isOwn: boolean; likeCount: number; parentCommentId: string; - replies: { + replies: Array<{ body: string; createdDatetime: string; id: string; @@ -77,14 +77,14 @@ interface BasicPost { likeCount: number; parentCommentId: string; rootCommentId: string; - }[]; + }>; rootCommentId: string; user: { iconUrl: string; name: string; userId: string; }; - }[]; + }>; }; coverImageUrl: string | null; creatorId: string; @@ -152,13 +152,13 @@ export interface ArticlePost extends BasicPost { export interface FilePost extends BasicPost { type: 'file'; body: { - files: { + files: Array<{ extension: string; id: string; name: string; size: number; url: string; - }[]; + }>; text: string; }; } @@ -177,14 +177,14 @@ export interface VideoPost extends BasicPost { export interface ImagePost extends BasicPost { type: 'image'; body: { - images: { + images: Array<{ id: string; originalUrl: string; thumbnailUrl: string; width: number; height: number; extension: string; - }[]; + }>; text: string; }; } @@ -199,11 +199,11 @@ export interface TextPost extends BasicPost { interface TextBlock { type: 'p'; text: string; - styles?: { + styles?: Array<{ length: number; offset: number; type: 'bold'; - }[]; + }>; } interface HeaderBlock { diff --git a/lib/routes/fanbox/utils.tsx b/lib/routes/fanbox/utils.tsx index da6abc5874724c..09478a3bed315e 100644 --- a/lib/routes/fanbox/utils.tsx +++ b/lib/routes/fanbox/utils.tsx @@ -100,9 +100,8 @@ async function parseVideo(body: VideoPost['body']) { } async function parseArtile(body: ArticlePost['body']) { - let ret: Array = []; - for (let x = 0; x < body.blocks.length; ++x) { - const b = body.blocks[x]; + let ret: string[] = []; + for (const b of body.blocks) { ret.push('

'); switch (b.type) { diff --git a/lib/routes/fangchan/list.tsx b/lib/routes/fangchan/list.tsx index 68d42daa9a243c..2d61e2def3bb7d 100644 --- a/lib/routes/fangchan/list.tsx +++ b/lib/routes/fangchan/list.tsx @@ -15,8 +15,8 @@ export const handler = async (ctx: Context): Promise => { const { id = 'datalist' } = ctx.req.param(); const limit: number = Number.parseInt(ctx.req.query('limit') ?? '30', 10); - const baseUrl: string = 'http://www.fangchan.com'; - const apiBaseUrl: string = 'http://news.fangchan.com'; + const baseUrl = 'http://www.fangchan.com'; + const apiBaseUrl = 'http://news.fangchan.com'; const targetUrl: string = new URL(id.endsWith('/') ? id : `${id}/`, baseUrl).href; const apiUrl: string = new URL(`api/${id.endsWith('/') ? id.replace(/\/$/, '') : id}.json`, apiBaseUrl).href; @@ -134,7 +134,7 @@ export const handler = async (ctx: Context): Promise => { ) ).filter((_): _ is DataItem => true); - const author: string = '中房网'; + const author = '中房网'; return { title: `${author} - ${$('div.curmbs a').text()}`, diff --git a/lib/routes/fantube/types.ts b/lib/routes/fantube/types.ts index 9908eab702ec13..735dd2c48fba78 100644 --- a/lib/routes/fantube/types.ts +++ b/lib/routes/fantube/types.ts @@ -18,9 +18,9 @@ interface Plan { subscribersCount: number; planPosts: { totalCount: number; - nodes: { + nodes: Array<{ post: PlanPost; - }[]; + }>; }; } @@ -82,9 +82,9 @@ export interface PostReelNode { creator: CreatorFragment; comments: Comments; planPosts: { - nodes: { + nodes: Array<{ plan: Plan; - }[]; + }>; }; favoritesCount: number; contentData: { diff --git a/lib/routes/fediverse/timeline.ts b/lib/routes/fediverse/timeline.ts index 210f9b3b6d068a..31ff44fc853f72 100644 --- a/lib/routes/fediverse/timeline.ts +++ b/lib/routes/fediverse/timeline.ts @@ -80,7 +80,7 @@ async function handler(ctx) { const items = firstOutbox.orderedItems; - const itemResolvers = [] as Promise[]; + const itemResolvers = [] as Array>; for (const item of items) { if (!['Announce', 'Create', 'Update'].includes(item.type)) { diff --git a/lib/routes/follow/profile.ts b/lib/routes/follow/profile.ts index e28834080ffd20..79eaeb3937e5a4 100644 --- a/lib/routes/follow/profile.ts +++ b/lib/routes/follow/profile.ts @@ -52,7 +52,7 @@ async function handler(ctx: Context): Promise { return { title: `${profile.data.name}'s subscriptions`, - item: ([]>subscriptions.data.filter((i) => !isInbox(i) && !(isFeed(i) && !!i.feeds.errorAt))).map((subscription) => { + item: (subscriptions.data.filter((i) => !isInbox(i) && !(isFeed(i) && !!i.feeds.errorAt)) as Array>).map((subscription) => { if (isList(subscription)) { return { title: subscription.lists.title, diff --git a/lib/routes/furaffinity/status.ts b/lib/routes/furaffinity/status.ts index e9dc5041fc65da..ac5deb083cdcb0 100644 --- a/lib/routes/furaffinity/status.ts +++ b/lib/routes/furaffinity/status.ts @@ -42,7 +42,7 @@ async function handler() { ? `Status: FA Server Online
Guests: ${data.online.guests}
Registered: ${data.online.registered}
Other: ${data.online.other}
Total: ${data.online.total}
FA Server Time: ${data.fa_server_time}
FA Server Time at: ${data.fa_server_time_at}` : 'FA Server Offline'; - const items: { title: string; link: string; description: string }[] = [ + const items: Array<{ title: string; link: string; description: string }> = [ { title: `Status: ${Object.keys(data)[0]}`, link: 'https://www.furaffinity.net/', diff --git a/lib/routes/furaffinity/user.ts b/lib/routes/furaffinity/user.ts index f7ac1e981a850b..60c7ce54404c1d 100644 --- a/lib/routes/furaffinity/user.ts +++ b/lib/routes/furaffinity/user.ts @@ -104,7 +104,7 @@ async function handler(ctx) { Favorite Animal: ${favorites_animal}
Favorite Website: ${favorites_website}
Favorite Food: ${favorites_food}

Contact Information:
${contact_result} Watchers Count: ${watchers_count}
Watching Count: ${watching_count} `; - const items: { title: string; link: string; description: string }[] = [ + const items: Array<{ title: string; link: string; description: string }> = [ { title: `${data.name}'s User Profile`, link: `https://www.furaffinity.net/user/${username}`, diff --git a/lib/routes/gamebase/news.tsx b/lib/routes/gamebase/news.tsx index 7b6103e1fd6816..14003396002e27 100644 --- a/lib/routes/gamebase/news.tsx +++ b/lib/routes/gamebase/news.tsx @@ -43,9 +43,9 @@ export const handler = async (ctx: Context): Promise => { const limit: number = Number.parseInt(ctx.req.query('limit') ?? '30', 10); - const baseUrl: string = 'https://news.gamebase.com.tw'; + const baseUrl = 'https://news.gamebase.com.tw'; const targetUrl: string = new URL(`news${category === 'all' ? '' : `/newslist?type=${category}`}`, baseUrl).href; - const apiBaseUrl: string = 'https://api.gamebase.com.tw'; + const apiBaseUrl = 'https://api.gamebase.com.tw'; const apiUrl: string = new URL('api/news/getNewsList', apiBaseUrl).href; const response = await ofetch(apiUrl, { @@ -69,7 +69,7 @@ export const handler = async (ctx: Context): Promise => { const linkUrl: string | undefined = item.news_no ? `news/detail/${item.news_no}` : undefined; const categories: string[] = [item.system]; const authors: DataItem['author'] = item.nickname; - const guid: string = `gamebase-news-${item.news_no}`; + const guid = `gamebase-news-${item.news_no}`; const image: string | undefined = item.news_img; const updated: number | string = item.updated ?? pubDate; diff --git a/lib/routes/gaoyu/blog.ts b/lib/routes/gaoyu/blog.ts index 77752dc8cd45c1..56b7cd30cc4b38 100644 --- a/lib/routes/gaoyu/blog.ts +++ b/lib/routes/gaoyu/blog.ts @@ -14,7 +14,7 @@ import { renderDescription } from './templates/description'; export const handler = async (ctx: Context): Promise => { const limit: number = Number.parseInt(ctx.req.query('limit') ?? '20', 10); - const baseUrl: string = 'https://www.gaoyu.me'; + const baseUrl = 'https://www.gaoyu.me'; const targetUrl: string = new URL('blog', baseUrl).href; const response = await ofetch(targetUrl); diff --git a/lib/routes/gcores/parser.ts b/lib/routes/gcores/parser.ts index 596fc4bf4aa334..4fc13d65cbc450 100644 --- a/lib/routes/gcores/parser.ts +++ b/lib/routes/gcores/parser.ts @@ -43,7 +43,7 @@ interface Content { entityMap: { [key: string]: Entity }; } -const imageBaseUrl: string = 'https://image.gcores.com'; +const imageBaseUrl = 'https://image.gcores.com'; const STYLES: Readonly> = { BOLD: { fontWeight: 'bold' }, @@ -167,7 +167,7 @@ const parseBlock = (block: Block, entityMap: Readonly>): // Group ranges by offset and length const groupedRangesMap = new Map(); - const groupedRanges: { offset: number; length: number; styles: Style[]; entities: Entity[] }[] = []; + const groupedRanges: Array<{ offset: number; length: number; styles: Style[]; entities: Entity[] }> = []; for (const range of combinedRanges) { const rangeKey = `${range.offset}-${range.length}`; diff --git a/lib/routes/gcores/util.ts b/lib/routes/gcores/util.ts index a80c7bbd5b6779..a18b16bf3638b0 100644 --- a/lib/routes/gcores/util.ts +++ b/lib/routes/gcores/util.ts @@ -8,11 +8,11 @@ import { parseDate } from '@/utils/parse-date'; import { parseContent } from './parser'; import { renderDescription } from './templates/description'; -const baseUrl: string = 'https://www.gcores.com'; -const imageBaseUrl: string = 'https://image.gcores.com'; -const audioBaseUrl: string = 'https://alioss.gcores.com'; +const baseUrl = 'https://www.gcores.com'; +const imageBaseUrl = 'https://image.gcores.com'; +const audioBaseUrl = 'https://alioss.gcores.com'; -const types: Set = new Set(['radios', 'articles', 'news', 'videos', 'talks']); +const types = new Set(['radios', 'articles', 'news', 'videos', 'talks']); const processItems = async (limit: number, query: any, apiUrl: string, targetUrl: string): Promise => { const response = await ofetch(apiUrl, { @@ -61,7 +61,7 @@ const processItems = async (limit: number, query: any, apiUrl: string, targetUrl ] : undefined; - const guid: string = `gcores-${item.id}`; + const guid = `gcores-${item.id}`; const image: string | undefined = (attributes.cover ?? attributes.thumb) ? new URL(attributes.cover ?? attributes.thumb, imageBaseUrl).href : undefined; const updated: number | string = pubDate; diff --git a/lib/routes/gitstar-ranking/index.tsx b/lib/routes/gitstar-ranking/index.tsx index 3f58ab6d7cf3ee..99a4ce7dade1a7 100644 --- a/lib/routes/gitstar-ranking/index.tsx +++ b/lib/routes/gitstar-ranking/index.tsx @@ -51,7 +51,7 @@ export const handler = async (ctx: Context): Promise => { const { category = 'repositories' } = ctx.req.param(); const limit: number = Number.parseInt(ctx.req.query('limit') ?? '100', 10); - const baseUrl: string = 'https://gitstar-ranking.com'; + const baseUrl = 'https://gitstar-ranking.com'; const targetUrl: string = new URL(category, baseUrl).href; const response = await ofetch(targetUrl); @@ -64,7 +64,7 @@ export const handler = async (ctx: Context): Promise => { .map((el): Element => { const $el: Cheerio = $(el); - const stargazersCount: number = Number($el.find('span.stargazers_count').text()?.trim()); + const stargazersCount = Number($el.find('span.stargazers_count').text()?.trim()); const title: string = $el.find('span.hidden-xs').text()?.trim(); const image: string | undefined = $el.find('img.avatar_image_big').attr('src'); const language: string | undefined = $el.find('div.repo-language').text()?.trim(); @@ -83,7 +83,7 @@ export const handler = async (ctx: Context): Promise => { }); const linkUrl: string | undefined = $el.attr('href'); const categories: string[] = language ? [language] : []; - const guid: string = `gitstar-ranking-${title}-${stargazersCount}`; + const guid = `gitstar-ranking-${title}-${stargazersCount}`; const processedItem: DataItem = { title: `${title} ⭐${stargazersCount}`, diff --git a/lib/routes/go/jihs/idwr.ts b/lib/routes/go/jihs/idwr.ts index e3ebd4602c040a..b4ee2d730a348b 100644 --- a/lib/routes/go/jihs/idwr.ts +++ b/lib/routes/go/jihs/idwr.ts @@ -12,7 +12,7 @@ export const handler = async (ctx: Context): Promise => { const { year = new Date().getFullYear() } = ctx.req.param(); const limit: number = Number.parseInt(ctx.req.query('limit') ?? '30', 10); - const baseUrl: string = 'https://id-info.jihs.go.jp'; + const baseUrl = 'https://id-info.jihs.go.jp'; const targetUrl: string = new URL(`surveillance/idwr/jp/idwr/${year}/`, baseUrl).href; const response = await ofetch(targetUrl); @@ -52,7 +52,7 @@ export const handler = async (ctx: Context): Promise => { const enclosureUrl: string | undefined = linkUrl ? new URL(linkUrl, targetUrl).href : undefined; if (enclosureUrl) { - const enclosureType: string = `application/${enclosureUrl.split(/\./).pop()}`; + const enclosureType = `application/${enclosureUrl.split(/\./).pop()}`; const enclosureTitle: string = $enclosureEl.text(); processedItem = { diff --git a/lib/routes/gov/general/general.ts b/lib/routes/gov/general/general.ts index d060e356c4afec..fe65e569b8eb59 100644 --- a/lib/routes/gov/general/general.ts +++ b/lib/routes/gov/general/general.ts @@ -177,8 +177,8 @@ const gdgov = async (info, ctx) => { const zcjdlink = 'https://zcjd.cloud.gd.gov.cn/api/home/article' + idlink.search; const response = await got(zcjdlink); const data = response.data.data; - for (let index = 0; index < data.jie_du_items.length; index++) { - data.jie_du_items[index].jd_content = data.jie_du_items[index].jd_content.replaceAll(/((\n {4})|(\n))/g, '

'); + for (const item of data.jie_du_items) { + item.jd_content = item.jd_content.replaceAll(/((\n {4})|(\n))/g, '

'); } return { diff --git a/lib/routes/gov/mee/nnsa.ts b/lib/routes/gov/mee/nnsa.ts index baa6523d404d90..a03e555967e475 100644 --- a/lib/routes/gov/mee/nnsa.ts +++ b/lib/routes/gov/mee/nnsa.ts @@ -14,7 +14,7 @@ export const handler = async (ctx: Context): Promise => { const { category = 'ywdt/hjyw' } = ctx.req.param(); const limit: number = Number.parseInt(ctx.req.query('limit') ?? '15', 10); - const baseUrl: string = 'https://nnsa.mee.gov.cn'; + const baseUrl = 'https://nnsa.mee.gov.cn'; const targetUrl: string = new URL(category.endsWith('/') ? category : `${category}/`, baseUrl).href; const response = await ofetch(targetUrl); @@ -54,7 +54,7 @@ export const handler = async (ctx: Context): Promise => { const title: string = $$('meta[name="ArticleTitle"]').attr('content') ?? item.title; const description: string | undefined = $$('div.Custom_UnionStyle').html() ?? undefined; const pubDateStr: string | undefined = $$('meta[name="PubDate"]').attr('content'); - const categoryEls: Cheerio[] = [$$('meta[name="ColumnName"]'), $$('meta[name="ColumnType"]'), $$('meta[name="ContentSource"]'), $$('meta[name="source"]')]; + const categoryEls: Array> = [$$('meta[name="ColumnName"]'), $$('meta[name="ColumnType"]'), $$('meta[name="ContentSource"]'), $$('meta[name="source"]')]; const categories: string[] = [...new Set(categoryEls.map((el) => $$(el)?.attr('content') ?? '').filter(Boolean))]; const authors: DataItem['author'] = [$$('meta[name="Author"]'), $$('meta[name="author"]'), $$('meta[name="source"]')] .filter((authorEl) => $$(authorEl).attr('content')) diff --git a/lib/routes/gov/moa/gjs.ts b/lib/routes/gov/moa/gjs.ts index bfe60e1952e880..45b7b1ad0be41e 100644 --- a/lib/routes/gov/moa/gjs.ts +++ b/lib/routes/gov/moa/gjs.ts @@ -14,7 +14,7 @@ export const handler = async (ctx: Context): Promise => { const { category = 'gzdt' } = ctx.req.param(); const limit: number = Number.parseInt(ctx.req.query('limit') ?? '30', 10); - const baseUrl: string = 'http://www.gjs.moa.gov.cn'; + const baseUrl = 'http://www.gjs.moa.gov.cn'; const targetUrl: string = new URL(category.endsWith('/') ? category : `${category}/`, baseUrl).href; const response = await ofetch(targetUrl); @@ -86,7 +86,7 @@ export const handler = async (ctx: Context): Promise => { const enclosureUrl: string | undefined = $enclosureEl.attr('href'); if (enclosureUrl) { - const enclosureType: string = `application/${enclosureUrl.split('.').pop()}`; + const enclosureType = `application/${enclosureUrl.split('.').pop()}`; const enclosureTitle: string = $enclosureEl.text(); processedItem = { @@ -106,7 +106,7 @@ export const handler = async (ctx: Context): Promise => { ) ).filter((_): _ is DataItem => true); - const author: string = '中华人民共和国农业农村部国际合作司'; + const author = '中华人民共和国农业农村部国际合作司'; const description: string = $('meta[name="ColumnName"]').attr('content') ?? ''; return { diff --git a/lib/routes/gov/mot/index.ts b/lib/routes/gov/mot/index.ts index d82e53457bc917..da2416e1648e84 100644 --- a/lib/routes/gov/mot/index.ts +++ b/lib/routes/gov/mot/index.ts @@ -13,7 +13,7 @@ export const handler = async (ctx: Context): Promise => { const { category = 'jiaotongyaowen' } = ctx.req.param(); const limit: number = Number.parseInt(ctx.req.query('limit') ?? '30', 10); - const baseUrl: string = 'https://www.mot.gov.cn'; + const baseUrl = 'https://www.mot.gov.cn'; const targetUrl: string = new URL(category.endsWith('/') ? category : `${category}/`, baseUrl).href; const response = await ofetch(targetUrl); diff --git a/lib/routes/grainoil/category.ts b/lib/routes/grainoil/category.ts index cb16b1debabdd8..54e6be4e91a0d6 100644 --- a/lib/routes/grainoil/category.ts +++ b/lib/routes/grainoil/category.ts @@ -13,7 +13,7 @@ export const handler = async (ctx: Context): Promise => { const { category, id } = ctx.req.param(); const limit: number = Number.parseInt(ctx.req.query('limit') ?? '30', 10); - const baseUrl: string = 'http://load.grainoil.com.cn'; + const baseUrl = 'http://load.grainoil.com.cn'; const targetUrl: string = new URL(`${category}/${id}.jspx`, baseUrl).href; const response = await ofetch(targetUrl); diff --git a/lib/routes/hex-rays/index.ts b/lib/routes/hex-rays/index.ts index 337a4f4efc62d8..f1448cb4dfdcb4 100644 --- a/lib/routes/hex-rays/index.ts +++ b/lib/routes/hex-rays/index.ts @@ -56,7 +56,7 @@ async function handler(/* ctx*/): Promise { item.description = content('.post-body').html(); return item; }) - ) as Promise[] + ) as Array> ); return { diff --git a/lib/routes/hit/hitgs.ts b/lib/routes/hit/hitgs.ts index 430ee5f0adbcda..a38c24934d9a84 100644 --- a/lib/routes/hit/hitgs.ts +++ b/lib/routes/hit/hitgs.ts @@ -15,7 +15,7 @@ export const handler = async (ctx: Context): Promise => { const { id = 'tzgg' } = ctx.req.param(); const limit: number = Number.parseInt(ctx.req.query('limit') ?? '10', 10); - const baseUrl: string = 'https://hitgs.hit.edu.cn'; + const baseUrl = 'https://hitgs.hit.edu.cn'; const targetUrl: string = new URL(`${id}/list.htm`, baseUrl).href; const response = await ofetch(targetUrl); @@ -94,7 +94,7 @@ export const handler = async (ctx: Context): Promise => { const enclosureUrl: string | undefined = $enclosureEl.attr('href'); if (enclosureUrl) { - const enclosureType: string = `application/${enclosureUrl.split(/\./).pop() || 'octet-stream'}`; + const enclosureType = `application/${enclosureUrl.split(/\./).pop() || 'octet-stream'}`; const enclosureTitle: string | undefined = $enclosureEl.attr('sudyfile-attr')?.match(/'title':'(.*?)'/)?.[1]; processedItem = { diff --git a/lib/routes/home-assistant/hacs.ts b/lib/routes/home-assistant/hacs.ts index 593b655c9dd691..42c83bb6447819 100644 --- a/lib/routes/home-assistant/hacs.ts +++ b/lib/routes/home-assistant/hacs.ts @@ -20,7 +20,7 @@ async function handler() { return Object.values(response); }) ) - ).flat() as { + ).flat() as Array<{ manifest: { name: string; }; @@ -32,7 +32,7 @@ async function handler() { topics?: string[]; last_updated: string; last_fetched: number; - }[]; + }>; return { title: 'HACS Repositories', diff --git a/lib/routes/huggingface/daily-papers.ts b/lib/routes/huggingface/daily-papers.ts index acfb3351a959bb..6ba57137b9bdef 100644 --- a/lib/routes/huggingface/daily-papers.ts +++ b/lib/routes/huggingface/daily-papers.ts @@ -33,7 +33,7 @@ interface Paper { id: string; summary: string; upvotes: number; - authors: { name: string }[]; + authors: Array<{ name: string }>; } interface DailyPaperItem { diff --git a/lib/routes/hupu/index.ts b/lib/routes/hupu/index.ts index 3c9d32e48fd67e..e072cd5766921e 100644 --- a/lib/routes/hupu/index.ts +++ b/lib/routes/hupu/index.ts @@ -75,7 +75,7 @@ export const route: Route = { throw new Error(`Expected '${dataKey}' property not found in pageProps for category: ${category || 'home'}`); } - const rawDataArray: (HomePostItem | NewsDataItem)[] = (() => { + const rawDataArray: Array = (() => { const data = (pageProps as any)[dataKey]; return Array.isArray(data) ? data : []; })(); diff --git a/lib/routes/ifanr/digest.ts b/lib/routes/ifanr/digest.ts index e53dd3289cfa05..7f4877b7c2be83 100644 --- a/lib/routes/ifanr/digest.ts +++ b/lib/routes/ifanr/digest.ts @@ -10,8 +10,8 @@ import { parseDate } from '@/utils/parse-date'; export const handler = async (ctx: Context): Promise => { const limit: number = Number.parseInt(ctx.req.query('limit') ?? '20', 10); - const baseUrl: string = 'https://www.ifanr.com'; - const apiBaseUrl: string = 'https://sso.ifanr.com'; + const baseUrl = 'https://www.ifanr.com'; + const apiBaseUrl = 'https://sso.ifanr.com'; const targetUrl: string = new URL('digest', baseUrl).href; const apiUrl: string = new URL('api/v5/wp/buzz', apiBaseUrl).href; @@ -30,8 +30,8 @@ export const handler = async (ctx: Context): Promise => { const title: string = item.post_title; const description: string = item.post_content; const pubDate: number | string = item.created_at; - const linkUrl: string = `digest/${item.post_id}`; - const guid: string = `ifanr-digest-${item.post_id}`; + const linkUrl = `digest/${item.post_id}`; + const guid = `ifanr-digest-${item.post_id}`; const updated: number | string = item.updated_at ?? pubDate; const processedItem: DataItem = { diff --git a/lib/routes/ifun/n/util.ts b/lib/routes/ifun/n/util.ts index 41f7162b806f76..450a0eebc635d4 100644 --- a/lib/routes/ifun/n/util.ts +++ b/lib/routes/ifun/n/util.ts @@ -1,15 +1,15 @@ import type { DataItem } from '@/types'; import { parseDate } from '@/utils/parse-date'; -const author: string = '趣集'; -const language: string = 'zh-CN'; -const rootUrl: string = 'https://n.ifun.cool'; +const author = '趣集'; +const language = 'zh-CN'; +const rootUrl = 'https://n.ifun.cool'; const processItems: (items: any[], limit: number) => DataItem[] = (items: any[], limit: number) => items.slice(0, limit).map((item): DataItem => { const title: string = item.title; const description: string = item.content; - const guid: string = `ifun-n-${item.id}`; + const guid = `ifun-n-${item.id}`; const author: DataItem['author'] = item.author; diff --git a/lib/routes/iknowwhatyoudownload/daily.tsx b/lib/routes/iknowwhatyoudownload/daily.tsx index f4e360d1913eec..fee7539da98a72 100644 --- a/lib/routes/iknowwhatyoudownload/daily.tsx +++ b/lib/routes/iknowwhatyoudownload/daily.tsx @@ -47,7 +47,7 @@ async function handler(ctx) { const $ = load(response.data); - const numStats: { percent: string; desc: string }[] = []; + const numStats: Array<{ percent: string; desc: string }> = []; $('.usePercent').each((_, elem) => { numStats.push({ percent: $(elem).text(), diff --git a/lib/routes/indianexpress/section.ts b/lib/routes/indianexpress/section.ts index 38bbbfb08623ff..d58b9a184c6bb1 100644 --- a/lib/routes/indianexpress/section.ts +++ b/lib/routes/indianexpress/section.ts @@ -12,7 +12,7 @@ export const handler = async (ctx: Context): Promise => { const limit: number = Number.parseInt(ctx.req.query('limit') ?? '50', 10); const apiSlug = 'wp-json/wp/v2'; - const baseUrl: string = 'https://indianexpress.com'; + const baseUrl = 'https://indianexpress.com'; const apiUrl = new URL(`${apiSlug}/article`, baseUrl).href; const apiSearchUrl = new URL(`${apiSlug}/ie_section`, baseUrl).href; diff --git a/lib/routes/infzm/types.ts b/lib/routes/infzm/types.ts index 1f6ba32da0bf51..83cbe3dcfeecb5 100644 --- a/lib/routes/infzm/types.ts +++ b/lib/routes/infzm/types.ts @@ -2,12 +2,12 @@ export interface ContentsResponse { code: number; msg: string; data: { - contents: { + contents: Array<{ id: number; subject: string; author: string; publish_time: string; - }[]; + }>; current_term: { id: number; title: string; diff --git a/lib/routes/inspirehep/types.ts b/lib/routes/inspirehep/types.ts index 44c44cfb6a9010..ba3f03ec797410 100644 --- a/lib/routes/inspirehep/types.ts +++ b/lib/routes/inspirehep/types.ts @@ -12,133 +12,133 @@ interface Links { interface Metadata { number_of_authors: number; date: string; - publication_info: { + publication_info: Array<{ year: number; artid?: string; journal_volume?: string; journal_title?: string; journal_issue?: string; - }[]; + }>; citation_count: number; is_collection_hidden: boolean; - authors: { + authors: Array<{ uuid: string; record: { $ref: string; }; full_name: string; first_name: string; - ids: { + ids: Array<{ schema: string; value: string; - }[]; + }>; last_name: string; recid: number; - affiliations: { + affiliations: Array<{ value: string; record: { $ref: string; }; curated_relation?: boolean; - }[]; - raw_affiliations: { + }>; + raw_affiliations: Array<{ value: string; - }[]; + }>; curated_relation?: boolean; - }[]; + }>; citation_count_without_self_citations: number; - titles: { + titles: Array<{ title: string; source: string; - }[]; + }>; texkeys: string[]; - imprints: { + imprints: Array<{ date: string; publisher?: string; - }[]; - abstracts: { + }>; + abstracts: Array<{ value: string; source: string; - }[]; + }>; document_type: string[]; control_number: number; - inspire_categories: { + inspire_categories: Array<{ term: string; source?: string; - }[]; + }>; number_of_pages?: number; - keywords?: { + keywords?: Array<{ value: string; source?: string; schema?: string; - }[]; + }>; thesis_info?: { - institutions: { + institutions: Array<{ name: string; record: { $ref: string; }; curated_relation?: boolean; - }[]; + }>; degree_type: string; date: string; }; - license?: { + license?: Array<{ url: string; license: string; imposing?: string; - }[]; - persistent_identifiers?: { + }>; + persistent_identifiers?: Array<{ value: string; schema: string; source: string; - }[]; - supervisors?: { + }>; + supervisors?: Array<{ uuid: string; record: { $ref: string; }; full_name: string; inspire_roles: string[]; - }[]; - isbns?: { + }>; + isbns?: Array<{ value: string; medium?: string; - }[]; - urls?: { + }>; + urls?: Array<{ value: string; description?: string; - }[]; - dois?: { + }>; + dois?: Array<{ value: string; - }[]; + }>; number_of_references?: number; - external_system_identifiers?: { + external_system_identifiers?: Array<{ url_name: string; url_link: string; - }[]; - report_numbers?: { + }>; + report_numbers?: Array<{ value: string; - }[]; - accelerator_experiments?: { + }>; + accelerator_experiments?: Array<{ name: string; record: { $ref: string; }; - }[]; - documents?: { + }>; + documents?: Array<{ source: string; key: string; url: string; fulltext: boolean; hidden: boolean; filename: string; - }[]; + }>; citation_pdf_urls?: string[]; - fulltext_links?: { + fulltext_links?: Array<{ description: string; value: string; - }[]; + }>; } interface Literature { @@ -163,26 +163,26 @@ export interface AuthorResponse { bai: string; facet_author_name: string; should_display_positions: boolean; - positions: { + positions: Array<{ institution: string; current: boolean; display_date: string; record: { $ref: string; }; - }[]; - project_membership: { + }>; + project_membership: Array<{ name: string; record: { $ref: string; }; current: boolean; curated_relation: boolean; - }[]; - ids: { + }>; + ids: Array<{ value: string; schema: string; - }[]; + }>; name: { value: string; preferred_name: string; @@ -203,8 +203,8 @@ export interface LiteratureResponse { total: number; }; links: Links; - sort_options: { + sort_options: Array<{ value: string; title: string; - }[]; + }>; } diff --git a/lib/routes/investor/index.ts b/lib/routes/investor/index.ts index b1e82c70976107..b1b2755339d2fa 100644 --- a/lib/routes/investor/index.ts +++ b/lib/routes/investor/index.ts @@ -13,7 +13,7 @@ export const handler = async (ctx: Context): Promise => { const { id = 'home/zxdt' } = ctx.req.param(); const limit: number = Number.parseInt(ctx.req.query('limit') ?? '20', 10); - const baseUrl: string = 'https://www.investor.org.cn'; + const baseUrl = 'https://www.investor.org.cn'; const targetUrl: string = new URL(id.endsWith('/') ? id : `${id}/`, baseUrl).href; const response = await ofetch(targetUrl); diff --git a/lib/routes/iresearch/report.ts b/lib/routes/iresearch/report.ts index 329c44649c4096..2fc2a1075dd088 100644 --- a/lib/routes/iresearch/report.ts +++ b/lib/routes/iresearch/report.ts @@ -212,8 +212,8 @@ export const handler = async (ctx: Context): Promise => { const type: number = typeObj.value; const id: string | undefined = idObj ? String(idObj.value) : undefined; - const baseUrl: string = 'https://www.iresearch.com.cn'; - const imageBaseUrl: string = 'https://pic.iresearch.cn'; + const baseUrl = 'https://www.iresearch.com.cn'; + const imageBaseUrl = 'https://pic.iresearch.cn'; const targetUrl: string = new URL(`report.shtml?type=${type}${id ? `&classId=${id}` : ''}`, baseUrl).href; const apiUrl: string = new URL(`api/${typeObj.slug}`, baseUrl).href; const apiDetailUrl: string = new URL(`api/${typeObj.detailSlug}`, baseUrl).href; @@ -282,8 +282,8 @@ export const handler = async (ctx: Context): Promise => { const medias: Record> = (() => { const result: Record> = {}; - const medium: string = 'image'; - let count: number = 0; + const medium = 'image'; + let count = 0; for (const media of images) { const url: string | undefined = media; @@ -293,7 +293,7 @@ export const handler = async (ctx: Context): Promise => { } count += 1; - const key: string = `${medium}${count}`; + const key = `${medium}${count}`; result[key] = { url, @@ -377,8 +377,8 @@ export const handler = async (ctx: Context): Promise => { const medias: Record> = (() => { const result: Record> = {}; - const medium: string = 'image'; - let count: number = 0; + const medium = 'image'; + let count = 0; for (const media of images) { const url: string | undefined = media; @@ -388,7 +388,7 @@ export const handler = async (ctx: Context): Promise => { } count += 1; - const key: string = `${medium}${count}`; + const key = `${medium}${count}`; result[key] = { url, diff --git a/lib/routes/javtiful/actress.ts b/lib/routes/javtiful/actress.ts index b9d013c7b9c47b..6e1dd5dc4b6492 100644 --- a/lib/routes/javtiful/actress.ts +++ b/lib/routes/javtiful/actress.ts @@ -27,7 +27,7 @@ export const route: Route = { async function handler(ctx): Promise { const { id } = ctx.req.param(); const html = await ofetch(`https://javtiful.com/actress/${id}`); - const $ = load(html); + const $ = load((html as string)); const items: DataItem[] = $('section .card:not(:has(.bg-danger))') .toArray() .map((item) => parseItems($(item))); diff --git a/lib/routes/javtiful/channel.ts b/lib/routes/javtiful/channel.ts index 1aa1a2e512a1bc..917513a61747ea 100644 --- a/lib/routes/javtiful/channel.ts +++ b/lib/routes/javtiful/channel.ts @@ -27,7 +27,7 @@ export const route: Route = { async function handler(ctx): Promise { const { id } = ctx.req.param(); const html = await ofetch(`https://javtiful.com/channel/${id}`); - const $ = load(html); + const $ = load((html as string)); const items: DataItem[] = $('section .card:not(:has(.bg-danger))') .toArray() .map((item) => parseItems($(item))); diff --git a/lib/routes/jbma/report.ts b/lib/routes/jbma/report.ts index 844f01edd87329..1aa2d9f0b9cec7 100644 --- a/lib/routes/jbma/report.ts +++ b/lib/routes/jbma/report.ts @@ -13,7 +13,7 @@ export const handler = async (ctx: Context): Promise => { const apiSlug = 'wp-json/wp/v2'; - const baseUrl: string = 'https://jbma.net'; + const baseUrl = 'https://jbma.net'; const apiUrl = new URL(`${apiSlug}/report`, baseUrl).href; let targetUrl: string = new URL('report/', baseUrl).href; @@ -63,7 +63,7 @@ export const handler = async (ctx: Context): Promise => { } } - const mediaMap: Map = new Map(); + const mediaMap = new Map(); if (postIds.length > 0) { const mediaApiUrl = new URL(`${apiSlug}/media`, baseUrl).href; const mediaResponse = await ofetch(mediaApiUrl, { diff --git a/lib/routes/jike/topic.ts b/lib/routes/jike/topic.ts index 21d11be851709d..81080963412651 100644 --- a/lib/routes/jike/topic.ts +++ b/lib/routes/jike/topic.ts @@ -64,8 +64,8 @@ async function handler(ctx) { const links = upper.find('a').map((_, ele) => $(ele).attr('href')); const texts = upper.find('span.text').map((_, ele) => $(ele).text()); let description = ''; - for (const [i, link] of links.entries()) { - description += `${i + 1}、${texts[i]}
`; + for (let i = 0; i < links.length; i++) { + description += `${i + 1}、${texts[i]}
`; } description = description.replace(/
$/, ''); return description; diff --git a/lib/routes/jingzhengu/news.ts b/lib/routes/jingzhengu/news.ts index 8b32d905c83712..c2dcc87eea877e 100644 --- a/lib/routes/jingzhengu/news.ts +++ b/lib/routes/jingzhengu/news.ts @@ -25,7 +25,7 @@ export const route: Route = { async function handler() { const baseUrl = 'https://www.jingzhengu.com'; - const payload: Map = new Map([ + const payload = new Map([ ['pageNo', 1], ['middleware', String(Date.now())], ]); @@ -49,7 +49,7 @@ async function handler() { const items = await Promise.all( list.map((item) => cache.tryGet(item.link, async () => { - const payload: Map = new Map([ + const payload = new Map([ ['id', item.id], ['middleware', String(Date.now())], ]); diff --git a/lib/routes/jisilu/util.ts b/lib/routes/jisilu/util.ts index de1dce60c9ea95..1b48164f2f163b 100644 --- a/lib/routes/jisilu/util.ts +++ b/lib/routes/jisilu/util.ts @@ -8,7 +8,7 @@ import ofetch from '@/utils/ofetch'; import { parseDate } from '@/utils/parse-date'; import timezone from '@/utils/timezone'; -const rootUrl: string = 'https://www.jisilu.cn'; +const rootUrl = 'https://www.jisilu.cn'; const processItems: ($: CheerioAPI, targetEl: Cheerio, limit: number) => Promise = async ($: CheerioAPI, targetEl: Cheerio, limit: number) => { const items: DataItem[] = targetEl diff --git a/lib/routes/jl1mall/forum.ts b/lib/routes/jl1mall/forum.ts index 6da9e863506d3a..f2bbbca277afd8 100644 --- a/lib/routes/jl1mall/forum.ts +++ b/lib/routes/jl1mall/forum.ts @@ -56,7 +56,7 @@ export const handler = async (ctx: Context): Promise => { const { type = '2', key } = ctx.req.param(); const limit: number = Number.parseInt(ctx.req.query('limit') ?? '30', 10); - const baseUrl: string = 'https://www.jl1mall.com'; + const baseUrl = 'https://www.jl1mall.com'; const targetUrl: string = new URL('forum', baseUrl).href; const apiUrl: string = new URL(`postApi/${type === 'recommend' ? 'recommend' : 'post'}/getPostData`, baseUrl).href; const apiRacerUrl: string = new URL('postApi/racer/getRacerList', baseUrl).href; @@ -92,7 +92,7 @@ export const handler = async (ctx: Context): Promise => { }, ] : undefined; - const guid: string = `jl1mall-${item.postId}`; + const guid = `jl1mall-${item.postId}`; const image: string | undefined = item.pictureLink; const updated: number | string = pubDate; @@ -118,7 +118,7 @@ export const handler = async (ctx: Context): Promise => { return processedItem; }); - const title: string = '星林社区'; + const title = '星林社区'; return { title: name ? `${title} - ${name}` : title, diff --git a/lib/routes/joneslanglasalle/index.ts b/lib/routes/joneslanglasalle/index.ts index f08770056b613a..60f1c9b21a9709 100644 --- a/lib/routes/joneslanglasalle/index.ts +++ b/lib/routes/joneslanglasalle/index.ts @@ -36,7 +36,7 @@ export const handler = async (ctx: Context): Promise => { // default limit is 12 const limit: number = Number.parseInt(ctx.req.query('limit') ?? '12', 10); - const rootUrl: string = 'https://www.joneslanglasalle.com.cn'; + const rootUrl = 'https://www.joneslanglasalle.com.cn'; const targetUrl: string = new URL(`${lang}/${category}`, rootUrl).href; const response = await ofetch(targetUrl); diff --git a/lib/routes/jpmorganchase/research.ts b/lib/routes/jpmorganchase/research.ts index ece655603a3a00..f5397c29d66bfd 100644 --- a/lib/routes/jpmorganchase/research.ts +++ b/lib/routes/jpmorganchase/research.ts @@ -69,7 +69,7 @@ function fetchDataItem(entry: IndexEntry): Promise { return cache.tryGet(url, async () => { let authors: string[] = []; - let description: string = ''; + let description = ''; let category: string[] = []; let articleDate: string = entry.date; const pageContent: string = await ofetch(url); diff --git a/lib/routes/juejin/aicoding.ts b/lib/routes/juejin/aicoding.ts index 22a394422a5b01..ff33b9ed6c4d25 100644 --- a/lib/routes/juejin/aicoding.ts +++ b/lib/routes/juejin/aicoding.ts @@ -69,10 +69,10 @@ export const route: Route = { async function handler(ctx) { const { tag, sort } = ctx.req.param(); const sortType = sort === 'hot' ? 1 : 2; - let tagList: { + let tagList: Array<{ tag_id: string; tag: Tag; - }[], + }>, currentTag: Tag | undefined, tagId: string | undefined; if (tag) { diff --git a/lib/routes/juejin/utils.ts b/lib/routes/juejin/utils.ts index 6e7a836f25e08b..6f87b7f94e3137 100644 --- a/lib/routes/juejin/utils.ts +++ b/lib/routes/juejin/utils.ts @@ -139,4 +139,4 @@ export const getTagList = () => }, }); return response.data; - }) as Promise<{ tag_id: string; tag: Tag }[]>; + }) as Promise>; diff --git a/lib/routes/kiro/blog.ts b/lib/routes/kiro/blog.ts index f016cd0f4603e6..1c17a77814be02 100644 --- a/lib/routes/kiro/blog.ts +++ b/lib/routes/kiro/blog.ts @@ -12,7 +12,7 @@ import { parseDate } from '@/utils/parse-date'; export const handler = async (ctx: Context): Promise => { const limit: number = Number.parseInt(ctx.req.query('limit') ?? '30', 10); - const baseUrl: string = 'https://kiro.dev'; + const baseUrl = 'https://kiro.dev'; const targetUrl: string = new URL('blog/', baseUrl).href; const response = await ofetch(targetUrl); diff --git a/lib/routes/kiro/changelog.ts b/lib/routes/kiro/changelog.ts index 23e987de44b90e..c76e50fd71d6b3 100644 --- a/lib/routes/kiro/changelog.ts +++ b/lib/routes/kiro/changelog.ts @@ -12,7 +12,7 @@ import { parseDate } from '@/utils/parse-date'; export const handler = async (ctx: Context): Promise => { const limit: number = Number.parseInt(ctx.req.query('limit') ?? '30', 10); - const baseUrl: string = 'https://kiro.dev'; + const baseUrl = 'https://kiro.dev'; const targetUrl: string = new URL('changelog/', baseUrl).href; const response = await ofetch(targetUrl); @@ -27,7 +27,7 @@ export const handler = async (ctx: Context): Promise => { .map((el): Element => { const $el: Cheerio = $(el); - const title: string = `${$el.parent().find('span').text()} ${$el.find('h3').text()}`; + const title = `${$el.parent().find('span').text()} ${$el.find('h3').text()}`; const description: string | undefined = $el.parent().parent().find('div.prose').html() ?? undefined; const pubDateStr: string | undefined = $el.parent().parent().parent().find('time').text(); const linkUrl: string | undefined = $el.attr('href'); @@ -59,7 +59,7 @@ export const handler = async (ctx: Context): Promise => { const detailResponse = await ofetch(item.link); const $$: CheerioAPI = load(detailResponse); - const title: string = `${$$('article span').first().text()} ${$$('article h3').text()}`; + const title = `${$$('article span').first().text()} ${$$('article h3').text()}`; const description: string | undefined = $$('div.prose').html() ?? undefined; const pubDateStr: string | undefined = $$('time').text(); const image: string | undefined = $$('meta[property="og:image"]').attr('content'); diff --git a/lib/routes/koyso/index.tsx b/lib/routes/koyso/index.tsx index e4acd8bd4771fd..5e9fd534f5dd4b 100644 --- a/lib/routes/koyso/index.tsx +++ b/lib/routes/koyso/index.tsx @@ -31,7 +31,7 @@ export const handler = async (ctx: Context): Promise => { const { category = '0', sort = 'latest' } = ctx.req.param(); const limit: number = Number.parseInt(ctx.req.query('limit') ?? '30', 10); - const baseUrl: string = 'https://koyso.to'; + const baseUrl = 'https://koyso.to'; const targetUrl: string = new URL(`?${category === '0' ? '' : `category=${category}&`}sort=${sort}`, baseUrl).href; const response = await ofetch(targetUrl); diff --git a/lib/routes/kpopping/kpics.ts b/lib/routes/kpopping/kpics.ts index 55629ebd41458f..328f366b1a503b 100644 --- a/lib/routes/kpopping/kpics.ts +++ b/lib/routes/kpopping/kpics.ts @@ -15,7 +15,7 @@ export const handler = async (ctx: Context): Promise => { const { filter } = ctx.req.param(); const limit: number = Number.parseInt(ctx.req.query('limit') ?? '30', 10); - const baseUrl: string = 'https://kpopping.com'; + const baseUrl = 'https://kpopping.com'; const targetUrl: string = new URL(`kpics${filter ? `/${filter}` : ''}`, baseUrl).href; const response = await ofetch(targetUrl); @@ -121,8 +121,8 @@ export const handler = async (ctx: Context): Promise => { continue; } - const medium: string = 'image'; - const key: string = `${medium}${imageCount++}`; + const medium = 'image'; + const key = `${medium}${imageCount++}`; medias[key] = { url, diff --git a/lib/routes/kpopping/news.ts b/lib/routes/kpopping/news.ts index 6ab9e14472fd7a..770e529fe6708f 100644 --- a/lib/routes/kpopping/news.ts +++ b/lib/routes/kpopping/news.ts @@ -16,7 +16,7 @@ export const handler = async (ctx: Context): Promise => { const { filter } = ctx.req.param(); const limit: number = Number.parseInt(ctx.req.query('limit') ?? '2', 10); - const baseUrl: string = 'https://kpopping.com'; + const baseUrl = 'https://kpopping.com'; const targetUrl: string = new URL(`news${filter ? `/${filter}` : ''}`, baseUrl).href; const response = await ofetch(targetUrl); diff --git a/lib/routes/kuaishou/profile.ts b/lib/routes/kuaishou/profile.ts index e0eaf9e29e271c..96509139c43349 100644 --- a/lib/routes/kuaishou/profile.ts +++ b/lib/routes/kuaishou/profile.ts @@ -67,7 +67,7 @@ async function handler(ctx) { waitUntil: 'domcontentloaded', }); await page.goto(`https://live.kuaishou.com/profile/${principalId}`); - const resData = (await promise.catch((error) => error)) as Array; + const resData = (await promise.catch((error) => error)) as any[]; await browser.close(); const data: Data = { diff --git a/lib/routes/leetcode/dailyquestion-solution-en.ts b/lib/routes/leetcode/dailyquestion-solution-en.ts index 478af48ba309d2..8155c8a57c02db 100644 --- a/lib/routes/leetcode/dailyquestion-solution-en.ts +++ b/lib/routes/leetcode/dailyquestion-solution-en.ts @@ -152,8 +152,8 @@ async function handler() { return pngList.map((v) => `![pic](${path.resolve(`/problems/${questionTitle}/solution/`, v.image)})`).join('\n'); }; const strs = await Promise.all(matched.map((v) => fn(v))); - for (const [i, element] of matched.entries()) { - s = s.replace(element, strs[i]); + for (let i = 0; i < matched.length; i++) { + s = s.replace(matched[i], strs[i]); } return s; }; @@ -198,8 +198,8 @@ async function handler() { return code.map((c) => `###${c.langSlug}\n\r \`\`\`${c.langSlug}\n ${c.code}\n\`\`\``).join('\n\r'); }; const strs = await Promise.all(matched.map((v) => fn(v))); - for (const [i, element] of matched.entries()) { - s = s.replace(element, strs[i]); + for (let i = 0; i < matched.length; i++) { + s = s.replace(matched[i], strs[i]); } return s; }; diff --git a/lib/routes/lhratings/research.ts b/lib/routes/lhratings/research.ts index 9a70f9d8640d58..f8a10f9fe35877 100644 --- a/lib/routes/lhratings/research.ts +++ b/lib/routes/lhratings/research.ts @@ -12,7 +12,7 @@ export const handler = async (ctx: Context): Promise => { const { type = '1' } = ctx.req.param(); const limit: number = Number.parseInt(ctx.req.query('limit') ?? '20', 10); - const baseUrl: string = 'https://www.lhratings.com'; + const baseUrl = 'https://www.lhratings.com'; const targetUrl: string = new URL(`research.html?type=${type}`, baseUrl).href; const response = await ofetch(targetUrl); diff --git a/lib/routes/lineageos/changes.ts b/lib/routes/lineageos/changes.ts index 6894ea5f8d2e0b..d0d8dc92fae6b3 100644 --- a/lib/routes/lineageos/changes.ts +++ b/lib/routes/lineageos/changes.ts @@ -10,7 +10,7 @@ import { parseDate } from '@/utils/parse-date'; export const handler = async (ctx: Context): Promise => { const limit: number = Number.parseInt(ctx.req.query('limit') ?? '30', 10); - const baseUrl: string = 'https://download.lineageos.org'; + const baseUrl = 'https://download.lineageos.org'; const targetUrl: string = new URL('changes', baseUrl).href; const apiUrl: string = new URL('api/v2/changes', baseUrl).href; diff --git a/lib/routes/linkresearcher/types.ts b/lib/routes/linkresearcher/types.ts index f93aa153a42a40..8bb45b1d55579e 100644 --- a/lib/routes/linkresearcher/types.ts +++ b/lib/routes/linkresearcher/types.ts @@ -46,7 +46,7 @@ export interface ThesesDetailResponse { link: string; onlineTime: number; original: boolean; - paperList: { + paperList: Array<{ authors: string[]; checkname: string; doi: string; @@ -59,11 +59,11 @@ export interface ThesesDetailResponse { title: string; translateSummary: string; type: string; - }[]; - relevant: { + }>; + relevant: Array<{ timestamp: number; type: string; - }[]; + }>; source: { sourceId: string; sourceName: string; @@ -84,10 +84,10 @@ export interface InformationDetailResponse { id: string; onlineTime: number; original: boolean; - relevant: { + relevant: Array<{ timestamp: number; type: string; - }[]; + }>; source: { sourceId: string; sourceName: string; diff --git a/lib/routes/ltaaa/article.ts b/lib/routes/ltaaa/article.ts index 5fb699ce56067a..66c2ce872b2e8b 100644 --- a/lib/routes/ltaaa/article.ts +++ b/lib/routes/ltaaa/article.ts @@ -14,7 +14,7 @@ import { renderDescription } from './templates/description'; export const handler = async (ctx: Context): Promise => { const limit: number = Number.parseInt(ctx.req.query('limit') ?? '30', 10); - const baseUrl: string = 'https://www.ltaaa.cn'; + const baseUrl = 'https://www.ltaaa.cn'; const targetUrl: string = new URL('article', baseUrl).href; const response = await ofetch(targetUrl); diff --git a/lib/routes/maccms/type.ts b/lib/routes/maccms/type.ts index 092e38ad54472a..2d73ce55ce5b01 100644 --- a/lib/routes/maccms/type.ts +++ b/lib/routes/maccms/type.ts @@ -5,8 +5,8 @@ export type Result = { pagecount: number; limit: string; total: number; - list: Array; - class?: Array; + list: Vod[]; + class?: Class[]; }; export type Class = { diff --git a/lib/routes/mangadex/_feed.ts b/lib/routes/mangadex/_feed.ts index 9e8d72940f40c7..02d87d080b008b 100644 --- a/lib/routes/mangadex/_feed.ts +++ b/lib/routes/mangadex/_feed.ts @@ -91,7 +91,7 @@ export async function getMangaMetaByIds(ids: string[], needCover: boolean = true } return data.data; } - )) as Array; + )) as any[]; const languages = [...(typeof lang === 'string' ? [lang] : lang || []), ...(await getFilteredLanguages())].filter(Boolean); diff --git a/lib/routes/mangadex/mdlist/feed.ts b/lib/routes/mangadex/mdlist/feed.ts index 7d157deeb806e6..7a6b31b4f00bdd 100644 --- a/lib/routes/mangadex/mdlist/feed.ts +++ b/lib/routes/mangadex/mdlist/feed.ts @@ -131,7 +131,7 @@ async function handler(ctx) { }, config.cache.routeExpire, false - )) as Record[]; + )) as Array>; const mangaIds = feed.map((chapter) => chapter?.relationships.find((relationship) => relationship.type === 'manga')?.id); diff --git a/lib/routes/mangadex/user/feed.ts b/lib/routes/mangadex/user/feed.ts index 749312b0ce1619..94a95e94ae1312 100644 --- a/lib/routes/mangadex/user/feed.ts +++ b/lib/routes/mangadex/user/feed.ts @@ -101,7 +101,7 @@ async function handler(ctx) { }, config.cache.routeExpire, false - )) as Record[]; + )) as Array>; const mangaIds = feed.map((chapter) => chapter?.relationships.find((relationship) => relationship.type === 'manga')?.id); diff --git a/lib/routes/mathpix/blog.tsx b/lib/routes/mathpix/blog.tsx index 74b474b260dbe8..a43b200c7225fb 100644 --- a/lib/routes/mathpix/blog.tsx +++ b/lib/routes/mathpix/blog.tsx @@ -13,7 +13,7 @@ import { parseDate } from '@/utils/parse-date'; export const handler = async (ctx: Context): Promise => { const limit: number = Number.parseInt(ctx.req.query('limit') ?? '30', 10); - const baseUrl: string = 'https://mathpix.com'; + const baseUrl = 'https://mathpix.com'; const targetUrl: string = new URL('blog', baseUrl).href; const response = await ofetch(targetUrl); diff --git a/lib/routes/mercari/types.ts b/lib/routes/mercari/types.ts index f2c11e5ef58e75..5a9633bca40130 100644 --- a/lib/routes/mercari/types.ts +++ b/lib/routes/mercari/types.ts @@ -93,11 +93,11 @@ export interface ItemDetail { root_category_name: string; brand_group_id: number; }; - parent_categories_ntiers: { + parent_categories_ntiers: Array<{ id: number; name: string; display_order: number; - }[]; + }>; item_condition: { id: number; name: string; @@ -174,28 +174,28 @@ export interface ItemDetail { }; omakase: boolean; }; - item_attributes: { + item_attributes: Array<{ id: string; text: string; - values: { + values: Array<{ id: string; text: string; - }[]; + }>; deep_facet_filterable: boolean; show_on_ui: boolean; - }[]; + }>; is_dismissed: boolean; photo_descriptions: string[]; meta_title: string; meta_subtitle: string; price_promotion_area_details: { promotion_type: string; - promotion_info: { + promotion_info: Array<{ label_text: string; supplementary_text: string; expire_time: number; promotion_duration: number; - }[]; + }>; }; }; meta: object; @@ -221,24 +221,24 @@ export interface ShopItemDetail { reviewCount: string; }; allowDirectMessage: boolean; - shopItems: { + shopItems: Array<{ productId: string; displayName: string; productTags: string[]; thumbnail: string; price: string; - }[]; + }>; isInboundXb: boolean; }; photos: string[]; description: string; - categories: { + categories: Array<{ categoryId: string; displayName: string; parentId: string; rootId: string; hasChild: boolean; - }[]; + }>; brand: null; condition: { displayName: string; @@ -266,12 +266,12 @@ export interface ShopItemDetail { promotions: any[]; productStats: null; timeSaleDetails: null; - variants: { + variants: Array<{ variantId: string; displayName: string; quantity: string; size: string; - }[]; + }>; shippingFeeConfig: null; variationGrouping: null; }; diff --git a/lib/routes/mi/crowdfunding.ts b/lib/routes/mi/crowdfunding.ts index 7aa8d2b53eacaf..32f964e16608a0 100644 --- a/lib/routes/mi/crowdfunding.ts +++ b/lib/routes/mi/crowdfunding.ts @@ -30,7 +30,7 @@ export const route: Route = { }; const getDetails = async (list: CrowdfundingList[]) => { - const result: Promise[] = list.flatMap((section) => section.items.map((item) => utils.getCrowdfundingItem(item))); + const result: Array> = list.flatMap((section) => section.items.map((item) => utils.getCrowdfundingItem(item))); return await Promise.all(result); }; diff --git a/lib/routes/misskey/types.ts b/lib/routes/misskey/types.ts index 2aff1cc2f15510..65ab43bed92ce9 100644 --- a/lib/routes/misskey/types.ts +++ b/lib/routes/misskey/types.ts @@ -35,11 +35,11 @@ export interface MisskeyNote { poll?: { expiresAt: string | null; multiple: boolean; - choices: { + choices: Array<{ text: string; votes: number; isVoted: boolean; - }[]; + }>; }; emojis?: Record; tags?: string[]; diff --git a/lib/routes/musify/index.ts b/lib/routes/musify/index.ts index 9eaf8c9db04214..f686bff4210324 100644 --- a/lib/routes/musify/index.ts +++ b/lib/routes/musify/index.ts @@ -11,7 +11,7 @@ export const handler = async (ctx: Context): Promise => { const { language = '' } = ctx.req.param(); const limit: number = Number.parseInt(ctx.req.query('limit') ?? '30', 10); - const baseUrl: string = 'https://musify.club'; + const baseUrl = 'https://musify.club'; const targetUrl: string = new URL(language, baseUrl).href; const response = await ofetch(targetUrl); diff --git a/lib/routes/musikguru/news.ts b/lib/routes/musikguru/news.ts index 8409768c3badbb..a98b390e679912 100644 --- a/lib/routes/musikguru/news.ts +++ b/lib/routes/musikguru/news.ts @@ -15,7 +15,7 @@ import { renderDescription } from './templates/description'; export const handler = async (ctx: Context): Promise => { const limit: number = Number.parseInt(ctx.req.query('limit') ?? '10', 10); - const baseUrl: string = 'https://musikguru.de'; + const baseUrl = 'https://musikguru.de'; const targetUrl: string = new URL('news/', baseUrl).href; const response = await ofetch(targetUrl); diff --git a/lib/routes/mycard520/news.ts b/lib/routes/mycard520/news.ts index b2338fd6016ce0..1e850e21e55528 100644 --- a/lib/routes/mycard520/news.ts +++ b/lib/routes/mycard520/news.ts @@ -13,7 +13,7 @@ export const handler = async (ctx: Context): Promise => { const { category = 'cardgame' } = ctx.req.param(); const limit: number = Number.parseInt(ctx.req.query('limit') ?? '18', 10); - const baseUrl: string = 'https://app.mycard520.com.tw'; + const baseUrl = 'https://app.mycard520.com.tw'; const targetUrl: string = new URL(`category/${category.endsWith('/') ? category : `${category}/`}`, baseUrl).href; const response = await ofetch(targetUrl); diff --git a/lib/routes/myfans/types.ts b/lib/routes/myfans/types.ts index 82863e5a27970d..d48294fc195675 100644 --- a/lib/routes/myfans/types.ts +++ b/lib/routes/myfans/types.ts @@ -48,12 +48,12 @@ export interface Post { liked: boolean; likes_count: number; user: UserProfile; - post_images: { + post_images: Array<{ file_url: string; square_thumbnail_url: string; raw_image_height: number; raw_image_width: number; - }[]; + }>; visible: boolean; publish_end_at: null; published_at: string; @@ -66,7 +66,7 @@ export interface Post { amount: number; auto_message_body: string; } | null; - plans: { + plans: Array<{ id: string; product_name: string; monthly_price: number; @@ -81,7 +81,7 @@ export interface Post { limited_number: null; status: string; } | null; - }[]; + }>; video_processing: boolean | null; video_duration: { hours: string | null; diff --git a/lib/routes/natgeo/dailyselection.ts b/lib/routes/natgeo/dailyselection.ts index 8f4403d07a89e3..f798fce0a15528 100644 --- a/lib/routes/natgeo/dailyselection.ts +++ b/lib/routes/natgeo/dailyselection.ts @@ -33,10 +33,10 @@ async function handler() { let sort = 0; let addtime = ''; - for (let i = 0; i < data.data.album.length; i++) { - if (Number.parseInt(data.data.album[i].ds) === 1) { - sort = data.data.album[i].sort; - addtime = data.data.album[i].addtime; + for (const album of data.data.album) { + if (Number.parseInt(album.ds) === 1) { + sort = album.sort; + addtime = album.addtime; break; } } diff --git a/lib/routes/neea/jlpt.ts b/lib/routes/neea/jlpt.ts index 637cb8e753eac5..e43520e35c4c92 100644 --- a/lib/routes/neea/jlpt.ts +++ b/lib/routes/neea/jlpt.ts @@ -12,7 +12,7 @@ import { parseDate } from '@/utils/parse-date'; export const handler = async (ctx: Context): Promise => { const limit: number = Number.parseInt(ctx.req.query('limit') ?? '30', 10); - const baseUrl: string = 'https://jlpt.neea.cn'; + const baseUrl = 'https://jlpt.neea.cn'; const targetUrl: string = new URL('index.do', baseUrl).href; const response = await ofetch(targetUrl); diff --git a/lib/routes/nmc/publish.ts b/lib/routes/nmc/publish.ts index b02a868d0ded35..d05834f7e13335 100644 --- a/lib/routes/nmc/publish.ts +++ b/lib/routes/nmc/publish.ts @@ -15,7 +15,7 @@ export const handler = async (ctx: Context): Promise => { const { id = 'hourly-temperature/html' } = ctx.req.param(); const limit: number = Number.parseInt(ctx.req.query('limit') ?? '50', 10); - const baseUrl: string = 'https://www.nmc.cn'; + const baseUrl = 'https://www.nmc.cn'; const pathSegment: string = id.split(/\//).pop() === 'htm' ? 'htm' : 'html'; const targetUrl: string = new URL(`publish/${id.replace(new RegExp(String.raw`\/${pathSegment}$`), '')}.${pathSegment}`, baseUrl).href; @@ -37,7 +37,7 @@ export const handler = async (ctx: Context): Promise => { .map((el) => $(el).text().trim()); const pubDateStr: string | undefined = `${timeStrArray.pop()}:00 ${timeStrArray.join('/')}`; - const title: string = `${pubDateStr} - ${$el.find('div.title').text().replaceAll(/\s/g, '')}`; + const title = `${pubDateStr} - ${$el.find('div.title').text().replaceAll(/\s/g, '')}`; const description: string | undefined = renderDescription({ description: $el.find('div.writing').html(), }); @@ -55,7 +55,7 @@ export const handler = async (ctx: Context): Promise => { url: undefined, avatar: undefined, })); - const guid: string = `${linkUrl}#${pubDateStr}`; + const guid = `${linkUrl}#${pubDateStr}`; const upDatedStr: string | undefined = pubDateStr; const processedItem: DataItem = { @@ -84,7 +84,7 @@ export const handler = async (ctx: Context): Promise => { const image: string | undefined = $el.attr('data-img'); - const title: string = `${$el.find('div').text().trim()} - ${$('div.nav1 a.actived, div#menuNavBar button.dropdown-toggle') + const title = `${$el.find('div').text().trim()} - ${$('div.nav1 a.actived, div#menuNavBar button.dropdown-toggle') .toArray() .map((el) => $(el).text().trim()) .join(' - ')}`; @@ -101,7 +101,7 @@ export const handler = async (ctx: Context): Promise => { const year: string | undefined = image?.match(/product\/(\d{4})\//)?.[1]; const pubDateStr: string | undefined = `${year ? `${year}/` : ''}${$el.attr('data-time')}`; const linkUrl: string | undefined = targetUrl; - const guid: string = `${linkUrl}#${pubDateStr}`; + const guid = `${linkUrl}#${pubDateStr}`; const upDatedStr: string | undefined = pubDateStr; const processedItem: DataItem = { diff --git a/lib/routes/obsidian/plugins.ts b/lib/routes/obsidian/plugins.ts index 2d09a56e8003b6..70e1aacc771000 100644 --- a/lib/routes/obsidian/plugins.ts +++ b/lib/routes/obsidian/plugins.ts @@ -11,13 +11,13 @@ export const route: Route = { }; async function handler() { - const data = JSON.parse(await ofetch('https://raw.githubusercontent.com/obsidianmd/obsidian-releases/refs/heads/master/community-plugins.json')) as { + const data = JSON.parse(await ofetch('https://raw.githubusercontent.com/obsidianmd/obsidian-releases/refs/heads/master/community-plugins.json')) as Array<{ id: string; name: string; author: string; description: string; repo: string; - }[]; + }>; const stats = JSON.parse(await ofetch('https://raw.githubusercontent.com/obsidianmd/obsidian-releases/HEAD/community-plugin-stats.json')) as { [key: string]: { downloads: number; diff --git a/lib/routes/oceanengine/arithmetic-index.tsx b/lib/routes/oceanengine/arithmetic-index.tsx index 67f24c93daed3c..f8b42d37cc6657 100644 --- a/lib/routes/oceanengine/arithmetic-index.tsx +++ b/lib/routes/oceanengine/arithmetic-index.tsx @@ -159,7 +159,7 @@ async function handler(ctx) { }; } -const OceanengineContent = ({ queryListText, queries }: { queryListText: string; queries: { key: string; links: string[] }[] }) => ( +const OceanengineContent = ({ queryListText, queries }: { queryListText: string; queries: Array<{ key: string; links: string[] }> }) => (

关键词:

{queryListText} diff --git a/lib/routes/okx/index.ts b/lib/routes/okx/index.ts index ab909d6cfe7ecf..b47037a30e51a2 100644 --- a/lib/routes/okx/index.ts +++ b/lib/routes/okx/index.ts @@ -94,7 +94,7 @@ async function handler(ctx: Context) { const $ = load(data); const ssrData = JSON.parse($('script[data-id="__app_data_for_ssr__"]').text()); - const itemsTemp: { title: string; link: string; pubDate: Date }[] = + const itemsTemp: Array<{ title: string; link: string; pubDate: Date }> = ssrData?.appContext?.initialProps?.sectionData?.articleList?.items?.map((item: { title: string; slug: string; publishTime: string }) => ({ title: item.title, link: `${baseUrl}/zh-hans/help/${item.slug}`, diff --git a/lib/routes/openrice/chart.tsx b/lib/routes/openrice/chart.tsx index 56a5a2cd615db2..f75835073f79ec 100644 --- a/lib/routes/openrice/chart.tsx +++ b/lib/routes/openrice/chart.tsx @@ -29,7 +29,7 @@ async function handler(ctx) { const lang = ctx.req.param('lang') ?? 'zh'; const category = ctx.req.param('category') ?? 'most-bookmarked'; - const urlPath: string = `/${lang}/hongkong/explore/chart/${category}`; + const urlPath = `/${lang}/hongkong/explore/chart/${category}`; const response = await ofetch(baseUrl + urlPath); const $ = load(response); diff --git a/lib/routes/orcid/index.tsx b/lib/routes/orcid/index.tsx index 4889506408f130..8e14d117a4487f 100644 --- a/lib/routes/orcid/index.tsx +++ b/lib/routes/orcid/index.tsx @@ -29,22 +29,22 @@ async function handler(ctx) { const response = await got(currentUrl); const items = response.data.groups; - const works = []; + const works: any[] = []; const out = []; for (const item of items) { - for (let j = 0; j < item.works.length; j++) { - works.push(item.works[j]); + for (const work of item.works) { + works.push(work); } } works.map((work) => { let Str = ''; - for (let l = 0; l < work.workExternalIdentifiers.length; l++) { - Str += work.workExternalIdentifiers[l].url - ? '' + work.workExternalIdentifiers[l].externalIdentifierType.value + ': ' + work.workExternalIdentifiers[l].externalIdentifierId.value + '
' - : work.workExternalIdentifiers[l].externalIdentifierType.value + ': ' + work.workExternalIdentifiers[l].externalIdentifierId.value + '
'; + for (const identifier of work.workExternalIdentifiers) { + Str += identifier.url + ? '' + identifier.externalIdentifierType.value + ': ' + identifier.externalIdentifierId.value + '
' + : identifier.externalIdentifierType.value + ': ' + identifier.externalIdentifierId.value + '
'; } const info = { diff --git a/lib/routes/ornl/all-news.ts b/lib/routes/ornl/all-news.ts index 833e94ad187d61..cd0ea8b6822c3f 100644 --- a/lib/routes/ornl/all-news.ts +++ b/lib/routes/ornl/all-news.ts @@ -14,7 +14,7 @@ import { renderDescription } from './templates/description'; export const handler = async (ctx: Context): Promise => { const limit: number = Number.parseInt(ctx.req.query('limit') ?? '10', 10); - const baseUrl: string = 'https://www.ornl.gov'; + const baseUrl = 'https://www.ornl.gov'; const targetUrl: string = new URL('all-news', baseUrl).href; const response = await ofetch(targetUrl); diff --git a/lib/routes/oschina/column.ts b/lib/routes/oschina/column.ts index 8efe261a00d1a2..e3d78545fe2149 100644 --- a/lib/routes/oschina/column.ts +++ b/lib/routes/oschina/column.ts @@ -16,7 +16,7 @@ export const handler = async (ctx: Context): Promise => { const { id } = ctx.req.param(); const limit: number = Number.parseInt(ctx.req.query('limit') ?? '10', 10); - const baseUrl: string = 'https://www.oschina.net'; + const baseUrl = 'https://www.oschina.net'; const userHostRegex: string = String.raw`https://my\.oschina\.net`; const targetUrl: string = new URL(`news/column?columnId=${id}`, baseUrl).href; @@ -104,7 +104,7 @@ export const handler = async (ctx: Context): Promise => { url: $authorEl.attr('href'), }; }); - const guid: string = `oschina-${$$('val[data-name="objId"]').attr('data-value')}`; + const guid = `oschina-${$$('val[data-name="objId"]').attr('data-value')}`; const image: string | undefined = $$('val[data-name="sharePic"]').attr('data-value'); const upDatedStr: string | undefined = $$('meta[property="bytedance:updated_time"]').attr('content') || pubDateStr; diff --git a/lib/routes/oschina/event.ts b/lib/routes/oschina/event.ts index b25c375580723a..13f8e9e852979f 100644 --- a/lib/routes/oschina/event.ts +++ b/lib/routes/oschina/event.ts @@ -15,7 +15,7 @@ export const handler = async (ctx: Context): Promise => { const { category = 'latest' } = ctx.req.param(); const limit: number = Number.parseInt(ctx.req.query('limit') ?? '30', 10); - const baseUrl: string = 'https://www.oschina.net'; + const baseUrl = 'https://www.oschina.net'; const targetUrl: string = new URL(`event?tab=${category}`, baseUrl).href; const apiUrl: string = new URL('action/ajax/get_more_event_list', baseUrl).href; diff --git a/lib/routes/oshwhub/explore.ts b/lib/routes/oshwhub/explore.ts index f5b81381a42885..d97c50b687cde9 100644 --- a/lib/routes/oshwhub/explore.ts +++ b/lib/routes/oshwhub/explore.ts @@ -47,7 +47,7 @@ export const handler = async (ctx: Context): Promise => { const { type = 'new', origin = 'all', projectTag } = ctx.req.param(); const limit: number = Number.parseInt(ctx.req.query('limit') ?? '15', 10); - const baseUrl: string = 'https://oshwhub.com'; + const baseUrl = 'https://oshwhub.com'; const apiUrl: string = new URL('api/project', baseUrl).href; const apiTagUrl: string = new URL('api/project_tags', baseUrl).href; const targetUrl: string = new URL('explore', baseUrl).href; @@ -209,7 +209,7 @@ export const handler = async (ctx: Context): Promise => { const enclosureUrl: string | undefined = `https://image.lceda.cn${attachment.src}`; const enclosureType: string = attachment.mime; const enclosureTitle: string = attachment.name; - const enclosureLength: number = Number(attachment.size); + const enclosureLength = Number(attachment.size); processedItem = { ...processedItem, diff --git a/lib/routes/osu/beatmaps/latest-ranked.tsx b/lib/routes/osu/beatmaps/latest-ranked.tsx index 82527d92556151..7de7c5948b1663 100644 --- a/lib/routes/osu/beatmaps/latest-ranked.tsx +++ b/lib/routes/osu/beatmaps/latest-ranked.tsx @@ -15,7 +15,7 @@ const actualParametersDescTable = ` | \`modeInTitle\` | \`true\` | \`true\` or \`false\` Add mode info into feed title. `; -const descriptionDoc: string = ` +const descriptionDoc = ` Subscribe to the new beatmaps on https://osu.ppy.sh/beatmapsets. #### Parameter Description diff --git a/lib/routes/p-articles/utils.ts b/lib/routes/p-articles/utils.ts index 3a9810419d640d..692eb34c509e24 100644 --- a/lib/routes/p-articles/utils.ts +++ b/lib/routes/p-articles/utils.ts @@ -3,7 +3,7 @@ import { load } from 'cheerio'; import { parseDate } from '@/utils/parse-date'; import timezone from '@/utils/timezone'; -const rootUrl: string = 'https://p-articles.com'; +const rootUrl = 'https://p-articles.com'; const ProcessFeed = (info, data) => { // const $ = cheerio.load(data); diff --git a/lib/routes/papers/category.ts b/lib/routes/papers/category.ts index 9c5fe4ee70ff41..dbd08451f30019 100644 --- a/lib/routes/papers/category.ts +++ b/lib/routes/papers/category.ts @@ -15,7 +15,7 @@ export const handler = async (ctx: Context): Promise => { const { id } = ctx.req.param(); const limit: number = Number.parseInt(ctx.req.query('limit') ?? '50', 10); - const baseUrl: string = 'https://papers.cool'; + const baseUrl = 'https://papers.cool'; const targetUrl: string = new URL(`${id}?show=${limit}`, baseUrl).href; const response = await ofetch(targetUrl); @@ -50,7 +50,7 @@ export const handler = async (ctx: Context): Promise => { }; }); const doi: string = $el.attr('id') as string; - const guid: string = `papers.cool-${doi}`; + const guid = `papers.cool-${doi}`; const upDatedStr: string | undefined = pubDateStr; let processedItem: DataItem = { diff --git a/lib/routes/parliament.uk/petitions.tsx b/lib/routes/parliament.uk/petitions.tsx index afae92e7802941..1b13d806bbaf85 100644 --- a/lib/routes/parliament.uk/petitions.tsx +++ b/lib/routes/parliament.uk/petitions.tsx @@ -12,7 +12,7 @@ export const handler = async (ctx: Context): Promise => { const { state = 'all' } = ctx.req.param(); const limit: number = Number.parseInt(ctx.req.query('limit') ?? '50', 10); - const rootUrl: string = 'https://petition.parliament.uk'; + const rootUrl = 'https://petition.parliament.uk'; const targetUrl: string = new URL(`petitions?state=${state}`, rootUrl).href; const jsonUrl: string = new URL('petitions.json', rootUrl).href; diff --git a/lib/routes/picuki/profile.ts b/lib/routes/picuki/profile.ts index 96b9d32863b999..1c691784dec9c5 100644 --- a/lib/routes/picuki/profile.ts +++ b/lib/routes/picuki/profile.ts @@ -142,7 +142,7 @@ async function handler(ctx) { title: string; description: string; image: string; - items: { + items: Array<{ title: string; author: string; renderData: { @@ -152,7 +152,7 @@ async function handler(ctx) { }; link: string; guid: string; - }[]; + }>; }; const items: DataItem[] = data.items.map((item) => ({ diff --git a/lib/routes/pixelstech/index.ts b/lib/routes/pixelstech/index.ts index ecf8a696222803..8fa99f48145d34 100644 --- a/lib/routes/pixelstech/index.ts +++ b/lib/routes/pixelstech/index.ts @@ -15,7 +15,7 @@ export const handler = async (ctx: Context): Promise => { const { topic } = ctx.req.param(); const limit: number = Number.parseInt(ctx.req.query('limit') ?? '10', 10); - const baseUrl: string = 'https://www.pixelstech.net'; + const baseUrl = 'https://www.pixelstech.net'; const targetUrl: string = new URL(`feed/${topic ?? ''}`, baseUrl).href; const response = await ofetch(targetUrl); diff --git a/lib/routes/pixiv/novel-api/series/types.ts b/lib/routes/pixiv/novel-api/series/types.ts index de946d0556e065..6d40b23ade7969 100644 --- a/lib/routes/pixiv/novel-api/series/types.ts +++ b/lib/routes/pixiv/novel-api/series/types.ts @@ -85,10 +85,10 @@ export interface AppNovelSeriesDetail { export interface AppNovelSeries { novel_series_detail: AppNovelSeriesDetail; - novels: { + novels: Array<{ id: string; title: string; create_date: Date; user: AppUser; - }[]; + }>; } diff --git a/lib/routes/producereport/index.ts b/lib/routes/producereport/index.ts index e5aac57e82907b..ead272f1d52bd3 100644 --- a/lib/routes/producereport/index.ts +++ b/lib/routes/producereport/index.ts @@ -15,7 +15,7 @@ export const handler = async (ctx: Context): Promise => { const { category = 'produce/fresh-fruits/apples' } = ctx.req.param(); const limit: number = Number.parseInt(ctx.req.query('limit') ?? '10', 10); - const baseUrl: string = 'https://www.producereport.com'; + const baseUrl = 'https://www.producereport.com'; const targetUrl: string = new URL(category, baseUrl).href; const response = await ofetch(targetUrl); diff --git a/lib/routes/python/release.ts b/lib/routes/python/release.ts index 40f80c933a3c72..d34555abbccd21 100644 --- a/lib/routes/python/release.ts +++ b/lib/routes/python/release.ts @@ -12,7 +12,7 @@ import { parseDate } from '@/utils/parse-date'; export const handler = async (ctx: Context): Promise => { const limit: number = Number.parseInt(ctx.req.query('limit') ?? '30', 10); - const baseUrl: string = 'https://www.python.org'; + const baseUrl = 'https://www.python.org'; const targetUrl: string = new URL('downloads', baseUrl).href; const response = await ofetch(targetUrl); diff --git a/lib/routes/qiche365/recall.ts b/lib/routes/qiche365/recall.ts index 4d18836b800dee..7a07881f0be5d5 100644 --- a/lib/routes/qiche365/recall.ts +++ b/lib/routes/qiche365/recall.ts @@ -31,7 +31,7 @@ async function handler(ctx): Promise { }, }); - const $ = load(html); + const $ = load((html as string)); const items: DataItem[] = $('li') .toArray() .map((item) => { diff --git a/lib/routes/qq/ac/utils.tsx b/lib/routes/qq/ac/utils.tsx index 28cebab54036e0..420ccf4f84c242 100644 --- a/lib/routes/qq/ac/utils.tsx +++ b/lib/routes/qq/ac/utils.tsx @@ -70,7 +70,7 @@ const ProcessItems = async (ctx, currentUrl, time, title) => { export { mobileRootUrl, ProcessItems, rootUrl }; -const QqAcDescription = ({ image, description, chapters }: { image: string; description: string; chapters: { link?: string; title?: string; image?: string }[] }) => ( +const QqAcDescription = ({ image, description, chapters }: { image: string; description: string; chapters: Array<{ link?: string; title?: string; image?: string }> }) => ( <> {image === '' ? null : } {description === '' ? null :

{description}

} diff --git a/lib/routes/qq/lol/news.ts b/lib/routes/qq/lol/news.ts index d9480e9cf1e38f..80dcc36b5a4fdf 100644 --- a/lib/routes/qq/lol/news.ts +++ b/lib/routes/qq/lol/news.ts @@ -14,8 +14,8 @@ export const handler = async (ctx: Context): Promise => { const { category = 23 } = ctx.req.param(); const limit: number = Number.parseInt(ctx.req.query('limit') ?? '30', 10); - const baseUrl: string = 'https://lol.qq.com'; - const apiBaseUrl: string = 'https://apps.game.qq.com'; + const baseUrl = 'https://lol.qq.com'; + const apiBaseUrl = 'https://apps.game.qq.com'; const targetUrl: string = new URL('news/index.shtml', baseUrl).href; const apiListUrl: string = new URL('cmc/zmMcnTargetContentList', apiBaseUrl).href; const apiInfoUrl: string = new URL('cmc/zmMcnContentInfo', apiBaseUrl).href; @@ -101,7 +101,7 @@ export const handler = async (ctx: Context): Promise => { }, ] : undefined; - const guid: string = `qq-lol-${result.iDocID}`; + const guid = `qq-lol-${result.iDocID}`; const image: string | undefined = result.sIMG ? (result.sIMG.startsWith('http') ? result.sIMG : `https:${result.sIMG}`) : undefined; const updated: number | string = result.sIdxTime ?? pubDate; diff --git a/lib/routes/raspberrypi/magazine.ts b/lib/routes/raspberrypi/magazine.ts index f17657be0ac9cf..666abd77791f86 100644 --- a/lib/routes/raspberrypi/magazine.ts +++ b/lib/routes/raspberrypi/magazine.ts @@ -14,7 +14,7 @@ import { renderDescription } from './templates/description'; export const handler = async (ctx: Context): Promise => { const limit: number = Number.parseInt(ctx.req.query('limit') ?? '12', 10); - const baseUrl: string = 'https://magazine.raspberrypi.com'; + const baseUrl = 'https://magazine.raspberrypi.com'; const targetUrl: string = new URL('issues', baseUrl).href; const response = await ofetch(targetUrl); @@ -112,7 +112,7 @@ export const handler = async (ctx: Context): Promise => { const enclosureUrl: string | undefined = $$$enclosureEl.attr('href') ? new URL($$$enclosureEl.attr('href') as string, baseUrl).href : undefined; if (enclosureUrl) { - const enclosureType: string = 'application/pdf'; + const enclosureType = 'application/pdf'; processedItem = { ...processedItem, diff --git a/lib/routes/resetera/thread.ts b/lib/routes/resetera/thread.ts index fc344114142816..998f0b82f7db2a 100644 --- a/lib/routes/resetera/thread.ts +++ b/lib/routes/resetera/thread.ts @@ -140,7 +140,7 @@ const handler: Route['handler'] = async (ctx) => { category: hasImage ? ['image'] : undefined, // 有图打标签,供全局过滤使用 }; }) - .filter(Boolean) as NonNullable[]; + .filter(Boolean) as Array>; }); // 4) 显式排序:postId 降序;再按时间兜底 diff --git a/lib/routes/rockthejvm/articles.ts b/lib/routes/rockthejvm/articles.ts index e1844ddabfe4b2..a75dc0df633699 100644 --- a/lib/routes/rockthejvm/articles.ts +++ b/lib/routes/rockthejvm/articles.ts @@ -14,7 +14,7 @@ import { renderDescription } from './templates/description'; export const handler = async (ctx: Context): Promise => { const limit: number = Number.parseInt(ctx.req.query('limit') ?? '30', 10); - const baseUrl: string = 'https://rockthejvm.com'; + const baseUrl = 'https://rockthejvm.com'; const targetUrl: string = new URL('articles/1', baseUrl).href; const response = await ofetch(targetUrl); diff --git a/lib/routes/samrdprc/index.ts b/lib/routes/samrdprc/index.ts index b31d86d08c95f0..38da5cd8ab5443 100644 --- a/lib/routes/samrdprc/index.ts +++ b/lib/routes/samrdprc/index.ts @@ -13,7 +13,7 @@ export const handler = async (ctx: Context): Promise => { const { id = 'xwdt/gzdt' } = ctx.req.param(); const limit: number = Number.parseInt(ctx.req.query('limit') ?? '17', 10); - const baseUrl: string = 'https://www.samrdprc.org.cn'; + const baseUrl = 'https://www.samrdprc.org.cn'; const targetUrl: string = new URL(id.endsWith('/') ? id : `${id}/`, baseUrl).href; const response = await ofetch(targetUrl); diff --git a/lib/routes/scientificamerican/podcast.ts b/lib/routes/scientificamerican/podcast.ts index 38a931eb0e66a6..6a65d41537b42d 100644 --- a/lib/routes/scientificamerican/podcast.ts +++ b/lib/routes/scientificamerican/podcast.ts @@ -15,7 +15,7 @@ export const handler = async (ctx: Context): Promise => { const { id } = ctx.req.param(); const limit: number = Number.parseInt(ctx.req.query('limit') ?? '12', 10); - const baseUrl: string = 'https://www.scientificamerican.com'; + const baseUrl = 'https://www.scientificamerican.com'; const targetUrl: string = new URL(`podcast${id ? `/${id}` : 's'}/`, baseUrl).href; const response = await ofetch(targetUrl); @@ -51,7 +51,7 @@ export const handler = async (ctx: Context): Promise => { url: author.url ? new URL(author.url, baseUrl).href : undefined, avatar: author.picture_file, })); - const guid: string = `-${item.id}`; + const guid = `-${item.id}`; const updated: number | string = item.release_date ?? pubDate; let processedItem: DataItem = { @@ -77,7 +77,7 @@ export const handler = async (ctx: Context): Promise => { const enclosureUrl: string | undefined = item.media_url; if (enclosureUrl) { - const enclosureType: string = `audio/${enclosureUrl.replace(/\?.*$/, '').split(/\./).pop()}`; + const enclosureType = `audio/${enclosureUrl.replace(/\?.*$/, '').split(/\./).pop()}`; processedItem = { ...processedItem, @@ -134,7 +134,7 @@ export const handler = async (ctx: Context): Promise => { url: author.url ? new URL(author.url, baseUrl).href : undefined, avatar: author.picture_file, })); - const guid: string = `scientificamerican-${articleData.id}`; + const guid = `scientificamerican-${articleData.id}`; const updated: number | string = articleData.updated_at_date_time ?? pubDate; let processedItem: DataItem = { @@ -159,7 +159,7 @@ export const handler = async (ctx: Context): Promise => { const enclosureUrl: string | undefined = articleData.media_url; if (enclosureUrl) { - const enclosureType: string = `audio/${enclosureUrl.replace(/\?.*$/, '').split(/\./).pop()}`; + const enclosureType = `audio/${enclosureUrl.replace(/\?.*$/, '').split(/\./).pop()}`; processedItem = { ...processedItem, diff --git a/lib/routes/scoop/apps.tsx b/lib/routes/scoop/apps.tsx index ad554805335f3f..e5e9dc32de10a8 100644 --- a/lib/routes/scoop/apps.tsx +++ b/lib/routes/scoop/apps.tsx @@ -36,8 +36,8 @@ export const handler = async (ctx: Context): Promise => { const { query = 's=2&d=1&n=true&dm=true&o=true' } = ctx.req.param(); const limit: number = Number.parseInt(ctx.req.query('limit') ?? '50', 10); - const baseUrl: string = 'https://scoop.sh'; - const apiBaseUrl: string = 'https://scoopsearch.search.windows.net'; + const baseUrl = 'https://scoop.sh'; + const apiBaseUrl = 'https://scoopsearch.search.windows.net'; const targetUrl: string = new URL(`/#/apps?${query}`, baseUrl).href; const apiUrl: string = new URL('indexes/apps/docs/search', apiBaseUrl).href; @@ -45,7 +45,7 @@ export const handler = async (ctx: Context): Promise => { const $: CheerioAPI = load(targetResponse); const language = $('html').attr('lang') ?? 'en'; - const scriptRegExp: RegExp = /