Shopify / Shopify/theme-tools

[Feature Request]: LiquidSchema(node) check type for SourceType.LiquidHtml

Open
#817 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area:theme-check tech debt
Dominant language
TypeScript
Stars
234
Forks
92
Avg merge
1d 3h
Merged PRs (30d)
6

Description

Feature Request

In theme-check-common, this is far too common of a pattern:

  create(context) {
    return {
      async LiquidRawTag(node) {
        if (node.name !== 'schema' || node.body.kind !== 'json') return;

        const schema = await getSchema(context);

        const { validSchema, ast } = schema ?? {};
        if (
          !validSchema ||
          validSchema instanceof Error ||
          !ast ||
          ast instanceof Error
        ) {
          return;
        }

As our library of theme checks grow, this is only becoming a larger bit of duplicated overhead between checks that validate some details within a valid liquid schema.

Describe the solution you'd like
Id like to see a new CheckNodeMethod like LiquidSchema that only triggers once these checks are performed. Then we only trigger checks like this once the liquid schema has passed basic json validation.

This can improve readability and performance across all liquid checks that look at the liquid schema.
It can look like:


export const SomeSweetNewCheck: LiquidCheckDefinition = {
  meta: { ...meta, type: SourceCodeType.LiquidHtml },

  create(context) {
    return {
      async LiquidSchema(node) {
        const { validSchema, ast } = node.schema;
        ...
        // Insert sweet functionality here

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in theme-check-common by reading the existing LiquidRawTag handling and the CheckNodeMethod and LiquidCheckDefinition patterns. Define what the LiquidSchema node should expose after valid JSON schema parsing, then verify that schema-specific checks can use it and that the new event only runs for SourceCodeType.LiquidHtml.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.