Skip to content

Commit 3f7d5e7

Browse files
committed
lint fixes
1 parent 5937019 commit 3f7d5e7

File tree

2 files changed

+16
-17
lines changed

2 files changed

+16
-17
lines changed

src/components/Notice/Notice.jsx

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import { Alert, Button, Container } from 'react-bootstrap'
66
const Notice = ({ alert, buttonProps, dismissible, withBackButton }) => {
77
const [show, setShow] = useState(true)
88
const { title, body, variant } = alert
9-
let onClick, text
9+
let onClick
10+
let text
1011
if (withBackButton) ({ onClick, text } = buttonProps)
1112

1213
return (
@@ -16,27 +17,25 @@ const Notice = ({ alert, buttonProps, dismissible, withBackButton }) => {
1617
{title && (
1718
<Alert.Heading>{title}</Alert.Heading>
1819
)}
19-
{body.map((text, index) => {
20-
// If "text" is a JSON string, return it as a formatted code block
20+
{body.map((message, index) => {
21+
// If "message" is a JSON string, return it as a formatted code block
2122
// Otherwise, return it as a regular string
2223
const isJSONParsable = () => {
2324
try {
24-
JSON.parse(text)
25+
JSON.parse(message)
2526
return true
2627
} catch (error) {
2728
return false
2829
}
2930
}
30-
const isJavascriptObject = isJSONParsable(text)
31+
const isJavascriptObject = isJSONParsable(message)
3132

3233
return (
33-
<>
34-
{isJavascriptObject ? (
35-
<pre className='mb-0' key={index}>{text}</pre>
36-
) : (
37-
<p className='mb-0' key={index}>{text}</p>
38-
)}
39-
</>
34+
isJavascriptObject ? (
35+
<pre className='mb-0' key={index}>{message}</pre>
36+
) : (
37+
<p className='mb-0' key={index}>{message}</p>
38+
)
4039
)
4140
})}
4241
{withBackButton && (

src/components/Notice/Notice.stories.jsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Default.args = {
1313
alert: {
1414
title: '',
1515
body: ['A standard alert.'],
16-
variant: 'warning'
16+
variant: 'warning',
1717
},
1818
buttonProps: {},
1919
dismissible: true,
@@ -26,7 +26,7 @@ Error.args = {
2626
title: "We're sorry, something went wrong.",
2727
body: [
2828
JSON.stringify({
29-
message: 'This is how an error would present in dev. There are instances where there may be several api errors on a single page. We would render them all.',
29+
message: 'There are instances where there may be several api errors on a single page. We would render them all.',
3030
name: 'First',
3131
status: 422,
3232
}, null, 2),
@@ -41,11 +41,11 @@ Error.args = {
4141
status: 422,
4242
}, null, 2),
4343
],
44-
variant: 'warning'
44+
variant: 'warning',
4545
},
4646
buttonProps: {
4747
onClick: () => console.log('click me!'),
48-
text: 'Click to return to the previous page.'
48+
text: 'Click to return to the previous page.',
4949
},
5050
dismissible: false,
5151
withBackButton: true,
@@ -56,7 +56,7 @@ UnauthorizedUser.args = {
5656
alert: {
5757
title: 'Unauthorized',
5858
body: ['Please sign in to access this page.'],
59-
variant: 'info'
59+
variant: 'info',
6060
},
6161
buttonProps: {},
6262
dismissible: false,

0 commit comments

Comments
 (0)