Repository navigation
feat(mcp): add a lint-templates agent tool - #415
Merged
Merged
Conversation
It parses every component template with the project's own @angular/compiler and reports parse errors, track $index on object lists, images without alt, click handlers without a key handler, legacy structural directives and ngClass or ngStyle bindings. Refs #372.
Contributor
|
View your CI Pipeline Execution ↗ for commit ff7f891
💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗ ☁️ Nx Cloud last updated this comment at |
🚀 Deploying Preview to Cloudflare 🚀Preview Deployments by commit
|
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 and why
The "template diagnostics lint-templates tool" item from #372.
pangular:lint-templatesparses every component template in the project (inlinetemplateandtemplateUrlfiles) and reports problems, in the same finding format aslint-pipes.template-parse-error@forwithouttrackincludedtrack-by-indextrack $index(or an alias of it) on a loop whose body reads a field of the item; form-array rows bound by index are exemptimg-missing-alt<img>withoutalt,[alt]or[attr.alt], unless hidden or presentationalclick-without-key(click)on a non-interactive native element with no key handler, unless hidden or presentationallegacy-control-flow*ngIf,*ngFor,*ngSwitchCase,*ngSwitchDefault(Angular 17+ only)ngclass-ngstyle[ngClass]or[ngStyle]@angular/compiler(resolved from the project'spackage.json) and walks the same AST Angular compiles, so there are no regexes and no new dependency. Without a compiler the answer says so. A failed load is not cached.templatesIn,sourceRootsandwalkFilesfrom the pipes scan. Escapes in quoted inline templates keep their length, so line numbers match the file; a backtick template with${}is skipped.rule,file(path substring),severity,limit(default 50, max 200). Unknown rules or severities are rejected.redactText.components, not page-bound, so the stdio server keeps it.On the demo app's 31 templates it reports nothing and takes about 200 ms.
Left out
auditaggregation and has no panel RPC yet.Docs: a
lint-templatessection inagents/tools.md(tool count, arguments and rules),inspectors/components.md, the structured-output table inagents/mcp-server.md,security.mdnext tolint-pipes, and a row in the shippedpangular-inspectorskill.Refs #372.
How it was verified
pnpm commit:checkpnpm format:checkpnpm typecheckpnpm test:devtools(3168). Newtemplate-lint.test.ts(27 tests) with the workspace's real compiler: parse errors with correct lines (inline,templateUrl, escaped quotes,${}skipped); positive and negative cases for each rule; rules inside nested blocks; the legacy rule off below Angular 17; the no-compiler answer; the cache (no re-parse, re-parse after an edit, finding gone after a fix); filters, unknown arguments,limitand the tool handler.pnpm skills:checkapps/docsupdated andpnpm docs:buildpassesapp, so noextension:buildSummary by CodeRabbit
New Features
Documentation