fix: eslint warnings (#252)
This commit is contained in:
@@ -1,22 +1,23 @@
|
||||
'use client';
|
||||
import { useState, useEffect, useContext } from 'react';
|
||||
import { title, subtitle } from '@/components/primitives';
|
||||
import { Card, CardBody, Chip, Divider } from '@heroui/react';
|
||||
import { Folder, Clipboard, FlaskConical } from 'lucide-react';
|
||||
import { ProgressSeriesType } from '@/types/run';
|
||||
import { HomeMessages } from './page';
|
||||
import { TokenContext } from '@/utils/TokenProvider';
|
||||
import { aggregateBasicInfo, aggregateTestPriority, aggregateTestType, aggregateProgress } from './aggregate';
|
||||
import Config from '@/config/config';
|
||||
import { useTheme } from 'next-themes';
|
||||
import { aggregateBasicInfo, aggregateTestPriority, aggregateTestType, aggregateProgress } from './aggregate';
|
||||
import { HomeMessages } from './page';
|
||||
import TestTypesChart from './TestTypesDonutChart';
|
||||
import TestPriorityChart from './TestPriorityDonutChart';
|
||||
import TestProgressBarChart from './TestProgressColumnChart';
|
||||
import Config from '@/config/config';
|
||||
import { TokenContext } from '@/utils/TokenProvider';
|
||||
import { ProgressSeriesType } from '@/types/run';
|
||||
import { title, subtitle } from '@/components/primitives';
|
||||
import { TestRunCaseStatusMessages } from '@/types/status';
|
||||
import { TestTypeMessages } from '@/types/testType';
|
||||
import { PriorityMessages } from '@/types/priority';
|
||||
import { ProjectType } from '@/types/project';
|
||||
import { CasePriorityCountType, CaseTypeCountType } from '@/types/chart';
|
||||
import { logError } from '@/utils/errorHandler';
|
||||
|
||||
const apiServer = Config.apiServer;
|
||||
|
||||
@@ -38,8 +39,8 @@ async function fetchProject(jwt: string, projectId: number) {
|
||||
}
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error: any) {
|
||||
console.error('Error fetching data:', error.message);
|
||||
} catch (error: unknown) {
|
||||
logError('Error fetching data:', error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +60,7 @@ export function ProjectHome({
|
||||
priorityMessages,
|
||||
}: Props) {
|
||||
const context = useContext(TokenContext);
|
||||
const { theme, setTheme } = useTheme();
|
||||
const { theme } = useTheme();
|
||||
const [project, setProject] = useState<ProjectType>({
|
||||
id: 0,
|
||||
name: '',
|
||||
@@ -88,13 +89,13 @@ export function ProjectHome({
|
||||
try {
|
||||
const data = await fetchProject(context.token.access_token, Number(projectId));
|
||||
setProject(data);
|
||||
} catch (error: any) {
|
||||
console.error('Error in effect:', error.message);
|
||||
} catch (error: unknown) {
|
||||
logError('Error in effect:', error);
|
||||
}
|
||||
}
|
||||
|
||||
fetchDataEffect();
|
||||
}, [context]);
|
||||
}, [context, projectId]);
|
||||
|
||||
useEffect(() => {
|
||||
async function aggregate() {
|
||||
@@ -118,7 +119,7 @@ export function ProjectHome({
|
||||
}
|
||||
|
||||
aggregate();
|
||||
}, [project]);
|
||||
}, [project, testRunCaseStatusMessages]);
|
||||
|
||||
return (
|
||||
<div className="container mx-auto max-w-5xl pt-6 px-6 flex-grow">
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import React from 'react';
|
||||
import { useState, useEffect } from 'react';
|
||||
import dynamic from 'next/dynamic';
|
||||
import { priorities } from '@/config/selection';
|
||||
@@ -34,7 +33,7 @@ export default function TestPriorityDonutChart({ priorityCounts, priorityMessage
|
||||
const colors = priorities.map((entry) => entry.chartColor);
|
||||
const legend = {
|
||||
labels: {
|
||||
colors: priorities.map((entry) => {
|
||||
colors: priorities.map(() => {
|
||||
if (theme === 'light') {
|
||||
return 'black';
|
||||
} else {
|
||||
@@ -52,7 +51,7 @@ export default function TestPriorityDonutChart({ priorityCounts, priorityMessage
|
||||
};
|
||||
|
||||
updateChartDate();
|
||||
}, [priorityCounts, theme]);
|
||||
}, [priorityCounts, priorityMessages, theme]);
|
||||
|
||||
return <Chart options={chartData.options} series={chartData.series} type="donut" width={'100%'} height={'100%'} />;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import React from 'react';
|
||||
import { useState, useEffect } from 'react';
|
||||
import dynamic from 'next/dynamic';
|
||||
import { ProgressSeriesType } from '@/types/run';
|
||||
@@ -24,7 +23,7 @@ export default function TestProgressBarChart({ progressSeries, progressCategorie
|
||||
useEffect(() => {
|
||||
const updateChartDate = () => {
|
||||
if (progressSeries) {
|
||||
const legendsLabelColors = testRunCaseStatus.map((itr) => {
|
||||
const legendsLabelColors = testRunCaseStatus.map(() => {
|
||||
if (theme === 'light') {
|
||||
return 'black';
|
||||
} else {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import React from 'react';
|
||||
import { useState, useEffect } from 'react';
|
||||
import dynamic from 'next/dynamic';
|
||||
import { testTypes } from '@/config/selection';
|
||||
@@ -33,7 +32,7 @@ export default function TestTypesDonutChart({ typesCounts, testTypeMessages, the
|
||||
const colors = testTypes.map((entry) => entry.chartColor);
|
||||
const legend = {
|
||||
labels: {
|
||||
colors: testTypes.map((entry) => {
|
||||
colors: testTypes.map(() => {
|
||||
if (theme === 'light') {
|
||||
return 'black';
|
||||
} else {
|
||||
@@ -51,7 +50,7 @@ export default function TestTypesDonutChart({ typesCounts, testTypeMessages, the
|
||||
};
|
||||
|
||||
updateChartDate();
|
||||
}, [typesCounts, theme]);
|
||||
}, [typesCounts, theme, testTypeMessages]);
|
||||
|
||||
return <Chart options={chartData.options} series={chartData.series} type="donut" width={'100%'} height={'100%'} />;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ function aggregateBasicInfo(project: ProjectType) {
|
||||
|
||||
function aggregateTestType(project: ProjectType): CaseTypeCountType[] {
|
||||
// count how many test cases are for each type
|
||||
const typesCounts: number[] = testTypes.map((entry) => {
|
||||
const typesCounts: number[] = testTypes.map(() => {
|
||||
return 0;
|
||||
});
|
||||
project.Folders.forEach((folder) => {
|
||||
@@ -38,7 +38,7 @@ function aggregateTestType(project: ProjectType): CaseTypeCountType[] {
|
||||
|
||||
function aggregateTestPriority(project: ProjectType) {
|
||||
// count how many test cases are for each priority
|
||||
const priorityCounts: number[] = priorities.map((entry) => {
|
||||
const priorityCounts: number[] = priorities.map(() => {
|
||||
return 0;
|
||||
});
|
||||
project.Folders.forEach((folder) => {
|
||||
@@ -58,10 +58,10 @@ function aggregateTestPriority(project: ProjectType) {
|
||||
|
||||
function aggregateProgress(project: ProjectType, testRunCaseStatusMessages: TestRunCaseStatusMessages) {
|
||||
type ChartSeries = { name: string; data: number[] };
|
||||
let series: ChartSeries[] = testRunCaseStatus.map((status) => {
|
||||
const series: ChartSeries[] = testRunCaseStatus.map((status) => {
|
||||
return { name: testRunCaseStatusMessages[status.uid], data: [] };
|
||||
});
|
||||
let categories: string[] = [];
|
||||
const categories: string[] = [];
|
||||
|
||||
project.Runs.forEach((run) => {
|
||||
if (!run.RunCases) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { LocaleCodeType } from '@/types/locale';
|
||||
import { ProjectHome } from './ProjectHome';
|
||||
import { getTranslations } from 'next-intl/server';
|
||||
import { useTranslations } from 'next-intl';
|
||||
import { ProjectHome } from './ProjectHome';
|
||||
import { LocaleCodeType } from '@/types/locale';
|
||||
import { PriorityMessages } from '@/types/priority';
|
||||
import { TestTypeMessages } from '@/types/testType';
|
||||
import { TestRunCaseStatusMessages } from '@/types/status';
|
||||
|
||||
Reference in New Issue
Block a user