Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: make lint rule docs better looking #1277

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lint/_data.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Sidebar, SidebarLink } from "../types.ts";
import { extractYaml } from "jsr:@std/[email protected]";
import { walk } from "jsr:@std/fs";
import { basename } from "jsr:@std/path";
import { extractYaml } from "jsr:@std/[email protected]";
import { Sidebar, SidebarLink } from "../types.ts";

async function generateSidebarItems() {
const sidebarItems = [];
Expand Down Expand Up @@ -43,9 +43,9 @@ export const lintRulePages = await generateSidebarItems();

export const sidebar = [
{
title: "Lint rules",
title: "Deno lint rules",
items: lintRulePages,
},
] satisfies Sidebar;

export const sectionTitle = "Lint rules";
export const sectionTitle = "Deno lint rules";
19 changes: 0 additions & 19 deletions lint/index.md

This file was deleted.

65 changes: 65 additions & 0 deletions lint/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
type LintIconType = "jsr" | "react" | "jsx" | "recommended" | "fresh";

export const title = "Lint rules";
export const toc = [];

const getReadableIconName = (iconType: LintIconType) => {
if (["jsx", "jsr"].includes(iconType)) {
return iconType.toUpperCase();
}
return iconType.charAt(0).toUpperCase() + iconType.slice(1);
};

const getLintIcon = (
type: LintIconType,
) => {
const svgFileName = type === "recommended" ? "checkmark" : type;
return (
<img
src={`/img/${svgFileName}.svg`}
class="size-6"
alt={type}
/>
);
};

export default function LintRulesIndex(
data: Lume.Data,
_helpers: Lume.Helpers,
) {
const TYPES = [
"recommended",
"fresh",
"jsx",
"react",
"jsr",
] as LintIconType[];
return (
<div>
<ul class="flex gap-1 flex-col mb-8 !list-none !pl-0">
{TYPES.map((iconType) => (
<li>
{getLintIcon(iconType)} = {getReadableIconName(iconType)}
</li>
))}
</ul>

<ul class="flex flex-col gap-4 !list-none !pl-0">
{data.lintRulePages.map((lintRule) => (
<li class="border-t md:border md:rounded-md pt-8 pb-4 md:p-4">
<div class="flex flex-row justify-start items-center gap-4 mb-4">
<a href={lintRule.href} class="block text-lg font-mono">
{lintRule.label}
</a>{" "}
{lintRule.tags.map((tag: LintIconType) => getLintIcon(tag))}
</div>
<div>
Lorem ipsum dolor sit amet, <pre>consectetur</pre>{" "}
adipiscing elit, sed do eiusmod tempor.
</div>
</li>
))}
</ul>
</div>
);
}
10 changes: 10 additions & 0 deletions static/img/checkmark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions static/img/fresh.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions static/img/jsr.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions static/img/jsx.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions static/img/react.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/** @type {import('npm:tailwindcss').Config} */
export default {
content: [
"{by-example,deploy,_components,_includes,runtime,static,subhosting,404,examples}/**/*.{md,ts,tsx}",
"{by-example,deploy,_components,_includes,runtime,static,subhosting,404,examples,lint}/**/*.{md,ts,tsx}",
"*.{ts,tsx}",
],
corePlugins: {
Expand Down
Loading