Skip to content

feat(check): catch app-level mistakes before the app runs (#207) - #230

Merged
JuroOravec merged 14 commits into
mainfrom
fix/static-checks-207-app
Oct 21, 2026
Merged

JuroOravec merged 14 commits into
mainfrom
fix/static-checks-207-app

Conversation

@JuroOravec

Copy link
Copy Markdown
Member

Part of #207, stacked on #229; merge that first. It adds checks that need the loaded app (citry --app ... check), and two plain bug fixes.

New and extended rules

Mistake Example Code Default
Repeated component without #c-key <c-for each="c in cards"><c-Card .../></c-for> citry.browser.missing-component-key error
A component writes to its own prop @click="open = false", where open is a prop citry.browser.prop-assignment error in the template; at most a warning for writes in component JS
Unknown field in a server event payload save({amont: 1}) citry.browser.unknown-server-event-field error
Missing required field save({}) citry.browser.missing-server-event-field error
Wrong literal type save({amount: '1'}) citry.browser.incompatible-server-event-field error
Misspelled CSS variable from css_data() var(--acent) citry.css.misspelled-variable warning
Boolean prop given text :open="x ? 'open' : 'closed'" citry.browser.incompatible-component-prop (fixed) error
js_data() value JSON can't carry PurePosixPath(...) citry.js-data.unsupported-type (extended to the editor and --types) warning
Template not checked because the base class is in another module class Card(AppComponent) citry.check.template-not-checked information

Each new rule has a rule_* setting.

How the rules avoid wrong reports

  • Missing #c-key: the rule follows how the page is actually rendered. It fires only when the component or the repeated child uses Vue, and skips transparent and simple=True children, and children of a keyed component. The runtime error for a missing or duplicate key now names the tag, the template and the line.
  • Payload rules:
    • Values are checked with the server's own rules. A handler that also accepts GET is reported only if reading the value from the query string fails too.
    • Pydantic data classes are skipped.
    • A call with no arguments is skipped on a <form>, on any element that could contain a form, and for submit.
    • A template shared by components whose data classes differ is skipped.
  • Writes to props from component JS: the analyzer confirms the write targets the component itself, but the assignment is read from the text, so JS writes stay warnings.

Plain fixes

  • A Literal[...] field on an Events data class no longer fails at runtime with "Unsupported annotation". It validates, and the OpenAPI document lists its values.
  • docs/design/events.md §5.1 now describes what the runtime does: arguments written in @c-submit replace the form's fields, and the JSON path checks values strictly.

Evidence

  • Benchmark: all 16 cases for these mistakes are now reported. The other 46 ported cases give the same output as before.
  • False findings: none in docs_site (111 components), citry_ui (322 components), the 8 example apps, the clean benchmark app, or citry check --static over the whole repository.
  • Reviews: an independent code review found two rules that would have reported working code, both fixed. A separate prose pass followed.
  • Tests: ruff and mypy (including --platform linux) pass. The Python test suites pass; the last fix, which made the --types js_data() check fast enough for citry_ui, was re-tested on its own.

🤖 Generated with Claude Code

JuroOravec and others added 13 commits October 21, 2026 12:13
…M event tables

The template lint rules for #207 need more data from the standards than the
attribute index gave: which attributes are boolean, every WAI-ARIA 1.2 and
1.3 state and property, SVG and obsolete HTML element names, and the DOM
event names a listener may use. The generator now reads each from its
published source, with saved copies accepted for an offline refresh.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ver (#207)

citry check and the editor now report, from the template alone:
misspelled attributes, elements, and DOM events; unknown aria-* names;
block elements inside <p>; literal ids two elements always render; <img>
without alt (warning); v-model on an element that holds no value; and Vue
expressions that are not valid JavaScript. The misspelled-directive rule
now covers v-* names such as v-iff, the attribute-value rule reports a
boolean attribute with a value other than its own name, and the
component-listener rule reports lowercase names such as @hdie and gets a
rule_undeclared_component_event setting.

Each rule has a rule_* setting on LintSettings and on a component's Lint
class, and the template-only ones also run in citry check --static.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…mplate rules

From the independent review of the #207 rules: the Vue-only checks (v-*
directive typos, v-model targets, DOM event names) now skip v-pre content,
which Vue leaves as written; a whitespace-only Vue expression is reported;
obsolete block elements close a paragraph and <noscript> does not; <slot>
bindings are slot props; c-empty counts as a condition for duplicate ids; a
root <img> inside a top-level c-if chain counts as the single root; no
message suggests v-once or v-memo; a bound boolean string gets its own
message. The catalog text now matches the code, and the editor drops a
TypeScript error that repeats an invalid Vue expression.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Two separate top-level c-if blocks can both render, so neither image there
is the single root Vue passes a parent's alt to. Also correct the docs and
catalog wording the second review pass found.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A data class field annotated as Literal[...] failed every call with
"Unsupported annotation". It now accepts exactly the listed values, each
read by its own type's rule, and the OpenAPI document lists them as an
enum. The events design also now says what the runtime does with a form:
arguments written in @c-submit replace the form's fields instead of
joining them, and the JSON path checks values strictly.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…c-key

The render error for a component that a loop repeats without #c-key, or
with a duplicate key, said only "repeated component call". It now names
the tag as written, its template, and the line.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
)

With the application loaded, citry check now reports a component that
<c-for> repeats without #c-key on a page that uses Vue; a component that
assigns to its own Vue prop (the editor reports it too, and a write in
component JavaScript is at most a warning); @c-* arguments the server
would reject: an unknown key, a missing required field, or a literal of
the wrong type; and a var(--name) one typing slip from a css_data() key.
Each has a rule_* setting.

A Boolean Vue prop given a string other than '' or its own name is now
reported, and a condition whose two results are literals is typed as
either result. A js_data() module constant that JSON cannot carry is a
warning in citry check, and a value ty types as a standard non-JSON type,
such as PurePosixPath, is a warning in the editor and citry check
--types. citry check --static notes, and the editor marks, a template it
skips because the base class comes from another module.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
From the independent review of the #207 batch 2 rules: a component inside
a keyed component call needs no key of its own, an inner loop's c-empty
repeats with the outer loop, and a js_data() that the source shows always
returns {} does not make the page use Vue. A handler that accepts GET is
checked against its query-string reading too, only the last of two equal
keys is checked, and an Enum member in a Literal field matches its value
of any type. The --types command adds only the js_data() warnings that
need ty, and drops a repeat only at the same place in the same file. A
name js_data() imports or binds itself hides a module constant. The docs,
catalog, and changelogs now say what the code does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…a non-JSON type

citry check --types read every component once per file to find these
warnings, which made a large library's check run out of time. It now
searches only the files where ty typed a js_data() value as a type JSON
cannot carry.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The new template checks and their generated HTML and ARIA tables took the
wheel to 1,251,430 bytes, past the 1,220 KiB cap set at 1,188,823 bytes.
The cap is now 1,320 KiB, about 100 KB above the measured size.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts:
#	CHANGELOG.md
#	docs/design/ide_integration.md
#	docs_site/content/ide/template-linting.md
#	packages/protocol/diagnostics/CHANGELOG.md
#	packages/py/citry/citry/_checker.py
#	packages/py/citry/citry/_diagnostic_catalog.py
#	packages/py/citry/citry/_linting.py
#	packages/py/citry/citry/analysis.py
#	packages/py/citry/citry/settings.py
#	packages/py/citry/tests/test_diagnostics.py
#	packages/py/citry_lsp/CHANGELOG.md
#	packages/py/citry_lsp/citry_lsp/engine.py
Base automatically changed from fix/static-checks-207 to main October 21, 2026 13:31
@JuroOravec
JuroOravec merged commit b592203 into main Oct 21, 2026
25 of 26 checks passed
@JuroOravec
JuroOravec deleted the fix/static-checks-207-app branch October 21, 2026 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant