今日已更新 246 条资讯 | 累计 21112 条内容
关于我们

How to add eslint-disable comments in pug code inside a Vue SFC file?

/u/bcons-php-Console 2026年06月04日 16:26 5 次阅读 来源:Reddit r/webdev

Hi! I'm having some trouble with eslint-disable comments for HTML elements defined inside a Vue SFC pug template, eslint do not recognize them and keeps throwing warnings. What I've tried so far: Comments inside the pug template, both // and //- <template lang="pug"> // eslint-disable-next-line vuejs-accessibility/no-static-element-interactions -- Standard video player click-to-play-pause behavior video(@click="togglePause" ...) </template> <template lang="pug"> //- eslint-disable-next-line vuejs-accessibility/no-static-element-interactions -- Standard video player click-to-play-pause behavior video(@click="togglePause" ...) </template> My next options are not optimal, but I ran out of ideas: A comment inside the script setup tag (it is placed before the template in the file): <script setup> //eslint-disable vuejs-accessibility/no-static-element-interactions </script> A comment at the very top of the file, before any other code <!-- eslint-disable vuejs-accessibility/no-static-element-interactions --> <script setup></script> <template lang="pug"></template> None of this worked. The only way I managed to make this work was creating overrides in .eslintrc.cjs: // Since eslint-disable comments do not work for HTML elements inside pug we // must include those overrides here. overrides: [ { // Standard video player click-to-pause behavior files: ["src/components/common/SimpleMp4Viewer.vue"], rules: { "vuejs-accessibility/no-static-element-interactions": "off" } } ] Do you know if I am missing something here? The eslint related packages I have in my projects are: dependencies "eslint-config-prettier": "^10.1.8", devDependencies "@rushstack/eslint-patch": "^1.8.0", "@vue/eslint-config-prettier": "^9.0.0", "eslint": "^8.57.0", "eslint-define-config": "^2.1.0", "eslint-plugin-unused-imports": "^4.4.1", "eslint-plugin-vue": "^9.27.0", "eslint-plugin-vue-pug": "^0.6.2", "eslint-plugin-vuejs-accessibility": "^2.5.0", Thank you! submitted by /u/bcons-php-Console [link] [留言]

本文内容来源于互联网,版权归原作者所有
查看原文