theme-check incorrectly flags options_by_name keys containing spaces as invalid
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 234
- Forks
- 92
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 6
Description
Describe the bug
When a quoted string including a space is included within the opening line of a forloop, theme-check incorrectly reports is as invalid syntax.
Source
{%- for value in product.options_by_name['hello world'].values -%}
{{ value }}
{%- endfor -%}
Expected behaviour
The syntax is fine - there are no issues using this syntax in a theme, so there should be no reported theme-check errors.
Actual behaviour
A syntax error is reported after the space in the quoted string.
Also when theme-check tries to autofix the error on save, it actually creates broken syntax.
The snippet described earlier gets "corrected" to
{%- for value in product.options_by_name['hello -%}
{{ value }}
{%- endfor -%}
I suspect simply not flagging the error to begin would prevent this.
Debugging information
- OS [e.g. Windows, Mac, Linux]: Mac
- OS Version: Tahoe 26.3.1 (a)
- Theme Check Version [e.g. 0.1.0]: 3.94.1 (shopify-cli, I'm not sure if theme check has a different version or where I'd find it)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the reported Liquid for-loop in theme-check 3.94.1 and trace the parser or diagnostic path handling bracketed keys with spaces. Add a regression test for the valid options_by_name['hello world'] expression, then verify that linting reports no error and autofix does not alter the syntax.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- developer-experience, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100