style(eslint): add eslint-plugin-n (#12393)

This commit is contained in:
Tony
2023-04-27 05:16:11 +08:00
committed by GitHub
parent da0cab5e90
commit 5b6d7cb524
21 changed files with 254 additions and 122 deletions
+3 -3
View File
@@ -748,7 +748,7 @@ router.get('/shu/:type?', lazyloadRouteHandler('./routes/universities/shu/index'
router.get('/shu/jwc/:type?', lazyloadRouteHandler('./routes/universities/shu/jwc'));
// 北京科技大学天津学院
router.get('/ustb/tj/news/:type?', lazyloadRouteHandler('./routes/universities/ustb/tj/news'));
// router.get('/ustb/tj/news/:type?', lazyloadRouteHandler('./routes/universities/ustb/tj/news'));
// 深圳大学
// router.get('/szu/yz/:type?', lazyloadRouteHandler('./routes/universities/szu/yz'));
@@ -3046,8 +3046,8 @@ router.get('/141ppv/:type/:key?', lazyloadRouteHandler('./routes/141ppv/141ppv')
router.get('/curiouscat/user/:id', lazyloadRouteHandler('./routes/curiouscat/user'));
// Telecompaper
router.get('/telecompaper/news/:caty/:year?/:country?/:type?', lazyloadRouteHandler('./routes/telecompaper/news'));
router.get('/telecompaper/search/:keyword?/:company?/:sort?/:period?', lazyloadRouteHandler('./routes/telecompaper/search'));
// router.get('/telecompaper/news/:caty/:year?/:country?/:type?', lazyloadRouteHandler('./routes/telecompaper/news'));
// router.get('/telecompaper/search/:keyword?/:company?/:sort?/:period?', lazyloadRouteHandler('./routes/telecompaper/search'));
// 水木社区
router.get('/newsmth/account/:id', lazyloadRouteHandler('./routes/newsmth/account'));
+1 -1
View File
@@ -3,7 +3,7 @@ const got = require('@/utils/got');
module.exports = async (ctx) => {
const type = ctx.params.type || 'all';
const rssData = {
isType: ctx.params.type ? true : false,
isType: !!ctx.params.type,
Title: `湖南省政府采购网`,
Desc: `湖南省政府采购网`,
Link: `http://www.ccgp-hunan.gov.cn/page/notice/more.jsp`,
+1 -1
View File
@@ -58,7 +58,7 @@ module.exports = async (ctx) => {
const $ = cheerio.load(response);
const data = JSON.parse($('script[type="application/ld+json"]').first().text());
const { transformed } = parsePreloadedStateJSON($);
const VideoObject = data['@type'] === 'VideoObject' ? true : false;
const VideoObject = data['@type'] === 'VideoObject';
const lede = !VideoObject ? transformed.article.headerProps.lede : null;
let articleBody = '';
+1 -1
View File
@@ -15,7 +15,7 @@ module.exports = async (ctx) => {
let overview = false;
if (titles[ctx.params.category]) {
category = ctx.params.category;
overview = ctx.params.overview ? true : false;
overview = !!ctx.params.overview;
category = category === 'tech' ? 'technews' : category;
} else if (ctx.params.category) {
overview = true;
+4
View File
@@ -0,0 +1,4 @@
module.exports = {
'/news/:caty/:year?/:country?/:type?': ['nczitzk'],
'/search/:keyword?/:company?/:sort?/:period?': ['nczitzk'],
};
@@ -1,6 +1,7 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const tough = require('tough-cookie');
// eslint-disable-next-line n/no-extraneous-require
const FormData = require('form-data');
module.exports = async (ctx) => {
+15
View File
@@ -0,0 +1,15 @@
module.exports = {
'telecompaper.com': {
_name: 'Telecompaper',
'.': [
{
title: 'News',
docs: 'https://docs.rsshub.app/journal.html#telecompaper',
},
{
title: 'Search',
docs: 'https://docs.rsshub.app/journal.html#telecompaper',
},
],
},
};
+4
View File
@@ -0,0 +1,4 @@
module.exports = (router) => {
router.get('/news/:caty/:year?/:country?/:type?', require('./news'));
router.get('/search/:keyword?/:company?/:sort?/:period?', require('./search'));
};
+2 -22
View File
@@ -1,25 +1,5 @@
module.exports = {
'/yjsy/news/adma': ['DA1Y1'],
'/yjsy/news/all': ['DA1Y1'],
'/yjsy/news/cicst': ['DA1Y1'],
'/yjsy/news/cres': ['DA1Y1'],
'/yjsy/news/huasheng': ['DA1Y1'],
'/yjsy/news/iet': ['DA1Y1'],
'/yjsy/news/ihmm': ['DA1Y1'],
'/yjsy/news/marx': ['DA1Y1'],
'/yjsy/news/me': ['DA1Y1'],
'/yjsy/news/metall': ['DA1Y1'],
'/yjsy/news/mse': ['DA1Y1'],
'/yjsy/news/ncms': ['DA1Y1'],
'/yjsy/news/saee': ['DA1Y1'],
'/yjsy/news/scce': ['DA1Y1'],
'/yjsy/news/sd': ['DA1Y1'],
'/yjsy/news/seee': ['DA1Y1'],
'/yjsy/news/sem': ['DA1Y1'],
'/yjsy/news/sfs': ['DA1Y1'],
'/yjsy/news/shuli': ['DA1Y1'],
'/yjsy/news/skl': ['DA1Y1'],
'/yjsy/news/slam': ['DA1Y1'],
'/yjsy/news/wenfa': ['DA1Y1'],
'/tj/news/:type?': ['henbf'],
'/yjsy/news/:type': ['DA1Y1'],
'/yzxc/tzgg': ['yanbot-team'],
};
+8
View File
@@ -9,6 +9,14 @@ module.exports = {
target: '/ustb/yjsy/news/:type',
},
],
tj: [
{
title: '天津学院',
docs: 'https://docs.rsshub.app/university.html#bei-jing-ke-ji-da-xue',
source: ['/*'],
target: '/ustb/tj/news/all',
},
],
yzxc: [
{
title: '研究生招生信息网',
+1
View File
@@ -1,4 +1,5 @@
module.exports = function (router) {
router.get('/tj/news/:type?', require('./tj/news'));
router.get('/yjsy/news/:type', require('./yjsy/news'));
router.get('/yzxc/tzgg', require('./yzxc/tzgg'));
};
@@ -1,7 +1,7 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const dayjs = require('dayjs');
const _ = require('lodash');
const { parseDate } = require('@/utils/parse-date');
const timezone = require('@/utils/timezone');
const baseUrl = 'http://tj.ustb.edu.cn';
const maps = {
@@ -22,18 +22,17 @@ const maps = {
function getNews(data) {
const $ = cheerio.load(data);
return $('div[class="classnews"] ul li a')
.slice(0, 5)
.map((_, elem) => ({
.toArray()
.map((elem) => ({
link: baseUrl + elem.attribs.href,
title: elem.children[0].data,
pubDate: dayjs(elem.attribs.href.split('/')[3].split('.')[0]).toString(),
}))
.get();
pubDate: timezone(parseDate(elem.attribs.href.split('/')[3].split('.')[0].substring(0, 14), 'YYYYMMDDHHmmss'), 8),
}));
}
module.exports = async (ctx) => {
let type = ctx.params.type || 'all';
if (!_.includes(_.keys(maps), type)) {
if (!Object.keys(maps).includes(type)) {
type = 'all';
}
@@ -46,14 +45,14 @@ module.exports = async (ctx) => {
if (type === 'all') {
const all = await Promise.all(
Object.values(maps).map(async (link) => {
const response = await got.get(baseUrl + link);
const response = await got(baseUrl + link);
const news = getNews(response.data);
return Promise.resolve(news);
return news;
})
);
responseData.item = _.orderBy(_.flatMapDepth(all), (res) => new Date(res.pubDate), ['desc']);
responseData.item = all.flatMap((res) => res);
} else {
const response = await got.get(baseUrl + maps[type]);
const response = await got(baseUrl + maps[type]);
const news = getNews(response.data);
responseData.item = news;
}