Repository navigation
feat(events): check form fields and event arguments in the editor; same form handling with and without JS (#207) - #231
Merged
Conversation
…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]>
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]>
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() binds 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]>
…#207) A form that calls a server event can keep Django's hidden csrfmiddlewaretoken input inside it. The dispatcher removes the names in extensions_defaults["events"]["_csrf_field_names"] (default csrfmiddlewaretoken) from a call's args before it checks the data class, on the JavaScript and the no-JavaScript paths alike, unless the class declares the name. The setting is engine-wide like _max_envelope_bytes and is checked when the engine is built. Also commits the #207 proposals and the maintainer's decisions as the design record for this work. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…t JavaScript (#207) The browser now sends a form's controls as text and marks the call with argsSource: "form", a new optional field of the citry-events/1 call record (changed in place, still version 1). The dispatcher builds marked args as StringArgs, so "3" fills an int field and a checked checkbox a bool field, exactly as the no-JS form codec does. A call without the mark, from page code, an API client, or older browser code, stays strict JSON. The spec, schema, Python and TypeScript protocol code, conformance cases, and the constraint registry change together; the shipped Python copy and the browser bundles are regenerated. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… once the app loads (#207) With the application loaded, the editor and citry check --types now read the component catalog's owner_file and owner_qualname for each inline template, JavaScript, and CSS, and pass the module-level class names to static discovery as app_components. Discovery accepts those classes even though their base class is not traceable from the file, so their templates get every check. The app worker also says whether each component renders its template as Citry's own template language, so a template in another language is never parsed as Citry. Without the app, or for a class added or renamed since it loaded, the template-not-checked notice stays, now saying the template is checked once Citry loads the application and finds the class. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…or too (#207) The Events handler description (Citry.inspect_components, events.md 9.1) now carries extra_fields, which says whether an argument key the data class does not declare fails the call, and validated_by, which says whether Citry's own rules or Pydantic check the values. The editor builds what each handler accepts from it and runs the same @c-* argument rules as citry check, skipping a Pydantic model, a description from an older Citry, and a handler whose method or data class has unsaved edits. A new rule pair checks a form whose @c-submit sends its fields: a control whose name the data class does not declare (citry.browser.unknown-form-field), and, when the template shows every control, a required field no control sends (citry.browser.missing-form-field). Disabled controls, controls tied to another form, buttons, file inputs, and the host CSRF field names the server removes are skipped. Both rules have rule_* settings and run in citry check with the app loaded and in the editor. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- The browser now sends the name and value of the submit button that sent a form, as a post without JavaScript does, and the form-field rule checks a named submit button; an image input, a #c-ignore region, and a bound attribute with a modifier such as :name.prop are handled. - The editor compares a handler's data class with its file on disk using the location the app worker now sends, reads saved files without newline translation, so a file with CRLF line endings is checked, and caches the saved text and parsed definitions between passes. - A Pydantic validation_alias counts as declaring a host CSRF field name. - A class the loaded app lists is read even when it is decorated. - The spec, design docs, user docs, catalog texts, settings docstrings, and changelogs now say what the code does: the form and query adapters bind text, a bad argsSource rejects the envelope, text binds at any depth, a misspelled control fails only the submits that send it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- The editor treats a data class file that no buffer holds as the file the app read, so a closed file with CRLF line endings keeps the rules on. - The form-field rule checks the x and y names an image button sends instead of its bare name, skips a button whose click is prevented, and reads Vue's ^name and .name shorthands as bindings. - A decorated class the loaded app lists is read even when its base is Citry's own Component. - The docs, spec, and catalog say how image buttons behave. Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # CHANGELOG.md # docs/design/events.md # docs/design/ide_integration.md # docs_site/content/ide/template-linting.md # packages/protocol/diagnostics/CHANGELOG.md # packages/protocol/diagnostics/v1/catalog.json # packages/py/citry/citry/_checker.py # packages/py/citry/citry/_diagnostic_catalog.py # packages/py/citry/citry/_linting.py # packages/py/citry/citry/_registry_lint.py # packages/py/citry/citry/analysis.py # packages/py/citry/citry/ext/events/schemas.py # packages/py/citry/citry/settings.py # packages/py/citry/tests/test_analysis.py # packages/py/citry/tests/test_check_app_rules.py # packages/py/citry/tests/test_diagnostics.py # packages/py/citry_lsp/CHANGELOG.md # packages/py/citry_lsp/citry_lsp/engine.py # packages/py/citry_lsp/tests/test_engine.py
… as a link Co-Authored-By: Claude Opus 5.5 <[email protected]>
… config does The root config targets Python 3.10, which has no tomllib, so ruff groups it with third-party imports, as the other benchmark tests already do. main has the same failure; #232 carries the identical fix. Co-Authored-By: Claude Opus 5.5 <[email protected]>
12 tasks
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.
Part of #207, stacked on #230. It implements the proposals approved in
docs/design/issue_207_proposals.md, which this PR also adds as the design record for #207.What changes
citry check --typesaccept the classes the app registers in a file, so those templates get checked too (proposal 1, Option 2). If the app can't load, or a class changed since it loaded, the notice from feat(check): catch app-level mistakes before the app runs (#207) #230 stays.Citry.inspect_components,events.md§9.1):extra_fields("reject"or"ignore");validated_by("citry"or"pydantic"). A Pydantic model withextra="forbid"still converts values and reads aliases, whichextra_fieldsalone can't express.csrfmiddlewaretokenhidden input can stay inside the form, and posts with and without JavaScript both work.extensions_defaults["events"]["_csrf_field_names"]; the default iscsrfmiddlewaretoken.argsSource: "form", a new optional field incitry-events/1, changed in place. The server then applies the same text conversion as for a form posted without JavaScript.event.argsdirectly, or a strict Pydantic model, now gets"3"where it used to get3. The changelog says so.citry.browser.unknown-form-field(error) andcitry.browser.missing-form-field. They compare a form's static control names with the handler's data class. Both run incitry checkwith the app loaded and in the editor. They handle named submit buttons, image buttons, spreads and#c-ignore.Evidence
🤖 Generated with Claude Code