---
url: https://pug-lint.dev/guide/shopify-polaris.md
description: >-
  Lint and fix Pug templates in a Shopify app built with polaris-vue-elements:
  Polaris web component wrappers, v-model, named slots and eslint --fix.
---

# Using with Shopify Polaris

Shopify apps that run inside the Shopify admin build their UI with
[Polaris web components](https://shopify.dev/docs/api/app-home/web-components) (`<s-button>`,
`<s-text-field>`, `<s-modal>`…). In Vue 3,
[`polaris-vue-elements`](https://polaris-vue-elements.dev/?ref=pug-lint) wraps them as typed
components (`SButton`, `STextField`, `SModal`), and those work in Pug templates like any other
Vue component. This plugin lints and fixes them with no extra configuration.

## Setup

```sh
npm install polaris-vue-elements
npm install --save-dev pug eslint eslint-plugin-vue vue-eslint-parser eslint-plugin-pug-vue
```

```js
// eslint.config.js
import pluginVue from 'eslint-plugin-vue'
import vuePug from 'eslint-plugin-pug-vue'

export default [
  ...pluginVue.configs['flat/recommended'],
  ...vuePug.configs.recommended,
]
```

For the Polaris runtime script and the `isCustomElement` option that `s-*` tags need, follow
[polaris-vue-elements' Getting started](https://polaris-vue-elements.dev/guide/getting-started?ref=pug-lint).

## Before and after `eslint --fix`

A template with inconsistent indentation, quotes and attribute blocks:

```pug
div
    STextField(v-model="name"   label='Name'  )
    SButton(commandFor="demo-modal",command="--show") Open
    s-button(variant="primary" @click="name = ''") Reset
    SModal(id="demo-modal" heading="Demo")
       SText Hello
       template(v-slot:primary-action)
         SButton(variant="primary" commandFor="demo-modal" command="--hide") Close
```

After `eslint --fix`:

```pug
div
  STextField(v-model="name" label="Name")
  SButton(command-for="demo-modal" command="--show") Open
  s-button(variant="primary" @click="name = ''") Reset
  SModal#demo-modal(heading="Demo")
    SText Hello
    template(#primary-action)
      SButton(variant="primary" command-for="demo-modal" command="--hide") Close
```

* [`vue-pug/indent`](/rules/indent), [`vue-pug/attribute-quotes`](/rules/attribute-quotes),
  [`vue-pug/attribute-commas`](/rules/attribute-commas),
  [`vue-pug/no-multi-spaces`](/rules/no-multi-spaces) and
  [`vue-pug/attribute-parens-spacing`](/rules/attribute-parens-spacing) fixed the layout.
* [`vue-pug/prefer-shorthand`](/rules/prefer-shorthand) turned `id="demo-modal"` into
  `#demo-modal`; the button's `command-for` still opens the modal.
* eslint-plugin-vue's `vue/v-slot-style` and `vue/attribute-hyphenation` rewrote the slot to
  `#primary-action` and `commandFor` to `command-for`, which the wrappers accept as well.

The fixed template renders the same in the browser: `v-model` updates, the button opens the
modal, and the Close button lands in the modal's `primary-action` slot.

## Further reading

* [Using Pug templates](https://polaris-vue-elements.dev/guide/pug?ref=pug-lint) in the
  polaris-vue-elements docs: translating its HTML examples to Pug.
* [vue/\* rules on Pug](./vue-rules): how eslint-plugin-vue rules behave on Pug templates.
