refactor: 优化eslint配置,提升代码质量 (#1341)

* feat: 统一并标准化eslint

* lint: napcat.webui

* lint: napcat.webui

* lint: napcat.core

* build: fix

* lint: napcat.webui

* refactor: 重构eslint

* Update README.md
This commit is contained in:
时瑾
2025-11-03 16:30:45 +08:00
committed by GitHub
parent d5b8f886d6
commit 06f6a542f5
651 changed files with 37981 additions and 37587 deletions

View File

@@ -1,5 +1,5 @@
import clsx from 'clsx'
import { type ReactNode, createContext, forwardRef, useContext } from 'react'
import clsx from 'clsx';
import { type ReactNode, createContext, forwardRef, useContext } from 'react';
export interface TabsContextValue {
activeKey: string
@@ -8,8 +8,8 @@ export interface TabsContextValue {
const TabsContext = createContext<TabsContextValue>({
activeKey: '',
onChange: () => {}
})
onChange: () => {},
});
export interface TabsProps {
activeKey: string
@@ -18,12 +18,12 @@ export interface TabsProps {
className?: string
}
export function Tabs({ activeKey, onChange, children, className }: TabsProps) {
export function Tabs ({ activeKey, onChange, children, className }: TabsProps) {
return (
<TabsContext.Provider value={{ activeKey, onChange }}>
<div className={clsx('flex flex-col gap-2', className)}>{children}</div>
</TabsContext.Provider>
)
);
}
export interface TabListProps {
@@ -31,10 +31,10 @@ export interface TabListProps {
className?: string
}
export function TabList({ children, className }: TabListProps) {
export function TabList ({ children, className }: TabListProps) {
return (
<div className={clsx('flex items-center gap-1', className)}>{children}</div>
)
);
}
export interface TabProps extends React.ButtonHTMLAttributes<HTMLDivElement> {
@@ -46,17 +46,17 @@ export interface TabProps extends React.ButtonHTMLAttributes<HTMLDivElement> {
export const Tab = forwardRef<HTMLDivElement, TabProps>(
({ className, isSelected, value, ...props }, ref) => {
const { onChange } = useContext(TabsContext)
const { onChange } = useContext(TabsContext);
const handleClick = (e: React.MouseEvent<HTMLDivElement>) => {
onChange(value)
props.onClick?.(e)
}
onChange(value);
props.onClick?.(e);
};
return (
<div
ref={ref}
role="tab"
role='tab'
aria-selected={isSelected}
onClick={handleClick}
className={clsx(
@@ -68,11 +68,11 @@ export const Tab = forwardRef<HTMLDivElement, TabProps>(
)}
{...props}
/>
)
);
}
)
);
Tab.displayName = 'Tab'
Tab.displayName = 'Tab';
export interface TabPanelProps {
value: string
@@ -80,10 +80,10 @@ export interface TabPanelProps {
className?: string
}
export function TabPanel({ value, children, className }: TabPanelProps) {
const { activeKey } = useContext(TabsContext)
export function TabPanel ({ value, children, className }: TabPanelProps) {
const { activeKey } = useContext(TabsContext);
if (value !== activeKey) return null
if (value !== activeKey) return null;
return <div className={clsx('flex-1', className)}>{children}</div>
return <div className={clsx('flex-1', className)}>{children}</div>;
}