perf: eslint

mack-mac
mackt 7 months ago
parent 129b7ac7c7
commit 5846c05e08

@ -1,53 +1,58 @@
{
"extends": [
"next/core-web-vitals",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended",
"eslint-config-prettier"
],
"plugins": ["prettier"],
"rules": {
"@typescript-eslint/no-explicit-any": ["off"], // 使any
"@typescript-eslint/ban-ts-comment": "off", // 使@ts-ignore
"@typescript-eslint/no-non-null-assertion": "off", // 使
"@typescript-eslint/no-var-requires": "off", // 使CommonJS
"no-console": ["warn", { "allow": ["warn", "error"] }], // console.log
"no-debugger": "warn",
"import/order": [
"error",
{
"groups": ["builtin", "external", "parent", "sibling", "index", "internal", "object", "type"], //
//
"pathGroups": [
{
"pattern": "react*",
"group": "builtin",
"position": "before"
},
{
"pattern": "@/components/**",
"group": "parent",
"position": "before"
},
{
"pattern": "@/utils/**",
"group": "parent",
"position": "after"
},
{
"pattern": "@/apis/**",
"group": "parent",
"position": "after"
}
],
"pathGroupsExcludedImportTypes": ["react"],
"newlines-between": "always", //
//
"alphabetize": {
"order": "asc",
"caseInsensitive": true
}
}
]
}
}
{
"extends": [
"next/core-web-vitals",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended",
"eslint-config-prettier"
],
"plugins": ["prettier"],
"rules": {
"@typescript-eslint/no-explicit-any": ["off"], // 使any
"@typescript-eslint/ban-ts-comment": "off", // 使@ts-ignore
"@typescript-eslint/no-non-null-assertion": "off", // 使
"@typescript-eslint/no-var-requires": "off", // 使CommonJS
"no-console": ["warn", { "allow": ["warn", "error"] }], // console.log
"no-debugger": "warn",
"import/order": [
"error",
{
"groups": ["builtin", "external", "parent", "sibling", "index", "internal", "object", "type"], //
//
"pathGroups": [
{
"pattern": "@/components/ui/**", //
"group": "internal", //
"position": "after"
},
{
"pattern": "react*",
"group": "builtin",
"position": "before"
},
{
"pattern": "@/components/**",
"group": "parent",
"position": "before"
},
{
"pattern": "@/utils/**",
"group": "parent",
"position": "after"
},
{
"pattern": "@/apis/**",
"group": "parent",
"position": "after"
}
],
"pathGroupsExcludedImportTypes": ["react"],
"newlines-between": "always", //
//
"alphabetize": {
"order": "asc",
"caseInsensitive": true
}
}
]
}
}

@ -18,7 +18,7 @@ export default function AudioPlayer({
className?: string;
onSwitchShowCard: () => void;
}) {
const { audioId, order, playQueue, showCard, switchSongByDiff, setOrder, setShowCard } = useAudioStore(
const { audioId, order, playQueue, showCard, switchSongByDiff, setOrder } = useAudioStore(
useShallow((state) => {
return {
audioId: state.audioId,
@ -27,7 +27,6 @@ export default function AudioPlayer({
showCard: state.showCard,
setOrder: state.setOrder,
switchSongByDiff: state.switchSongByDiff,
setShowCard: state.setShowCard,
};
}),
);

@ -1,5 +1,5 @@
'use client';
import { useEffect, useState } from 'react';
import { useEffect } from 'react';
import dynamic from 'next/dynamic';
import { useShallow } from 'zustand/react/shallow';
@ -10,17 +10,13 @@ import PlayerCard from './PlayerCard';
import useAudioStore from '@/store/audio';
const PlayerBar = ({ className }: { className?: string }) => {
const { show, audioId, order, playQueue, showCard, setShow, setOrder, setShowCard } = useAudioStore(
const { show, audioId, showCard, setShow, setShowCard } = useAudioStore(
useShallow((state) => {
return {
show: state.show,
audioId: state.audioId,
order: state.order,
playQueue: state.playQueue,
showCard: state.showCard,
setShow: state.setShow,
setOrder: state.setOrder,
switchSongByDiff: state.switchSongByDiff,
setShowCard: state.setShowCard,
};
}),

@ -2,13 +2,13 @@
import { useShallow } from 'zustand/react/shallow';
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
import { HoverCard, HoverCardPortal, HoverCardContent, HoverCardTrigger } from '@/components/ui/hover-card';
import UserCard from './UserCard';
import useUserStore from '@/store/user';
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
import { HoverCard, HoverCardPortal, HoverCardContent, HoverCardTrigger } from '@/components/ui/hover-card';
export default function HeaderAvatar({ className }: { className?: string }) {
const { userInfo } = useUserStore(
useShallow((state) => ({

@ -6,9 +6,10 @@ import { useShallow } from 'zustand/react/shallow';
import logout from '@/utils/logout';
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
import useUserStore from '@/store/user';
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
interface Props {
className?: string;
}

@ -17,9 +17,7 @@ interface Props {
export default function JournalItem({ listId, songList, className }: Props) {
const { setPlayList, setAudioId, playListId } = useAudioStore(
useShallow((state) => ({
setplayList: state.setPlayList,
setAudioId: state.setAudioId,
playList: state.playList,
setPlayList: state.setPlayList,
playListId: state.playListId,
})),

@ -2,7 +2,7 @@ import * as React from 'react';
import * as AvatarPrimitive from '@radix-ui/react-avatar';
import { cn } from '/src/lib/utils';
import { cn } from '@/lib/utils';
const Avatar = React.forwardRef<
React.ElementRef<typeof AvatarPrimitive.Root>,

@ -1,48 +0,0 @@
import * as React from 'react';
import { Slot } from '@radix-ui/react-slot';
import { cva, type VariantProps } from 'class-variance-authority';
import { cn } from '/src/lib/utils';
const buttonVariants = cva(
'inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50',
{
variants: {
variant: {
default: 'bg-primary text-primary-foreground hover:bg-primary/90',
destructive: 'bg-destructive text-destructive-foreground hover:bg-destructive/90',
outline: 'border border-input bg-background hover:bg-accent hover:text-accent-foreground',
secondary: 'bg-secondary text-secondary-foreground hover:bg-secondary/80',
ghost: 'hover:bg-accent hover:text-accent-foreground',
link: 'text-primary underline-offset-4 hover:underline',
},
size: {
default: 'h-10 px-4 py-2',
sm: 'h-9 rounded-md px-3',
lg: 'h-11 rounded-md px-8',
icon: 'h-10 w-10',
},
},
defaultVariants: {
variant: 'default',
size: 'default',
},
},
);
export interface ButtonProps
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
VariantProps<typeof buttonVariants> {
asChild?: boolean;
}
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
({ className, variant, size, asChild = false, ...props }, ref) => {
const Comp = asChild ? Slot : 'button';
return <Comp className={cn(buttonVariants({ variant, size, className }))} ref={ref} {...props} />;
},
);
Button.displayName = 'Button';
export { Button, buttonVariants };

@ -2,7 +2,7 @@ import * as React from 'react';
import * as HoverCardPrimitive from '@radix-ui/react-hover-card';
import { cn } from '/src/lib/utils';
import { cn } from '@/lib/utils';
const HoverCard = HoverCardPrimitive.Root;

@ -16,7 +16,6 @@ interface AuioState {
showCard: boolean;
/** 当前音频id */
audioId: string;
audioInfo: SongInfo | null;
/** 歌单列表 */
playList: SongInfo[];
/** 播放队列 */
@ -104,7 +103,6 @@ const useAuioState = create<AuioState>()(
playListId: '',
playList: [],
playQueue: [],
audioInfo: get()?.playList.length ? get().playList.find((item) => item.id === get().audioId) : null,
setAudioId,
setOrder,
setShow: (value) =>

Loading…
Cancel
Save