shopify theme check 报错找不到具体文件怎么定位
现象#
终端末尾只有一行 3 offenses found 和一段被折行的 LiquidHTMLSyntaxError,看不到文件名;CI 退出码为 1,本地编辑器却一条红线都没有。
原因#
- 默认 text 输出按严重级别聚合,长路径被终端宽度截断,文件行被推到上一屏
- 语法错误由 LiquidHTML 解析器抛出,offense 的 location 指向模板起点而非出错 token
- CI 用 --fail-level 改了阈值,warning 也计入失败,日志却只打印 error 段落
- .theme-check.yml 里的 ignore 把真正出问题的目录排除,报错其实来自另一份副本
处理步骤#
- 改用机器可读输出:
shopify theme check --output json > check.json - 取文件与行列:
jq '.issues[] | {filePath, startRow}' check.json - 显式限定目录:
shopify theme check --path .,防止扫到上层仓库 - 生成默认配置核对忽略项:
shopify theme check --init,确认 ignore 没有误伤 sections - 把可疑文件单独抽到临时主题目录,用
--path ./tmp-theme复跑,排除其它文件干扰
验收标准#
check.json 中每条 issue 都带 filePath 与行列号,逐条修完后 shopify theme check 退出码为 0。
本文由 风格技术 技术团队整理,适用于 Shopify 标准版与 Plus 店铺。Shopify 平台能力迭代较快,具体操作路径与字段以官方文档和店铺后台实际版本为准。