Skip to content
Closed
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
37 changes: 18 additions & 19 deletions astro.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import icon from "astro-icon";
import sitemap from "@astrojs/sitemap";
import react from "@astrojs/react";

import { readdir } from "fs/promises";
import { fileURLToPath } from "url";
import { readdir } from "node:fs/promises";
import { fileURLToPath } from "node:url";

import rehypeTitleFigure from "rehype-title-figure";
import rehypeMermaid from "./src/plugins/rehype/mermaid.ts";
Expand All @@ -19,22 +19,21 @@ import rehypeExternalLinks from "./src/plugins/rehype/external-links.ts";
import rehypeHeadingSlugs from "./src/plugins/rehype/heading-slugs.ts";

async function autogenSections() {
const sections = (
await readdir("./src/content/docs/", {
withFileTypes: true,
})
)
.filter((x) => x.isDirectory())
.map((x) => x.name);
return sections.map((x) => {
return {
label: x,
autogenerate: {
directory: x,
collapsed: true,
},
};
const entities = await readdir("./src/content/docs/", {
withFileTypes: true,
});

return entities
.filter((x) => x.isDirectory())
.map((x) => {
return {
label: x.name,
autogenerate: {
directory: x.name,
collapsed: true,
},
};
});
}

const sidebar = await autogenSections();
Expand Down Expand Up @@ -167,10 +166,10 @@ export default defineConfig({
resolve: {
alias: {
"./Page.astro": fileURLToPath(
new URL("./src/components/overrides/Page.astro", import.meta.url),
new URL("src/components/overrides/Page.astro", import.meta.url),
),
"../components/Page.astro": fileURLToPath(
new URL("./src/components/overrides/Page.astro", import.meta.url),
new URL("src/components/overrides/Page.astro", import.meta.url),
),
},
},
Expand Down
8 changes: 4 additions & 4 deletions bin/fetch-ai-models.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import fs from "fs";
import fs from "node:fs";

fetch("https://ai.cloudflare.com/api/models")
.then((res) => res.json())
.then((data) => {
data.models.forEach((model) => {
for (const model of data.models) {
const fileName = model.name.split("/")[2];
fs.writeFileSync(
`./src/content/workers-ai-models/${fileName}.json`,
JSON.stringify(model, null, 4),
JSON.stringify(model, undefined, 4),
"utf-8",
);
});
}
});
10 changes: 5 additions & 5 deletions bin/fetch-warp-releases.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import fs from "fs";
import fs from "node:fs";
import YAML from "yaml";
import { marked } from "marked";

Expand All @@ -15,19 +15,19 @@ for (const track of tracks) {
fetch(`https://downloads.cloudflareclient.com/v1/update/json/${track}`)
.then((res) => res.json())
.then((data) => {
data.items.forEach((item) => {
for (const item of data.items) {
const path = `./src/content/warp-releases/${track}/${item.version}.yaml`;

if (fs.existsSync(path)) {
console.log(`${track} ${item.version} already exists.`);
return;
continue;
}

console.log(`Saving ${track} ${item.version}.`);

let markdown = item.releaseNotes;

markdown.replace(/\r\n/g, "\n");
markdown.replaceAll("\r\n", "\n");

for (const line of linesToRemove) {
markdown = markdown.replace(line, "");
Expand Down Expand Up @@ -57,6 +57,6 @@ for (const track of tracks) {
}),
"utf-8",
);
});
}
});
}
2 changes: 1 addition & 1 deletion bin/post-preview-url-comment/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const filenameToPath = (filename: string) => {
.split("/")
.filter(Boolean);

const changelogIdx = segments.findIndex((s) => s === "changelog");
const changelogIdx = segments.indexOf("changelog");

if (changelogIdx !== -1) {
segments.splice(changelogIdx + 1, 1);
Expand Down
2 changes: 1 addition & 1 deletion bin/validate-redirects.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { readFile } from "fs/promises";
import { readFile } from "node:fs/promises";

async function main() {
const redirects = await readFile("public/_redirects", { encoding: "utf-8" });
Expand Down
53 changes: 52 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import pluginUnicorn from "eslint-plugin-unicorn";
import pluginTailwind from "eslint-plugin-tailwindcss";
import pluginJavaScript from "@eslint/js";
import pluginTypeScript from "typescript-eslint";
import pluginReact from "eslint-plugin-react";
import pluginAstro from "eslint-plugin-astro";
import pluginReactA11y from "eslint-plugin-jsx-a11y";
import pluginReactHooks from "eslint-plugin-react-hooks";
import pluginYml from "eslint-plugin-yml";
import pluginJson from "eslint-plugin-json";

import globals from "globals";

Expand All @@ -20,17 +25,63 @@ export default [
...pluginAstro.configs.recommended,
...pluginAstro.configs["jsx-a11y-recommended"],
{
files: ["**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}"],
files: ["**/*.{jsx,mjsx,tsx,mtsx}"],
...pluginReact.configs.flat.recommended,
...pluginReactA11y.flatConfigs.recommended,
...pluginReact.configs.flat["jsx-runtime"],
...pluginReactHooks.configs["recommended-latest"],
},
...pluginTailwind.configs["flat/recommended"],
pluginUnicorn.configs.recommended,
pluginJson.configs.recommended,
...pluginYml.configs["flat/recommended"],
{
settings: {
tailwindcss: {
whitelist: [
"not-content",
"sl-hidden",
"sl-flex",
"sl-markdown-content",
"feedback-prompt",
"bleed",
"gray",
"live-code-layout",
"tryit-sidebar",
"tryit-code",
],
},
},
},
{
ignores: [".astro/", ".wrangler/", "dist/", ".github/"],
},
{
rules: {
"no-var": "error",
"unicorn/better-regex": "error",
"unicorn/prevent-abbreviations": "off",
"unicorn/filename-case": "off",
"unicorn/text-encoding-identifier-case": "off",
"unicorn/no-anonymous-default-export": "off",
"unicorn/prefer-global-this": "off",
"unicorn/explicit-length-check": "off",
"unicorn/no-null": "off",
"unicorn/prefer-spread": "off",
"unicorn/no-process-exit": "off",
"unicorn/prefer-top-level-await": "off",
"unicorn/prefer-dom-node-text-content": "off",
"unicorn/prefer-add-event-listener": "off",
"unicorn/template-indent": "off",
"unicorn/no-nested-ternary": "off",
"unicorn/numeric-separators-style": [
"error",
{ onlyIfContainsSeparator: true },
],
"unicorn/consistent-function-scoping": [
"error",
{ checkArrowFunctions: false },
],
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": [
"error",
Expand Down
Loading
Loading