forked from denoland/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.page.tsx
More file actions
125 lines (119 loc) · 3.72 KB
/
index.page.tsx
File metadata and controls
125 lines (119 loc) · 3.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
type LintIconType = "jsr" | "react" | "jsx" | "recommended" | "fresh";
export const title = "List of rules";
export const toc = [];
export const oldUrl = "/lint/rules";
const getReadableIconName = (iconType: LintIconType) => {
if (["jsx", "jsr"].includes(iconType)) {
return iconType.toUpperCase();
}
return iconType.charAt(0).toUpperCase() + iconType.slice(1);
};
export const getLintIcon = (
type: LintIconType,
) => {
const svgFileName = type === "recommended" ? "checkmark" : type;
return (
<img
src={`/img/${svgFileName}.svg`}
class="size-6 !bg-transparent"
alt={getReadableIconName(type)}
title={getReadableIconName(type)}
/>
);
};
export default function LintRulesIndex(
data: Lume.Data,
helpers: Lume.Helpers,
) {
const TAGS = [
"recommended",
"fresh",
"jsx",
"react",
"jsr",
"workspace",
] as LintIconType[];
return (
<div>
<div class="flex flex-col gap-4 mb-8">
<p>
These lint rules are provided by the{" "}
<a href="/runtime/reference/cli/lint/">
<code>deno lint</code>
</a>{" "}
command. You can enable sets of rules in <code>deno.json(c)</code>
{" "}
by adding their tags (e.g. <code>recommended</code>,{" "}
<code>react</code>) to the{" "}
<a href="/runtime/fundamentals/configuration/#linting">
<code>lint.rules.tags</code>
</a>{" "}
array.
</p>
<p>
If no tag is provided, then the <code>recommended</code>{" "}
set of rules will be enabled by default.
</p>
<input
type="text"
id="lint-rule-search"
placeholder="Search lint rules"
className="
w-full
lg:flex
rounded-md
items-center
text-sm
leading-6
py-1.5 pl-2 pr-3
border
text-slate-600
bg-slate-100
dark:bg-background-secondary
dark:text-slate-200
dark:highlight-white/5
dark:hover:bg-slate-700
dark:border-foreground-tertiary
hover:bg-slate-200
duration-150 ease-in-out"
/>
<ul class="flex flex-wrap gap-2 mb-8 !list-none !pl-0">
{TAGS.map((iconType) => (
<li class="p-1.5 px-3 rounded-md bg-background-secondary/30 border border-background-secondary w-max max-w-full !m-0 whitespace-pre-wrap">
{getLintIcon(iconType)} {getReadableIconName(iconType)}
</li>
))}
</ul>
</div>
<ul class="flex flex-col gap-4 !list-none !pl-0">
{data.lintRulePages.map((lintRule, idx: number) => (
<li
class="border-t md:border md:rounded-md pt-8 pb-4 md:p-4 lint-rule-box dark:border-gray-700 !mt-0"
id={lintRule.title}
>
<div class="flex flex-row justify-start items-center gap-4 mb-2">
<a href={lintRule.href} class="block font-mono">
{lintRule.title}
</a>{" "}
{lintRule.tags.map((tag: LintIconType) => (
<div class="bg-background-secondary/30 border border-background-secondary rounded-md p-1">
{getLintIcon(tag)}
</div>
))}
</div>
<div
class="text-sm [&>*]:last:mb-0"
dangerouslySetInnerHTML={{
__html: helpers.md(
lintRule.content.split(/\n\n/)[0] +
` <a href="${lintRule.href}">Details<span class="sr-only"> about ${lintRule.label}</span></a>`,
),
}}
>
</div>
</li>
))}
</ul>
</div>
);
}