Skip to content

Commit 79a8401

Browse files
authored
Fix lints and run linter as part of CI (#644)
1 parent 714cde7 commit 79a8401

15 files changed

Lines changed: 63 additions & 35 deletions

File tree

.github/scripts/update-example-dates.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,31 @@
33
const fs = require("node:fs");
44
const path = require("node:path");
55

6+
// Regex patterns defined at top level for performance
7+
const TITLE_PATTERN = /title="([^"]+)"/;
8+
const HREF_PATTERN = /href="([^"]+)"/;
9+
const GITHUB_PATTERN = /https:\/\/github\.com\/([^/]+\/[^/]+)/;
10+
611
function parseRepositoriesFromMDX(content) {
712
const repositories = [];
813

914
// Regex to find all SampleAppCard components with title and href
1015
const sampleAppCardRegex = /<SampleAppCard\s+([^>]+)>/g;
1116

12-
let match;
13-
while ((match = sampleAppCardRegex.exec(content)) !== null) {
17+
let match = sampleAppCardRegex.exec(content);
18+
while (match !== null) {
1419
const propsString = match[1];
1520

1621
// Extract title and href from props
17-
const titleMatch = propsString.match(/title="([^"]+)"/);
18-
const hrefMatch = propsString.match(/href="([^"]+)"/);
22+
const titleMatch = propsString.match(TITLE_PATTERN);
23+
const hrefMatch = propsString.match(HREF_PATTERN);
1924

2025
if (titleMatch && hrefMatch) {
2126
const title = titleMatch[1];
2227
const href = hrefMatch[1];
2328

2429
// Check if it's a GitHub URL and extract repo name
25-
const githubMatch = href.match(/https:\/\/github\.com\/([^/]+\/[^/]+)/);
30+
const githubMatch = href.match(GITHUB_PATTERN);
2631

2732
if (githubMatch) {
2833
const repoName = githubMatch[1];
@@ -33,6 +38,7 @@ function parseRepositoriesFromMDX(content) {
3338
});
3439
}
3540
}
41+
match = sampleAppCardRegex.exec(content);
3642
}
3743

3844
return repositories;
@@ -123,7 +129,7 @@ async function updateExampleDates() {
123129
);
124130

125131
// Update dates for each repository
126-
repoData.forEach((repo) => {
132+
for (const repo of repoData) {
127133
// Find the SampleAppCard with this title and update its date
128134
const titleRegex = new RegExp(
129135
`(title="${repo.title.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}"[\\s\\S]*?)date="[^"]*"`,
@@ -139,7 +145,7 @@ async function updateExampleDates() {
139145
} else {
140146
console.warn(`Could not find or update date for "${repo.title}"`);
141147
}
142-
});
148+
}
143149

144150
// Write the updated content back
145151
fs.writeFileSync(mdxPath, content, "utf8");

.github/workflows/test.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ jobs:
3838
- name: Install dependencies
3939
run: pnpm install
4040

41+
- name: Run linter
42+
run: pnpm run lint
43+
4144
- name: Try a build
4245
run: pnpm build
4346

app/_components/platform-card.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,13 @@ export const PlatformCard: React.FC<PlatformCardProps> = ({
2626
<CardHeader>
2727
<div className="flex items-center space-x-5">
2828
<div className="relative flex h-10 w-10 items-center justify-center overflow-hidden rounded-lg">
29-
<img alt={`${name} logo`} className="size-9" src={icon} />
29+
<img
30+
alt={`${name} logo`}
31+
className="size-9"
32+
height={36}
33+
src={icon}
34+
width={36}
35+
/>
3036
</div>
3137
<div>
3238
<CardTitle className="mb-0.5 text-base text-gray-900 dark:text-gray-50">

app/_components/sample-app-card.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ type SampleAppCardProps = {
1616
export function SampleAppCard({
1717
title,
1818
description,
19-
image,
2019
href,
2120
blank = false,
2221
tags = [],
@@ -57,8 +56,8 @@ export function SampleAppCard({
5756
</p>
5857
{tags.length > 0 && (
5958
<div className="flex flex-wrap gap-2 pt-2">
60-
{tags.map((tag, index) => {
61-
const getTagColor = (tag: string) => {
59+
{tags.map((tag) => {
60+
const getTagColor = (tagName: string) => {
6261
const languages = [
6362
"JavaScript",
6463
"Python",
@@ -89,13 +88,13 @@ export function SampleAppCard({
8988
"Stytch",
9089
];
9190

92-
if (languages.includes(tag)) {
91+
if (languages.includes(tagName)) {
9392
return "bg-gradient-to-br from-emerald-600 to-emerald-800";
9493
}
95-
if (frameworks.includes(tag)) {
94+
if (frameworks.includes(tagName)) {
9695
return "bg-gradient-to-br from-blue-600 to-blue-800";
9796
}
98-
if (integrations.includes(tag)) {
97+
if (integrations.includes(tagName)) {
9998
return "bg-gradient-to-br from-yellow-600 to-yellow-800";
10099
}
101100
return "bg-gradient-to-br from-gray-600 to-gray-800";
@@ -104,7 +103,7 @@ export function SampleAppCard({
104103
return (
105104
<span
106105
className={`inline-flex w-fit shrink-0 items-center justify-center overflow-hidden whitespace-nowrap rounded-md border-0 border-transparent px-2 py-1 font-semibold text-[0.725rem] text-white uppercase leading-4 tracking-wide shadow-md ${getTagColor(tag)}`}
107-
key={index}
106+
key={tag}
108107
>
109108
{tag}
110109
</span>

app/_components/scope-picker.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,14 @@ export default function ScopePicker({ tools }: ScopePickerProps) {
7373
<button
7474
className="rounded bg-blue-100 px-2 py-1 text-blue-700 text-xs transition-colors hover:bg-blue-200 dark:bg-blue-900 dark:text-blue-300 dark:hover:bg-blue-800"
7575
onClick={selectAll}
76+
type="button"
7677
>
7778
Select all
7879
</button>
7980
<button
8081
className="rounded bg-gray-100 px-2 py-1 text-gray-600 text-xs transition-colors hover:bg-gray-200 dark:bg-gray-700 dark:text-gray-400 dark:hover:bg-gray-600"
8182
onClick={clearAll}
83+
type="button"
8284
>
8385
Clear
8486
</button>
Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
11
import Link from "next/link";
22

3-
interface SubpageListProps {
3+
type SubpageListProps = {
44
basePath: string;
5-
meta: Record<string, any>;
6-
}
5+
meta: Record<string, string | { title: string } | unknown>;
6+
};
77

88
export function SubpageList({ basePath, meta }: SubpageListProps) {
99
const subpages = Object.entries(meta).filter(([key]) => key !== "index");
1010

1111
return (
1212
<ul className="x:ms-[1.5em] x:not-first:mt-[1.25em] x:list-disc x:[:is(ol,ul)_&]:my-[.75em]">
1313
{subpages.map(([key, title]) => {
14-
const linkText =
15-
typeof title === "string"
16-
? title
17-
: typeof title === "object" && title !== null && "title" in title
18-
? (title as { title: string }).title
19-
: String(title);
14+
let linkText: string;
15+
if (typeof title === "string") {
16+
linkText = title;
17+
} else if (
18+
typeof title === "object" &&
19+
title !== null &&
20+
"title" in title
21+
) {
22+
linkText = (title as { title: string }).title;
23+
} else {
24+
linkText = String(title);
25+
}
2026
return (
2127
<li className="x:my-[.5em]" key={key}>
2228
<Link

app/_components/tabbed-code-block/copy-button.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { usePostHog } from "posthog-js/react";
55
import { useCallback, useState } from "react";
66

77
const COPY_TIMEOUT_MS = 1500;
8+
const CONTENT_PREVIEW_LENGTH = 100;
89

910
export function CopyButton({
1011
content,
@@ -28,7 +29,7 @@ export function CopyButton({
2829
// Track code copy event
2930
posthog?.capture("code_copied", {
3031
content_length: content.length,
31-
content_preview: content.substring(0, 100),
32+
content_preview: content.substring(0, CONTENT_PREVIEW_LENGTH),
3233
});
3334
} catch {
3435
// Silent fail

app/en/guides/create-tools/error-handling/page.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: "Handle Errors"
33
description: "Learn how to implement robust error handling in your tools for better user experience"
44
---
55

6-
import { SubpageList } from '../../../../_components/SubpageList';
6+
import { SubpageList } from '../../../../_components/subpage-list';
77
import meta from './_meta';
88

99
# Handle Errors

app/en/guides/create-tools/evaluate-tools/page.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: "Evaluate Tools"
33
description: "Learn how to systematically test and improve your tools with Arcade's evaluation framework"
44
---
55

6-
import { SubpageList } from '../../../../_components/SubpageList';
6+
import { SubpageList } from '../../../../_components/subpage-list';
77
import meta from './_meta';
88

99
# Evaluate Tools

app/en/guides/create-tools/tool-basics/page.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: "Build a Tool"
33
description: "Learn the fundamentals of building tools with Arcade's MCP Server framework"
44
---
55

6-
import { SubpageList } from '../../../../_components/SubpageList';
6+
import { SubpageList } from '../../../../_components/subpage-list';
77
import meta from './_meta';
88

99
# Build a Tool

0 commit comments

Comments
 (0)