From 9949ffce6acb4ac29246b7c67430c1c9f5204fc5 Mon Sep 17 00:00:00 2001 From: literat Date: Thu, 14 Dec 2023 10:50:42 +0100 Subject: [PATCH] Style(web-react): Fix lint errors and warnings --- packages/web-react/config/rollup.config.js | 2 +- packages/web-react/src/components/Dropdown/Dropdown.tsx | 8 ++++---- packages/web-react/src/hooks/useIsomorphicLayoutEffect.ts | 1 + packages/web-react/src/types/header.ts | 2 ++ packages/web-react/src/types/item.ts | 1 + packages/web-react/src/types/shared/element.ts | 1 + packages/web-react/src/types/tabs.ts | 1 + packages/web-react/src/utils/string.ts | 1 + 8 files changed, 12 insertions(+), 5 deletions(-) diff --git a/packages/web-react/config/rollup.config.js b/packages/web-react/config/rollup.config.js index a1a7fbc941..9b7296e97e 100644 --- a/packages/web-react/config/rollup.config.js +++ b/packages/web-react/config/rollup.config.js @@ -1,6 +1,6 @@ +import replace from '@rollup/plugin-replace'; import path from 'path'; import { terser as minify } from 'rollup-plugin-terser'; -import replace from '@rollup/plugin-replace'; const entryPoints = require('../scripts/entryPoints'); diff --git a/packages/web-react/src/components/Dropdown/Dropdown.tsx b/packages/web-react/src/components/Dropdown/Dropdown.tsx index ed8ce40266..400b6358b4 100644 --- a/packages/web-react/src/components/Dropdown/Dropdown.tsx +++ b/packages/web-react/src/components/Dropdown/Dropdown.tsx @@ -1,9 +1,12 @@ +/** + * @deprecated Dropdown component is deprecated and will be removed in the next major version. Please use "DropdownModern" component instead. + */ import classNames from 'classnames'; import React, { LegacyRef, createElement, useRef } from 'react'; import { Placements } from '../../constants'; -import DropdownWrapper from './DropdownWrapper'; import { useDeprecationMessage, useStyleProps } from '../../hooks'; import { SpiritDropdownProps } from '../../types'; +import DropdownWrapper from './DropdownWrapper'; import { useDropdown } from './useDropdown'; import { useDropdownAriaProps } from './useDropdownAriaProps'; import { useDropdownStyleProps } from './useDropdownStyleProps'; @@ -13,9 +16,6 @@ const defaultProps = { placement: Placements.BOTTOM_LEFT, }; -/** - * @deprecated Dropdown component is deprecated and will be removed in the next major version. Please use "DropdownModern" component instead. - */ export const Dropdown = (props: SpiritDropdownProps) => { const { id = Math.random().toString(36).slice(2, 7), diff --git a/packages/web-react/src/hooks/useIsomorphicLayoutEffect.ts b/packages/web-react/src/hooks/useIsomorphicLayoutEffect.ts index 2d23f9a44d..578e54e625 100644 --- a/packages/web-react/src/hooks/useIsomorphicLayoutEffect.ts +++ b/packages/web-react/src/hooks/useIsomorphicLayoutEffect.ts @@ -1,5 +1,6 @@ /** * This file fixes the problem of using useLayoutEffect hook on the server side. + * * @see https://gist.github.com/gaearon/e7d97cdf38a2907924ea12e4ebdf3c85 * @see https://medium.com/@alexandereardon/uselayouteffect-and-ssr-192986cdcf7a */ diff --git a/packages/web-react/src/types/header.ts b/packages/web-react/src/types/header.ts index a68fc98b5f..f872969b57 100644 --- a/packages/web-react/src/types/header.ts +++ b/packages/web-react/src/types/header.ts @@ -58,6 +58,7 @@ export interface BaseHeaderDialogLinkProps extends ChildrenProps, StyleProps, Tr export type HeaderDialogLinkProps = { /** * The HTML element or React element used to render the Link, e.g. 'a'. + * * @default 'a' */ elementType?: E; @@ -79,6 +80,7 @@ export interface HeaderLinkBaseProps extends ChildrenProps, StyleProps, Transfer export type HeaderLinkProps = { /** * The HTML element or React element used to render the Link, e.g. 'a'. + * * @default 'a' */ elementType?: E; diff --git a/packages/web-react/src/types/item.ts b/packages/web-react/src/types/item.ts index ae04b74ac0..9e846f8142 100644 --- a/packages/web-react/src/types/item.ts +++ b/packages/web-react/src/types/item.ts @@ -4,6 +4,7 @@ import { StyleProps, TransferProps } from './shared'; export interface AriaItemElementTypeProps { /** * The HTML element or React element used to render the item, e.g. 'div', 'span'. + * * @default 'button' */ elementType?: T | JSXElementConstructor; diff --git a/packages/web-react/src/types/shared/element.ts b/packages/web-react/src/types/shared/element.ts index 27fdf11189..70523c34a0 100644 --- a/packages/web-react/src/types/shared/element.ts +++ b/packages/web-react/src/types/shared/element.ts @@ -21,6 +21,7 @@ export type SpiritPolymorphicElementPropsWithoutRef = >; /** * Type React's forwarded ref with `PolymorphicRef` to allow generic `elementType` to be strongly typed, e.g. component allows switching of elements + * * @see https://www.freecodecamp.org/news/build-strongly-typed-polymorphic-components-with-react-and-typescript/ */ export type PolymorphicRef = React.ComponentPropsWithRef['ref']; diff --git a/packages/web-react/src/types/tabs.ts b/packages/web-react/src/types/tabs.ts index 2b617601a6..9bca2dfc7b 100644 --- a/packages/web-react/src/types/tabs.ts +++ b/packages/web-react/src/types/tabs.ts @@ -21,6 +21,7 @@ export interface TabLinkBaseProps extends ChildrenProps, StyleProps, TransferPro export type TabLinkProps = { /** * The HTML element or React element used to render the Link, e.g. 'a'. + * * @default 'a' */ elementType?: E; diff --git a/packages/web-react/src/utils/string.ts b/packages/web-react/src/utils/string.ts index f8b1f03a0b..2ff6c6f02e 100644 --- a/packages/web-react/src/utils/string.ts +++ b/packages/web-react/src/utils/string.ts @@ -1,5 +1,6 @@ /** * Converts a kebab-case string to camelCase + * * @param str */ export const kebabCaseToCamelCase = (str: string): string => str.replace(/-([a-z])/g, (g) => g[1].toUpperCase());