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

Commit 2abffee

Browse files
committed
feat: add rule document link (fixes #5)
1 parent a2b4f20 commit 2abffee

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/components/Message.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
import React from "react";
22
import { Alert } from "react-bootstrap";
3+
import { TS_ESLINT_SCOPE } from "@/components/constants";
34
import type { FC } from "react";
45
import type { Linter } from "eslint";
56

7+
const DOCS_PATH =
8+
"https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/";
9+
610
interface Props {
711
message: Linter.LintMessage;
812
}
@@ -12,7 +16,15 @@ export const Message: FC<Props> = ({ message }) => {
1216

1317
return (
1418
<Alert variant={fatal ? "danger" : "primary"}>
15-
{`${line}:${column} - ${lintMsg} (${ruleId})`}
19+
{`${line}:${column} - ${lintMsg} (`}
20+
<Alert.Link
21+
target="_blank"
22+
rel="noopener noreferrer"
23+
href={`${DOCS_PATH}${ruleId?.replace(`${TS_ESLINT_SCOPE}/`, "")}.md`}
24+
>
25+
{ruleId}
26+
</Alert.Link>
27+
{")"}
1628
</Alert>
1729
);
1830
};

src/components/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Linter } from "eslint";
22

33
export const EDITING_TIMEOUT = 300;
4-
4+
export const TS_ESLINT_SCOPE = "@typescript-eslint";
55
export const DEFAULT_CODE = `
66
async function invalidInTryCatch1() {
77
try {

0 commit comments

Comments
 (0)