[2.0.0-alpha3] Component validator: validate definition and more rules

Created on 27 June 2024, 2 months ago
Updated 3 July 2024, 2 months ago

Problem/Motivation

Follow up πŸ“Œ [2.0.0-alpha3] Compoennt validator: some changes and additions Fixed

Definition rules

Note: SDC already has a JSON schema to validate component definitions, maybe we can extend this one and trigger the validation instead of doing a specific mechanism.

Twig rules

Methods

When checking the callables, check also the methods. Example: 'media--type-' ~ media.bundle()|clean_class,. They are all forbidden except the ones
from Attribute.php -> OK

Other rules

  • Loop.parent
    • [Error] Breaking the flow. Bad performance -> OK
  • No {% if slot %}{{ slot }} {% endif %} => {{ slot }}
    • [Warning] -> KO, hard to detect
  • Typing of filters & nodes & arguments filters: when applied directly (according to the component definition)

    For example is used as argument or with filter or function...
    • [Error] ->Seems very complex, already checked by Twig for types, need more use case of examples.
  • No chained ternary:
    {% set variable = condition ? value_1 : condition_2 ? value_2 : default %}
    • [Error] -> OK
  • β€œ|default(expression)” filter instead of shorthand ternary β€œ?: default”
    • [Warning] -> OK
  • Ternary test with result bool
    {% set is_button = item.url == 'route:<front>' ? true : false %}
    • [Notice] -> OK
πŸ“Œ Task
Status

Fixed

Version

2.0

Component

UI Patterns Devel [2.x only]

Created by

πŸ‡«πŸ‡·France mogtofu33

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024