alpinejs-devtools icon indicating copy to clipboard operation
alpinejs-devtools copied to clipboard

Markup warnings/lint

Open HugoDF opened this issue 4 years ago • 2 comments
trafficstars

Additional things we can write our own "warning" for (see https://github.com/alpinejs/alpine/discussions/975)

  • x-init on an element without x-data (v2)
  • Alpine directives outside of x-data
  • Alpine is loaded but there is no x-data on the page
  • an alpine directive is being used on an element that doesn't have x-data and has no element with x-data in its ancestors
  • x-if/x-for on a non-template element
  • template with more than 1 child node

We need to have a think about how to highlight template's that have issues (they're visually hidden... maybe having warnings is enough).

Originally posted by @HugoDF in https://github.com/alpine-collective/alpinejs-devtools/issues/126#issuecomment-757334781

HugoDF avatar Jan 09 '21 17:01 HugoDF

x-for requires a non-template child (whereas x-if does not require this)

There are only three valid templates (these, and only these, attributes may appear)

1. x-if
2. x-for
3. x-for :key

markfirmware avatar Jan 18 '21 19:01 markfirmware

Maybe relevant discussion for a warning https://github.com/alpinejs/alpine/discussions/1038

HugoDF avatar Jan 26 '21 10:01 HugoDF