Skip to content

feat(check): typed emits, citry.Secret, development-only page checks, CSS class rules (#207) - #242

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

JuroOravec merged 21 commits into
mainfrom
fix/static-checks-207-more

Conversation

@JuroOravec

Copy link
Copy Markdown
Member

Part of #207. It implements the maintainer's decisions on items 8 and 11 to 14 in docs/design/issue_207_proposals.md, plus two new opt-in CSS rules.

What changes

  • Item 8, typed emits (m30, m60):
    • The props-and-events guide has a new "Catch payload mistakes" section on typed emits.
    • In the TypeScript check, a method listener on a component tag, such as @hide="hideCard", is compared with the child's emit payload.
  • Item 11, citry.Secret[T] (m42): a new public marker type.
    • You read the value with get_secret_value(). It shows as *** as text, and comparing two secrets takes constant time.
    • Rendering refuses it in js_data(), css_data() and State, with an error naming the component and the key.
    • A cached component can't take a Secret input, and a secret is never part of the cache key.
    • citry.js-data.unsupported-type reports it before the app runs.
    • New docs sections: "Keep tokens off the page" and "Keep secrets server-side".
  • 12a: the runtime errors for a missing or duplicate #c-key now name the right template and line, including template files and slot fills.
  • 12b: when Vue's compiler fails on v-model, the render error now names the element, the template and the line.
  • 12c, development mode only (m14): after the first mount, a browser check compares the server's HTML with Vue's first render. On a difference it logs a console warning naming the component, the element and the first difference. Production pages don't load it.
  • 12d, development mode only (m57): each page logs one warning listing every id used twice, with the components and template files involved.
  • 13, rule_misspelled_css_class: a warning, in citry check with the app loaded. It reports a static class one typo away from a class in the component's own CSS that no registered component's CSS declares.
  • New, both off by default:
    • rule_undeclared_css_class: reports every class no CSS Citry reads declares. Citry reads component css and css_file, local Dependencies stylesheets and template <style> elements.
    • rule_undeclared_css_variable: reports every var(--x) with no fallback that nothing declares or sets. That includes css_data() keys and --x strings in templates, JavaScript and Python.
    • Stylesheets linked by URL aren't read, which is why both rules are opt-in.
  • 14c: CLAUDE.md and docs/agent/INDEX.md now list all six Python binding submodules. 14a and 14b were already on main.
  • Proposals document:
    • The decisions table covers items 8 to 14. Items 9 and 10 wait for the plan's approval.
    • A new section 15 proposes a check for inject() keys that no ancestor provides (m50), for the maintainer to decide.

Wheel size

The wheel is 1,360,663 bytes, so the cap moves from 1,320 to 1,344 KiB (commit 427e9a9a0). Revert that commit if you'd rather shrink the wheel, for example by minifying dev_checks.js.

Evidence

  • Local checks: the fast gate is clean apart from the three Rust phases, which couldn't run because a git submodule wasn't checked out in this worktree; no Rust changed. The docs build check reports 0 errors. mypy is clean, including with --platform linux.
  • False findings: the on-by-default CSS rule reports nothing on any example app, the benchmark app, citry_ui or the docs site.
  • Reviews: three independent reviewers (the check and citry.Secret, the runtime and editor changes, and a separate prose pass), then a re-review of the fixes.

Known limits

  • The three CSS rules run only in citry check with the app loaded, not in the editor.
  • A secret held in a plain string is still not detected.
  • The benchmark cases for m14, m30, m42, m57 and m60 won't change. They use a plain-string token, array-form emits, an untyped handler, and production mode.
  • The Rust parser's own #c-key clash message still has the old wording; Rust couldn't be built here.

🤖 Generated with Claude Code

JuroOravec and others added 14 commits October 21, 2026 20:00
CLAUDE.md and the agent index named only template_parser, safe_eval and
html_transform (plus i18n in the index); lib.rs also registers vue and
template_formatter.

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

Section 5.1 already says written arguments replace the form's fields; the
component-tag section still described a merge that the browser runtime
does not do (both paths go through declarativeEventArgs in _vue/client.js).

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

A listener written as a bare method name, such as @hide="hideCard", is
now passed to a generated function typed from the child's emits, so tsc
compares the method's parameters with the payload (m60). The props and
events guide documents typed emits, which also report a wrong payload at
the child's $emit call (m30).

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

12a: the missing and duplicate #c-key messages now give the template and
line for inline templates, template files, slot fills and template-valued
attributes, include the repeated value, and explain nested loops; the
element-key conflict shares one message with the parser's wording.

12b: when the Vue compiler reports MODEL_HELPER_MISMATCH, the render
searches the authored templates the Vue template came from with the
invalid-model-target rule and names each element, its template and line.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A Secret[T] wraps a server-only value such as an API token. Its text form
is ***, so a template never shows it; js_data(), css_data() and State
refuse it with an error naming the component and key path; and the
citry.js-data.unsupported-type rule reports it statically (annotations,
module constants, also nested in literals, and values ty types as Secret).
The component options and security guides explain how to keep tokens off
the page (m42).

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

citry.css.misspelled-class (rule_misspelled_css_class, a warning) reports
a static class one slip from a class selector in the component's own CSS
that no CSS Citry reads declares (m16). citry.css.undeclared-class and
citry.css.undeclared-variable are off by default ("ignore", which the
diagnostics schema now allows with a configurable severity) and report
every class no CSS Citry reads declares and every var(--x) without a
fallback that nothing sets. All three run in citry check with the app
loaded. _css_scan.py is the one reader of selectors and custom property
declarations.

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

12c: with Citry(mode="development"), a hydrating page inlines
_vue/dev_checks.js, and the runtime compares each shell's served HTML with
Vue's first render and logs a console warning naming the component, the
element, the first difference, and the data-allow-mismatch value that
silences it (m14). Production pages carry no flag and no script.

12d: in development mode, serialization collects each component's own ids
and issues one RuntimeWarning per page listing every id two components (or
two renders of one) wrote, with the components and template files (m57).

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

The decisions table records what was built for items 8, 11, 12a-12d, 13,
the two off-by-default CSS rules, and 14. Section 15 proposes a check for
an inject() key no ancestor provides (m50) for the maintainer to decide.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
CSS rules: the misspelled-class rule no longer reports a missing final
d/r/n of a word family or a slip in a short first hyphen part (p-4/px-4),
reads other components' stylesheets only when a class is one slip from
the component's own CSS, and the variable messages say the property gets
its initial or inherited value.

Secret: constant-time equality for text and bytes; css_data() refuses a
Secret even without CSS; a Secret in a cache key gets its own error and is
never hashed into the key; citry check also follows attributes, *, both
branches of a conditional and Const(); the js-data warning has a Secret
message in citry check and the editor; the State error names the class.

Development checks: same-tag v-if/v-else branches are paired by their
whole subtree within a budget, so a correct page no longer warns; the
script is read once; warnings from the repeated-id, CSP and JavaScript
policy checks point at the caller's code (_caller_warnings.py).

Render errors: an element-key clash names its template, line and column;
the v-model search reads template-valued attributes. Prose fixes across
the docs, docstrings, messages, changelogs and design docs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Development checks: an agreeing pair outranks any number of differing
pairs, a branch rejected only by the quick text check gets a full
comparison while budget remains, and the budget now charges the text
search (raised to 200,000 steps). Caller warnings work through a
symlinked import path and document the Events response case.

CSS rule: the final d/r/n exclusion covers only listed UI words
(collapse, disable, show, toggle, ...), the short-first-part exclusion
covers only a doubled or dropped letter, and a word already ending in s
is not excused, so heade, iu-button and progres are reported again.

Secret: the static walk reads attributes without running user code,
judges only built-in values, survives deep nesting and skips a value a
property shadows; equality treats str and bytes subclasses as text;
css_data() refuses a nested Secret with or without CSS; the js-data
message says a field can hold a Secret. Prose fixes in the docs,
changelogs and design docs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The CSS checks, citry.Secret, and the development-mode browser check
(_vue/dev_checks.js) grow the wheel to 1,360,663 bytes, 9 KB over the cap
the earlier #207 batch set. The cap moves to 1,344 KiB, about 15 KB of
headroom.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
On Python 3.10, types.SimpleNamespace lists its own C __getattribute__ in its
class namespace, so the js_data() Secret check took it for a hook that might
run code and left SETTINGS.auth.token unchecked. It runs no user code, so it
joins object, type and ModuleType.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
pytest puts a test's id in the PYTEST_CURRENT_TEST environment variable, and
the deeply nested @media case made it longer than the 32,767 characters
Windows allows.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@JuroOravec
JuroOravec changed the base branch from main to benchmarks/errors-citry-unreleased October 22, 2026 07:20
@JuroOravec
JuroOravec added this pull request to stack #219 October 22, 2026 07:20
Base automatically changed from benchmarks/errors-citry-unreleased to main October 22, 2026 07:26
# Conflicts:
#	benchmarks/errors/frameworks/citry/framework.toml
#	docs/design/vue.md
JuroOravec and others added 6 commits October 22, 2026 11:45
Give hot reload and development mode their own guides: /guides/hot-reload/
covers file reloading only, and /guides/development-mode/ covers
Citry(mode="development") and what it turns on. /guides/dev-server/ now
redirects to the hot reload page, and every link points at the new pages.

On the pages this branch touched, move typing, linting, and error detail
out of the main flow into one section near the end of each page:
"Keep tokens off the page" now sits before "Check JS code" on Component
options, and Props and events gains "Catch mistakes early". The full list
of rules for method listeners moves to the VS Code page, and the CSS
class rule details move to the template linting page's less common cases.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@JuroOravec
JuroOravec merged commit 6b1db5e into main Oct 22, 2026
8 checks passed
JuroOravec added a commit that referenced this pull request Oct 22, 2026
@JuroOravec
JuroOravec deleted the fix/static-checks-207-more branch October 22, 2026 10:19
@JuroOravec
JuroOravec restored the fix/static-checks-207-more branch October 22, 2026 10:19
@JuroOravec
JuroOravec deleted the fix/static-checks-207-more branch October 22, 2026 10:24
JuroOravec added a commit that referenced this pull request Oct 22, 2026
Main brought two checks whose findings carry ranges: the CSS class rules
(#242) and the unknown inject key rule (#243). Both already counted from
0 in UTF-16 units through `_byte_offset_coordinates`, but neither said
which text it counts in, so the report rejected them. The CSS class
findings are now built with `_ranged_finding` from their template source,
and the inject key findings are marked as counting in the component's
Python file. Their tests now also check `source_kind`; no expected
position changed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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