Repository navigation
fix: catch more template mistakes in citry check - #206
Merged
Merged
Conversation
`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]>
12 tasks
…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]>
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.
Fixes #202. Closes three of the gaps the error-prevention benchmark (#205, #158) found in Citry's checks.
Changes
template_data()(citry check --typesskips template type checks when a component has notemplate_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 coverscitry check --types, the editor, and thejs_data()type inference.citry.template.invalid-attribute-valueis an error by default, socitry checkfails on<button type="sumbit">. It stays a warning in--staticmode and in an editor without the app, where the per-component override cannot apply.citry.template.misspelled-directive(error by default) reports ac-*attribute that looks like a misspelled directive, such asc-iff,c-If,c-else-iforc-model. Real HTML attribute names (c-id,c-form,c-kindon<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_dictfills 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
scripts/check.pyfast profile:status: PASSED.--platform linux: pass.Open decisions
<form autocomplete="nope">, a common workaround for Chrome autofill, is now an error.Known gap, not caused by this PR
The editor and
--typesfind no inline template on a class with a mixin or an imported component base, such asclass G(Base, Component), so nothing in it is checked.🤖 Generated with Claude Code