theme-check
theme-check copied to clipboard
Feature Request - Add flag to filter errors for specific files
I think this is a pretty important feature for people who are adding Theme Check to existing themes. The codebase I'm working on has a huge amount of errors and it's not realistic for us to fix everything in one pass.
My ideal situation would be:
shopify theme check [file1] [file2]
I think this should work with lint-staged without having to configure too much stuff
This could work but we're faced with a choice on the implementation side:
- We disable whole theme checks -- checks that work on multiple files at once -- when going that route (e.g. unused snippets, matching translations)
- We keep whole theme checks
What would you expect the tool did for you if you didn't look at the docs?
I would expect the whole theme checks to be Enabled, but only report errors for the given files. And if autofix
is enabled, then autofix should not touch any file out of the args.
I've added partial support for this in Shopify/theme-check-action. Now that we annotate files, if you have the following configuration, only the diff'ed files will be annotated on your PR:
- name: Theme Check
uses: shopify/theme-check-action@v1
with:
theme_root: '.' # optional, could be './dist'
token: ${{ github.token }}
base: main
Is that enough for you?
The approach I used was to use -o json
option and filter the results after the fact. I didn't go with the CLI argument route because shells typically have a limit of arguments you pass to them. By outputting the list of diffed files to a file, we can avoid the 250 argument limit as well as requiring you to write a complicated pattern that might work.
A --filter
might still be desirable. But I'm not sure it's that great for this particular use case. Maybe if we let that accept files as input. I'm open to suggestions.