Skip to content

Commit

Permalink
chore(deps-dev): bump eslint-plugin-unicorn from 56.0.1 to 57.0.0 (DI…
Browse files Browse the repository at this point in the history
…Ygod#18392)

* chore(deps-dev): bump eslint-plugin-unicorn from 56.0.1 to 57.0.0

Bumps [eslint-plugin-unicorn](https://github.com/sindresorhus/eslint-plugin-unicorn) from 56.0.1 to 57.0.0.
- [Release notes](https://github.com/sindresorhus/eslint-plugin-unicorn/releases)
- [Commits](sindresorhus/eslint-plugin-unicorn@v56.0.1...v57.0.0)

---
updated-dependencies:
- dependency-name: eslint-plugin-unicorn
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>

* chore: remove unicorn plugin

* style: fix eslint issues

* style: fix more issues

* chore: flat config unicorn

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Tony <[email protected]>
  • Loading branch information
dependabot[bot] and TonyRL authored Feb 18, 2025
1 parent 3759def commit 8a0efc0
Show file tree
Hide file tree
Showing 60 changed files with 222 additions and 334 deletions.
34 changes: 17 additions & 17 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import prettier from 'eslint-plugin-prettier';
import stylistic from '@stylistic/eslint-plugin';
import unicorn from 'eslint-plugin-unicorn';
import typescriptEslint from '@typescript-eslint/eslint-plugin';
import n from 'eslint-plugin-n';
import globals from 'globals';
import tsParser from '@typescript-eslint/parser';
import parser from 'yaml-eslint-parser';
import yamlParser from 'yaml-eslint-parser';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import js from '@eslint/js';
Expand All @@ -15,7 +16,6 @@ const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
});

export default [{
Expand All @@ -32,17 +32,16 @@ export default [{
],
}, ...compat.extends(
'eslint:recommended',
'plugin:n/recommended',
'plugin:prettier/recommended',
'plugin:yml/recommended',
'plugin:@typescript-eslint/recommended',
),
unicorn.configs.recommended,
n.configs['flat/recommended-script'],
unicorn.configs.recommended,
{
plugins: {
prettier,
'@stylistic': stylistic,
unicorn,
'@typescript-eslint': typescriptEslint,
},

Expand Down Expand Up @@ -71,9 +70,9 @@ export default [{
// suggestions
'arrow-body-style': 'error',
'block-scoped-var': 'error',
curly: 'error',
'curly': 'error',
'dot-notation': 'error',
eqeqeq: 'error',
'eqeqeq': 'error',

'default-case': ['warn', {
commentPattern: '^no default$',
Expand Down Expand Up @@ -151,6 +150,7 @@ export default [{
'unicorn/no-hex-escape': 'warn',
'unicorn/no-null': 'off',
'unicorn/no-object-as-default-parameter': 'warn',
'unicorn/no-nested-ternary': 'warn',
'unicorn/no-process-exit': 'off',
'unicorn/no-useless-switch-case': 'off',

Expand Down Expand Up @@ -261,17 +261,17 @@ export default [{
files: ['.puppeteerrc.cjs', 'api/vercel.ts'],
rules: {
'@typescript-eslint/no-require-imports': 'off',
}
},
}, {
files: ['**/*.yaml', '**/*.yml'],
files: ['**/*.yaml', '**/*.yml'],

languageOptions: {
parser,
},
languageOptions: {
parser: yamlParser,
},

rules: {
'lines-around-comment': ['error', {
beforeBlockComment: false,
}],
},
rules: {
'lines-around-comment': ['error', {
beforeBlockComment: false,
}],
},
}];
48 changes: 15 additions & 33 deletions lib/routes/12306/zxdt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Route } from '@/types';
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import * as url from 'node:url';
import { parseDate } from '@/utils/parse-date';

export const route: Route = {
path: '/zxdt/:id?',
Expand Down Expand Up @@ -40,41 +40,23 @@ async function handler(ctx) {
const name = $('div.nav_center > a:nth-child(4)').text();

const list = $('#newList > ul > li')
.map(function () {
const info = {
title: $(this).find('a').text(),
link: $(this).find('a').attr('href'),
date: $(this).find('span').text().slice(1, -1),
};
return info;
})
.get();
.toArray()
.map((item) => ({
title: $(item).find('a').text(),
link: new URL($(item).find('a').attr('href'), link).href,
pubDate: parseDate($(item).find('span').text().slice(1, -1)),
}));

const out = await Promise.all(
list.map(async (info) => {
const title = info.title;
const date = info.date;
const itemUrl = url.resolve(link, info.link);
list.map((info) =>
cache.tryGet(info.link, async () => {
const response = await got.get(info.link);
const $ = load(response.data);
info.description = $('.article-box').html() || $('.content_text').html() || '文章已被删除';

const cacheIn = await cache.get(itemUrl);
if (cacheIn) {
return JSON.parse(cacheIn);
}

const response = await got.get(itemUrl);
const $ = load(response.data);
let description = $('.article-box').html();
description = description ? description.replaceAll('src="', `src="${url.resolve(itemUrl, '.')}`).trim() : $('.content_text').html() || '文章已被删除';

const single = {
title,
link: itemUrl,
description,
pubDate: new Date(date).toUTCString(),
};
cache.set(itemUrl, JSON.stringify(single));
return single;
})
return info;
})
)
);

return {
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/163/news/rank.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ async function handler(ctx) {
const $ = load(iconv.decode(response.data, 'gbk'));

const list = $('div.tabContents')
.eq(timeRange[time].index + (category === 'whole' ? (type === 'click' ? -1 : 2) : type === 'click' ? 0 : 2))
.eq(timeRange[time].index + (category === 'whole' ? (type === 'click' ? -1 : 2) : (type === 'click' ? 0 : 2)))
.find('table tbody tr td a')
.toArray()
.map((item) => {
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/6park/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ async function handler(ctx) {

const rootUrl = 'https://club.6parkbbs.com';
const indexUrl = `${rootUrl}/${id}/index.php`;
const currentUrl = `${indexUrl}${type === '' || keyword === '' ? '' : type === 'gold' ? '?app=forum&act=gold' : `?action=search&act=threadsearch&app=forum&${type}=${keyword}&submit=${type === 'type' ? '查询' : '栏目搜索'}`}`;
const currentUrl = `${indexUrl}${type === '' || keyword === '' ? '' : (type === 'gold' ? '?app=forum&act=gold' : `?action=search&act=threadsearch&app=forum&${type}=${keyword}&submit=${type === 'type' ? '查询' : '栏目搜索'}`)}`;

const response = await got({
method: 'get',
Expand Down
1 change: 1 addition & 0 deletions lib/routes/anthropic/news.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import got from '@/utils/got';
import { load } from 'cheerio';
import cache from '@/utils/cache';
import { Route } from '@/types';

export const route: Route = {
path: '/news',
Expand Down
1 change: 0 additions & 1 deletion lib/routes/appstore/price.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ async function handler(ctx) {
title: unsupported,
item: [{ title: unsupported }],
};
return;
}

let result = res.data.results.apps;
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/aqara/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ async function handler(ctx) {

if (filterMatches) {
const filterRegion = filterMatches[1];
const filterType = filterMatches[2] === 'tag' ? 'tags' : filterMatches[2] === 'category' ? 'categories' : filterMatches[2];
const filterType = filterMatches[2] === 'tag' ? 'tags' : (filterMatches[2] === 'category' ? 'categories' : filterMatches[2]);
const filterKeyword = decodeURI(filterMatches[3].split('/').pop());
const filterApiUrl = new URL(`${filterRegion}/${apiSlug}/${filterType}?search=${filterKeyword}`, rootUrl).href;

Expand Down
1 change: 1 addition & 0 deletions lib/routes/aqicn/aqi.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
import { Route } from '@/types';

export const route: Route = {
path: '/:city/:pollution?',
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/bilibili/danmaku.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ async function handler(ctx) {

let danmakuText = danmakuResponse.body;

danmakuText = await ((danmakuText[0] & 0x0f) === 0x08 ? zlib.inflateSync(danmakuText) : zlib.inflateRawSync(danmakuText));
danmakuText = await ((danmakuText[0] & 0x0F) === 0x08 ? zlib.inflateSync(danmakuText) : zlib.inflateRawSync(danmakuText));

let danmakuList = [];
const $ = load(danmakuText, { xmlMode: true });
Expand Down
1 change: 1 addition & 0 deletions lib/routes/bnu/fe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
import cache from '@/utils/cache';
import { Route } from '@/types';

export const route: Route = {
path: '/fe/:category',
Expand Down
1 change: 1 addition & 0 deletions lib/routes/bnu/jwb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
import cache from '@/utils/cache';
import { Route } from '@/types';

export const route: Route = {
path: '/jwb',
Expand Down
1 change: 0 additions & 1 deletion lib/routes/cnblogs/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export const route: Route = {
handler,
url: 'www.cnblogs.com/pick',
description: `在博客园主页的分类出可查看所有类型。例如,go 的分类地址为: \`https://www.cnblogs.com/cate/go/\`, 则: [\`/cnblogs/cate/go\`](https://rsshub.app/cnblogs/cate/go)`,
url: 'www.cnblogs.com/aggsite/headline',
};

async function handler(ctx) {
Expand Down
3 changes: 1 addition & 2 deletions lib/routes/cngal/weekly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const route: Route = {
url: 'www.cngal.org/',
};

async function handler(ctx) {
async function handler() {
const response = await got('https://www.cngal.org/api/news/GetWeeklyNewsOverview');

return {
Expand All @@ -45,5 +45,4 @@ async function handler(ctx) {
link: `https://www.cngal.org/articles/index/${item.id}`,
})),
};
ctx.state.json = response.data;
}
1 change: 0 additions & 1 deletion lib/routes/cuilingmag/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ export const route: Route = {
| [数字治理](https://www.cuilingmag.com/category/digital_governance) | [digital_governance](https://rsshub.app/cuilingmag/digital_governance) |
| [Noema精选](https://www.cuilingmag.com/category/selected_noema) | [selected_noema](https://rsshub.app/cuilingmag/selected_noema) |
`,
categories: ['new-media'],

features: {
requireConfig: false,
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/dealstreetasia/home.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ async function fetchPage() {
title: item.post_title || item.title || 'No Title',
link: item.post_url || item.link || '',
description: item.post_excerpt || item.excerpt || '',
pubDate: item.post_date ? new Date(item.post_date).toUTCString() : item.date ? new Date(item.date).toUTCString() : '',
pubDate: item.post_date ? new Date(item.post_date).toUTCString() : (item.date ? new Date(item.date).toUTCString() : ''),
category: item.category_link ? item.category_link.replaceAll(/(<([^>]+)>)/gi, '') : '', // Clean HTML if category_link exists
image: item.image_url ? item.image_url.replace(/\?.*$/, '') : '', // Remove query parameters if image_url exists
}));
Expand Down
6 changes: 3 additions & 3 deletions lib/routes/dedao/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ async function handler(ctx) {

const data = JSON.parse(response.data.match(/window.__INITIAL_STATE__= (.*);<\/script>/)[1]);

let items = (category === 'news' ? data.news : category === 'figure' ? data.figure : data.videoList).map((item) => ({
let items = (category === 'news' ? data.news : (category === 'figure' ? data.figure : data.videoList)).map((item) => ({
title: item.title,
pubDate: parseDate(item.online_time),
link: `${rootUrl}/${category === 'news' ? 'article/' : category === 'figure' ? 'people/' : ''}${item.online_time.split('T')[0].split('-').join('')}/${item.token}`,
link: `${rootUrl}/${category === 'news' ? 'article/' : (category === 'figure' ? 'people/' : '')}${item.online_time.split('T')[0].split('-').join('')}/${item.token}`,
}));

items = await Promise.all(
Expand All @@ -53,7 +53,7 @@ async function handler(ctx) {
);

return {
title: `得到${category === 'video' ? '' : '大事件'} - ${category === 'news' ? '新闻' : category === 'figure' ? '人物故事' : '视频'}`,
title: `得到${category === 'video' ? '' : '大事件'} - ${category === 'news' ? '新闻' : (category === 'figure' ? '人物故事' : '视频')}`,
link: rootUrl,
item: items,
description: data.description,
Expand Down
4 changes: 2 additions & 2 deletions lib/routes/deepseek/news.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Route, Data, DataItem } from '@/types';
import ofetch from '@/utils/ofetch';
import { load } from 'cheerio';
import * as cheerio from 'cheerio';
import cache from '@/utils/cache';

const ROOT_URL = 'https://api-docs.deepseek.com/zh-cn';
Expand All @@ -12,7 +12,7 @@ const ARTICLE_TITLE_SELECTOR = ARTICLE_CONTENT_SELECTOR + ' > h1';
// 获取消息列表 / get article list
const fetchPageContent = async (url: string) => {
const response = await ofetch(url);
return load(response);
return cheerio.load(response);
};

// 提取正文内容 / extract article content
Expand Down
6 changes: 1 addition & 5 deletions lib/routes/douyin/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ interface ShareInfo {
share_title_myself: string;
share_title_other: string;
share_desc_info: string;
share_link_desc: string;
}

interface Author {
Expand Down Expand Up @@ -422,11 +423,6 @@ interface TextExtra {
search_query_id: string;
}

interface ShareInfo {
share_url: string;
share_link_desc: string;
}

interface RiskInfos {
vote: boolean;
warn: boolean;
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/e-hentai/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ async function handler(ctx) {
$('.itd').parent().remove();

let items = $('table.gltc tbody tr')
.slice(1, ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) + 1 : needImages ? 16 : 26)
.slice(1, ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) + 1 : (needImages ? 16 : 26))
.toArray()
.map((item) => {
item = $(item);
Expand Down
4 changes: 2 additions & 2 deletions lib/routes/epicgames/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ async function handler(ctx) {
let linkSlug =
item.catalogNs.mappings && item.catalogNs.mappings.length > 0
? item.catalogNs.mappings[0].pageSlug
: item.offerMappings && item.offerMappings.length > 0
: (item.offerMappings && item.offerMappings.length > 0
? item.offerMappings[0].pageSlug
: (item.productSlug ?? item.urlSlug);
: (item.productSlug ?? item.urlSlug));
if (item.offerType === 'ADD_ON') {
linkSlug = item.offerMappings[0].pageSlug;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/espn/news.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const route: Route = {
author: itemDetail.byline,
pubDate: item.date,
// for videos and shortstops, no need to extract full text below
description: itemType === 'Media' ? renderMedia(itemDetail.video[0]) : itemType === 'Shortstop' ? itemDetail.headline : '',
description: itemType === 'Media' ? renderMedia(itemDetail.video[0]) : (itemType === 'Shortstop' ? itemDetail.headline : ''),
};
});

Expand Down
4 changes: 0 additions & 4 deletions lib/routes/fanbox/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,6 @@ export interface TextPost extends BasicPost {
};
}

export interface PostDetailResponse {
body: PostDetail;
}

interface TextBlock {
type: 'p';
text: string;
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/fantia/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ async function handler(ctx) {

const rootUrl = 'https://fantia.jp';
const apiUrl = `${rootUrl}/api/v1/search/${type}?keyword=${keyword}&peroid=${period}&brand_type=0&category=${caty === 'all' ? '' : caty}&order=${order}${
rating === 'all' ? '' : rating === 'general' ? '&rating=general' : '&adult=1'
rating === 'all' ? '' : (rating === 'general' ? '&rating=general' : '&adult=1')
}&per_page=30`;
const response = await got({
method: 'get',
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/follow/profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async function handler(ctx: Context): Promise<Data> {
const handleOrId = ctx.req.param('uid');
const host = 'https://api.follow.is';

const handle = isBizId(handleOrId || '') ? handleOrId : handleOrId.startsWith('@') ? handleOrId.slice(1) : handleOrId;
const handle = isBizId(handleOrId || '') ? handleOrId : (handleOrId.startsWith('@') ? handleOrId.slice(1) : handleOrId);

const searchParams = new URLSearchParams({ handle });

Expand Down
2 changes: 1 addition & 1 deletion lib/routes/followin/news.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ async function handler(ctx) {
const items = await Promise.all(list.map((item) => parseItem(item, cache.tryGet)));

return {
title: `${lang === 'en' ? 'News' : lang === 'vi' ? 'Bản tin' : '快讯'} - Followin`,
title: `${lang === 'en' ? 'News' : (lang === 'vi' ? 'Bản tin' : '快讯')} - Followin`,
link: `${baseUrl}/${lang}/news`,
image: favicon,
language: lang,
Expand Down
Loading

0 comments on commit 8a0efc0

Please sign in to comment.