Skip to content

यह पेज एक अनुवाद है। यदि यह अंग्रेज़ी पेज से अलग है, तो अंग्रेज़ी पेज ही सही है। English

शुरुआत करें ​

eslint-plugin-pug-vue Vue single-file components में <template lang="pug"> (और lang="jade") को lint और format करता है:

  • eslint-plugin-vue के आपके vue/* rules Pug templates पर चलते हैं, अपने सामान्य नामों और आपके सामान्य options के साथ।
  • vue-pug/* rules खुद Pug को format करते हैं: indentation, attribute layout, quotes, commas, shorthands। एक वैकल्पिक rule Pug के compile-time constructs रिपोर्ट करता है।
  • Pug template को छूने वाला हर fix ESLint के लागू करने से पहले जाँचा जाता है (fix guard), इसलिए --fix और fix-on-save templates को नहीं तोड़ते।
  • न Prettier और न कोई अलग formatter: fixes ESLint से आते हैं।

आवश्यकताएँ ​

  • Node.js ^22.13.0 || >=24
  • ESLint ^9.15.0 || ^10.0.0, केवल flat config (eslint.config.js)
  • eslint-plugin-vue ^10.0.0 और vue-eslint-parser ^10.0.0

Install ​

sh
npm install --save-dev eslint eslint-plugin-vue vue-eslint-parser eslint-plugin-pug-vue
sh
pnpm add -D eslint eslint-plugin-vue vue-eslint-parser eslint-plugin-pug-vue
sh
yarn add -D eslint eslint-plugin-vue vue-eslint-parser eslint-plugin-pug-vue

Configure करें ​

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,
]

...vuePug.configs.recommended को eslint-plugin-vue configs के बाद रखें। यह parser options, processor और वे rules सेट करता है जिनका Pug के लिए बंद होना ज़रूरी है। बाद का कोई config जो अपना processor सेट करे, या किसी crash करने वाले rule को फिर चालू कर दे, Pug फ़ाइलों की linting तोड़ देता है।

चलाएँ ​

sh
npx eslint .          # report problems
npx eslint . --fix    # fix what can be fixed

VS Code में save पर fix करने के लिए Editor सेटअप देखें।

अगले कदम ​

MIT License के अंतर्गत जारी।