mirror of
https://github.com/lifegpc/bookdownload.git
synced 2026-07-06 05:21:15 +08:00
Add react lint support
This commit is contained in:
@@ -1,16 +1,37 @@
|
||||
import { defineConfig } from "eslint/config";
|
||||
import eslint from '@eslint/js';
|
||||
import tseslint from 'typescript-eslint';
|
||||
import reactLint from 'eslint-plugin-react';
|
||||
|
||||
export default defineConfig([
|
||||
eslint.configs.recommended,
|
||||
...tseslint.configs.recommended,
|
||||
{
|
||||
plugins: {
|
||||
react: reactLint,
|
||||
},
|
||||
rules: reactLint.configs.recommended.rules,
|
||||
languageOptions: {
|
||||
parserOptions: reactLint.configs.recommended.parserOptions,
|
||||
},
|
||||
settings: {
|
||||
react: {
|
||||
version: "detect",
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
rules: {
|
||||
'@typescript-eslint/no-unused-vars': ['warn', {
|
||||
varsIgnorePattern: '^_',
|
||||
argsIgnorePattern: '^_',
|
||||
}],
|
||||
'react/react-in-jsx-scope': 'off',
|
||||
'react/jsx-boolean-value': 'error',
|
||||
'react/jsx-curly-brace-presence': ['error', {
|
||||
props: 'never',
|
||||
children: 'never',
|
||||
}]
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
"esbuild": "^0.27.3",
|
||||
"esbuild-plugin-eslint": "^0.3.12",
|
||||
"eslint": "9",
|
||||
"eslint-plugin-react": "^7.37.5",
|
||||
"pocketbase": "^0.26.8",
|
||||
"react": "^19.2.4",
|
||||
"react-dom": "^19.2.4",
|
||||
@@ -22,7 +23,8 @@
|
||||
"scripts": {
|
||||
"build": "node build.js --dev",
|
||||
"builddbg": "node build.js --dev --debug",
|
||||
"buildrel": "node build.js"
|
||||
"buildrel": "node build.js",
|
||||
"lint": "eslint src"
|
||||
},
|
||||
"type": "module"
|
||||
}
|
||||
|
||||
@@ -8,5 +8,5 @@ export type AlertWarnProps = {
|
||||
};
|
||||
|
||||
export default function AlertWarn({ title = "警告", content, onClose, okText = "好的" }: AlertWarnProps) {
|
||||
return <Modal title={title} open={true} onOk={onClose} onCancel={onClose} okText={okText} cancelButtonProps={{ style: { display: "none" } }}>{content}</Modal>
|
||||
return <Modal title={title} open onOk={onClose} onCancel={onClose} okText={okText} cancelButtonProps={{ style: { display: "none" } }}>{content}</Modal>
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ async function make_storage_persist() {
|
||||
}
|
||||
}
|
||||
|
||||
async function save_data<T>(db: IDBDatabase, storeName: string, data: T, key?: IDBValidKey) {
|
||||
function save_data<T>(db: IDBDatabase, storeName: string, data: T, key?: IDBValidKey) {
|
||||
return new Promise<IDBValidKey>((resolve, reject) => {
|
||||
const tx = db.transaction(storeName, 'readwrite');
|
||||
const store = tx.objectStore(storeName);
|
||||
@@ -28,7 +28,7 @@ async function save_data<T>(db: IDBDatabase, storeName: string, data: T, key?: I
|
||||
type QdChapterKey = [number, number, number];
|
||||
type QdChapterHashKey = [number, number, string];
|
||||
|
||||
async function get_data<T>(db: IDBDatabase, storeName: string, key: IDBValidKey | IDBKeyRange, index?: string): Promise<T | undefined> {
|
||||
function get_data<T>(db: IDBDatabase, storeName: string, key: IDBValidKey | IDBKeyRange, index?: string): Promise<T | undefined> {
|
||||
return new Promise<T | undefined>((resolve, reject) => {
|
||||
const tx = db.transaction(storeName, 'readonly');
|
||||
const store = tx.objectStore(storeName);
|
||||
@@ -47,7 +47,7 @@ type GetAllOptions = {
|
||||
count?: number;
|
||||
}
|
||||
|
||||
async function get_datas<T>(db: IDBDatabase, storeName: string, key?: IDBValidKey | IDBKeyRange, options?: GetAllOptions): Promise<T[]> {
|
||||
function get_datas<T>(db: IDBDatabase, storeName: string, key?: IDBValidKey | IDBKeyRange, options?: GetAllOptions): Promise<T[]> {
|
||||
return new Promise<T[]>((resolve, reject) => {
|
||||
const tx = db.transaction(storeName, 'readonly');
|
||||
const store = tx.objectStore(storeName);
|
||||
@@ -61,7 +61,7 @@ async function get_datas<T>(db: IDBDatabase, storeName: string, key?: IDBValidKe
|
||||
});
|
||||
}
|
||||
|
||||
async function get_data_with_convert<T, U>(db: IDBDatabase, storeName: string, convert: (key: IDBValidKey, data: T, list: U[]) => Promise<void> | void , key?: IDBValidKey | IDBKeyRange, index?: string): Promise<U[]> {
|
||||
function get_data_with_convert<T, U>(db: IDBDatabase, storeName: string, convert: (key: IDBValidKey, data: T, list: U[]) => Promise<void> | void , key?: IDBValidKey | IDBKeyRange, index?: string): Promise<U[]> {
|
||||
return new Promise<U[]>((resolve, reject) => {
|
||||
const list: U[] = [];
|
||||
const tx = db.transaction(storeName, 'readonly');
|
||||
@@ -92,7 +92,7 @@ async function get_data_with_convert<T, U>(db: IDBDatabase, storeName: string, c
|
||||
});
|
||||
}
|
||||
|
||||
async function get_keys<K extends IDBValidKey = IDBValidKey>(db: IDBDatabase, storeName: string, query?: IDBValidKey | IDBKeyRange, options?: GetAllOptions): Promise<K[]> {
|
||||
function get_keys<K extends IDBValidKey = IDBValidKey>(db: IDBDatabase, storeName: string, query?: IDBValidKey | IDBKeyRange, options?: GetAllOptions): Promise<K[]> {
|
||||
return new Promise<K[]>((resolve, reject) => {
|
||||
const tx = db.transaction(storeName, 'readonly');
|
||||
const store = tx.objectStore(storeName);
|
||||
@@ -106,7 +106,7 @@ async function get_keys<K extends IDBValidKey = IDBValidKey>(db: IDBDatabase, st
|
||||
});
|
||||
}
|
||||
|
||||
async function get_count(db: IDBDatabase, storeName: string, key?: IDBValidKey | IDBKeyRange, index?: string): Promise<number> {
|
||||
function get_count(db: IDBDatabase, storeName: string, key?: IDBValidKey | IDBKeyRange, index?: string): Promise<number> {
|
||||
return new Promise<number>((resolve, reject) => {
|
||||
const tx = db.transaction(storeName, 'readonly');
|
||||
const store = tx.objectStore(storeName);
|
||||
|
||||
@@ -62,7 +62,7 @@ export default function BookIndex() {
|
||||
</Flex>
|
||||
<Affix offsetTop={10}>
|
||||
<Flex justify="flex-end" className={styles.affix}>
|
||||
<Switch checked={bookStatus.showSavedOnly} onChange={setShowSavedOnly} checkedChildren={"仅显示已保存章节"} unCheckedChildren={"显示所有章节"} />
|
||||
<Switch checked={bookStatus.showSavedOnly} onChange={setShowSavedOnly} checkedChildren="仅显示已保存章节" unCheckedChildren="显示所有章节" />
|
||||
</Flex>
|
||||
</Affix>
|
||||
{bookStatus.showSavedOnly && err && <Result status="error" title="加载章节列表失败" subTitle={err} extra={<Button type="primary" onClick={handle}>重试</Button>} />}
|
||||
|
||||
@@ -51,7 +51,7 @@ export default function Books() {
|
||||
pageSizeOptions={[10, 20, 50, 100]}
|
||||
onChange={(page, pageSize) => { setPage(page); setPageSize(pageSize); setSearchParams({ page: String(page), pageSize: String(pageSize) }); }}
|
||||
showTotal={(total, range) => `共 ${total} 条,当前显示 ${range[0]} - ${range[1]} 条`}
|
||||
showSizeChanger={true}
|
||||
showSizeChanger
|
||||
/>
|
||||
</Affix>)}
|
||||
{!pageData && !err && <Skeleton active />}
|
||||
|
||||
Reference in New Issue
Block a user