Skip to content
This repository was archived by the owner on Sep 14, 2022. It is now read-only.

Commit e1b4fba

Browse files
committed
chore: merge component
1 parent 222838e commit e1b4fba

File tree

2 files changed

+28
-35
lines changed

2 files changed

+28
-35
lines changed

src/components/LintMessage.tsx

Lines changed: 0 additions & 30 deletions
This file was deleted.

src/components/LintMessages.tsx

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,46 @@
11
import React from "react";
2-
import { LintMessage } from "@/components/LintMessage";
2+
import { TS_ESLINT_SCOPE } from "@/components/constants";
33
import { Alert } from "react-bootstrap";
44
import type { FC } from "react";
55
import type { Linter } from "eslint";
66

7+
const DOCS_PATH =
8+
"https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/";
9+
710
interface Props {
811
messages?: Linter.LintMessage[];
912
}
1013

1114
export const LintMessages: FC<Props> = (props) => {
12-
if (props.messages?.length === 0) {
15+
if (!(props.messages?.length)) {
1316
return <Alert variant="success"> Lint Free :) </Alert>;
1417
}
1518

1619
return (
1720
<>
18-
{props.messages?.map((message, index) => (
19-
<LintMessage key={index} message={message} />
20-
))}
21+
{props.messages?.map(
22+
({ line, column, message: lintMsg, ruleId, fatal }, index) => {
23+
const variant = fatal ? "danger" : "primary";
24+
const key = `lint-msg-${index}`;
25+
const docUrl = `${DOCS_PATH}${ruleId?.replace(
26+
`${TS_ESLINT_SCOPE}/`,
27+
""
28+
)}.md`;
29+
return (
30+
<Alert variant={variant} key={key}>
31+
{`${line}:${column} - ${lintMsg}`}(
32+
<Alert.Link
33+
target="_blank"
34+
rel="noopener noreferrer"
35+
href={docUrl}
36+
>
37+
{ruleId}
38+
</Alert.Link>
39+
)
40+
</Alert>
41+
);
42+
}
43+
)}
2144
</>
2245
);
2346
};

0 commit comments

Comments
 (0)