Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for Valid Block Targeting #561

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Conversation

navdeep5
Copy link

@navdeep5 navdeep5 commented Nov 5, 2024

What are you adding in this PR?

Resolves #554 and #555

This PR introduces enhanced validation checks for theme blocks, combining two main functionalities:

  1. Soft Validation of Nested Blocks

    • Validates that block types referenced in presets adhere to the following criteria:
      • Must be explicitly declared in the root-level blocks array OR
      • The @theme block type must be declared at the root level (exceptions: private blocks)
        image
    • Private blocks (prefixed with _) must always be explicitly declared at the root level.
      image
  2. File Existence Check

    • After the soft validation, the PR ensures that all block type files exist.
      image

We are combining these checks into one as they are both responsible for ensuring we have "valid block targets" and it also decreases the number of I/Os required.

What's next? Any followup issues?

With this being a new check, we will want to update https://github.com/Shopify/shopify-dev so users can understand their errors. Developer Docs changes: https://github.com/Shopify/shopify-dev/pull/50568

What did you learn?

This is my first time contributing to this repo so there was a lot to learn in general. However, something that I think will be useful for following checks is being able to traverse the JSON AST of the liquid schema in a controlled and robust manner.

Before you deploy

  • This PR includes a new checks or changes the configuration of a check
    • I included a minor bump changeset
    • It's in the allChecks array in src/checks/index.ts
    • I ran yarn build and committed the updated configuration files
      • If applicable, I've updated the theme-app-extension.yml config
  • I included a minor bump changeset
  • My feature is backward compatible
  • I included a patch bump changeset

@navdeep5 navdeep5 changed the title Check for block targeting Check for Valid Block Targeting Nov 6, 2024
@navdeep5 navdeep5 marked this pull request as ready for review November 6, 2024 15:29
Copy link
Contributor

@albchu albchu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really great start here. Thanks Nav!

@navdeep5 navdeep5 linked an issue Nov 7, 2024 that may be closed by this pull request
@navdeep5 navdeep5 force-pushed the navdeep-block-targetting branch 2 times, most recently from 8e60308 to 3d3d201 Compare November 7, 2024 15:50
@navdeep5 navdeep5 marked this pull request as draft November 12, 2024 21:59
@navdeep5 navdeep5 marked this pull request as ready for review November 13, 2024 15:41
@navdeep5 navdeep5 requested a review from albchu November 13, 2024 19:01
Copy link
Contributor

@albchu albchu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code changes and tophat lgtm. The presets as hash stuff also works like magic.

May you also get eyes from Mia and CP on this before we merge?

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.

Verify existence of blocks Block Targeting validation on preset blocks
3 participants