2.5.0 • Published 28 days ago

@shopify/theme-check-common v2.5.0

Weekly downloads
-
License
MIT
Repository
github
Last release
28 days ago

Theme Check helps you follow best practices by analyzing the files inside your Shopify theme.

Theme Check is available to code editors that support the Language Server Protocol.

You may be interested by the sibling modules:

  • @shopify/theme-check-common: (you are here) npm module to run checks on a Theme (runtime agnostic).
  • @shopify/theme-check-node: npm module to run checks from a Node.js runtime.
  • @shopify/theme-check-browser: npm module to run checks in a Browser.

Installation

CLI

Theme Check is integrated in the Shopify CLI.

shopify theme check

As a library

There are three libraries:

yarn add @shopify/theme-check-node
yarn add @shopify/theme-check-common
yarn add @shopify/theme-check-browser

Usage

This repo only contains the library over the functionality. The CLI is implemented in Shopify/cli.

For CLI usage documentation, refer to shopify.dev.

Node

The node version comes with batteries included. All you need is the root path of the theme.

// simple-cli.ts
import { check } from '@shopify/theme-check-node';

async function main() {
  const root = process.cwd();
  const offenses = await check(root);
  console.log(offenses);
}

main();

Browser

The browser version is a bit more complex, you need to provide your own implementation of all the dependency injections.

import { simpleCheck, recommended, ThemeData, Config, Dependencies } from '@shopify/theme-check-browser';

async function main() {
  const themeDesc = {
    'snippets/product-card.liquid': '{{ product | image_url | image_tag }}',
    'snippets/for-loop.liquid': '{% for variant in product.variants %}...{% endfor %}',
  };

  const config: Config = {
    checks: recommended,
    settings: {},
    root: '/',
  };

  const dependencies: Dependencies = {
    // ...
  };

  const offenses = await simpleCheck(themeDesc, config, dependencies);

  console.log(offenses);
}

main();

Contributing

See CONTRIBUTING.md.

2.5.0

28 days ago

2.4.0

1 month ago

2.3.0

1 month ago

2.2.2

2 months ago

2.2.1

2 months ago

2.2.0

2 months ago

2.1.0

2 months ago

2.0.4

3 months ago

2.0.3

3 months ago

2.0.2

3 months ago

2.0.1

3 months ago

2.0.0

4 months ago

1.22.0

5 months ago

1.21.0

6 months ago

1.20.1

6 months ago

1.20.0

6 months ago

1.19.0

6 months ago

1.18.2

6 months ago

1.18.1

6 months ago

1.18.0

6 months ago

1.17.0

7 months ago

1.16.1

7 months ago

1.16.0

7 months ago

1.15.0

7 months ago

1.14.1

7 months ago

1.14.0

7 months ago

1.13.1

7 months ago

1.13.0

7 months ago