Repository navigation
chore(lint): check the code samples on the pages a PR changes - #2623
Merged
Merged
Conversation
bruno-andrade-azion
requested review from
a team and
marcus-souza-azion
as code owners
November 10, 2026 17:23
This was referenced Nov 10, 2026
9 of 14 tasks
Add `pnpm lint:codeblocks`, which parses the code samples in the docs: a json block must be JSON, a JavaScript or TypeScript block must be free of syntax errors, and the JSON body of a curl --data in a shell block must parse. It reads the conventions the docs use on purpose (bare <placeholder> values, ... and … elisions, member fragments, diff in the fence meta, jsonc, jsonl) and lets a partial block opt out with nolint. A new Code blocks workflow runs it over the pages each PR changes and annotates every finding on its line. It is advisory: it turns red but is not a required check and sits outside the CI gate, so the PR author decides whether to fix the sample.
A PR that changes lint-codeblocks.mjs or its workflow changes no page, so it took the "no page changed" path and the script never ran in CI. It now checks every page, as the Changelog entries workflow does. A mistyped path passed to the script now exits 2 instead of checking nothing and passing.
bruno-andrade-azion
force-pushed
the
chore/mm-16258-code-block-lint
branch
from
November 16, 2026 17:51
7426af0 to
d59bdbd
Compare
… parses A bare <placeholder> is accepted in json blocks and curl bodies only; in JavaScript and TypeScript it goes inside a string. A method signature alone parses with an elided body. Aligns the lint:codeblocks line with the other commands in CONTRIBUTING.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Related issue: MM-16258
Pages affected: none. This PR adds tooling (
apps/docs/scripts/lint-codeblocks.mjs,.github/workflows/code-blocks.yml, thelint:codeblocksscripts) and documents it inAGENTS.md,.github/CONTRIBUTING.mdand.github/GOVERNANCE.md.The October docs review found samples that readers cannot paste. Seven Marketplace integration guides had Arguments JSON with trailing commas,
//comments and keys missing a closing quote. An API body sent"service_id": :id, and two JSON responses never closed their braces. Checking that the samples parse would have caught all of those before review.What the lint checks.
pnpm lint:codeblocks [files]parses everyjsonblock, checks JavaScript and TypeScript blocks for syntax errors (with the TypeScript parser, no type checking), and parses the JSON body of acurl --datainbash/shblocks. Shell quoting is read the way the shell reads it, so'\''and'"'"'are handled. A body that expands a variable is skipped. A path that is not a.mdor.mdxfile, such as a mistyped one, exits 2 instead of checking nothing and passing, aslint:changelogdoes.Some conventions are deliberate, and the lint accepts them:
<placeholder>;...or…elisions;diffin the fence meta, where each side is checked;jsoncandjsonlblocks.A block that is partial on purpose opts out with
nolintin its fence meta. JSON errors point at the exact line, through a small validator, because V8 gives no position for an unexpected token. The contributor docs list the conventions.How it runs. A new Code blocks workflow runs the script on every PR, over the
.md/.mdxpages underapps/docs/src/{content,includes}that the PR changes. A PR that changes the script or the workflow itself checks every page instead, as the Changelog entries workflow does, so a change to the lint is always run in CI. It annotates each finding on its line and writes a table to the run Summary. A manual run (workflow_dispatch) checks every page.The workflow is advisory on purpose. A finding turns the check red, but it is not a required status check (the ruleset on
mainrequires only Design system adoption), so the PR author decides whether to fix the sample. It also stays out of the CI gate, whose workflow, scripts and baselines this PR does not touch.What it finds today. On
main(0d8178e94) it reports 16 findings in 12 of 2,298 files, 8 in each language:jsonin the Send Event Endpoint integration guide;jsonin the Data Stream payload page;jsonblock in the AI Inference troubleshooting reference;That is why the Code blocks check is red on this PR: it changes the script, so it checks every page and reports those 16. Fixing them is content work, so it goes in a separate PR, not this one.
Rebased onto
main. The Changelog entries PR addedlint:changelogon the same lines of bothpackage.jsonfiles,AGENTS.md,CONTRIBUTING.mdandGOVERNANCE.md. Each conflict keeps both sides, the changelog lines first. InGOVERNANCE.md, "it is not one of the three" became "it is not a ratchet", the wording of the Changelog entries paragraph that now sits before it.How I checked it
\"and'\''quoting,#inside quotes,--data @file) agreed.JSON.parseon 3,428 JSON texts from the corpus and on 5,080 random one-character mutations.maintakes about 22 seconds locally.count=all, a page-only PR (fix(opennext): migrate the OpenNext guide to the v4 azion.config.js format #2651) givescount=2, and a PR without pages (chore(lint): accept the use-case closing in lint-links #2632) takes the "no page changed" path.<path> is not a .md or .mdx file.eslint --max-warnings 0andprettier --checkpass on the changed files.nolintin its meta, rendered through@astrojs/markdown-remark, has no trace of the meta in the HTML.pnpm build:localpassed before the rebase. I did not run it again after the rebase; the CI Build job passed on the rebased head.Not verified: the per-page path (a PR that changes pages but not the script) has not run on GitHub; it was simulated locally only.
workflow_dispatchonly becomes available once the file is onmain.Type of change
feat)fix) — typo, broken link, wrong informationdocs) — rewrite, expansion, upkeepi18n)refactor/chore) — reviewed by UXE, no content mixed inAuthor checklist
type(scope): summary(see GOVERNANCE.md §4)title,description,meta_tags,namespace,permalink,last_reviewed— no page is added or changedAGENTS.md, points to.github/CONTRIBUTING.md#code-samplespt-brupdated in this PR or follow-upi18nissue created: — no page text changed; the lint coversenandpt-brpages alikepnpm build:local(build + frontmatter check) without errors — it passed before the rebase ontomain; not rerun since, though the CI Build job passed on the rebased head