Skip to content

Schema rejects styleguide:, so a fixture-less component cannot have a definition #49

Description

@parisek

What happens

parisek/styleguide's ComponentParser decides whether a component is renderable from three signals: a styleguide.twig, any named variant sibling, or an explicit styleguide: true in the component metadata (ComponentParser.php:220 and :289). The third exists for components that render themselves globally and ship no fixture of their own.

schemas/component.fields.schema.json does not list styleguide among its root properties and sets additionalProperties: false, so the key cannot be carried in a <name>.yaml.

The same parser is YAML-first: once <name>.yaml exists it becomes the metadata source and the twig front-comment stops being read entirely. So for a component whose only catalogue claim is styleguide: true, authoring a definition silently drops it out of the catalogue — and with it, any visual or behaviour coverage keyed off the catalogue entry.

Nothing errors in either direction, which is what makes it worth reporting.

Reproduction

On a parisek/styleguide consumer, take a component that has no styleguide.twig and carries styleguide: true in its twig front-comment (ours is a cookie-consent bar — global chrome, renders itself, no fixture).

  1. vendor/bin/fields-migrate path/to/component/<name> — succeeds, reports OK. The styleguide key is dropped, since the schema has no slot for it.
  2. Run the catalogue audit — the component now appears in the "no fixture, nothing renders it" list.
  3. Delete the sidecar — it moves back out.
  4. Try to keep the key by hand-adding styleguide: true to the YAML — fields-validate rejects it on additionalProperties.

There is no state in which the component has both a definition and its catalogue entry.

Suggested fix

Add styleguide (boolean) to the schema's root properties. It is metadata the styleguide package already consumes, and it projects into neither acf.json nor block.json, so it is inert for every generator and lint downstream.

The general rule behind the specific fix, which may be worth checking more broadly than this one key: every root key ComponentParser reads has to be expressible in a definition, or the two metadata formats are not interchangeable — and the YAML-first precedence already treats them as if they were. styleguide is the one we hit; it may not be the only one.

Downstream state

We are backfilling YAML sidecars across the whole component set. Every Basic-category component now has one except this cookie bar, which is deliberately left on the twig front-comment fallback until this is resolved.

We are separately considering whether the right answer on our side is to author a real styleguide.twig fixture for it, which would remove the need for the key entirely for us. That is not an argument against the schema gap — a component that legitimately has no fixture still cannot have a definition today — but it does mean this is not blocking us.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions