Skip to content

Commit

Permalink
fix: eslint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
johnflank committed Sep 2, 2021
1 parent fa93109 commit 9ea0e43
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 25 deletions.
1 change: 1 addition & 0 deletions src/components/Canary/data.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { isEmpty } from "./utils";

export function CanarySorter(check) {
return GetName(check).toLowerCase();
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Canary/labels.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,4 @@ export function filterChecksByLabels(checks, labelFilters) {
}
});
return newChecks;
}
}
5 changes: 3 additions & 2 deletions src/components/Canary/renderers.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export function Duration({ ms }) {
try {
ms = Number(ms);
} catch (e) {
// eslint-disable-next-line no-console
console.error("invalid number format", ms);
return "";
}
Expand Down Expand Up @@ -74,7 +75,7 @@ export function Latency({ check }) {

export function Percentage({ val, upper, lower }) {
const empty = <span className="text-gray-500 text-light text-xs">-</span>;
if ((isEmpty(lower) && isEmpty(val)) || (upper == 0 && lower == 0)) {
if ((isEmpty(lower) && isEmpty(val)) || (upper === 0 && lower === 0)) {
return empty;
}
if (upper != null && lower != null) {
Expand All @@ -101,7 +102,7 @@ export function Percentage({ val, upper, lower }) {

export function Title({ check, showIcon = true }) {
if (check == null) {
return <span className="bg-red-400" > null</span>
return <span className="bg-red-400"> null</span>;
}
return (
<>
Expand Down
6 changes: 1 addition & 5 deletions src/components/Canary/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ export function StatusList({ check, checkStatuses }) {
return (
<>
{check.checkStatuses.map((status) => (
<CanaryStatus
key={status.id}
status={status}
className="mr-0.5"
/>
<CanaryStatus key={status.id} status={status} className="mr-0.5" />
))}
</>
);
Expand Down
10 changes: 5 additions & 5 deletions src/components/Canary/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useEffect, useState } from "react";
import { FaChevronRight } from "react-icons/fa";
import { Title, Uptime, Latency } from "./renderers";
import { StatusList } from "./status";
import { aggregate } from "./aggregate"
import { aggregate } from "./aggregate";

export function CanaryTable({
className,
Expand Down Expand Up @@ -84,13 +84,12 @@ export function CanaryTable({
);
}


function TableGroupRow({ title, items, onClick, showIcon, ...rest }) {
const [expanded, setExpanded] = useState(false);
const [aggregated, setAggregated] = useState(null);

useEffect(() => {
setAggregated(aggregate(title, items))
setAggregated(aggregate(title, items));
}, [items, items.length]);

return (
Expand All @@ -107,8 +106,9 @@ function TableGroupRow({ title, items, onClick, showIcon, ...rest }) {
<td className="px-6 py-3 w-full">
<div className="flex items-center select-none">
<FaChevronRight
className={`${expanded ? "transform rotate-90" : ""
} mr-4 duration-75`}
className={`${
expanded ? "transform rotate-90" : ""
} mr-4 duration-75`}
/>
<Title check={aggregated} />
</div>
Expand Down
5 changes: 1 addition & 4 deletions src/components/Canary/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ export function getPercentage(uptime) {
if (uptime == null) {
return null;
}
if (uptime.uptime) {
uptime = uptime;
}
if (uptime.passed + uptime.failed == 0) {
if (uptime.passed + uptime.failed === 0) {
return null;
}
return uptime.passed / (uptime.passed + uptime.failed);
Expand Down
3 changes: 2 additions & 1 deletion src/components/Status/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import "./style.css"
import "./style.css";

export function Status({ good, mixed, className = "" }) {
if (mixed) {
className += " bg-mixed";
Expand Down
5 changes: 1 addition & 4 deletions src/components/Table/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ export function Table({ columns, data, id }) {
// eslint-disable-next-line react/no-array-index-key
<tr key={`${id}.${idx}`}>
{columns.map((column) => (
<td
key={column.name}
className="px-6 py-4 "
>
<td key={column.name} className="px-6 py-4 ">
<div className="text-sm text-gray-900">
{row[column.name.toLowerCase()]}
</div>
Expand Down
5 changes: 2 additions & 3 deletions src/pages/Examples/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,9 @@ export function Examples() {
<Icon icon={Icons.s3} />
<Icon name="s3" />
<Icon name="mongo" />
<Status good={true} />
<Status good />
<Status good={false} className="h-16 w-16" />
<Status mixed={true} className="h-16 w-16" />
<Status mixed className="h-16 w-16" />
</div>
</section>
<section className="p-8 rounded-md shadow-md mb-12 border border-gray-200">
Expand Down Expand Up @@ -260,7 +260,6 @@ export function Examples() {
</div>
</section>


<section className="p-8 rounded-md shadow-md mb-12 border border-gray-200">
<h4>Card</h4>
<div className="mt-4 bg-gray-50 p-8 rounded-md">
Expand Down

0 comments on commit 9ea0e43

Please sign in to comment.