अपने vue/* rules को <template lang="pug"> पर चलाएँ, eslint --fix से Pug को format करें, और हर template को सुरक्षित रखें: हर fix लागू होने से पहले जाँचा जाता है।
npm i -D eslint-plugin-pug-vue<template lang="pug">div.card(·class="shadow"·,·:title·=·"title"·)····h2(·v-if='title'·)·{{·title·}}····input(v-model="name"·,·type='text'·disabled)/</template>vue/* rules, Pug पर eslint-plugin-vue के rules Pug templates पर अपने सामान्य नामों और options के साथ चलते हैं: गायब keys, अप्रयुक्त variables, attribute का क्रम, deprecated syntax। जो थोड़े-से rules Pug पर काम नहीं कर सकते, उन्हें बंद कर दिया जाता है, या केवल Pug templates के अंदर चुप कराया जाता है, ताकि वे आपके HTML templates को जाँचते रहें।
<template lang="pug">
ul
li(v-for="todo in todos") {{ todo.title }}
</template>3:3 error Elements in iteration expect to have 'v-bind:key' directives vue/require-v-for-keyeslint --fix से formatting बारह छोटे vue-pug/* rules खुद Pug को format करते हैं: indentation, attribute blocks की spacing, commas, quotes और line breaks, तथा .class / #id shorthands। हर rule के options हैं, और आप किसी को भी बंद कर सकते हैं। न Prettier, और न कोई दूसरा formatter जो save करते समय ESLint से टकराए।
// 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,
]Pug में indentation ही structure है: एक line हिलाइए और tree बदल जाता है। इसलिए ESLint किसी Pug template में fix लिखे, उससे पहले plugin उसे जाँचता है, चाहे fix किसी भी rule से आया हो:
//- the same template to the guard
p(class="intro lead") Hello
p.intro.lead Hello
//- a different one: a class is gone
p.intro Helloइसलिए vue-pug/prefer-shorthand पहली line को दूसरी में बदल सकता है, लेकिन जो fix कोई class खो दे, या किसी line को दूसरे parent में ले जाए, वह कभी लागू नहीं होता।
इसे flat config वाला ESLint 9.15 या 10, eslint-plugin-vue 10 और vue-eslint-parser 10 चाहिए। शुरुआत करें में install, config और VS Code में fix-on-save के चरण हैं। eslint-plugin-vue-pug से आ रहे हैं? माइग्रेशन गाइड पढ़ें।