dictator-datastar
WASM decree for Dictator that lints Datastar HTML attributes.
Rules
| Rule | Description |
|---|---|
datastar/no-alpine-vue-attrs |
Disallows Alpine.js/Vue.js style attributes (x-*, v-*, @*, :*) |
datastar/require-value |
Requires values for expression-based attributes |
datastar/for-template |
Requires data-for on <template> elements |
datastar/typo |
Detects common typos (data-intersects → data-on-intersect) |
datastar/invalid-modifier |
Validates modifier syntax (__debounce.500ms, __once) |
datastar/action-syntax |
Validates @get(), @post() SSE action syntax |
Examples
Valid Datastar
Count:
Submit
Violations
<!-- datastar/no-alpine-vue-attrs -->
<!-- Use data-show -->
<!-- Use data-on:click -->
<!-- datastar/typo -->
<!-- Use data-on-intersect -->
<!-- Use data-on:click (colon, not hyphen) -->
<!-- datastar/for-template -->
<!-- Must be on <template> -->
<!-- datastar/action-syntax -->
<!-- Missing parentheses: @get('/path') -->
<!-- Empty URL not allowed -->
<!-- datastar/invalid-modifier -->
<!-- Unknown modifier -->
Attribute Order
This decree does not enforce attribute ordering. Datastar processes attributes in DOM order, and the order is semantic (dependency-based), not stylistic. For example:
<!-- Signal must be defined before it's used -->
<!-- Correct -->
<!-- Also valid if foo exists elsewhere -->
The correct order depends on your specific use case and signal dependencies.
Building
Requires Rust with wasm32-wasip2 target:
Testing
Configuration
All rules are enabled by default. The decree uses DatastarConfig internally:
DatastarConfig
Supported Modifiers
Event modifiers (data-on:*)
__once, __passive, __capture, __debounce, __throttle, __delay, __window, __outside, __prevent, __stop, __viewtransition
Intersect modifiers (data-on-intersect)
__once, __half, __full, __threshold
Persist modifiers (data-persist)
__session
Init modifiers (data-init)
__delay, __viewtransition
Case modifiers (many attributes)
__case.camel, __case.kebab, __case.snake, __case.pascal
License
MIT