eslint --fix automatic fixes and corrections to make eslint happier

Signed-off-by: Matt Ray <github@mattray.dev>
This commit is contained in:
Matt Ray
2023-06-17 12:51:46 +10:00
committed by Fredrik Adelöw
parent 5511693aa0
commit 4d0d3e3207
6 changed files with 26 additions and 28 deletions
@@ -36,7 +36,7 @@ const useStyles = makeStyles({
})
function toBarLabels(allocationRange) {
let keyToFill = {}
const keyToFill = {}
let p = 0
let g = 0
let b = 0
@@ -79,7 +79,7 @@ function toBarLabels(allocationRange) {
}
}
let labels = []
const labels = []
for (const key in keyToFill) {
labels.push({
dataKey: key,
@@ -127,7 +127,7 @@ const RangeChart = ({ data, currency, height }) => {
const CustomTooltip = (params) => {
const { active, payload } = params
if (!payload || payload.length == 0) {
if (!payload || payload.length === 0) {
return null
}
@@ -20,7 +20,7 @@ import { primary, greyscale, browns } from '../../constants/colors';
import { toCurrency } from '../../util';
function toPieData(top, other, idle) {
let slices = []
const slices = []
for (const i in top) {
const allocation = top[i]
@@ -70,7 +70,7 @@ const SummaryChart = ({ top, other, idle, currency, height }) => {
const radius = outerRadius * 1.1
let x = cx + radius * Math.cos(-midAngle * RADIAN)
x += x > cx ? 2 : -2
let y = cy + radius * Math.sin(-midAngle * RADIAN)
const y = cy + radius * Math.sin(-midAngle * RADIAN)
// y -= Math.min(Math.abs(2 / Math.cos(-midAngle * RADIAN)), 8)
if (percent < 0.02) {
@@ -145,7 +145,7 @@ const AllocationReport = ({ allocationData, cumulativeData, totalData, currency
>
{cell.numeric
? (cell.label === 'Efficiency'
? (totalData.totalEfficiency == 1.0 && totalData.cpuReqCoreHrs == 0 && totalData.ramReqByteHrs == 0)
? (totalData.totalEfficiency === 1.0 && totalData.cpuReqCoreHrs === 0 && totalData.ramReqByteHrs === 0)
? "Inf%"
: `${round(totalData.totalEfficiency*100, 1)}%`
: toCurrency(totalData[cell.id], currency))
@@ -158,13 +158,13 @@ const AllocationReport = ({ allocationData, cumulativeData, totalData, currency
row.name = "Unmounted PVs"
}
let isIdle = row.name.indexOf("__idle__") >= 0
let isUnallocated = row.name.indexOf("__unallocated__") >= 0
let isUnmounted = row.name.indexOf("Unmounted PVs") >= 0
const isIdle = row.name.indexOf("__idle__") >= 0
const isUnallocated = row.name.indexOf("__unallocated__") >= 0
const isUnmounted = row.name.indexOf("Unmounted PVs") >= 0
// Replace "efficiency" with Inf if there is usage w/o request
let efficiency = round(row.totalEfficiency*100, 1)
if (row.totalEfficiency == 1.0 && row.cpuReqCoreHrs == 0 && row.ramReqByteHrs == 0) {
if (row.totalEfficiency === 1.0 && row.cpuReqCoreHrs === 0 && row.ramReqByteHrs === 0) {
efficiency = "Inf"
}
@@ -57,7 +57,7 @@ const columns = [
]
const toCSVLine = (datum) => {
let cols = []
const cols = []
forEach(columns, c => {
if (c.currency) {
@@ -84,7 +84,7 @@ const DownloadControl = ({
// Create download link
const a = document.createElement("a")
a.href = URL.createObjectURL(new Blob([csv], { type: "text/csv" }))
const filename = title.toLowerCase().replace(/\s/gi, '-')
const filename = title.toLocaleLowerCase('en-US').replace(/\s/gi, '-')
a.setAttribute("download", `${filename}-${Date.now()}.csv`)
// Click the link
@@ -81,12 +81,14 @@ function generateTitle({ window, aggregateBy, accumulate }) {
if (checkCustomWindow(window)) {
windowName = toVerboseTimeRange(window)
} else {
/* eslint no-console: ["error", { allow: ["warn"] }] */
console.warn(`unknown window: ${window}`)
}
}
let aggregationName = get(find(aggregationOptions, { value: aggregateBy }), 'name', '').toLowerCase()
const aggregationName = get(find(aggregationOptions, { value: aggregateBy }), 'name', '').toLocaleLowerCase('en-US')
if (aggregationName === '') {
/* eslint no-console: ["error", { allow: ["warn"] }] */
console.warn(`unknown aggregation: ${aggregateBy}`)
}
@@ -100,9 +102,6 @@ function generateTitle({ window, aggregateBy, accumulate }) {
}
export const OpenCostReport = () => {
console.log("get the URL from the config")
const baseUrl = "http://localhost:9003";
const classes = useStyles()
// Allocation data state
const [allocationData, setAllocationData] = useState([])
@@ -169,12 +168,11 @@ export const OpenCostReport = () => {
setErrors([])
try {
// get the baseUrl from the Basecamp config
console.log("get the baseUrl from the Basecamp config")
// TODO get the baseUrl from the Basecamp config
const baseUrl = "http://localhost:9003";
const resp = await AllocationService.fetchAllocation(baseUrl, window, aggregateBy, { accumulate })
if (resp.data && resp.data.length > 0) {
const allocationRange = resp.data
console.log(allocationRange);
for (const i in allocationRange) {
// update cluster aggregations to use clusterName/clusterId names
allocationRange[i] = sortBy(allocationRange[i], a => a.totalCost)
@@ -92,12 +92,12 @@ const SelectWindow = ({ windowOptions, window, setWindow }) => {
useEffect(() => {
if (startDate !== null && endDate !== null) {
// Note: getTimezoneOffset() is calculated based on current system locale, NOT date object
let adjustedStartDate = new Date(startDate - startDate.getTimezoneOffset() * 60000)
let adjustedEndDate = new Date(endDate - endDate.getTimezoneOffset() * 60000)
const adjustedStartDate = new Date(startDate - startDate.getTimezoneOffset() * 60000)
const adjustedEndDate = new Date(endDate - endDate.getTimezoneOffset() * 60000)
setIntervalString(
adjustedStartDate.toISOString().split('.')[0] + "Z"
+ ","
+ adjustedEndDate.toISOString().split('.')[0] + "Z"
`${adjustedStartDate.toISOString().split('.')[0] }Z`
+ `,${
adjustedEndDate.toISOString().split('.')[0] }Z`
)
}
}, [startDate, endDate])
@@ -138,7 +138,7 @@ const SelectWindow = ({ windowOptions, window, setWindow }) => {
<MuiPickersUtilsProvider utils={DateFnsUtils}>
<KeyboardDatePicker
style={{ width: '144px' }}
autoOk={true}
autoOk
disableToolbar
variant="inline"
format="MM/dd/yyyy"
@@ -155,7 +155,7 @@ const SelectWindow = ({ windowOptions, window, setWindow }) => {
/>
<KeyboardDatePicker
style={{ width: '144px' }}
autoOk={true}
autoOk
disableToolbar
variant="inline"
format="MM/dd/yyyy"
@@ -184,7 +184,7 @@ const SelectWindow = ({ windowOptions, window, setWindow }) => {
</div>
<div className={classes.dateContainerColumn} style={{ paddingTop: 12, marginLeft: 18 }}>
{windowOptions.map(opt =>
<Typography key={opt.value}
(<Typography key={opt.value}
>
<Link
style={{ cursor: "pointer" }}
@@ -194,7 +194,7 @@ const SelectWindow = ({ windowOptions, window, setWindow }) => {
>
{opt.name}
</Link>
</Typography>
</Typography>)
)}
</div>
</div>