Skip to content
Open
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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,6 @@ bun.lock
*/build/*

# IntelliJ
.idea
.idea
.eslintcache
tsconfig.tsbuildinfo
31 changes: 17 additions & 14 deletions .remarkrc.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,22 @@ export default {
remarkPresetLintRecommended,
remarkNoInlineCodeFences,
remarkNoHtmlLinks,
[
remarkLintNoDeadUrls,
{
skipLocalhost: false,
skipOffline: true,
skipUrlPatterns: [
'https://github.com/signup',
'https://code.visualstudio.com/',
'https://www.conventionalcommits.org/en/v1.0.0/',
'https://vale.sh/',
'https://squoosh.app/',
], // Add known flaky URL patterns here
},
],
// only run dead link checker in CI to save time in dev
process.env.CI
? [
remarkLintNoDeadUrls,
{
skipLocalhost: false,
skipOffline: true,
skipUrlPatterns: [
'https://github.com/signup',
'https://code.visualstudio.com/',
'https://www.conventionalcommits.org/en/v1.0.0/',
'https://vale.sh/',
'https://squoosh.app/',
], // Add known flaky URL patterns here
},
]
: () => undefined,
],
};
7 changes: 1 addition & 6 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import js from '@eslint/js';
import astro from 'eslint-plugin-astro';
import globals from 'globals';
import process from 'node:process';
import tseslint from 'typescript-eslint';

import { defineConfig } from 'eslint/config';
Expand All @@ -21,8 +20,7 @@ export default defineConfig([
{ argsIgnorePattern: '^_' },
],
'@typescript-eslint/no-explicit-any': 'error',
// ci runs `astro check` which runs a full typescript checker
'no-undef': process.env.CI ? 'off' : 'error',
'no-undef': 'off',
},
},
{
Expand All @@ -42,8 +40,5 @@ export default defineConfig([
ImageMetadata: 'readonly',
},
},
rules: {
'no-undef': 'off',
},
},
]);
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"prebuild": "tsx scripts/generate-glossary.ts",
"predev": "tsx scripts/generate-glossary.ts",
"lint": "pnpm lint:eslint && pnpm lint:md && pnpm lint:regions && pnpm lint:glossary && pnpm typecheck && pnpm vale",
"lint:eslint": "eslint .",
"lint:eslint": "eslint \"src/**/*.{ts,astro,js,mjs,css}\" \"*.mjs\" --cache",
"lint:md": "remark src/content/docs --ext mdx --frail",
"lint:regions": "tsx scripts/validate-regions.ts",
"vale": "pnpm vale:setup && vale sync && vale src/content",
Expand All @@ -40,12 +40,13 @@
"@eslint/js": "^10.0.1",
"@types/estree": "^1.0.9",
"@types/mdast": "^4.0.4",
"@types/node": "^26.1.2",
"astro-eslint-parser": "^1.4.0",
"eslint": "^10.5.0",
"eslint-plugin-astro": "^1.7.0",
"mdast-util-mdx": "^3.0.0",
"husky": "^9.1.7",
"lint-staged": "^17.0.8",
"mdast-util-mdx": "^3.0.0",
"mdast-util-mdx-jsx": "^3.2.0",
"mdx2vast": "^0.3.1",
"prettier": "^3.8.4",
Expand Down
61 changes: 38 additions & 23 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 11 additions & 2 deletions scripts/validate-regions.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { readFileSync, readdirSync } from 'fs';
import { join, relative } from 'path';
import { basename, join, relative } from 'path';
import { fileURLToPath } from 'url';

const ROOT = fileURLToPath(new URL('..', import.meta.url));
const EXAMPLES_DIR = join(ROOT, 'examples');
const DOCS_DIR = join(ROOT, 'src', 'content', 'docs');
const SKIP_DIRS = new Set(['build', '.gradle', 'node_modules']);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might as well add the gradle directory (not .gradle) while you're at it, even if it doesn't improve perf by that much.


const START_RE = /^\s*(?:\/\/|#|--|<!--|-->)?\s*\[(\w+)\]\s*$/;
const END_RE = /^\s*(?:\/\/|#|--|<!--|-->)?\s*\[\/(\w+)\]\s*$/;
Expand All @@ -15,6 +16,7 @@ const CODE_REGION_SOURCES_KEY_RE = /^codeRegionSources:\s*$/;
const CODE_REGION_SOURCE_ENTRY_RE = /^\s+([\w-]+):\s*(.+?)\s*$/;

const errors: string[] = [];
const extensions: Set<string> = new Set();

function parseCodeRegionSources(content: string): Map<string, string> {
const sources = new Map<string, string>();
Expand All @@ -35,9 +37,9 @@ function parseCodeRegionSources(content: string): Map<string, string> {
const m = line.match(CODE_REGION_SOURCE_ENTRY_RE);
if (m) {
sources.set(m[1]!, m[2]!);
extensions.add(m[2]!.split('.').at(-1)!);
}
}

return sources;
}

Expand Down Expand Up @@ -147,11 +149,18 @@ function validateSource(filePath: string) {
}

function walkExamples(dir: string) {
if (SKIP_DIRS.has(basename(dir))) {
return;
}
for (const entry of readdirSync(dir, { withFileTypes: true })) {
const full = join(dir, entry.name);
if (entry.isDirectory()) {
walkExamples(full);
} else {
if (!extensions.has(full.split('.').at(-1)!)) {
// we only care about source files
continue;
}
validateSource(full);
}
}
Expand Down
4 changes: 3 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
"include": [".astro/types.d.ts", "**/*"],
"exclude": ["dist"],
"compilerOptions": {
"lib": ["DOM", "ESNext"],
"paths": {
"@components/*": ["./src/components/*"]
},
"checkJs": true
"checkJs": true,
"incremental": true
}
}