diff --git a/astro.config.ts b/astro.config.ts index 3e59ae1d5edd96..6ba08c87d26088 100644 --- a/astro.config.ts +++ b/astro.config.ts @@ -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"; @@ -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(); @@ -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), ), }, }, diff --git a/bin/fetch-ai-models.js b/bin/fetch-ai-models.js index 50e4593bcb1fe7..346d2c254fa0cd 100644 --- a/bin/fetch-ai-models.js +++ b/bin/fetch-ai-models.js @@ -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", ); - }); + } }); diff --git a/bin/fetch-warp-releases.js b/bin/fetch-warp-releases.js index ed31c49b183f7b..907e0eee012da7 100644 --- a/bin/fetch-warp-releases.js +++ b/bin/fetch-warp-releases.js @@ -1,4 +1,4 @@ -import fs from "fs"; +import fs from "node:fs"; import YAML from "yaml"; import { marked } from "marked"; @@ -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, ""); @@ -57,6 +57,6 @@ for (const track of tracks) { }), "utf-8", ); - }); + } }); } diff --git a/bin/post-preview-url-comment/util.ts b/bin/post-preview-url-comment/util.ts index cab02a7047602d..0b7e5109bbd969 100644 --- a/bin/post-preview-url-comment/util.ts +++ b/bin/post-preview-url-comment/util.ts @@ -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); diff --git a/bin/validate-redirects.ts b/bin/validate-redirects.ts index 9f4ab9ca608a35..2f4460809d4499 100644 --- a/bin/validate-redirects.ts +++ b/bin/validate-redirects.ts @@ -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" }); diff --git a/eslint.config.js b/eslint.config.js index 6b00c2c4932380..a7dfafcb95aa8e 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -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"; @@ -20,10 +25,33 @@ 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/"], @@ -31,6 +59,29 @@ export default [ { 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", diff --git a/package-lock.json b/package-lock.json index 8e104bc196f9cc..36423ff84f1c88 100644 --- a/package-lock.json +++ b/package-lock.json @@ -42,8 +42,13 @@ "dot-prop": "9.0.0", "eslint": "9.20.0", "eslint-plugin-astro": "1.3.1", + "eslint-plugin-json": "4.0.1", "eslint-plugin-jsx-a11y": "6.10.2", "eslint-plugin-react": "7.37.4", + "eslint-plugin-react-hooks": "5.1.0", + "eslint-plugin-tailwindcss": "3.18.0", + "eslint-plugin-unicorn": "57.0.0", + "eslint-plugin-yml": "1.17.0", "fast-glob": "3.3.3", "github-slugger": "2.0.0", "globals": "15.14.0", @@ -4197,6 +4202,13 @@ "undici-types": "~6.20.0" } }, + "node_modules/@types/normalize-package-data": { + "version": "2.4.4", + "resolved": "https://registry.npmjs.org/@types/normalize-package-data/-/normalize-package-data-2.4.4.tgz", + "integrity": "sha512-37i+OaWTh9qeK4LSHPsyRC7NahnGotNuZvjLSgcPzblpHB3rrCJxAOgI5gCdKm7coonsaX1Of0ILiTcnZjbfxA==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/picomatch": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/@types/picomatch/-/picomatch-3.0.2.tgz", @@ -6375,6 +6387,19 @@ "node": "*" } }, + "node_modules/builtin-modules": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-4.0.0.tgz", + "integrity": "sha512-p1n8zyCkt1BVrKNFymOHjcDSAl7oq/gUvfgULv2EblgpPVQlQr9yHnWjg9IJ2MhfwPqiYqMMrr01OY7yQoK2yA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18.20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/cac": { "version": "6.7.14", "resolved": "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz", @@ -6705,6 +6730,29 @@ "dev": true, "license": "MIT" }, + "node_modules/clean-regexp": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/clean-regexp/-/clean-regexp-1.0.0.tgz", + "integrity": "sha512-GfisEZEJvzKrmGWkvfhgzcz/BllN1USeqD2V6tg14OAOgaCD2Z/PUEuxnAZ/nPvmaHRG7a8y77p1T/IRQ4D1Hw==", + "dev": true, + "license": "MIT", + "dependencies": { + "escape-string-regexp": "^1.0.5" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/clean-regexp/node_modules/escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.8.0" + } + }, "node_modules/cli-boxes": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/cli-boxes/-/cli-boxes-3.0.0.tgz", @@ -7059,6 +7107,20 @@ "dev": true, "license": "MIT" }, + "node_modules/core-js-compat": { + "version": "3.40.0", + "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.40.0.tgz", + "integrity": "sha512-0XEDpr5y5mijvw8Lbc6E5AkjrHfp7eEoPlu36SWeAbcL8fn1G1ANe8DBlo2XoNN89oVpxWwOjYIPVzR4ZvsKCQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "browserslist": "^4.24.3" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/core-js" + } + }, "node_modules/cose-base": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/cose-base/-/cose-base-1.0.3.tgz", @@ -8657,6 +8719,20 @@ "eslint": ">=8.57.0" } }, + "node_modules/eslint-plugin-json": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-json/-/eslint-plugin-json-4.0.1.tgz", + "integrity": "sha512-3An5ISV5dq/kHfXdNyY5TUe2ONC3yXFSkLX2gu+W8xAhKhfvrRvkSAeKXCxZqZ0KJLX15ojBuLPyj+UikQMkOA==", + "dev": true, + "license": "MIT", + "dependencies": { + "lodash": "^4.17.21", + "vscode-json-languageservice": "^4.1.6" + }, + "engines": { + "node": ">=18.0" + } + }, "node_modules/eslint-plugin-jsx-a11y": { "version": "6.10.2", "resolved": "https://registry.npmjs.org/eslint-plugin-jsx-a11y/-/eslint-plugin-jsx-a11y-6.10.2.tgz", @@ -8744,6 +8820,19 @@ "eslint": "^3 || ^4 || ^5 || ^6 || ^7 || ^8 || ^9.7" } }, + "node_modules/eslint-plugin-react-hooks": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-5.1.0.tgz", + "integrity": "sha512-mpJRtPgHN2tNAvZ35AMfqeB3Xqeo273QxrHJsbBEPWODRM4r0yB6jfoROqKEYrOn27UtRPpcpHc2UqyBSuUNTw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "eslint": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0 || ^9.0.0" + } + }, "node_modules/eslint-plugin-react/node_modules/brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -8778,6 +8867,93 @@ "semver": "bin/semver.js" } }, + "node_modules/eslint-plugin-tailwindcss": { + "version": "3.18.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-tailwindcss/-/eslint-plugin-tailwindcss-3.18.0.tgz", + "integrity": "sha512-PQDU4ZMzFH0eb2DrfHPpbgo87Zgg2EXSMOj1NSfzdZm+aJzpuwGerfowMIaVehSREEa0idbf/eoNYAOHSJoDAQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "fast-glob": "^3.2.5", + "postcss": "^8.4.4" + }, + "engines": { + "node": ">=18.12.0" + }, + "peerDependencies": { + "tailwindcss": "^3.4.0" + } + }, + "node_modules/eslint-plugin-unicorn": { + "version": "57.0.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-unicorn/-/eslint-plugin-unicorn-57.0.0.tgz", + "integrity": "sha512-zUYYa6zfNdTeG9BISWDlcLmz16c+2Ck2o5ZDHh0UzXJz3DEP7xjmlVDTzbyV0W+XksgZ0q37WEWzN2D2Ze+g9Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-validator-identifier": "^7.25.9", + "@eslint-community/eslint-utils": "^4.4.1", + "ci-info": "^4.1.0", + "clean-regexp": "^1.0.0", + "core-js-compat": "^3.40.0", + "esquery": "^1.6.0", + "globals": "^15.15.0", + "indent-string": "^5.0.0", + "is-builtin-module": "^4.0.0", + "jsesc": "^3.1.0", + "pluralize": "^8.0.0", + "read-package-up": "^11.0.0", + "regexp-tree": "^0.1.27", + "regjsparser": "^0.12.0", + "semver": "^7.7.1", + "strip-indent": "^4.0.0" + }, + "engines": { + "node": ">=18.18" + }, + "funding": { + "url": "https://github.com/sindresorhus/eslint-plugin-unicorn?sponsor=1" + }, + "peerDependencies": { + "eslint": ">=9.20.0" + } + }, + "node_modules/eslint-plugin-unicorn/node_modules/globals": { + "version": "15.15.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-15.15.0.tgz", + "integrity": "sha512-7ACyT3wmyp3I61S4fG682L0VA2RGD9otkqGJIwNUMF1SWUombIIk+af1unuDYgMm082aHYwD+mzJvv9Iu8dsgg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint-plugin-yml": { + "version": "1.17.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-yml/-/eslint-plugin-yml-1.17.0.tgz", + "integrity": "sha512-Q3LXFRnNpGYAK/PM0BY1Xs0IY1xTLfM0kC986nNQkx1l8tOGz+YS50N6wXkAJkrBpeUN9OxEMB7QJ+9MTDAqIQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "debug": "^4.3.2", + "escape-string-regexp": "4.0.0", + "eslint-compat-utils": "^0.6.0", + "natural-compare": "^1.4.0", + "yaml-eslint-parser": "^1.2.1" + }, + "engines": { + "node": "^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/ota-meshi" + }, + "peerDependencies": { + "eslint": ">=6.0.0" + } + }, "node_modules/eslint-scope": { "version": "8.2.0", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-8.2.0.tgz", @@ -10346,6 +10522,26 @@ "hulk": "bin/hulk" } }, + "node_modules/hosted-git-info": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-7.0.2.tgz", + "integrity": "sha512-puUZAUKT5m8Zzvs72XWy3HtvVbTWljRE66cP60bxJzAqf2DgICo7lYTY2IHUmLnNpjYvw5bvmoHvPc0QO2a62w==", + "dev": true, + "license": "ISC", + "dependencies": { + "lru-cache": "^10.0.1" + }, + "engines": { + "node": "^16.14.0 || >=18.0.0" + } + }, + "node_modules/hosted-git-info/node_modules/lru-cache": { + "version": "10.4.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz", + "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==", + "dev": true, + "license": "ISC" + }, "node_modules/htm": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/htm/-/htm-3.1.1.tgz", @@ -10505,6 +10701,32 @@ "node": ">=0.8.19" } }, + "node_modules/indent-string": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-5.0.0.tgz", + "integrity": "sha512-m6FAo/spmsW2Ab2fU35JTYwtOKa2yAwXSwgjSv1TJzh4Mh7mC3lzAOVLBprb72XsTrgkEIsl7YrFNAiDiRhIGg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/index-to-position": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/index-to-position/-/index-to-position-0.1.2.tgz", + "integrity": "sha512-MWDKS3AS1bGCHLBA2VLImJz42f7bJh8wQsTGCzI3j519/CASStoDONUBVz2I/VID0MpiX3SGSnbOD2xUalbE5g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/inline-style-parser": { "version": "0.2.4", "resolved": "https://registry.npmjs.org/inline-style-parser/-/inline-style-parser-0.2.4.tgz", @@ -10710,6 +10932,22 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/is-builtin-module": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-4.0.0.tgz", + "integrity": "sha512-rWP3AMAalQSesXO8gleROyL2iKU73SX5Er66losQn9rWOWL4Gef0a/xOEOVqjWGMuR2vHG3FJ8UUmT700O8oFg==", + "dev": true, + "license": "MIT", + "dependencies": { + "builtin-modules": "^4.0.0" + }, + "engines": { + "node": ">=18.20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/is-callable": { "version": "1.2.7", "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.7.tgz", @@ -13167,6 +13405,16 @@ "node": ">= 0.6" } }, + "node_modules/min-indent": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/min-indent/-/min-indent-1.0.1.tgz", + "integrity": "sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, "node_modules/miniflare": { "version": "3.20250204.1", "resolved": "https://registry.npmjs.org/miniflare/-/miniflare-3.20250204.1.tgz", @@ -13444,6 +13692,21 @@ "node": "*" } }, + "node_modules/normalize-package-data": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-6.0.2.tgz", + "integrity": "sha512-V6gygoYb/5EmNI+MEGrWkC+e6+Rr7mTmfHrxDbLzxQogBkgzo76rkok0Am6thgSF7Mv2nLOajAJj5vDJZEFn7g==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "hosted-git-info": "^7.0.0", + "semver": "^7.3.5", + "validate-npm-package-license": "^3.0.4" + }, + "engines": { + "node": "^16.14.0 || >=18.0.0" + } + }, "node_modules/normalize-path": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", @@ -13843,6 +14106,24 @@ "dev": true, "license": "MIT" }, + "node_modules/parse-json": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-8.1.0.tgz", + "integrity": "sha512-rum1bPifK5SSar35Z6EKZuYPJx85pkNaFrxBK3mwdfSJ1/WKbYrjoW/zTPSjRRamfmVX1ACBIdFAO0VRErW/EA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.22.13", + "index-to-position": "^0.1.2", + "type-fest": "^4.7.1" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/parse-latin": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/parse-latin/-/parse-latin-7.0.0.tgz", @@ -14146,6 +14427,16 @@ "dev": true, "license": "MIT" }, + "node_modules/pluralize": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-8.0.0.tgz", + "integrity": "sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, "node_modules/points-on-curve": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/points-on-curve/-/points-on-curve-0.2.0.tgz", @@ -14669,6 +14960,44 @@ "pify": "^2.3.0" } }, + "node_modules/read-package-up": { + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/read-package-up/-/read-package-up-11.0.0.tgz", + "integrity": "sha512-MbgfoNPANMdb4oRBNg5eqLbB2t2r+o5Ua1pNt8BqGp4I0FJZhuVSOj3PaBPni4azWuSzEdNn2evevzVmEk1ohQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "find-up-simple": "^1.0.0", + "read-pkg": "^9.0.0", + "type-fest": "^4.6.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/read-pkg": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-9.0.1.tgz", + "integrity": "sha512-9viLL4/n1BJUCT1NXVTdS1jtm80yDEgR5T4yCelII49Mbj0v1rZdKqj7zCiYdbB0CuCgdrvHcNogAKTFPBocFA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/normalize-package-data": "^2.4.3", + "normalize-package-data": "^6.0.0", + "parse-json": "^8.0.0", + "type-fest": "^4.6.0", + "unicorn-magic": "^0.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/readdirp": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.1.1.tgz", @@ -14816,6 +15145,16 @@ "dev": true, "license": "MIT" }, + "node_modules/regexp-tree": { + "version": "0.1.27", + "resolved": "https://registry.npmjs.org/regexp-tree/-/regexp-tree-0.1.27.tgz", + "integrity": "sha512-iETxpjK6YoRWJG5o6hXLwvjYAoW+FEZn9os0PD/b6AP6xQwsa/Y7lCVgIixBbUPMfhu+i2LtdeAqVTgGlQarfA==", + "dev": true, + "license": "MIT", + "bin": { + "regexp-tree": "bin/regexp-tree" + } + }, "node_modules/regexp.prototype.flags": { "version": "1.5.4", "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.5.4.tgz", @@ -14837,6 +15176,32 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/regjsparser": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/regjsparser/-/regjsparser-0.12.0.tgz", + "integrity": "sha512-cnE+y8bz4NhMjISKbgeVJtqNbtf5QpjZP+Bslo+UqkIt9QPnX9q095eiRRASJG1/tz6dlNr6Z5NsBiWYokp6EQ==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "jsesc": "~3.0.2" + }, + "bin": { + "regjsparser": "bin/parser" + } + }, + "node_modules/regjsparser/node_modules/jsesc": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.0.2.tgz", + "integrity": "sha512-xKqzzWXDttJuOcawBt4KnKHHIf5oQ/Cxax+0PWFG+DFDgHNAdi+TXECADI+RYiFUMmx8792xsMbbgXj4CwnP4g==", + "dev": true, + "license": "MIT", + "bin": { + "jsesc": "bin/jsesc" + }, + "engines": { + "node": ">=6" + } + }, "node_modules/rehype": { "version": "13.0.2", "resolved": "https://registry.npmjs.org/rehype/-/rehype-13.0.2.tgz", @@ -15643,9 +16008,9 @@ "license": "MIT" }, "node_modules/semver": { - "version": "7.6.3", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", - "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", + "version": "7.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.1.tgz", + "integrity": "sha512-hlq8tAfn0m/61p4BVRcPzIGr6LKiMwo4VM6dGi6pt4qcRkmNzTcWq6eCEjEh+qXjkMDvPlOFFSGwQjoEa6gyMA==", "dev": true, "license": "ISC", "bin": { @@ -16003,6 +16368,42 @@ "url": "https://github.com/sponsors/wooorm" } }, + "node_modules/spdx-correct": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.2.0.tgz", + "integrity": "sha512-kN9dJbvnySHULIluDHy32WHRUu3Og7B9sbY7tsFLctQkIqnMh3hErYgdMjTYuqmcXX+lK5T1lnUt3G7zNswmZA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "spdx-expression-parse": "^3.0.0", + "spdx-license-ids": "^3.0.0" + } + }, + "node_modules/spdx-exceptions": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.5.0.tgz", + "integrity": "sha512-PiU42r+xO4UbUS1buo3LPJkjlO7430Xn5SVAhdpzzsPHsjbYVflnnFdATgabnLude+Cqu25p6N+g2lw/PFsa4w==", + "dev": true, + "license": "CC-BY-3.0" + }, + "node_modules/spdx-expression-parse": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.1.tgz", + "integrity": "sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "spdx-exceptions": "^2.1.0", + "spdx-license-ids": "^3.0.0" + } + }, + "node_modules/spdx-license-ids": { + "version": "3.0.21", + "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.21.tgz", + "integrity": "sha512-Bvg/8F5XephndSK3JffaRqdT+gyhfqIPwDHpX80tJrF8QQRYMo8sNMeaZ2Dp5+jhwKnUmIOyFFQfHRkjJm5nXg==", + "dev": true, + "license": "CC0-1.0" + }, "node_modules/stackback": { "version": "0.0.2", "resolved": "https://registry.npmjs.org/stackback/-/stackback-0.0.2.tgz", @@ -16350,6 +16751,22 @@ "node": ">=4" } }, + "node_modules/strip-indent": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-4.0.0.tgz", + "integrity": "sha512-mnVSV2l+Zv6BLpSD/8V87CW/y9EmmbYzGCIavsnsI6/nwn26DwffM/yztm30Z/I2DY9wdS3vXVCMnHDgZaVNoA==", + "dev": true, + "license": "MIT", + "dependencies": { + "min-indent": "^1.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/strip-json-comments": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", @@ -17606,6 +18023,19 @@ "ufo": "^1.5.4" } }, + "node_modules/unicorn-magic": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/unicorn-magic/-/unicorn-magic-0.1.0.tgz", + "integrity": "sha512-lRfVq8fE8gz6QMBuDM6a+LO3IAzTi05H6gCVaUpir2E1Rwpo4ZUog45KpNXKC/Mn3Yb9UDuHumeFTo9iV/D9FQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/unified": { "version": "11.0.5", "resolved": "https://registry.npmjs.org/unified/-/unified-11.0.5.tgz", @@ -17851,6 +18281,17 @@ "uuid": "dist/bin/uuid" } }, + "node_modules/validate-npm-package-license": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", + "integrity": "sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "spdx-correct": "^3.0.0", + "spdx-expression-parse": "^3.0.0" + } + }, "node_modules/validate.io-array": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/validate.io-array/-/validate.io-array-1.0.6.tgz", @@ -19331,6 +19772,37 @@ "node": ">= 14" } }, + "node_modules/yaml-eslint-parser": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/yaml-eslint-parser/-/yaml-eslint-parser-1.2.3.tgz", + "integrity": "sha512-4wZWvE398hCP7O8n3nXKu/vdq1HcH01ixYlCREaJL5NUMwQ0g3MaGFUBNSlmBtKmhbtVG/Cm6lyYmSVTEVil8A==", + "dev": true, + "license": "MIT", + "dependencies": { + "eslint-visitor-keys": "^3.0.0", + "lodash": "^4.17.21", + "yaml": "^2.0.0" + }, + "engines": { + "node": "^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/ota-meshi" + } + }, + "node_modules/yaml-eslint-parser/node_modules/eslint-visitor-keys": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, "node_modules/yaml-language-server": { "version": "1.15.0", "resolved": "https://registry.npmjs.org/yaml-language-server/-/yaml-language-server-1.15.0.tgz", diff --git a/package.json b/package.json index be377e4d6c2e61..d99e3b65b4e3f9 100644 --- a/package.json +++ b/package.json @@ -60,8 +60,13 @@ "dot-prop": "9.0.0", "eslint": "9.20.0", "eslint-plugin-astro": "1.3.1", + "eslint-plugin-json": "4.0.1", "eslint-plugin-jsx-a11y": "6.10.2", "eslint-plugin-react": "7.37.4", + "eslint-plugin-react-hooks": "5.1.0", + "eslint-plugin-tailwindcss": "3.18.0", + "eslint-plugin-unicorn": "57.0.0", + "eslint-plugin-yml": "1.17.0", "fast-glob": "3.3.3", "github-slugger": "2.0.0", "globals": "15.14.0", diff --git a/scripts/optimize-svgs.ts b/scripts/optimize-svgs.ts index 10e14ca65bc108..35dcc0b45f1054 100644 --- a/scripts/optimize-svgs.ts +++ b/scripts/optimize-svgs.ts @@ -1,4 +1,4 @@ -import { readFile, writeFile } from "fs/promises"; +import { readFile, writeFile } from "node:fs/promises"; import { optimize } from "svgo"; import glob from "fast-glob"; import { formatBytes } from "../src/util/helpers"; @@ -50,8 +50,8 @@ async function run() { ); optimizedSize += result.data.length; await writeFile(filePath, result.data); - } catch (err) { - console.error(`Error optimizing ${filePath}: ${err}`); + } catch (error) { + console.error(`Error optimizing ${filePath}: ${error}`); } finally { processed++; } diff --git a/src/components/Description.astro b/src/components/Description.astro index 0a5d1c985bba07..1421a69b49f13e 100644 --- a/src/components/Description.astro +++ b/src/components/Description.astro @@ -1,3 +1,3 @@ -
+
diff --git a/src/components/FieldCatalog.tsx b/src/components/FieldCatalog.tsx index bb2598175d415f..fe090aa1a09210 100644 --- a/src/components/FieldCatalog.tsx +++ b/src/components/FieldCatalog.tsx @@ -23,26 +23,22 @@ const FieldCatalog = ({ fields }: { fields: Fields }) => { }); const categories = [ - ...new Set( - fields - .map((field) => field.categories ?? []) - .flat() - .sort(), - ), + ...new Set(fields.flatMap((field) => field.categories ?? []).sort()), ]; // apply filters to the fields list const fieldList = mapped.filter((field) => { - if (filters.categories.length > 0) { - if (!field.categories?.some((c) => filters.categories.includes(c))) { - return false; - } + if ( + filters.categories.length > 0 && + !field.categories?.some((c) => filters.categories.includes(c)) + ) { + return false; } if (filters.search) { // search keywords - const keywordFound = field.keywords?.some( - (kw) => kw.indexOf(filters.search) >= 0, + const keywordFound = field.keywords?.some((kw) => + kw.includes(filters.search), ); if ( @@ -77,7 +73,7 @@ const FieldCatalog = ({ fields }: { fields: Fields }) => {
setFilters({ ...filters, search: e.target.value })} @@ -136,7 +132,7 @@ const FieldCatalog = ({ fields }: { fields: Fields }) => { >
{field.name} diff --git a/src/components/Flex.astro b/src/components/Flex.astro index e3d03f3928a2f6..0a34ac38d178f5 100644 --- a/src/components/Flex.astro +++ b/src/components/Flex.astro @@ -1,3 +1,3 @@ -
+
diff --git a/src/components/GitHubCode.astro b/src/components/GitHubCode.astro index f7442339733d15..316741beb7f33d 100644 --- a/src/components/GitHubCode.astro +++ b/src/components/GitHubCode.astro @@ -62,7 +62,7 @@ if (lines) { } contentLines = contentLines.filter( - (line) => !/<[/]?docs-tag name=".*">/.test(line), + (line) => !/<\/?docs-tag name=".*">/.test(line), ); --- diff --git a/src/components/Glossary.astro b/src/components/Glossary.astro index 1a2aaff4ecefe7..c90ac4642dee85 100644 --- a/src/components/Glossary.astro +++ b/src/components/Glossary.astro @@ -93,9 +93,9 @@ const INITIAL_VISIBLE_ROWS = 20; if (rows.length === 0) { button?.classList.add("hidden"); } - const extraRows = Array.from(rows).slice(0, 20); + const extraRows = [...rows].slice(0, 20); - extraRows.forEach((row) => row.classList.remove("hidden")); + for (const row of extraRows) row.classList.remove("hidden"); } if (button) { diff --git a/src/components/HomepageHero.astro b/src/components/HomepageHero.astro index 3f7400ad2ca4b1..798e384c9a943e 100644 --- a/src/components/HomepageHero.astro +++ b/src/components/HomepageHero.astro @@ -27,6 +27,7 @@ if (image) { } --- +{/* eslint-disable tailwindcss/no-custom-classname */}
{ darkImage && ( diff --git a/src/components/LearningPathCatalog.tsx b/src/components/LearningPathCatalog.tsx index b71cc42be4ec0f..057d3697b6bc22 100644 --- a/src/components/LearningPathCatalog.tsx +++ b/src/components/LearningPathCatalog.tsx @@ -50,16 +50,18 @@ const LearningPathCatalog = ({ // apply filters to the fields list const filtered = mapped.filter((path) => { - if (filters.groups.length > 0) { - if (!path.groups.some((c) => filters.groups.includes(c))) { - return false; - } + if ( + filters.groups.length > 0 && + !path.groups.some((c) => filters.groups.includes(c)) + ) { + return false; } - if (filters.products.length > 0) { - if (!path.products.some((c) => filters.products.includes(c))) { - return false; - } + if ( + filters.products.length > 0 && + !path.products.some((c) => filters.products.includes(c)) + ) { + return false; } return true; diff --git a/src/components/LinkTitleCard.astro b/src/components/LinkTitleCard.astro index a866096b90be9c..9fa5f228dcf0b7 100644 --- a/src/components/LinkTitleCard.astro +++ b/src/components/LinkTitleCard.astro @@ -12,6 +12,7 @@ interface Props { const { icon, title, href, ...attrs } = Astro.props; --- +{/* eslint-disable tailwindcss/no-custom-classname */}

{icon && } diff --git a/src/components/ListExamples.astro b/src/components/ListExamples.astro index 73ad6f9da9a953..6bddf54ff51730 100644 --- a/src/components/ListExamples.astro +++ b/src/components/ListExamples.astro @@ -19,11 +19,7 @@ const { directory, filters, additionalProducts } = props.parse(Astro.props); let target = Astro.params.slug?.split("/")[0]; -if (directory) { - target = directory; -} else { - target = target?.concat("/"); -} +target = directory ?? target?.concat("/"); const examples = await getCollection("docs", (entry) => { return ( diff --git a/src/components/ListTutorials.astro b/src/components/ListTutorials.astro index b1d4f75a442ebb..25b8fdb505c2d6 100644 --- a/src/components/ListTutorials.astro +++ b/src/components/ListTutorials.astro @@ -47,7 +47,7 @@ tutorials.push(...videos); tutorials.sort((a, b) => Number(b.data.updated) - Number(a.data.updated)); const timeAgo = (date?: Date) => { - if (!date) return undefined; + if (!date) return; return formatDistance(date, new Date(), { addSuffix: true }); }; --- diff --git a/src/components/MetaInfo.astro b/src/components/MetaInfo.astro index d302876d77b893..302a1858144fec 100644 --- a/src/components/MetaInfo.astro +++ b/src/components/MetaInfo.astro @@ -12,4 +12,4 @@ const props = z const { text } = props.parse(Astro.props); --- -{text} +{text} diff --git a/src/components/ModelCatalog.tsx b/src/components/ModelCatalog.tsx index 35083fc6e44b0b..0cad22aeb71f79 100644 --- a/src/components/ModelCatalog.tsx +++ b/src/components/ModelCatalog.tsx @@ -50,7 +50,7 @@ const ModelCatalog = ({ models }: { models: WorkersAIModelsSchema[] }) => { return []; }) - .filter((p) => Boolean(p)), + .filter(Boolean), }, model_display_name: model.name.split("/").at(-1), })); @@ -72,34 +72,35 @@ const ModelCatalog = ({ models }: { models: WorkersAIModelsSchema[] }) => { return []; }) - .filter((p) => Boolean(p)), + .filter(Boolean), ), ), ]; const modelList = mapped.filter(({ model }) => { - if (filters.authors.length > 0) { - if (!filters.authors.includes(model.name.split("/")[1])) { - return false; - } + if ( + filters.authors.length > 0 && + !filters.authors.includes(model.name.split("/")[1]) + ) { + return false; } - if (filters.tasks.length > 0) { - if (!filters.tasks.includes(model.task.name)) { - return false; - } + if (filters.tasks.length > 0 && !filters.tasks.includes(model.task.name)) { + return false; } - if (filters.capabilities.length > 0) { - if (!model.capabilities.some((c) => filters.capabilities.includes(c))) { - return false; - } + if ( + filters.capabilities.length > 0 && + !model.capabilities.some((c) => filters.capabilities.includes(c)) + ) { + return false; } - if (filters.search) { - if (!model.name.toLowerCase().includes(filters.search.toLowerCase())) { - return false; - } + if ( + filters.search && + !model.name.toLowerCase().includes(filters.search.toLowerCase()) + ) { + return false; } return true; @@ -110,7 +111,7 @@ const ModelCatalog = ({ models }: { models: WorkersAIModelsSchema[] }) => {

setFilters({ ...filters, search: e.target.value })} @@ -252,11 +253,11 @@ const ModelCatalog = ({ models }: { models: WorkersAIModelsSchema[] }) => { alt={`${authorInfo.name} logo`} /> ) : ( -
+
{author.slice(0, 1)}
)} - + {model.model_display_name} {isBeta && Beta} diff --git a/src/components/NetworkMap.astro b/src/components/NetworkMap.astro index 7311d05c658894..356f12d6208a4f 100644 --- a/src/components/NetworkMap.astro +++ b/src/components/NetworkMap.astro @@ -1,7 +1,4 @@ ---- - ---- - +{/* eslint-disable tailwindcss/no-custom-classname */} diff --git a/src/components/ProductCatalog.tsx b/src/components/ProductCatalog.tsx index fc856f6ccb68f3..5c330801ee6a61 100644 --- a/src/components/ProductCatalog.tsx +++ b/src/components/ProductCatalog.tsx @@ -18,24 +18,21 @@ const ProductCatalog = ({ products }: { products: ProductData[] }) => { groups: [], }); - const groups = [...new Set(products.map((product) => product.groups).flat())]; + const groups = [...new Set(products.flatMap((product) => product.groups))]; const productList = products.filter((product) => { - if (filters.groups.length > 0) { - if ( - filters.groups.filter((val) => product.groups.includes(val)).length === - 0 - ) { - return false; - } + if ( + filters.groups.length > 0 && + filters.groups.filter((val) => product.groups.includes(val)).length === 0 + ) { + return false; } - if (filters.search) { - if ( - !product.data.name.toLowerCase().includes(filters.search.toLowerCase()) - ) { - return false; - } + if ( + filters.search && + !product.data.name.toLowerCase().includes(filters.search.toLowerCase()) + ) { + return false; } return true; @@ -59,7 +56,7 @@ const ProductCatalog = ({ products }: { products: ProductData[] }) => {
setFilters({ ...filters, search: e.target.value })} @@ -128,11 +125,11 @@ const ProductCatalog = ({ products }: { products: ProductData[] }) => {
)} {!product.icon && ( -
- {product.data.name.substr(0, 1)} +
+ {product.data.name.slice(0, 1)}
)} - + {product.data.name}
diff --git a/src/components/RelatedProduct.astro b/src/components/RelatedProduct.astro index d307ea7196e05f..48479a68ee4d07 100644 --- a/src/components/RelatedProduct.astro +++ b/src/components/RelatedProduct.astro @@ -13,10 +13,10 @@ const props = z.object({ const { header, href, product } = props.parse(Astro.props); --- -
+
diff --git a/src/components/Stream.astro b/src/components/Stream.astro index a5e778ced4157b..00cf80fa67ae2d 100644 --- a/src/components/Stream.astro +++ b/src/components/Stream.astro @@ -22,7 +22,9 @@ url.searchParams.set("letterboxColor", "transparent"); // full url option if (thumbnailTimeOrURL !== undefined) { - if (!thumbnailTimeOrURL.startsWith("http")) { + if (thumbnailTimeOrURL.startsWith("http")) { + url.searchParams.set("poster", thumbnailTimeOrURL); + } else { const thumbnailUrl = new URL( `${videoId}/thumbnails/thumbnail.jpg`, baseUrl, @@ -31,8 +33,6 @@ if (thumbnailTimeOrURL !== undefined) { thumbnailUrl.searchParams.set("time", thumbnailTimeOrURL); url.searchParams.set("poster", encodeURI(thumbnailUrl.toString())); - } else { - url.searchParams.set("poster", thumbnailTimeOrURL); } } --- diff --git a/src/components/TroubleshootingList.astro b/src/components/TroubleshootingList.astro index fd8fba39e4d36c..eda865c5d31725 100644 --- a/src/components/TroubleshootingList.astro +++ b/src/components/TroubleshootingList.astro @@ -3,12 +3,12 @@ import { getEntry } from "astro:content"; import { getCollection } from "astro:content"; const currentSection = Astro.params.slug?.split("/")[0]; -const troubleshootingTypes = ["troubleshooting", "faq"]; +const troubleshootingTypes = new Set(["troubleshooting", "faq"]); const resources = await getCollection("docs", (entry) => { return ( entry.data.pcx_content_type && - troubleshootingTypes.includes(entry.data.pcx_content_type) && + troubleshootingTypes.has(entry.data.pcx_content_type) && entry.id.startsWith(`${currentSection}/`) ); }); @@ -31,11 +31,10 @@ const resources = await getCollection("docs", (entry) => { for (let i = 0; i < segments.length; i++) { let path; - if (i === 0) { - path = `${currentSection}/${segments[i]}`; - } else { - path = currentSection + "/" + segments.slice(0, i).join("/"); - } + path = + i === 0 + ? `${currentSection}/${segments[i]}` + : currentSection + "/" + segments.slice(0, i).join("/"); const entry = await getEntry("docs", path); diff --git a/src/components/TunnelCalculator.astro b/src/components/TunnelCalculator.astro index 48c69e0dbce4c4..f24a6723041df4 100644 --- a/src/components/TunnelCalculator.astro +++ b/src/components/TunnelCalculator.astro @@ -4,7 +4,7 @@ import { Card } from "@astrojs/starlight/components"; const configuration = Object.entries({ available_ports_per_host: { title: "Available ports per host", - default: 50000, + default: 50_000, }, cloudflared_replicas: { title: "Number of cloudflared replicas", @@ -25,7 +25,7 @@ const configuration = Object.entries({ const metrics = Object.entries({ tcp_per_sec: { title: "TCP requests per second", - default: 50000, + default: 50_000, }, non_dns_udp_req_per_sec: { title: "Non-DNS UDP requests per second", @@ -200,7 +200,8 @@ const metrics = Object.entries({ } } - document - .querySelectorAll("input[data-tunnel-calculator]") - .forEach((input) => input.addEventListener("change", calculate)); + for (const input of document.querySelectorAll( + "input[data-tunnel-calculator]", + )) + input.addEventListener("change", calculate); diff --git a/src/components/TypeScriptExample.astro b/src/components/TypeScriptExample.astro index f8e1753769f186..373f745ace4f6b 100644 --- a/src/components/TypeScriptExample.astro +++ b/src/components/TypeScriptExample.astro @@ -57,7 +57,8 @@ if (!code) { ); } -code = code.replace(/\u007f/g, "\n"); +/* eslint-disable unicorn/prefer-string-replace-all */ +code = code.replaceAll(/\u007F/g, "\n"); const js = await format(tsBlankSpace(code), { parser: "babel", useTabs: true }); diff --git a/src/components/WARPReleases.astro b/src/components/WARPReleases.astro index d712bdecbc0ebf..e32e540488dfd3 100644 --- a/src/components/WARPReleases.astro +++ b/src/components/WARPReleases.astro @@ -41,7 +41,7 @@ releases.sort(sortByDate); const latestRelease = releases.at(0); if (!latestRelease) { - throw new Error(); + throw new Error(`[WARPReleases] Unable to find any releases`); } const platform = latestRelease.platformName; diff --git a/src/components/WorkersIsolateDiagram.astro b/src/components/WorkersIsolateDiagram.astro index 269a89d1d6d745..7e20eaa035f335 100644 --- a/src/components/WorkersIsolateDiagram.astro +++ b/src/components/WorkersIsolateDiagram.astro @@ -1,7 +1,8 @@ --- -let range = (n: number) => [...Array(n).keys()]; +let range = (n: number) => [...Array.from({ length: n }).keys()]; --- +{/* eslint-disable tailwindcss/no-custom-classname */}
diff --git a/src/components/WranglerConfig.astro b/src/components/WranglerConfig.astro index 2c671554010fb6..a09198e7f6dd5d 100644 --- a/src/components/WranglerConfig.astro +++ b/src/components/WranglerConfig.astro @@ -24,7 +24,8 @@ if (!code) { ); } -code = code.replace(/\u007f/g, "\n"); +/* eslint-disable unicorn/prefer-string-replace-all */ +code = code.replaceAll(/\u007F/g, "\n"); const language = html.querySelector("[data-language]")?.attributes["data-language"]; diff --git a/src/components/astro/ListCard.astro b/src/components/astro/ListCard.astro index e0da2d22cf7cae..e8caeb40da8e59 100644 --- a/src/components/astro/ListCard.astro +++ b/src/components/astro/ListCard.astro @@ -3,6 +3,7 @@ import { Card } from "@astrojs/starlight/components"; export type Props = Parameters[0]; --- +{/* eslint-disable tailwindcss/no-custom-classname */}