Skip to content

Commit

Permalink
ci(eslint): resolve outstanding eslint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
tulup-conner committed Feb 20, 2023
1 parent da60e4c commit f3d3a55
Show file tree
Hide file tree
Showing 92 changed files with 298 additions and 235 deletions.
6 changes: 4 additions & 2 deletions src/docs/pages/TabsPage.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { FC, useRef, useState } from 'react';
import type { FC} from 'react';
import { useRef, useState } from 'react';
import { HiAdjustments, HiClipboardList, HiUserCircle } from 'react-icons/hi';
import { MdDashboard } from 'react-icons/md';
import { Button, Tabs, TabsRef } from '../../lib';
import type { TabsRef } from '../../lib';
import { Button, Tabs } from '../../lib';
import type { CodeExample } from './DemoPage';
import { DemoPage } from './DemoPage';

Expand Down
4 changes: 3 additions & 1 deletion src/lib/components/Accordion/Accordion.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { render, screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { FC } from 'react';
import type { FC } from 'react';
import { HiOutlineArrowCircleDown } from 'react-icons/hi';
import { describe, expect, it } from 'vitest';
import { Flowbite } from '../Flowbite';
Expand Down Expand Up @@ -48,6 +48,7 @@ describe('Components / Accordion', () => {
const user = userEvent.setup();
render(<TestAccordion />);

// eslint-disable-next-line @typescript-eslint/no-unused-vars
for (const _ of titles()) {
await user.tab();
}
Expand All @@ -61,6 +62,7 @@ describe('Components / Accordion', () => {
const user = userEvent.setup();
render(<TestAccordion alwaysOpen />);

// eslint-disable-next-line @typescript-eslint/no-unused-vars
for (const _ of titles()) {
await user.tab();
}
Expand Down
10 changes: 6 additions & 4 deletions src/lib/components/Accordion/Accordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ import classNames from 'classnames';
import type { ComponentProps, FC, PropsWithChildren, ReactElement } from 'react';
import { Children, cloneElement, useMemo, useState } from 'react';
import { HiChevronDown } from 'react-icons/hi';
import { DeepPartial } from '..';
import type { DeepPartial } from '..';
import { mergeDeep } from '../../helpers/mergeDeep';
import { FlowbiteBoolean } from '../Flowbite/FlowbiteTheme';
import type { FlowbiteBoolean } from '../Flowbite/FlowbiteTheme';
import { useTheme } from '../Flowbite/ThemeContext';
import { AccordionContent, FlowbiteAccordionComponentTheme } from './AccordionContent';
import type { FlowbiteAccordionComponentTheme } from './AccordionContent';
import { AccordionContent } from './AccordionContent';
import type { AccordionPanelProps } from './AccordionPanel';
import { AccordionPanel } from './AccordionPanel';
import { AccordionTitle, FlowbiteAccordionTitleTheme } from './AccordionTitle';
import type { FlowbiteAccordionTitleTheme } from './AccordionTitle';
import { AccordionTitle } from './AccordionTitle';

export interface FlowbiteAccordionTheme {
root: FlowbiteAccordionRootTheme;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/Accordion/AccordionContent.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import classNames from 'classnames';
import type { ComponentProps, FC, PropsWithChildren } from 'react';
import { DeepPartial } from '..';
import type { DeepPartial } from '..';
import { mergeDeep } from '../../helpers/mergeDeep';
import { useTheme } from '../Flowbite/ThemeContext';
import { useAccordionContext } from './AccordionPanelContext';
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/Accordion/AccordionTitle.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import classNames from 'classnames';
import type { ComponentProps, FC } from 'react';
import { DeepPartial } from '..';
import type { DeepPartial } from '..';
import { mergeDeep } from '../../helpers/mergeDeep';
import type { FlowbiteBoolean, FlowbiteHeadingLevel } from '../Flowbite/FlowbiteTheme';
import { useTheme } from '../Flowbite/ThemeContext';
Expand Down
6 changes: 4 additions & 2 deletions src/lib/components/Alert/Alert.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { render, screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { FC, useState } from 'react';
import type { FC} from 'react';
import { useState } from 'react';
import { HiEye, HiHeart, HiInformationCircle } from 'react-icons/hi';
import { describe, expect, it, vi } from 'vitest';
import { Flowbite } from '../Flowbite';

import { Alert, AlertProps } from './Alert';
import type { AlertProps } from './Alert';
import { Alert } from './Alert';

describe.concurrent('Components / Alert', () => {
describe.concurrent('A11y', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/Alert/Alert.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import classNames from 'classnames';
import type { ComponentProps, FC, PropsWithChildren, ReactNode } from 'react';
import { HiX } from 'react-icons/hi';
import { DeepPartial } from '..';
import type { DeepPartial } from '..';
import { mergeDeep } from '../../helpers/mergeDeep';
import type { FlowbiteColors } from '../Flowbite/FlowbiteTheme';
import { useTheme } from '../Flowbite/ThemeContext';
Expand Down
8 changes: 5 additions & 3 deletions src/lib/components/Avatar/Avatar.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import classNames from 'classnames';
import type { ComponentProps, FC, PropsWithChildren, ReactElement } from 'react';
import { DeepPartial } from '..';
import type { DeepPartial } from '..';
import { mergeDeep } from '../../helpers/mergeDeep';
import type { FlowbiteBoolean, FlowbiteColors, FlowbitePositions, FlowbiteSizes } from '../Flowbite/FlowbiteTheme';
import { useTheme } from '../Flowbite/ThemeContext';
import AvatarGroup, { FlowbiteAvatarGroupTheme } from './AvatarGroup';
import AvatarGroupCounter, { FlowbiteAvatarGroupCounterTheme } from './AvatarGroupCounter';
import type { FlowbiteAvatarGroupTheme } from './AvatarGroup';
import AvatarGroup from './AvatarGroup';
import type { FlowbiteAvatarGroupCounterTheme } from './AvatarGroupCounter';
import AvatarGroupCounter from './AvatarGroupCounter';

export interface FlowbiteAvatarTheme {
root: FlowbiteAvatarRootTheme;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/Avatar/AvatarGroup.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import classNames from 'classnames';
import type { ComponentProps, PropsWithChildren } from 'react';
import React from 'react';
import { DeepPartial } from '..';
import type { DeepPartial } from '..';
import { mergeDeep } from '../../helpers/mergeDeep';
import { useTheme } from '../Flowbite';

Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/Avatar/AvatarGroupCounter.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import classNames from 'classnames';
import type { ComponentProps, PropsWithChildren } from 'react';
import React from 'react';
import { DeepPartial } from '..';
import type { DeepPartial } from '..';
import { mergeDeep } from '../../helpers/mergeDeep';
import { useTheme } from '../Flowbite';

Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/Badge/Badge.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import classNames from 'classnames';
import type { ComponentProps, FC, PropsWithChildren } from 'react';
import { DeepPartial } from '..';
import type { DeepPartial } from '..';
import { mergeDeep } from '../../helpers/mergeDeep';
import type { FlowbiteBoolean, FlowbiteColors, FlowbiteSizes } from '../Flowbite/FlowbiteTheme';
import { useTheme } from '../Flowbite/ThemeContext';
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/Breadcrumb/Breadcrumb.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { render, screen } from '@testing-library/react';
import { FC } from 'react';
import type { FC } from 'react';
import { HiHome } from 'react-icons/hi';
import { describe, expect, it } from 'vitest';
import { Flowbite } from '../Flowbite';
Expand Down
5 changes: 3 additions & 2 deletions src/lib/components/Breadcrumb/Breadcrumb.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import classNames from 'classnames';
import type { ComponentProps, FC } from 'react';
import { DeepPartial } from '..';
import type { DeepPartial } from '..';
import { mergeDeep } from '../../helpers/mergeDeep';
import { useTheme } from '../Flowbite/ThemeContext';
import BreadcrumbItem, { FlowbiteBreadcrumbItemTheme } from './BreadcrumbItem';
import type { FlowbiteBreadcrumbItemTheme } from './BreadcrumbItem';
import BreadcrumbItem from './BreadcrumbItem';

export interface FlowbiteBreadcrumbTheme {
root: FlowbiteBreadcrumbRootTheme;
Expand Down
7 changes: 4 additions & 3 deletions src/lib/components/Breadcrumb/BreadcrumbItem.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import classNames from 'classnames';
import { ComponentProps, FC, forwardRef, PropsWithChildren } from 'react';
import type { ComponentProps, FC, PropsWithChildren } from 'react';
import { forwardRef } from 'react';
import { HiOutlineChevronRight } from 'react-icons/hi';
import { DeepPartial } from '..';
import type { DeepPartial } from '..';
import { mergeDeep } from '../../helpers/mergeDeep';
import { FlowbiteBoolean } from '../Flowbite/FlowbiteTheme';
import type { FlowbiteBoolean } from '../Flowbite/FlowbiteTheme';
import { useTheme } from '../Flowbite/ThemeContext';

export interface FlowbiteBreadcrumbItemTheme {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/Button/ButtonGroup.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import classNames from 'classnames';
import type { ComponentProps, FC, PropsWithChildren, ReactElement } from 'react';
import { Children, cloneElement, useMemo } from 'react';
import { DeepPartial } from '..';
import type { DeepPartial } from '..';
import { mergeDeep } from '../../helpers/mergeDeep';
import type { ButtonProps } from '../Button';
import { useTheme } from '../Flowbite/ThemeContext';
Expand Down
4 changes: 2 additions & 2 deletions src/lib/components/Card/Card.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import classNames from 'classnames';
import type { ComponentProps, FC, PropsWithChildren } from 'react';
import { DeepPartial } from '..';
import type { DeepPartial } from '..';
import { mergeDeep } from '../../helpers/mergeDeep';
import { FlowbiteBoolean } from '../Flowbite/FlowbiteTheme';
import type { FlowbiteBoolean } from '../Flowbite/FlowbiteTheme';
import { useTheme } from '../Flowbite/ThemeContext';

export interface FlowbiteCardTheme {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/Carousel/Carousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { HiOutlineChevronLeft, HiOutlineChevronRight } from 'react-icons/hi';
import ScrollContainer from 'react-indiana-drag-scroll';
import { mergeDeep } from '../../helpers/mergeDeep';
import windowExists from '../../helpers/window-exists';
import { FlowbiteBoolean } from '../Flowbite/FlowbiteTheme';
import type { FlowbiteBoolean } from '../Flowbite/FlowbiteTheme';
import { useTheme } from '../Flowbite/ThemeContext';

export interface FlowbiteCarouselTheme {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/Checkbox/Checkbox.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import classNames from 'classnames';
import type { ComponentProps } from 'react';
import { forwardRef } from 'react';
import { DeepPartial } from '..';
import type { DeepPartial } from '..';
import { mergeDeep } from '../../helpers/mergeDeep';
import { useTheme } from '../Flowbite/ThemeContext';

Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/DarkThemeToggle/DarkThemeToggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import classNames from 'classnames';
import type { ComponentProps, FC } from 'react';
import { useContext } from 'react';
import { HiMoon, HiSun } from 'react-icons/hi';
import { DeepPartial } from '..';
import type { DeepPartial } from '..';
import { mergeDeep } from '../../helpers/mergeDeep';
import { ThemeContext, useTheme } from '../Flowbite/ThemeContext';

Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/Dropdown/Dropdown.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { act, render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { FC } from 'react';
import type { FC } from 'react';
import { describe, expect, it } from 'vitest';
import { Dropdown } from './Dropdown';

Expand Down
55 changes: 32 additions & 23 deletions src/lib/components/Dropdown/Dropdown.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
import type { ComponentProps, FC, PropsWithChildren, ReactElement, ReactNode } from 'react';
import React, { Children, useMemo, useState } from 'react';
import React, { Children, useCallback, useMemo, useState } from 'react';
import { HiOutlineChevronDown, HiOutlineChevronLeft, HiOutlineChevronRight, HiOutlineChevronUp } from 'react-icons/hi';
import { DeepPartial } from '..';
import type { DeepPartial } from '..';
import { mergeDeep } from '../../helpers/mergeDeep';
import { uuid } from '../../helpers/uuid';
import type { ButtonProps } from '../Button';
import { Button } from '../Button';
import type { FloatingProps, FlowbiteFloatingTheme } from '../Floating';
import { Floating } from '../Floating';
import { useTheme } from '../Flowbite/ThemeContext';
import { DropdownDivider, FlowbiteDropdownDividerTheme } from './DropdownDivider';
import { DropdownHeader, FlowbiteDropdownHeaderTheme } from './DropdownHeader';
import { DropdownItem, FlowbiteDropdownItemTheme } from './DropdownItem';
import type { FlowbiteDropdownDividerTheme } from './DropdownDivider';
import { DropdownDivider } from './DropdownDivider';
import type { FlowbiteDropdownHeaderTheme } from './DropdownHeader';
import { DropdownHeader } from './DropdownHeader';
import type { FlowbiteDropdownItemTheme } from './DropdownItem';
import { DropdownItem } from './DropdownItem';

export interface FlowbiteDropdownFloatingTheme
extends FlowbiteFloatingTheme,
Expand Down Expand Up @@ -73,27 +77,32 @@ const DropdownComponent: FC<DropdownProps> = ({
const [closeRequestKey, setCloseRequestKey] = useState<string | undefined>(undefined);

// Extends DropdownItem's onClick to trigger a close request to the Floating component
const attachCloseListener: any = (node: ReactNode) => {
if (!React.isValidElement(node)) return node;
if ((node as ReactElement).type === DropdownItem)
return React.cloneElement(node, {
onClick: () => {
node.props.onClick?.();
dismissOnClick && setCloseRequestKey(uuid());
},
} as any);
if (node.props.children && typeof node.props.children === 'object') {
return React.cloneElement(node, {
// @ts-ignore
children: Children.map(node.props.children, attachCloseListener),
});
}
return node;
};
const attachCloseListener = useCallback(
// @ts-ignore TODO: Rewrite Dropdown
(node: ReactNode) => {
if (!React.isValidElement(node)) return node;
if ((node as ReactElement).type === DropdownItem)
return React.cloneElement(node, {
// @ts-ignore TODO: Rewrite Dropdown
onClick: () => {
node.props.onClick?.();
dismissOnClick && setCloseRequestKey(uuid());
},
});
if (node.props.children && typeof node.props.children === 'object') {
return React.cloneElement(node, {
// @ts-ignore TODO: Rewrite Dropdown
children: Children.map(node.props.children, attachCloseListener),
});
}
return node;
},
[dismissOnClick],
);

const content = useMemo(
() => <ul className={theme.content}>{Children.map(children, attachCloseListener)}</ul>,
[children, theme],
[attachCloseListener, children, theme.content],
);

const TriggerWrapper: FC<ButtonProps> = ({ children }): JSX.Element =>
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/Dropdown/DropdownItem.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import classNames from 'classnames';
import type { ComponentProps, FC, PropsWithChildren } from 'react';
import { DeepPartial } from '..';
import type { DeepPartial } from '..';
import { mergeDeep } from '../../helpers/mergeDeep';
import { useTheme } from '../Flowbite/ThemeContext';

Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/FileInput/FileInput.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import classNames from 'classnames';
import type { ComponentProps, ReactNode } from 'react';
import { forwardRef } from 'react';
import { DeepPartial } from '..';
import type { DeepPartial } from '..';
import { mergeDeep } from '../../helpers/mergeDeep';
import { useTheme } from '../Flowbite/ThemeContext';
import { HelperText } from '../HelperText';
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/Flowbite/Flowbite.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { afterEach, describe, expect, it } from 'vitest';
import { mergeDeep } from '../../helpers/mergeDeep';
import defaultTheme from '../../theme/default';
import { Flowbite, useTheme } from '../Flowbite';
import { ThemeContextProps } from './ThemeContext';
import type { ThemeContextProps } from './ThemeContext';

afterEach(() => {
localStorage.removeItem('theme');
Expand Down
Loading

0 comments on commit f3d3a55

Please sign in to comment.