diff --git a/.changeset/theme-check-respect-user-config.md b/.changeset/theme-check-respect-user-config.md new file mode 100644 index 0000000000..6107588da4 --- /dev/null +++ b/.changeset/theme-check-respect-user-config.md @@ -0,0 +1,5 @@ +--- +'@shopify/app': patch +--- + +`runThemeCheck` now respects a user's `.theme-check.yml` in the theme app extension root. When present, theme-check-node auto-discovery is used; otherwise the bundled `theme-check:theme-app-extension` config is applied as before. This lets extensions ignore source directories (e.g. a `src/` folder containing uncompiled Liquid templates) without forking the CLI. diff --git a/packages/app/src/cli/services/build/theme-check.ts b/packages/app/src/cli/services/build/theme-check.ts index 53a00faebd..5fcbb8b3fe 100644 --- a/packages/app/src/cli/services/build/theme-check.ts +++ b/packages/app/src/cli/services/build/theme-check.ts @@ -1,4 +1,5 @@ -import {readFileSync} from '@shopify/cli-kit/node/fs' +import {fileExists, readFileSync} from '@shopify/cli-kit/node/fs' +import {joinPath} from '@shopify/cli-kit/node/path' import {itemToString} from '@shopify/cli-kit/node/output' import {TokenItem} from '@shopify/cli-kit/node/ui' import {Severity, type Offense, check, path as pathUtils} from '@shopify/theme-check-node' @@ -60,7 +61,11 @@ function formatOffenses(offenses: Offense[]): TokenItem { } export async function runThemeCheck(directory: string): Promise { - const configPath = 'theme-check:theme-app-extension' + // Respect a user's `.theme-check.yml` in the extension root when present. + // Falling through to `undefined` lets theme-check-node auto-discover the + // user config; otherwise use the bundled theme-app-extension defaults. + const hasUserConfig = await fileExists(joinPath(directory, '.theme-check.yml')) + const configPath = hasUserConfig ? undefined : 'theme-check:theme-app-extension' const offenses = await check(directory, configPath) const formattedOffenses = formatOffenses(offenses) return itemToString(formattedOffenses)