Skip to content

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
ChiefOfGxBxL committed Nov 3, 2024
1 parent 748e3e5 commit f2342b7
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 12 deletions.
5 changes: 3 additions & 2 deletions src/components/Response/Redirect.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ function Titlebar({ url, time, size, statusCode, onClick }) {
Titlebar.propTypes = {
url: redirectShape.url,
time: redirectShape.time,
size: PropTypes.number.isRequired,
statusCode: PropTypes.number.isRequired,
onClick: PropTypes.func.isRequired,
};
Expand All @@ -39,8 +40,8 @@ function Redirect(props) {

const { method, url, time, statusCode } = response;

const contentLength = headers.find((header) => header.name.toLowerCase() === 'content-length')
const contentSize = contentLength ? Number(contentLength.value) : 0
const contentLength = headers.find(header => (header.name.toLowerCase() === 'content-length'));
const contentSize = contentLength ? Number(contentLength.value) : 0;

return (
<StyledResponse
Expand Down
11 changes: 10 additions & 1 deletion src/components/Response/Response.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ function Titlebar({ url, time, size, statusCode }) {
Titlebar.propTypes = {
url: responseShape.url,
time: PropTypes.node.isRequired,
size: PropTypes.number.isRequired,
statusCode: PropTypes.number.isRequired,
};

Expand Down Expand Up @@ -85,7 +86,15 @@ export function Response(props) {
return (
<StyledResponse
wrapResponse={wrapResponse}
header={<Titlebar statusCode={status} method={method} url={url} size={contentSize} time={time} />}
header={(
<Titlebar
statusCode={status}
method={method}
url={url}
size={contentSize}
time={time}
/>
)}
>
<Headers headers={interceptedResponse.responseHeaders} />
{type.html && <RenderedResponse html={body} />}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Response/SizeBytes.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function SizeBytes({ size }) {
}

SizeBytes.propTypes = {
size: PropTypes.number.isRequired
size: PropTypes.number.isRequired,
};

export default SizeBytes;
16 changes: 8 additions & 8 deletions src/utils/byteFormatter.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
const KB = 1024
const MB = 1024 * KB
const GB = 1024 * MB
const KB = 1024;
const MB = 1024 * KB;
const GB = 1024 * MB;

/*
* Formats the provided number in bytes as a string of bytes,
* KB, MB, or GB, with one decimal point and the unit suffix.
*/
export default function byteFormatter(bytes) {
if (bytes < 100) return `${bytes} bytes`
if (bytes > GB) return (bytes / GB).toFixed(1) + ' GB'
if (bytes > MB) return (bytes / MB).toFixed(1) + ' MB'
return (bytes / KB).toFixed(1) + ' KB'
}
if (bytes < 100) return `${bytes} bytes`;
if (bytes > GB) return `${(bytes / GB).toFixed(1)} GB`;
if (bytes > MB) return `${(bytes / MB).toFixed(1)} MB`;
return `${(bytes / KB).toFixed(1)} KB`;
};

Check failure on line 14 in src/utils/byteFormatter.js

View workflow job for this annotation

GitHub Actions / build (16.x)

Unnecessary semicolon

Check failure on line 14 in src/utils/byteFormatter.js

View workflow job for this annotation

GitHub Actions / build (16.x)

Unnecessary semicolon

0 comments on commit f2342b7

Please sign in to comment.