Skip to content

Commit

Permalink
fix components lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
talentlessguy committed Aug 7, 2024
1 parent 518a42e commit 20f200d
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 37 deletions.
1 change: 0 additions & 1 deletion components/src/components/atoms/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,6 @@ export const Button = React.forwardRef(
type={type}
// position={zIndex && 'relative'}
zIndex={zIndex}
// eslint-disable-next-line react/jsx-sort-props
onClick={onClick}
{...removeNullishProps(props)}
>
Expand Down
19 changes: 8 additions & 11 deletions components/src/components/atoms/FileInput/FileInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@ export const FileInput = React.forwardRef(
// Disallow file larger than max
if (maxSize && file.size > maxSize * 1_000_000) {
event?.preventDefault()
onError
&& onError(
if (onError)
onError(
`File is ${(file.size / 1_000_000).toFixed(
2,
)} MB. Must be smaller than ${maxSize} MB`,
)
)
return
}
setState(x => ({
Expand All @@ -109,7 +109,7 @@ export const FileInput = React.forwardRef(
name: file.name,
type: file.type,
}))
onChange && onChange(file)
if (onChange) onChange(file)
},
[maxSize, onChange, onError],
)
Expand Down Expand Up @@ -164,34 +164,32 @@ export const FileInput = React.forwardRef(
const handleFocus = React.useCallback(
(event: React.FocusEvent<HTMLInputElement>) => {
setState(x => ({ ...x, focused: true }))
onFocus && onFocus(event)
if (onFocus) onFocus(event)
},
[onFocus],
)

const handleBlur = React.useCallback(
(event: React.FocusEvent<HTMLInputElement>) => {
setState(x => ({ ...x, focused: false }))
onBlur && onBlur(event)
if (onBlur) onBlur(event)
},
[onBlur],
)

/* eslint-disable react-hooks/exhaustive-deps */
const reset = React.useCallback(
(event: React.MouseEvent<HTMLInputElement>) => {
event.preventDefault()
setState(initialState)
if (inputRef.current) inputRef.current.value = ''
onReset && onReset()
if (onReset) onReset()
},
// No need to add defaultValue
[inputRef, onReset],
)
/* eslint-enable react-hooks/exhaustive-deps */

// Display preview for default value
/* eslint-disable react-hooks/exhaustive-deps */

React.useEffect(() => {
if (!defaultValue) return
setState({
Expand All @@ -200,7 +198,6 @@ export const FileInput = React.forwardRef(
type: defaultValue.type,
})
}, [])
/* eslint-enable react-hooks/exhaustive-deps */

// Create URL for displaying media preview
React.useEffect(() => {
Expand Down
1 change: 1 addition & 0 deletions components/src/components/atoms/RecordItem/RecordItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ export const RecordItem = React.forwardRef<
children,
...props
},
// eslint-disable-next-line @typescript-eslint/no-unused-vars
ref,
) => {
const { copy, copied } = useCopied()
Expand Down
1 change: 1 addition & 0 deletions components/src/components/atoms/ScrollBox/ScrollBox.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unused-expressions */
import * as React from 'react'

import { commonVars } from '@/src/css/theme.css'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export const CountdownCircle = React.forwardRef(
const currentSeconds = calculateCurrentCount()
if (currentSeconds === 0) {
clearInterval(countInterval)
callback && callback()
if (callback) callback()
}
setCurrentCount(currentSeconds)
}, 1000)
Expand Down
3 changes: 3 additions & 0 deletions components/src/components/molecules/Dropdown/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,9 @@ const DropdownMenu = React.forwardRef<HTMLDivElement, DropdownMenuProps>(
direction,
state,
height,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
placement: _placement,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
mobilePlacement: _mobilePlacement,
...props
},
Expand Down Expand Up @@ -477,6 +479,7 @@ const useClickOutside = (
export const Dropdown = ({
children,
buttonProps,
// eslint-disable-next-line @eslint-react/no-unstable-default-props
items = [],
chevron = true,
align = 'left',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ describe('<PageButtons />', () => {

it('should render', () => {
render(
<ButtonsHelper current={1} mockCallback={_ => void 0} total={100} />,
<ButtonsHelper current={1} mockCallback={() => void 0} total={100} />,
)
expect(screen.getByTestId('pagebuttons')).toBeInTheDocument()
})

it('should show correct default max buttons', () => {
render(
<ButtonsHelper current={1} mockCallback={_ => void 0} total={100} />,
<ButtonsHelper current={1} mockCallback={() => void 0} total={100} />,
)
expect(screen.getAllByTestId('pagebutton').length).toBe(5)
})
Expand All @@ -41,7 +41,7 @@ describe('<PageButtons />', () => {
<ButtonsHelper
current={1}
max={10}
mockCallback={_ => void 0}
mockCallback={() => void 0}
total={100}
/>,
)
Expand All @@ -53,7 +53,7 @@ describe('<PageButtons />', () => {
alwaysShowFirst
alwaysShowLast
current={50}
mockCallback={_ => void 0}
mockCallback={() => void 0}
total={100}
/>,
)
Expand All @@ -62,7 +62,7 @@ describe('<PageButtons />', () => {
})
it('should not show first and last buttons if specified', () => {
render(
<ButtonsHelper current={50} mockCallback={_ => void 0} total={100} />,
<ButtonsHelper current={50} mockCallback={() => void 0} total={100} />,
)
expect(screen.queryByText('1')).not.toBeInTheDocument()
expect(screen.queryByText('100')).not.toBeInTheDocument()
Expand All @@ -73,21 +73,21 @@ describe('<PageButtons />', () => {
alwaysShowFirst
alwaysShowLast
current={50}
mockCallback={_ => void 0}
mockCallback={() => void 0}
total={100}
/>,
)
expect(screen.getAllByTestId('pagebutton-dots').length).toBe(2)
})
it('should show dots if alwaysShowFirst/alwaysShowLast is not specified', () => {
render(
<ButtonsHelper current={50} mockCallback={_ => void 0} total={100} />,
<ButtonsHelper current={50} mockCallback={() => void 0} total={100} />,
)
expect(screen.getAllByTestId('pagebutton-dots').length).toBe(2)
})
it('should not show buttons past the total page count', () => {
render(
<ButtonsHelper current={100} mockCallback={_ => void 0} total={100} />,
<ButtonsHelper current={100} mockCallback={() => void 0} total={100} />,
)
expect(screen.getByText('100')).toBeInTheDocument()
expect(screen.queryByText('101')).not.toBeInTheDocument()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ export const RadioButtonGroup = React.forwardRef(
const [value, setValue] = React.useState(_value)
React.useEffect(() => {
if (_value && _value != value) setValue(_value)

}, [_value])

const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
Expand Down
2 changes: 1 addition & 1 deletion components/src/components/molecules/Select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ export const Select = React.forwardRef(

const selectHighlightedIndex = (event: any) => {
const option = visibleOptions[highlightedIndex]
option && changeSelectedOption(option, event)
if (option) changeSelectedOption(option, event)
handleReset()
}

Expand Down
11 changes: 5 additions & 6 deletions components/src/tokens/color.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,11 @@ type NameColor = { [key in NamedShade]: string }
type ColorItem<
TObject extends Record<string, string>,
TName extends string,
> = TObject extends object
? {
[key in Exclude<keyof TObject, symbol> as `${TName}${key}`]: string
} & {
[T in `${TName}`]: string
}
> = TObject extends object ? {
[key in Exclude<keyof TObject, symbol> as `${TName}${key}`]: string
} & {
[T in `${TName}`]: string
}
: never
type CalculatedColors = WithRaw<ColorItem<NameColor, Hue | 'accent'>>
type AllColors = WithRaw<CalculatedColors & GeneratedCategories>
Expand Down
11 changes: 5 additions & 6 deletions components/src/tokens/colors2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,11 @@ type NameColor = { [key in NamedShade]: string }
type ColorItem<
TObject extends Record<string, string>,
TName extends string,
> = TObject extends object
? {
[key in Exclude<keyof TObject, symbol> as `${TName}${key}`]: string
} & {
[T in `${TName}`]: string
}
> = TObject extends object ? {
[key in Exclude<keyof TObject, symbol> as `${TName}${key}`]: string
} & {
[T in `${TName}`]: string
}
: never
type CalculatedColors = WithRaw<ColorItem<NameColor, Hue | 'accent'>>
type AllColors = WithRaw<CalculatedColors & GeneratedCategories>
Expand Down
4 changes: 2 additions & 2 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const baseConfig = tseslint.config(
},
},
{
ignores: ['docs/node_modules', 'docs/dist', 'docs/.next', '**/*.cjs', '**/*.js'],
ignores: ['docs/node_modules', 'docs/.next', '**/*.cjs', '**/*.js', '*/dist'],
},
eslint.configs.recommended,
...tseslint.configs.recommended,
Expand All @@ -36,7 +36,7 @@ const baseConfig = tseslint.config(
rules: {
'@eslint-react/dom/no-missing-button-type': 'off',
'stylistic/no-multiple-empty-lines': ['error', { max: 1 }],
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-explicit-any': 'off',
},
},
{
Expand Down

0 comments on commit 20f200d

Please sign in to comment.