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

Introducing UndefinedObject check #115

Merged
merged 3 commits into from
Sep 29, 2023
Merged

Introducing UndefinedObject check #115

merged 3 commits into from
Sep 29, 2023

Conversation

karreiro
Copy link
Contributor

Fixes https://github.com/Shopify/theme-check-js/issues/66

--demo.mp4

What are you adding in this PR?

The UndefinedObject check is being introduced to identify references to undefined Liquid objects.

This implementation largely mirrors the Ruby version, and intentionally skips snippet assets. This is because these assets depend on variables defined in parent templates, and Theme Check is designed to focus on single asset checks.

Looking ahead, the following issue is planned to be addressed next: #114. Once resolved, developers will be able to annotate available variables, thereby establishing an interface/contract between Liquid templates.

Finally, this check doesn't currently provide a fix or suggestion, as the main approaches would be about (1) removing the variable or (2) ignoring the check. To enhance this, I've opened a new issue: #113. This proposes a global 'ignore check' implementation, so all checks will be able to suggest an ignore dialog. I don't foresee this leading to overuse of the ignore function, as I the ignore-code introduces some noise.

Before you deploy

  • This PR fixes a bug
    • I included a patch bump changeset to this PR

Copy link
Contributor

@charlespwd charlespwd left a comment

Choose a reason for hiding this comment

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

Really excellent work. Only needs the access logic from TypeSystem and ready to go after.

karreiro and others added 2 commits September 29, 2023 09:55
Co-authored-by: CP Clermont <cp.clermont@shopify.com>
- Eliminate unnecessary usage of `node.blockEndPosition`
  since the `assign` tag doesn't have a corresponding end tag
- Implement `docset->objects[0]->access` logic to consider
  only global objects during this check
@karreiro
Copy link
Contributor Author

Thanks a lot for the review, @charlespwd! Changes applied :)

@karreiro karreiro requested a review from charlespwd September 29, 2023 08:56
Copy link
Contributor

@charlespwd charlespwd left a comment

Choose a reason for hiding this comment

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

Lesgoo

@charlespwd charlespwd merged commit 30dacb7 into main Sep 29, 2023
@charlespwd charlespwd deleted the fix-66 branch December 2, 2023 19:05
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.

2 participants