Skip to content

Commit

Permalink
chore: ESLint v9 (#5197)
Browse files Browse the repository at this point in the history
  • Loading branch information
s-sasaki-0529 authored Dec 24, 2024
1 parent bca802b commit b2f1541
Show file tree
Hide file tree
Showing 15 changed files with 432 additions and 231 deletions.
31 changes: 0 additions & 31 deletions .eslintrc.js

This file was deleted.

50 changes: 50 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import smarthr from 'eslint-config-smarthr'
import storybook from 'eslint-plugin-storybook'

/**
* @type {import('eslint').Linter.Config[]}
*/
export default [
...smarthr,
...storybook.configs['flat/recommended'],
{
rules: {
'jsx-a11y/anchor-is-valid': 'warn',
'jsx-a11y/click-events-have-key-events': 'warn',
'jsx-a11y/no-static-element-interactions': 'warn',
'jsx-a11y/label-has-associated-control': [
'error',
{
controlComponents: ['Input', 'InputWithTooltip'],
},
],
'@typescript-eslint/consistent-type-definitions': [
'error',
'type',
],
'smarthr/require-barrel-import': 'off',
'smarthr/a11y-anchor-has-href-attribute': [
'error',
{
checkType: 'allow-spread-attributes',
}
],
'smarthr/a11y-input-has-name-attribute': [
'error',
{
checkType: 'allow-spread-attributes',
}
],
},
},
{
ignores: [
'**/*.{mjs,js}',
'sandbox/',
'storybook-static/',
'packages/smarthr-ui/esm/',
'packages/smarthr-ui/lib/',
'packages/smarthr-ui/.storybook',
]
},
]
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"devDependencies": {
"@commitlint/cli": "^19.6.1",
"@commitlint/config-conventional": "^19.6.0",
"eslint": "^8.57.0",
"eslint-config-smarthr": "^7.3.0",
"eslint": "^9.17.0",
"eslint-config-smarthr": "^8.0.0",
"eslint-plugin-storybook": "^0.11.1",
"husky": "^9.1.7",
"lint-staged": "^15.2.11",
Expand Down
4 changes: 0 additions & 4 deletions packages/smarthr-ui/.eslintignore

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export function ButtonWrapper({
if (props.isAnchor) {
const { anchorRef, elementAs, isAnchor: _, ...others } = props
const Component = elementAs || 'a'
// eslint-disable-next-line jsx-a11y/anchor-has-content

return <Component {...others} className={anchorStyle} ref={anchorRef} />
} else {
const { buttonRef, disabled, onClick, ...others } = props
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ const ListBoxItemButton = <T,>({
)

return isNew ? (
// eslint-disable-next-line smarthr/a11y-clickable-element-has-text
<button
type="button"
key={option.id}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { Stack } from '../../../Layout'
import { Text } from '../../../Text'
import { SingleComboBox } from '../SingleComboBox'

// eslint-disable-next-line storybook/prefer-pascal-case
export const defaultItems = {
'option 1': {
label: 'option 1',
Expand Down Expand Up @@ -68,7 +67,6 @@ export const defaultItems = {
},
}

// eslint-disable-next-line storybook/prefer-pascal-case
export const prefixes = { なし: '', あり: <FaCirclePlusIcon /> }

export default {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ export const MessageDialogContentInner: FC<MessageDialogContentInnerProps> = ({
<DialogBody contentPadding={contentPadding} contentBgColor={contentBgColor}>
{description}
</DialogBody>
{/* eslint-disable-next-line smarthr/best-practice-for-layouts */}
<Cluster as="footer" justify="flex-end" className={actionArea()}>
<Button onClick={onClickClose} className="smarthr-ui-Dialog-closeButton">
{decorators?.closeButtonLabel?.(CLOSE_BUTTON_LABEL) || CLOSE_BUTTON_LABEL}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default {
},
args: {
title: 'フォームコントロール',
// eslint-disable-next-line smarthr/a11y-input-has-name-attribute, smarthr/a11y-input-in-form-control

children: <Input />,
},
parameters: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type { Meta, StoryObj } from '@storybook/react'
export default {
title: 'Forms(フォーム)/SearchInput',
component: SearchInput,
// eslint-disable-next-line smarthr/a11y-input-in-form-control

render: (args) => <SearchInput {...args} />,
args: {
tooltipMessage: '氏名、ヨミガナ、社員番号で検索できます。スペース区切りでAND検索ができます。',
Expand Down Expand Up @@ -55,7 +55,6 @@ export const Width: StoryObj<typeof SearchInput> = {
render: (args) => (
<Stack align="flex-start">
{['15em', '50%', 200].map((width) => (
// eslint-disable-next-line smarthr/a11y-input-in-form-control
<SearchInput {...args} width={width} key={width} />
))}
</Stack>
Expand Down
4 changes: 2 additions & 2 deletions packages/smarthr-ui/src/components/Layout/Cluster/Cluster.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ type Props<T extends React.ElementType> = PropsWithChildren<
> &
ComponentPropsWithoutRef<T>

const _Cluster = <T extends React.ElementType = 'div'>(
const ActualCluster = <T extends React.ElementType = 'div'>(
{ as, gap = 0.5, inline = false, align, justify, className, ...rest }: Props<T>,
ref: ForwardedRef<HTMLDivElement>,
) => {
Expand All @@ -119,4 +119,4 @@ const _Cluster = <T extends React.ElementType = 'div'>(
)
}

export const Cluster = genericsForwardRef(_Cluster)
export const Cluster = genericsForwardRef(ActualCluster)
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,9 @@ export const All: StoryFn = () => {
return (
<Stack as="article" gap="M" style={{ padding: '20px' }}>
<header>
{/* eslint-disable-next-line smarthr/a11y-heading-in-sectioning-content */}
<Heading>Reel</Heading>
</header>
<Stack as="section">
{/* eslint-disable-next-line smarthr/a11y-heading-in-sectioning-content */}
<Heading type="sectionTitle">
with <code>gap</code>, <code>padding</code>
</Heading>
Expand All @@ -46,7 +44,6 @@ export const All: StoryFn = () => {
</Reel>
</Stack>
<Stack as="section">
{/* eslint-disable-next-line smarthr/a11y-heading-in-sectioning-content */}
<Heading type="sectionTitle">
<code>TabBar</code>
</Heading>
Expand All @@ -66,7 +63,6 @@ export const All: StoryFn = () => {
</Reel>
</Stack>
<Stack as="section">
{/* eslint-disable-next-line smarthr/a11y-heading-in-sectioning-content */}
<Heading type="sectionTitle">
<code>Table</code>
</Heading>
Expand Down
1 change: 0 additions & 1 deletion packages/smarthr-ui/src/components/Picker/TimePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export const TimePicker = forwardRef<HTMLInputElement, PickerProps<Props>>(

return (
<span className={wrapperStyle}>
{/* eslint-disable-next-line smarthr/a11y-input-in-form-control */}
<input
{...rest}
data-smarthr-ui-input="true"
Expand Down
1 change: 0 additions & 1 deletion packages/smarthr-ui/src/hooks/usePortal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ export function usePortal() {
document.body.removeChild(portalRoot)
}
// spread parentSeqs array for deps
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [portalRoot, ...parentSeqs])

const isChildPortal = useCallback(
Expand Down
Loading

0 comments on commit b2f1541

Please sign in to comment.