Skip to content

fix: catch more template mistakes in citry check - #206

Merged
JuroOravec merged 5 commits into
mainfrom
fix/check-catches-more
Oct 20, 2026
Merged

JuroOravec merged 5 commits into
mainfrom
fix/check-catches-more

Conversation

@JuroOravec

Copy link
Copy Markdown
Member

Fixes #202. Closes three of the gaps the error-prevention benchmark (#205, #158) found in Citry's checks.

Before the next release: the new citry-lsp imports the new rule from citry.analysis, so it fails against citry 0.6.0. Raise the citry pin in packages/py/citry_lsp/pyproject.toml, MINIMUM_CITRY_VERSION, scripts/verify_citry_lsp_distribution.py and uv.lock together once the next citry version is chosen. No CI job tests the lowest supported citry, so CI will not catch this.

Changes

  • Template type checks run without template_data() (citry check --types skips template type checks when a component has no template_data() #202). The generated file that ty checks now sits next to the component's own source file. ty used to skip it when it landed in site-packages, an in-project .venv, or an editable install. This covers citry check --types, the editor, and the js_data() type inference.
  • citry.template.invalid-attribute-value is an error by default, so citry check fails on <button type="sumbit">. It stays a warning in --static mode and in an editor without the app, where the per-component override cannot apply.
  • New rule citry.template.misspelled-directive (error by default) reports a c-* attribute that looks like a misspelled directive, such as c-iff, c-If, c-else-if or c-model. Real HTML attribute names (c-id, c-form, c-kind on <track>) never trigger it, because the rule checks against the HTML Standard's attribute index. On custom elements it reports only clear typos. TemplateLintInfo.from_dict fills in the default when the new key is missing.

Rule docs, the diagnostics catalog, the design docs, and the citry, citry-lsp and citry-core changelogs are updated.

Checks

  • citry and citry_lsp test suites: 7,633 passed. docs_site tests: 1,038 passed.
  • scripts/check.py fast profile: status: PASSED.
  • mypy, including --platform linux: pass.
  • An independent reviewer with a separate prose pass, plus a docs cold read. Their findings are folded into the last commit.

Open decisions

  • When the app is not loaded, invalid attribute values give a warning and misspelled directives give an error. The reviewer suggested one shared rule for both.
  • <form autocomplete="nope">, a common workaround for Chrome autofill, is now an error.

Known gap, not caused by this PR

The editor and --types find no inline template on a class with a mixin or an imported component base, such as class G(Base, Component), so nothing in it is checked.

🤖 Generated with Claude Code

JuroOravec and others added 4 commits October 20, 2026 11:34
`citry.template.invalid-attribute-value` now defaults to "error" when the
component is known, so `citry check` fails on `<button type="sumbit">`.
`citry check --static` and an editor without the application keep a
warning, because no component's `Lint` "ignore" can reach them there.

A new test ties each catalog `defaultSeverity` to the `LintSettings` and
`TemplateLintInfo` defaults, so the copies cannot drift apart.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
ty reports findings only for its own project files, and the generated
Python file it checks sat next to the module it copied. A component with
no template_data() copies Citry's base class, and an inherited base can
live in site-packages, an editable install, or an in-project .venv, so
those template checks came back empty.

The generated file now sits next to the consuming component's own file
(its template file as a fallback) for the CLI check, the editor, and the
js_data() inference. js_data() inherited from a base outside the
workspace is now inferred too, and `citry check --types` skips component
files under a virtual environment or site-packages inside the workspace.

Fixes #202.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Citry renders any c-* name that is not a directive as an attribute, so
`<div c-iff="show">` rendered `<div iff>` with no message. The new lint
rule `citry.template.misspelled-directive` (error by default, setting
`rule_misspelled_directive`) reports a c-* name on an HTML element,
custom element, or <c-element> that is not an HTML attribute of that
element and is one edit from if/elif/else/for/empty/bind, the same name in
other letter case, a spelled-out elif, or a Vue or #c-* name with the
wrong prefix. `citry check`, `--static`, and the editor share the rule in
analysis.py; the parser and grammar do not change.

The HTML attribute names come from the WHATWG index:
scripts/generate_html_attribute_values.py now also writes
GLOBAL_ATTRIBUTES, ELEMENT_ATTRIBUTES, and CUSTOM_ELEMENT_ATTRIBUTES, so
c-id, c-form on <input>, and c-kind on <track> never trigger it. The
enumerated value table is unchanged by the refresh.

TemplateLintInfo.from_dict fills a missing rule_misspelled_directive with
its default, so a lint record from an older citry app worker still loads.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- misspelled-directive: on a custom element, which can define its own
  attributes such as `kind`, report only clear typos (an added, dropped,
  or swapped letter, other letter case, a spelled-out elif); suggest
  `c-if` for `c-show`, and stop suggesting `v-html` for `c-html`.
- invalid-attribute-value: accept `wrap="off"` on <textarea>, which every
  major browser supports.
- Move `rule_misspelled_directive` to the end of LintSettings so
  positional fields keep their places.
- js_data() inference checks for a duplicate request before it looks at
  the folders on disk.
- Docs, catalog text, docstrings, and changelogs: say which names are
  reported, explain the no-app severities and the `c-bind` way out, note
  that `c-for` is always the loop, update the `check --static` summary,
  and narrow the citry-lsp entry to what the fix covers.

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

Without a loaded application (`citry check --static`, and the editor
before the app loads), each component's own `Lint` class is now read
from its source with `ast`. A rule set to a string literal applies; a
rule the component does not set, or sets to a value the source does not
show, keeps its no-application severity. `Lint` inherited from a
component class in the same file applies nearest first, `Lint = None`
drops it, and a same-file subclass that keeps its base's template is an
extra owner, so the strictest severity wins. The values reach callers as
`PythonTemplateRegion.owner_lint` (new public `ComponentSourceLint`).

`citry.template.misspelled-directive` no longer treats a replaced
letter or a non-doubled added letter as a typo, so `c-kind`, `c-elsa`,
`c-form`, and `c-four` pass. Swapped, doubled, and missing letters,
case changes, spelled-out elif, and the c-show/c-model/c-key/c-ignore
names are still reported; a missing letter that leaves a one-letter
name or the word `or`, `bid`, or `bin` is not.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@JuroOravec
JuroOravec merged commit ad9e681 into main Oct 20, 2026
29 checks passed
@JuroOravec
JuroOravec deleted the fix/check-catches-more branch October 20, 2026 16:56
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.

citry check --types skips template type checks when a component has no template_data()

1 participant