Skip to content

Using with Shopify Polaris ​

Shopify apps that run inside the Shopify admin build their UI with Polaris web components (<s-button>, <s-text-field>, <s-modal>…). In Vue 3, polaris-vue-elements 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.

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

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 ​

Released under the MIT License.