Skip to content

Commit

Permalink
style: eslint autofix
Browse files Browse the repository at this point in the history
  • Loading branch information
HeartSquared committed Dec 2, 2024
1 parent b560a40 commit 9fa01bb
Show file tree
Hide file tree
Showing 109 changed files with 173 additions and 191 deletions.
2 changes: 1 addition & 1 deletion docs/components/DocsContainer/DefaultDocsContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useContext } from 'react'
// eslint-disable-next-line import/no-extraneous-dependencies

import { DocsContainer, DocsContainerProps, DocsContext } from '@storybook/blocks'
import { BackToTop } from './BackToTop'
import { Content, Main, DocsWrapper } from './Layout'
Expand Down
2 changes: 1 addition & 1 deletion docs/components/DosAndDonts/DosAndDonts.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { HTMLAttributes } from 'react'
// eslint-disable-next-line import/no-extraneous-dependencies

import { Canvas, Unstyled } from '@storybook/blocks'
import classnames from 'classnames'
import { Text } from '~components/Text'
Expand Down
2 changes: 1 addition & 1 deletion docs/components/Installation/Installation.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
// eslint-disable-next-line import/no-extraneous-dependencies

import { Source } from '@storybook/blocks'

export type InstallationProps = {
Expand Down
2 changes: 1 addition & 1 deletion docs/components/LinkTo/LinkTo.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { HTMLAttributes } from 'react'
// eslint-disable-next-line import/no-extraneous-dependencies

import { linkTo } from '@storybook/addon-links'
import classnames from 'classnames'

Expand Down
2 changes: 1 addition & 1 deletion docs/components/NoClipCanvas/NoClipCanvas.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useId, useState } from 'react'
// eslint-disable-next-line import/no-extraneous-dependencies

import { Source, SourceProps, Story, Unstyled } from '@storybook/blocks'
import classnames from 'classnames'
import styles from './NoClipCanvas.module.scss'
Expand Down
2 changes: 1 addition & 1 deletion docs/components/ResourceLinks/ResourceLinks.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { HTMLAttributes } from 'react'
// eslint-disable-next-line import/no-extraneous-dependencies

import { Unstyled } from '@storybook/blocks'
import classNames from 'classnames'
import { Text } from '~components/Text'
Expand Down
2 changes: 1 addition & 1 deletion docs/components/SbContent/SbContent.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { HTMLAttributes } from 'react'
// eslint-disable-next-line import/no-extraneous-dependencies

import { Unstyled } from '@storybook/blocks'
import classNames from 'classnames'
import styles from './SbContent.module.scss'
Expand Down
2 changes: 1 addition & 1 deletion docs/components/StickerSheet/StickerSheet.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { HTMLAttributes } from 'react'
// eslint-disable-next-line import/no-extraneous-dependencies

import isChromatic from 'chromatic'
import classnames from 'classnames'
import { Heading } from '~components/Heading'
Expand Down
1 change: 0 additions & 1 deletion docs/components/StickerSheet/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import { StoryObj } from '@storybook/react'

export type StickerSheetArgs<T extends Record<string, any>> = {
Expand Down
4 changes: 2 additions & 2 deletions packages/components/codemods/upgradeIconV1/transformIcon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const transformIcon = (
name: string,
isFilled?: boolean,
): ts.Node => {
const styles: Map<string, ts.JsxAttributeValue> = new Map()
const styles = new Map<string, ts.JsxAttributeValue>()

const newAttributes = node.attributes.properties.reduce<ts.JsxAttributeLike[]>((acc, attr) => {
if (ts.isJsxAttribute(attr)) {
Expand All @@ -79,7 +79,7 @@ export const transformIcon = (

if (propsToStyleMap.has(propName)) {
if (attr.initializer) {
styles.set(propsToStyleMap.get(propName) as string, attr.initializer)
styles.set(propsToStyleMap.get(propName)!, attr.initializer)
}
return acc
}
Expand Down
4 changes: 2 additions & 2 deletions packages/components/codemods/upgradeIconV1/upgradeIconV1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const upgradeIconV1 =

if (kaioComponentName === 'CaMonogramIcon') {
setImportToRemove(importsToRemove, oldImportSource, kaioComponentName)
const alias = componentToAliasMap.get('Brand') as string
const alias = componentToAliasMap.get('Brand')!

if (!kaioTagNames.has(alias)) {
setImportToAdd(importsToAdd, '@kaizen/components', {
Expand All @@ -52,7 +52,7 @@ export const upgradeIconV1 =

if (kaioComponentName === 'SpinnerIcon') {
setImportToRemove(importsToRemove, oldImportSource, kaioComponentName)
const alias = componentToAliasMap.get('LoadingSpinner') as string
const alias = componentToAliasMap.get('LoadingSpinner')!

if (!kaioTagNames.has(alias)) {
setImportToAdd(importsToAdd, '@kaizen/components', {
Expand Down
12 changes: 6 additions & 6 deletions packages/components/codemods/utils/getPropValueText.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,42 +17,42 @@ export const getJsxAttributeValue = (node: ts.Node): ts.JsxAttributeValue | unde
describe('getPropValueText', () => {
it('will return the text value of a string literal', () => {
const pancakeAst = parseJsx('<Pancake topping="jam" />')
const mockAttribute = getJsxAttributeValue(pancakeAst) as ts.JsxAttributeValue
const mockAttribute = getJsxAttributeValue(pancakeAst)!

expect(getPropValueText(mockAttribute)).toEqual('jam')
})

it('will return the text value of a expression with double quotes', () => {
const pancakeAst = parseJsx('<Pancake topping={"jam"} />')
const mockAttribute = getJsxAttributeValue(pancakeAst) as ts.JsxAttributeValue
const mockAttribute = getJsxAttributeValue(pancakeAst)!

expect(getPropValueText(mockAttribute)).toEqual('jam')
})

it('will return the text value of a expression with single quotes', () => {
const pancakeAst = parseJsx("<Pancake topping={'jam'} />")
const mockAttribute = getJsxAttributeValue(pancakeAst) as ts.JsxAttributeValue
const mockAttribute = getJsxAttributeValue(pancakeAst)!

expect(getPropValueText(mockAttribute)).toEqual('jam')
})

it('will return the text value of a expression with backticks', () => {
const pancakeAst = parseJsx('<Pancake topping={`jam`} />')
const mockAttribute = getJsxAttributeValue(pancakeAst) as ts.JsxAttributeValue
const mockAttribute = getJsxAttributeValue(pancakeAst)!

expect(getPropValueText(mockAttribute)).toEqual('jam')
})

it('will return undefined if a JSX element is used as a value', () => {
const pancakeAst = parseJsx('<Pancake topping={<Cheese />} />')
const mockAttribute = getJsxAttributeValue(pancakeAst) as ts.JsxAttributeValue
const mockAttribute = getJsxAttributeValue(pancakeAst)!

expect(getPropValueText(mockAttribute)).toBeUndefined()
})

it('will return undefined if a boolean value', () => {
const pancakeAst = parseJsx('<Pancake topping={false} />')
const mockAttribute = getJsxAttributeValue(pancakeAst) as ts.JsxAttributeValue
const mockAttribute = getJsxAttributeValue(pancakeAst)!

expect(getPropValueText(mockAttribute)).toBeUndefined()
})
Expand Down
2 changes: 1 addition & 1 deletion packages/components/codemods/utils/getPropValueText.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const getPropValueText = (propValue: ts.JsxAttributeValue): string | unde
if (expression) {
const expressionText = expression.getText()

if (expressionText.match(/^['"`]/)) {
if (/^['"`]/.exec(expressionText)) {
return expressionText.replace(/^['"`]|['"`]$/g, '')
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/components/codemods/utils/transformSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { printAst } from './printAst'

export type TransformSourceArgs = {
sourceFile: ts.SourceFile
transformers: Array<ts.TransformerFactory<ts.SourceFile>>
transformers: ts.TransformerFactory<ts.SourceFile>[]
}

export const transformSource = ({ sourceFile, transformers }: TransformSourceArgs): string => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const PROPS_COMPANY: CompanyAvatarProps = {
isCompany: true,
}

const ROWS: Array<{ title: string; size: AvatarSizes }> = [
const ROWS: { title: string; size: AvatarSizes }[] = [
{ title: 'XX-Large', size: 'xxlarge' },
{ title: 'X-Large', size: 'xlarge' },
{ title: 'Large', size: 'large' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default {
},
} satisfies Meta

const ROWS: Array<{ title: string; size: AvatarGroupSize }> = [
const ROWS: { title: string; size: AvatarGroupSize }[] = [
{ title: 'Large', size: 'large' },
{ title: 'Medium', size: 'medium' },
{ title: 'Small', size: 'small' },
Expand Down
3 changes: 1 addition & 2 deletions packages/components/src/Badge/_docs/Badge.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react'
import { Meta, StoryObj } from '@storybook/react'
import { BadgeAnimated } from '~components/Badge'
import { Badge } from '../index'
import { BadgeAnimated, Badge } from '~components/Badge'

const meta = {
title: 'Components/Badge',
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/ButtonGroup/ButtonGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const isFilterButton = (node: React.ReactNode): node is React.ReactElement<Filte
export type ButtonGroupProps = {
children:
| React.ReactElement<FilterButtonBaseProps | TooltipProps>
| Array<React.ReactElement<FilterButtonBaseProps | TooltipProps>>
| React.ReactElement<FilterButtonBaseProps | TooltipProps>[]
} & Omit<OverrideClassName<HTMLAttributes<HTMLDivElement>>, 'children'>

export const ButtonGroup = ({
Expand Down
4 changes: 2 additions & 2 deletions packages/components/src/Calendar/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const DayOfWeek = {
} as const

// Intentionally naming the type the same as the const for tree-shaking
// eslint-disable-next-line @typescript-eslint/no-redeclare

export type DayOfWeek = (typeof DayOfWeek)[keyof typeof DayOfWeek]

export const DateFormat = {
Expand All @@ -18,5 +18,5 @@ export const DateFormat = {
} as const

// Intentionally naming the type the same as the const for tree-shaking
// eslint-disable-next-line @typescript-eslint/no-redeclare

export type DateFormat = (typeof DateFormat)[keyof typeof DateFormat]
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const colors = [
'red',
'white',
'yellow',
] satisfies Array<CardProps['color']>
] satisfies CardProps['color'][]

const variants = [
'default',
Expand All @@ -33,7 +33,7 @@ const variants = [
'destructive',
'assertive',
'highlight',
] satisfies Array<CardProps['variant']>
] satisfies CardProps['variant'][]

const StickerSheetTemplate: StickerSheetStory = {
render: ({ isReversed, ...args }) => (
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/Card/_docs/Card.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const colors = [
'red',
'white',
'yellow',
] satisfies Array<CardProps['color']>
] satisfies CardProps['color'][]

export const Colors: Story = {
render: () => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ const StickerSheetTemplate: StickerSheetStory = {
{ title: 'Off', checkedStatus: 'off' },
{ title: 'On', checkedStatus: 'on' },
{ title: 'Mixed', checkedStatus: 'mixed' },
] satisfies Array<{
] satisfies {
title: string
checkedStatus: CheckboxProps['checkedStatus']
}>
}[]

return (
<StickerSheet isReversed={isReversed} headers={['Default', 'Hover', 'Focus', 'Disabled']}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ const StickerSheetTemplate: StickerSheetStory = {
{ title: 'Off', checkedStatus: 'off' },
{ title: 'On', checkedStatus: 'on' },
{ title: 'Mixed', checkedStatus: 'mixed' },
] satisfies Array<{
] satisfies {
title: string
checkedStatus: CheckboxFieldProps['checkedStatus']
}>
}[]

return (
<StickerSheet isReversed={isReversed} headers={['Default', 'Hover', 'Focus', 'Disabled']}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,17 @@ export const Playground: Story = {
<CheckboxGroup {...args}>
<CheckboxField
labelText="Checkbox one"
checkedStatus={checkedStatus['one']}
checkedStatus={checkedStatus.one}
onCheck={onCheckHandler('one')}
/>
<CheckboxField
labelText="Checkbox two"
checkedStatus={checkedStatus['two']}
checkedStatus={checkedStatus.two}
onCheck={onCheckHandler('two')}
/>
<CheckboxField
labelText="Checkbox three"
checkedStatus={checkedStatus['three']}
checkedStatus={checkedStatus.three}
onCheck={onCheckHandler('three')}
/>
</CheckboxGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { OverrideClassName } from '~components/types/OverrideClassName'
import styles from './CollapsibleGroup.module.scss'

export type CollapsibleGroupProps = {
children: Array<React.ReactElement<CollapsibleProps>>
children: React.ReactElement<CollapsibleProps>[]
separated?: boolean
sticky?: Sticky
noSectionPadding?: boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,20 @@ const StickerSheetTemplate: StickerSheetStory = {
'If providing further actions, include a link to an action or use a Default or Primary action.',
} satisfies EmptyStateProps

const variants = ['success', 'warning', 'informative', 'expert-advice'] satisfies Array<
EmptyStateProps['variant']
>
const variants = [
'success',
'warning',
'informative',
'expert-advice',
] satisfies EmptyStateProps['variant'][]

const illustrationTypes = [
'positive',
'neutral',
'negative',
'informative',
'action',
] satisfies Array<EmptyStateProps['illustrationType']>
] satisfies EmptyStateProps['illustrationType'][]

return (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ describe('<FilterBar />', () => {

describe('Context use cases', () => {
describe('getActiveFilterValues()', () => {
type Items = Array<{ value: string; label: string }>
type Items = { value: string; label: string }[]

type AsyncValues = {
city: string[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ import {
QueryParamConfig,
decodeQueryParams,
} from 'serialize-query-params'
import { DateRange, ItemType, SelectOption } from '~components/index'
import { FilterMultiSelect } from '../../../index'
import { DateRange, ItemType, SelectOption, FilterMultiSelect } from '~components/index'
import { FilterBar, Filters, useFilterBarContext } from '../index'
import { FilterBarMultiSelectProps } from '../subcomponents'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export type FilterBarContextValue<
updateValue: <Id extends keyof ValuesMap>(id: Id, value: ValuesMap[Id]) => void
showFilter: <Id extends keyof ValuesMap>(id: Id) => void
hideFilter: <Id extends keyof ValuesMap>(id: Id) => void
getInactiveFilters: () => Array<FilterAttributes<ValuesMap>>
getInactiveFilters: () => FilterAttributes<ValuesMap>[]
clearAllFilters: () => void
setFocus: <Id extends keyof ValuesMap>(id: Id | undefined) => void
focusId?: keyof ValuesMap
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/Filter/FilterBar/context/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ export type FilterBarState<ValuesMap extends FiltersValues> = {
focusId?: keyof ValuesMap
}

export type ActiveFiltersArray<ValuesMap extends FiltersValues> = Array<FilterAttributes<ValuesMap>>
export type ActiveFiltersArray<ValuesMap extends FiltersValues> = FilterAttributes<ValuesMap>[]
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('getInactiveFilters()', () => {
it('fetches only usable inactive filters', () => {
const state = {
filters: {
flavour: stateFilters['flavour'],
flavour: stateFilters.flavour,
sugarLevel: {
id: 'sugarLevel',
name: 'Sugar Level',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ import { FilterBarState } from '../types'
export const getInactiveFilters = <ValuesMap extends FiltersValues>({
filters,
activeFilterIds,
}: FilterBarState<ValuesMap>): Array<FilterAttributes<ValuesMap>> =>
}: FilterBarState<ValuesMap>): FilterAttributes<ValuesMap>[] =>
Object.values(filters).filter(({ id, isUsable }) => isUsable && !activeFilterIds.has(id))
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const FilterBarSelect = <Option extends SelectOption = SelectOption>({
const { getFilterState, setFilterOpenState, updateValue } = useFilterBarContext<
Option['value'] | undefined
>()
const [items, setItems] = useState<Array<SelectItem<Option>>>(propsItems)
const [items, setItems] = useState<SelectItem<Option>[]>(propsItems)

if (!id) throw Error('Missing `id` prop in FilterBarSelect')

Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/Filter/FilterBar/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export type FilterAttributes<ValuesMap extends FiltersValues, Id = keyof ValuesM
isUsableWhen?: FilterIsUsableWhen<ValuesMap>
}

export type Filters<ValuesMap extends FiltersValues> = Array<FilterAttributes<ValuesMap>>
export type Filters<ValuesMap extends FiltersValues> = FilterAttributes<ValuesMap>[]

export type FilterState<Id, Value> = {
id: Id
Expand Down
Loading

0 comments on commit 9fa01bb

Please sign in to comment.