79325122

Date: 2025-01-02 22:45:12
Score: 0.5
Natty:
Report link

a) Is there a way to set breakpoints and debug rules? I haven't found anything online about it.

Didn't find a debugger solution but could add console logs. Need to turn caching is off or delete existing cache so any saved edits would be reloaded when running lint again.

b) Is the parser configured correctly? The docs say to use a string parser: 'vue-eslint-parser', but it errors. Other sources say to use an import parser: vueEslintParser.

The docs are using a string but it wasn't working and had to use an import to get it to work.

import vueEslintParser from 'vue-eslint-parser'

export default [{
  languageOptions: {
    parser: vueEslintParser,

c) How to get access to parserServices? I saw this used a few ways but it ends up undefined here.

The code snippet in the docs didn't work for some reason. Looking at existing rules and defineTemplateBodyVisitor is wrapped by a util of the same name. Digging into it, found context.getSourceCode() which worked.

return context.getSourceCode().parserServices.defineTemplateBodyVisitor({ ... })
Reasons:
  • Blacklisted phrase (1): Is there a way
  • Long answer (-1):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Self-answer (0.5):
Posted by: 1192805