Skip to content

Vasty improve linting performance - #146

Open
httphypixelnet wants to merge 19 commits into
frcsoftware:mainfrom
httphypixelnet:fix/lint-performance
Open

Vasty improve linting performance#146
httphypixelnet wants to merge 19 commits into
frcsoftware:mainfrom
httphypixelnet:fix/lint-performance

Conversation

@httphypixelnet

@httphypixelnet httphypixelnet commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Description

Fixed unintended analyzation of non-source files in the validate-regions script and set remark to only check for dead links in a CI environment.

Closes #143 and #87

Meta

Merge checklist:

@github-actions

Copy link
Copy Markdown

🌐 Preview URL: https://pr-146.frcsoftware.pages.dev

Comment thread scripts/validate-regions.ts Outdated
@httphypixelnet
httphypixelnet requested a review from samfreund July 28, 2026 01:49
Comment thread .remarkrc.mjs Outdated
@httphypixelnet
httphypixelnet requested a review from a team as a code owner July 28, 2026 02:23
@github-actions github-actions Bot added the infra Any infrastructure for building the website or syncing files label Jul 28, 2026

@Daniel1464 Daniel1464 left a comment

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.

Great work! Here's another thing that probably should be bundled in this PR:

lint-staged actually passes the changed files as command-line args. Our lint-staged configuration calls pnpm format, which in turn calls prettier --write ., and pnpm lint, which calls eslint . and a bunch of other things. This meant that every time we made a commit, we were running the formatters on the whole repo instead of individual committed files.

To fix this, just change the lint-staged config in package.json to this:

"lint-staged": {
    "**/*": [
        "prettier --write",
        "eslint",
        "pnpm typecheck & pnpm lint:md & pnpm lint:regions",
        "pnpm vale:setup && vale sync && vale"
    ],
    "examples/**/*.java": "sh -c 'cd examples && ./gradlew spotlessApply'",
    "src/data/glossary.ts": [
        "pnpm generate:glossary",
        "git add src/content/docs/resources/glossary.mdx"
    ]
}

This allows for prettier, eslint, and vale to run only on your committed files (the other lint scripts seem to fail if you do that.

Comment thread scripts/validate-regions.ts Outdated
@httphypixelnet

Copy link
Copy Markdown
Contributor Author

See #140

@httphypixelnet

Copy link
Copy Markdown
Contributor Author

Not ready to be merged, still integrating changes from #140

@github-actions github-actions Bot added the Curriculum material Curriculum materials, lessons for students, etc label Jul 30, 2026
@httphypixelnet

Copy link
Copy Markdown
Contributor Author

Ready for final review

Comment thread lint-staged.config.mjs
Comment thread .husky/pre-push
@@ -1 +1,15 @@
pnpm typecheck --minimumFailingSeverity warning
if git diff --cached --name-only | grep -q '\.astro$'; then

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

git diff --cached won't actually do anything, that checks differences between staged and latest commit, but for a pre-push hook everything will have already been committed

Comment thread package.json
"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",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should lint scripts/ as well

Comment thread package.json
"typescript-eslint": "^8.61.1",
"vfile": "^6.0.3"
"vfile": "^6.0.3",
"typescript-7": "npm:typescript@^7.0.2"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

remind me why ts 7 is being added?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

speed

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For tsc yes? I don't think ts 7 is actually being used with tsc, upon local checking.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

when we don't need to typecheck astro files, ts7 is ~6x faster (on my machine)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

For tsc yes? I don't think ts 7 is actually being used with tsc, upon local checking.

Works on my machine, maybe PATH issues? If you have a global typescript@6 that might be the issue.

const m = line.match(CODE_REGION_SOURCE_ENTRY_RE);
if (m) {
sources.set(m[1]!, m[2]!);
extensions.add(m[2]!.split('.').at(-1)!);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Since we're only parsing extensions from the frontmatter, a full reference from a codeblock will get missed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Curriculum material Curriculum materials, lessons for students, etc infra Any infrastructure for building the website or syncing files stage0 stage1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Investigate run time of validate-regions

5 participants