Skip to content

Commit 665535c

Browse files
committed
feat(submission): show linter output
1 parent 074c7bf commit 665535c

File tree

4 files changed

+47
-0
lines changed

4 files changed

+47
-0
lines changed

src/api/dto/lint-error.dto.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export interface LintErrorDTO {
2+
message: string;
3+
4+
line: number | null;
5+
6+
column: number | null;
7+
8+
offset: number | null;
9+
}

src/components/Benchmarks/BenchmarkDetail.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ const BenchmarkDetail = ({
8787
qualityScore={jobData.qualityScore}
8888
cyclomaticComplexity={jobData.cyclomaticComplexity}
8989
lintScore={jobData.lintScore}
90+
lintErrors={jobData.lintErrors}
9091
isLoading={isProcessing}
9192
/>
9293
);

src/components/Benchmarks/Result.tsx

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react';
22
import Loader from 'react-loader-spinner';
3+
import { LintErrorDTO } from '../../api/dto/lint-error.dto';
34
interface LayoutProps {
45
status: string;
56
message: string;
@@ -11,6 +12,7 @@ interface LayoutProps {
1112
qualityScore?: number;
1213
cyclomaticComplexity?: number;
1314
lintScore?: number;
15+
lintErrors?: LintErrorDTO[];
1416
isLoading: boolean;
1517
}
1618

@@ -24,6 +26,7 @@ const Result: React.FC<LayoutProps> = ({
2426
memUsage,
2527
qualityScore,
2628
lintScore,
29+
lintErrors,
2730
isLoading,
2831
cyclomaticComplexity,
2932
}) => {
@@ -58,6 +61,11 @@ const Result: React.FC<LayoutProps> = ({
5861
value={stdout}
5962
isLoading={isLoading}
6063
/>
64+
<LinterOutput
65+
text={'Linter output'}
66+
lintErrors={lintErrors}
67+
isLoading={isLoading}
68+
/>
6169
<OutputsComponent
6270
text={'Error'}
6371
value={error}
@@ -97,6 +105,33 @@ const OutputsComponent: React.FC<OutputsComponentProps> = ({ text, value }) => {
97105
}
98106
};
99107

108+
interface LinterOutputProps {
109+
text?: string;
110+
lintErrors?: LintErrorDTO[];
111+
isLoading: boolean;
112+
}
113+
114+
const LinterOutput: React.FC<LinterOutputProps> = ({ text, lintErrors }) => {
115+
if (lintErrors) {
116+
return (
117+
<div className="mt-4">
118+
<b className="dark:text-gray-100">{text}:</b>
119+
<div
120+
className={'h-auto p-4 mt-2 w-full bg-gray-800 rounded-lg text-white'}
121+
>
122+
{lintErrors.map((error, i) => (
123+
<p>
124+
{error.column}:{error.line}: {error.message}
125+
</p>
126+
))}
127+
</div>
128+
</div>
129+
);
130+
} else {
131+
return <div />;
132+
}
133+
};
134+
100135
interface ScoresComponentProps {
101136
status: string | undefined;
102137
qualityScore: number | undefined;

src/hooks/submissions.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { useState } from 'react';
22
import { useMutation, useQuery } from 'react-query';
3+
import { LintErrorDTO } from '../api/dto/lint-error.dto';
34
import authenticatedRequest from '../components/utils/request';
45
import { useToken } from './token';
56

@@ -67,6 +68,7 @@ function useProcessInterval({
6768
qualityScore: number;
6869
cyclomaticComplexity: number;
6970
lintScore: number;
71+
lintErrors?: LintErrorDTO[];
7072
};
7173
} = await authenticatedRequest({
7274
url: `submissions/${processId}`,

0 commit comments

Comments
 (0)