Skip to content

feat(check): catch twelve more template mistakes before the app runs (#207) - #229

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

JuroOravec merged 5 commits into
mainfrom
fix/static-checks-207

Conversation

@JuroOravec

Copy link
Copy Markdown
Member

Part of #207. Moves twelve mistakes that the error-prevention benchmark found Citry missing, or reporting only when the page runs, into citry check and the editor. These are the rules that need no information beyond the template itself. The rules that need the loaded app come in a follow-up PR, and the larger designs are proposals waiting for review.

New and extended rules

Mistake Example Code Default
Misspelled attribute <div titel="x"> citry.template.misspelled-attribute error
Misspelled element <dvi> citry.template.misspelled-element error
Unknown ARIA name :aria-expandd="open" citry.template.unknown-aria-attribute error
Block element inside <p> <p><div>…</div></p> citry.template.invalid-nesting error
Same id twice two <div id="board"> citry.template.duplicate-id error
<img> without alt <img src="a.png"> citry.template.missing-image-alt warning
v-model on an element that holds no value <form v-model="q"> citry.browser.invalid-model-target error
Misspelled DOM event <button @clik="…"> citry.vue.misspelled-event warning
Vue expression with a syntax error v-if="open &&" citry.vue.invalid-expression error
Misspelled v- directive <p v-iff="x"> citry.template.misspelled-directive (extended) error
Boolean attribute with a value disabled="false", disabled="true" citry.template.invalid-attribute-value (extended) error
Component event the child doesn't emit <c-Card @hdie="…"> citry.browser.undeclared-component-event (extended, now configurable) warning

Each rule has a rule_* setting in LintSettings and in a component's Lint class.

How the rules avoid false matches:

  • Misspelled names: the attribute, element and DOM-event rules report only names one typing slip from a real name: two neighbouring letters swapped, one letter doubled, or one dropped.
  • ARIA names: every unknown aria-* name is reported, because authors can't invent new ones.
  • Boolean attributes: these follow the HTML standard. The value must be empty or the attribute's own name.
  • Data tables: HTML, SVG, obsolete elements, ARIA names, boolean attributes and DOM events are generated from the standards by scripts/generate_html_attribute_values.py.

Evidence

  • Benchmark cases: each of the twelve gives exactly one finding in both citry check and citry check --types. Eleven also show up in --static; the component-event rule needs the app.
  • False matches: none across the repository's 1,078 templates. In the docs' code blocks, only the intentional "wrong" examples match.
  • Python checks: the citry and citry_lsp test suites pass (7,870 tests), and ruff and mypy pass, including mypy with --platform linux.
  • Rust checks: the Rust phases of the local gate couldn't run in this worktree because a git submodule wasn't checked out. No Rust changed; CI runs them.

Release note

citry-lsp declares citry>=0.6.0 but needs the new names, so its minimum citry version must be raised at release. The same was already true on main.

🤖 Generated with Claude Code

JuroOravec and others added 5 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]>
@JuroOravec
JuroOravec changed the base branch from main to benchmarks/errors-shared-value October 21, 2026 10:53
@JuroOravec
JuroOravec added this pull request to stack #219 October 21, 2026 10:53
Base automatically changed from benchmarks/errors-shared-value to main October 21, 2026 10:58
@JuroOravec
JuroOravec merged commit 38bebd7 into main Oct 21, 2026
30 checks passed
@JuroOravec
JuroOravec deleted the fix/static-checks-207 branch October 21, 2026 13:31
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