Skip to content

Commit 794c5ac

Browse files
Merge pull request #376 from nginformatica/feat/apply-eslint-rule-of-hooks
Feat/apply eslint rule of hooks
2 parents 4660fb1 + 7100dfd commit 794c5ac

File tree

5 files changed

+423
-411
lines changed

5 files changed

+423
-411
lines changed

eslint.config.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,10 @@ const rulesTypescript = {
154154
'@typescript-eslint/consistent-type-imports': 'error'
155155
}
156156

157+
const rulesReactHooks = {
158+
'react-hooks/rules-of-hooks': 'error'
159+
}
160+
157161
export default tseslint.config(
158162
...tseslint.configs.recommended,
159163
{
@@ -203,6 +207,7 @@ export default tseslint.config(
203207
...rulesReact,
204208
...rulesEslint,
205209
...rulesImport,
210+
...rulesReactHooks,
206211
...rulesTypescript
207212
}
208213
}

package.json

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "flipper-ui",
3-
"version": "0.35.13",
3+
"version": "0.35.14",
44
"description": "React UI based on the @mui/material toolkit for the web",
55
"main": "dist/index.js",
66
"author": "NG",
@@ -59,12 +59,11 @@
5959
"@testing-library/react": "16.3.0",
6060
"@testing-library/user-event": "14.6.1",
6161
"@types/jest": "29.5.14",
62-
"@types/node": "22.14.1",
62+
"@types/node": "22.15.3",
6363
"@types/ramda": "0.30.2",
6464
"@types/react": "18.3.12",
65-
"@types/uuid": "10.0.0",
66-
"@typescript-eslint/eslint-plugin": "8.31.0",
67-
"@typescript-eslint/parser": "8.31.0",
65+
"@typescript-eslint/eslint-plugin": "8.31.1",
66+
"@typescript-eslint/parser": "8.31.1",
6867
"babel-loader": "10.0.0",
6968
"babel-plugin-import": "1.13.8",
7069
"babel-plugin-module-resolver": "5.0.2",
@@ -88,9 +87,9 @@
8887
"ts-jest": "29.3.2",
8988
"ts-loader": "9.5.2",
9089
"typescript": "5.8.3",
91-
"typescript-eslint": "8.31.0",
90+
"typescript-eslint": "8.31.1",
9291
"uuid": "11.1.0",
93-
"webpack": "5.99.6"
92+
"webpack": "5.99.7"
9493
},
9594
"peerDependencies": {
9695
"date-fns": "^4.0.0",

src/core/feedback/dialog-v2/dialog.stories.tsx

Lines changed: 52 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { useState } from 'react'
2+
import type { IProps } from './dialog'
23
import type { Meta, StoryObj } from '@storybook/react'
34
import Button from '@/core/inputs/button'
45
import { DialogV2, ConfirmDialog, RemoveDialog } from '.'
@@ -61,22 +62,24 @@ export default meta
6162

6263
type Story = StoryObj<typeof DialogV2>
6364

64-
export const dialog: Story = {
65-
render: ({ ...args }) => {
66-
const [open, setOpen] = useState(false)
65+
const Dialog = (args: IProps) => {
66+
const [open, setOpen] = useState(false)
67+
68+
return (
69+
<>
70+
<Button onClick={() => setOpen(true)}>OPEN DIALOG</Button>
71+
<DialogV2
72+
{...args}
73+
open={open}
74+
primaryButtonAction={() => setOpen(false)}
75+
secondaryButtonAction={() => setOpen(false)}
76+
/>
77+
</>
78+
)
79+
}
6780

68-
return (
69-
<>
70-
<Button onClick={() => setOpen(true)}>OPEN DIALOG</Button>
71-
<DialogV2
72-
{...args}
73-
open={open}
74-
primaryButtonAction={() => setOpen(false)}
75-
secondaryButtonAction={() => setOpen(false)}
76-
/>
77-
</>
78-
)
79-
},
81+
export const dialog: Story = {
82+
render: ({ ...args }) => <Dialog {...args} />,
8083
args: {
8184
title: 'Dialog Title',
8285
text: 'A content here!',
@@ -89,48 +92,48 @@ export const dialog: Story = {
8992
}
9093
}
9194

92-
export const removeDialog: Story = {
93-
render: ({ ...args }) => {
94-
const [open, setOpen] = useState(false)
95+
const RemoveDialogComponent = (args: IProps) => {
96+
const [open, setOpen] = useState(false)
97+
98+
return (
99+
<>
100+
<Button onClick={() => setOpen(true)}>OPEN REMOVE DIALOG</Button>
101+
<RemoveDialog
102+
{...args}
103+
open={open}
104+
onCancel={() => setOpen(false)}
105+
onConfirm={() => setOpen(false)}
106+
/>
107+
</>
108+
)
109+
}
95110

96-
return (
97-
<>
98-
<Button onClick={() => setOpen(true)}>
99-
OPEN REMOVE DIALOG
100-
</Button>
101-
<RemoveDialog
102-
{...args}
103-
open={open}
104-
onCancel={() => setOpen(false)}
105-
onConfirm={() => setOpen(false)}
106-
/>
107-
</>
108-
)
109-
},
111+
export const removeDialog: Story = {
112+
render: ({ ...args }) => <RemoveDialogComponent {...args} />,
110113
args: {
111114
title: '',
112115
text: 'Are you sure you want to remove this?'
113116
}
114117
}
115118

116-
export const confirmDialog: Story = {
117-
render: ({ ...args }) => {
118-
const [open, setOpen] = useState(false)
119+
const ConfirmDialogComponent = (args: IProps) => {
120+
const [open, setOpen] = useState(false)
119121

120-
return (
121-
<>
122-
<Button onClick={() => setOpen(true)}>
123-
OPEN CONFIRM DIALOG
124-
</Button>
125-
<ConfirmDialog
126-
{...args}
127-
open={open}
128-
onCancel={() => setOpen(false)}
129-
onConfirm={() => setOpen(false)}
130-
/>
131-
</>
132-
)
133-
},
122+
return (
123+
<>
124+
<Button onClick={() => setOpen(true)}>OPEN CONFIRM DIALOG</Button>
125+
<ConfirmDialog
126+
{...args}
127+
open={open}
128+
onCancel={() => setOpen(false)}
129+
onConfirm={() => setOpen(false)}
130+
/>
131+
</>
132+
)
133+
}
134+
135+
export const confirmDialog: Story = {
136+
render: ({ ...args }) => <ConfirmDialogComponent {...args} />,
134137
args: {
135138
title: 'Confirm',
136139
text: 'Are you sure you want to confirm this?'

src/core/feedback/dialog/dialog.stories.tsx

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { useState } from 'react'
2+
import type { IDialogProps } from '.'
23
import type { Meta, StoryObj } from '@storybook/react'
34
import Button from '@/core/inputs/button'
45
import Dialog from '.'
@@ -38,29 +39,31 @@ export default meta
3839

3940
type Story = StoryObj<typeof Dialog>
4041

41-
export const dialog: Story = {
42-
render: ({ ...args }) => {
43-
const [open, setOpen] = useState(false)
42+
const DialogComponent = (args: IDialogProps) => {
43+
const [open, setOpen] = useState(false)
44+
45+
return (
46+
<>
47+
<Button onClick={() => setOpen(true)}>OPEN DIALOG</Button>
48+
<Dialog
49+
{...args}
50+
open={open}
51+
actions={
52+
<Button
53+
margin='12px'
54+
variant='contained'
55+
onClick={() => setOpen(false)}>
56+
Close
57+
</Button>
58+
}
59+
onClose={() => setOpen(false)}
60+
/>
61+
</>
62+
)
63+
}
4464

45-
return (
46-
<>
47-
<Button onClick={() => setOpen(true)}>OPEN DIALOG</Button>
48-
<Dialog
49-
{...args}
50-
open={open}
51-
actions={
52-
<Button
53-
margin='12px'
54-
variant='contained'
55-
onClick={() => setOpen(false)}>
56-
Close
57-
</Button>
58-
}
59-
onClose={() => setOpen(false)}
60-
/>
61-
</>
62-
)
63-
},
65+
export const dialog: Story = {
66+
render: ({ ...args }) => <DialogComponent {...args} />,
6467
args: {
6568
title: 'Dialog Title',
6669
text: 'A text here!',

0 commit comments

Comments
 (0)