style: update oxlint to use simple-import-sort

This commit is contained in:
Tony
2026-03-04 03:13:57 +08:00
parent b6660ed585
commit 8043a5a819
22 changed files with 72 additions and 38 deletions
+11 -4
View File
@@ -11,7 +11,14 @@
"node": true
},
"plugins": ["eslint", "typescript", "node", "unicorn", "import"],
"jsPlugins": ["@stylistic/eslint-plugin", { "name": "js-import-x", "specifier": "eslint-plugin-import-x" }, { "name": "n", "specifier": "eslint-plugin-n" }, "./eslint-plugins/no-then.js", "./eslint-plugins/nsfw-flag.js"],
"jsPlugins": [
"@stylistic/eslint-plugin",
{ "name": "import-x-js", "specifier": "eslint-plugin-import-x" },
{ "name": "n", "specifier": "eslint-plugin-n" },
"eslint-plugin-simple-import-sort",
"./eslint-plugins/no-then.js",
"./eslint-plugins/nsfw-flag.js"
],
"rules": {
// #region --- ESLint js/recommended possible problems ---
"constructor-super": "error",
@@ -463,11 +470,11 @@
// oxfmt also handles import sorting
"sort-imports": "off",
"import-x/order": "off",
// "simple-import-sort/imports": "error",
// "simple-import-sort/exports": "error",
"simple-import-sort/imports": "error", // oxc doesn't sort named imports yet https://github.com/oxc-project/oxc/issues/13610
"simple-import-sort/exports": "error",
"import-x/first": "error",
"js-import-x/newline-after-import": "error", // oxc native not yet implemented
"import-x-js/newline-after-import": "error", // oxc native not yet implemented
"no-duplicate-imports": "off",
"import-x/no-duplicates": "error",
+4
View File
@@ -123,6 +123,10 @@ export default defineConfig([
selector: 'CallExpression[callee.property.name="catch"] > ArrowFunctionExpression[params.length=0] > BlockStatement[body.length=0]',
message: 'Usage of .catch(() => {}) is not allowed. Please handle the error appropriately.',
},
{
selector: 'CallExpression[callee.name="load"] AwaitExpression > CallExpression',
message: 'Do not use await in call expressions. Extract the result into a variable first.',
},
],
/*
'no-unneeded-ternary': 'error',
+2 -1
View File
@@ -20,7 +20,8 @@ describe('debug', () => {
const response = await app.request('/');
const $ = load(await response.text());
const html = await response.text();
const $ = load(html);
$('.debug-item').each((index, item) => {
const key = $(item).find('.debug-key').html()?.trim();
const value = $(item).find('.debug-value').html()?.trim();
+8 -4
View File
@@ -36,10 +36,12 @@ export const route: Route = {
async function handler(ctx) {
const { id } = ctx.req.param();
const link = `https://m.51read.org/xiaoshuo/${id}`;
const $book = load(await ofetch(link));
const bookHtml = await ofetch(link);
const $book = load(bookHtml);
const chapter = `https://m.51read.org/zhangjiemulu/${id}`;
const $chapter = load(await ofetch(chapter));
const chapterHtml = await ofetch(chapter);
const $chapter = load(chapterHtml);
const pageLength = $chapter('.ml-page select')
.find('option')
@@ -61,7 +63,8 @@ async function handler(ctx) {
const createItem = async (baseUrl: string, page: number) => {
const url = `${baseUrl}/${page}`;
const $latest = load(await ofetch(url));
const html = await ofetch(url);
const $latest = load(html);
const item = await Promise.all(
$latest('.kb-jp li>a')
.toArray()
@@ -73,7 +76,8 @@ const createItem = async (baseUrl: string, page: number) => {
const buildItem = (url: string) =>
cache.tryGet(url, async () => {
const $ = load(await ofetch(url));
const html = await ofetch(url);
const $ = load(html);
return {
title: $('h1').text(),
+4 -2
View File
@@ -29,7 +29,8 @@ export const route: Route = {
handler: async (ctx) => {
const { id } = ctx.req.param();
const link = `https://www.69shuba.cx/book/${id}.htm`;
const $ = load(await get(link));
const html = await get(link);
const $ = load(html);
const item = await Promise.all(
$('.qustime li>a')
@@ -51,7 +52,8 @@ export const route: Route = {
const createItem = (url: string) =>
cache.tryGet(url, async () => {
const $ = load(await get(url));
const html = await get(url);
const $ = load(html);
const { articleid, chapterid, chaptername } = parseObject(/bookinfo\s?=\s?{[\S\s]+?}/, $('head>script:not([src])').text());
const decryptionMap = parseObject(/_\d+\s?=\s?{[\S\s]+?}/, $('.txtnav+script').text());
+2 -1
View File
@@ -21,7 +21,8 @@ async function handler(ctx: Context): Promise<Data> {
throw new InvalidParameterError(`unknown site: ${site}`);
}
const link = `https://${INSTANCES.get(site)}/show_bug.cgi?id=${bugId}`;
const $ = load(await ofetch(`${link}&ctype=xml`));
const xml = await ofetch(`${link}&ctype=xml`);
const $ = load(xml);
const items = $('long_desc').map((index, rawItem) => {
const $ = load(rawItem, null, false);
return {
+2 -1
View File
@@ -62,7 +62,8 @@ export const route: Route = {
const items = await Promise.all(
list.map((item) =>
cache.tryGet(item.link!, async () => {
const $ = load(await ofetch(item.link!));
const html = await ofetch(item.link!);
const $ = load(html);
const content = $('.list_cont');
item.title = content.find('.title').text();
+2 -1
View File
@@ -35,7 +35,8 @@ export const route: Route = {
async function handler(ctx) {
const url = `https://news.dmzj.com/${ctx.req.param('category') || ''}`;
const $ = load((await got(url)).data);
const response = await got(url);
const $ = load(response.data);
return {
title: $('title').text(),
link: url,
+2 -1
View File
@@ -9,7 +9,8 @@ import got from '@/utils/got';
const baseURL = 'https://freecomputerbooks.com/';
async function cheerioLoad(url) {
return load((await got(url)).data);
const response = await got(url);
return load(response.data);
}
export const route: Route = {
+2 -1
View File
@@ -35,7 +35,8 @@ async function handler(ctx) {
const items = await Promise.all(
list.map((item) =>
cache.tryGet(item.link, async () => {
const content = load(await ofetch(item.link));
const html = await ofetch(item.link);
const content = load(html);
const ldjson = JSON.parse(content('[type="application/ld+json"]:not([data-schema])').text());
item.pubDate = parseDate(ldjson.datePublished);
+2 -1
View File
@@ -36,7 +36,8 @@ async function handler(ctx) {
const limit = Number.parseInt(ctx.req.query('limit')) || 12;
const link = getLink(category);
const $ = load(await get(link));
const html = await get(link);
const $ = load(html);
const title = $('head>title').text();
const description = $('head>meta[name="description"]').attr('content');
const image = $('head>link[rel="apple-touch-icon"]').attr('href');
+2 -1
View File
@@ -34,7 +34,8 @@ async function handler(ctx) {
const items = await Promise.all(
list.map((item) =>
cache.tryGet(item.link, async () => {
const content = load(await ofetch(item.link));
const html = await ofetch(item.link);
const content = load(html);
const ldjson = JSON.parse(content('script.rank-math-schema-pro').text())['@graph'].find((e) => e['@type'] === 'NewsArticle');
item.pubDate = parseDate(ldjson.datePublished);
+4 -2
View File
@@ -34,7 +34,8 @@ async function handler(ctx) {
const id = ctx.req.param('id');
const limit = Number.parseInt(ctx.req.query('limit')) || 5;
const link = `https://syosetu.org/novel/${id}`;
const $ = load(await get(link));
const html = await get(link);
const $ = load(html);
const title = $('span[itemprop="name"]').text();
const description = $('div.ss:nth-child(2)').text();
@@ -57,7 +58,8 @@ async function handler(ctx) {
chapter_list.map((chapter) => {
chapter.link = `${link}/${chapter.link}`;
return cache.tryGet(chapter.link, async () => {
const content = load(await get(chapter.link));
const html = await get(chapter.link);
const content = load(html);
chapter.description = content('#honbun').html();
return chapter;
});
+4 -2
View File
@@ -33,7 +33,8 @@ async function handler(ctx: Context): Promise<Data> {
const id = ctx.req.param('id');
const url = `https://kakuyomu.jp/works/${id}`;
const limit = Number.parseInt(ctx.req.query('limit') || '10');
const $ = load(await ofetch(url));
const html = await ofetch(url);
const $ = load(html);
const nextData = JSON.parse($('#__NEXT_DATA__').text());
@@ -56,7 +57,8 @@ async function handler(ctx: Context): Promise<Data> {
.map((item) => {
const episodeUrl = `https://kakuyomu.jp/works/${id}/episodes/${item.id}`;
return cache.tryGet(episodeUrl, async () => {
const $ = load(await ofetch(episodeUrl));
const html = await ofetch(episodeUrl);
const $ = load(html);
const description = $('.widget-episodeBody').html();
return {
title: item.title,
+2 -1
View File
@@ -22,7 +22,8 @@ export const route: Route = {
async function handler(ctx: Context): Promise<Data> {
const { id } = ctx.req.param();
const link = `https://www.linovelib.com/novel/${id}/catalog`;
const $ = load((await got(link)).data);
const response = await got(link);
const $ = load(response.data);
return {
title: `${$('.book-meta h1').text()} - 哔哩轻小说`,
link,
+4 -2
View File
@@ -28,7 +28,8 @@ export const route: Route = {
};
async function handler() {
const $ = load(await ofetch(NEWS_LINK));
const html = await ofetch(NEWS_LINK);
const $ = load(html);
const items = await Promise.all(
$('.list__side_border li')
.toArray()
@@ -43,7 +44,8 @@ async function handler() {
pubDate: timezone(parseDate($item.find('p span').first().text()), +9),
category: [category],
description: await cache.tryGet(link, async () => {
const $detail = load(await ofetch(link));
const detailHtml = await ofetch(link);
const $detail = load(detailHtml);
return $detail('.contents_area__inner').html()!;
}),
} as DataItem;
+2 -1
View File
@@ -51,7 +51,8 @@ export const route: Route = {
const items = await Promise.all(
list.map((item) =>
cache.tryGet(item.link!, async () => {
const $ = load(await ofetch(item.link!));
const html = await ofetch(item.link!);
const $ = load(html);
const content = $('.content');
item.author = content.find('.author span').text();
+2 -1
View File
@@ -68,7 +68,8 @@ export const route: Route = {
items = await Promise.all(
items.map((item) =>
cache.tryGet(item.link!, async () => {
const $ = load(await $get(item.link!));
const html = await $get(item.link!);
const $ = load(html);
item.description = $trim($('.text1[width="95%"] b').html()!);
return item;
})
+2 -1
View File
@@ -90,8 +90,9 @@ async function handler(ctx) {
)
);
const fallbackHtml = await ofetch(currentUrl);
return {
title: $('title').text() || load(await ofetch(currentUrl))('title').text(),
title: $('title').text() || load(fallbackHtml)('title').text(),
link: currentUrl,
item: items,
};
+2 -1
View File
@@ -26,7 +26,8 @@ export const route: Route = {
async function handler(ctx) {
const aid = Number.parseInt(ctx.req.param('id'));
const link = `https://www.wenku8.net/novel/${Math.floor(aid / 1000)}/${aid}/index.htm`;
const $ = load(await get(link));
const html = await get(link);
const $ = load(html);
const vid = $('.vcss').last().parent().next().find('a')[0].attribs.href.replace('.htm', '');
const volumeUrl = `https://dl.wenku8.com/packtxt.php?aid=${aid}&vid=${vid}&charset=gbk`;
const lastestChapters = $('.vcss')
+5 -8
View File
@@ -75,14 +75,11 @@ async function handler(ctx) {
item: await Promise.all(
data.map((item) =>
cache.tryGet(item.link, async () => {
const $ = load(
(
await got({
method: 'get',
url: item.link,
})
).body
);
const response = await got({
method: 'get',
url: item.link,
});
const $ = load(response.body);
item.author = /作者:(\S*)\s{4}/g.exec($('p', '.main_contit').text())[1];
item.description = $('#vsb_content').html();
return item;
+2 -1
View File
@@ -63,7 +63,8 @@ async function handler(ctx: Context): Promise<Data> {
const link = `${bbsOrigin}/forum.php?${params.toString()}`;
const $ = load(await ofetch<string>(link, { headers }));
const html = await ofetch<string>(link, { headers });
const $ = load(html);
const title = $('title').text().replace(' - 百合会 - Powered by Discuz!', '');