Description
Before You File a Bug Report Please Confirm You Have Done The Following...
- I'm using eslint-plugin-vue.
- I'm sure the problem is a parser problem. (If you are not sure, search for the issue in eslint-plugin-vue repo and open the issue in eslint-plugin-vue repo if there is no solution.
- I have tried restarting my IDE and the issue persists.
- I have updated to the latest version of the packages.
What version of ESLint are you using?
9.8.0
What version of eslint-plugin-vue
and vue-eslint-parser
are you using?
- vue-eslint-parser@9.4.3
- eslint-plugin-vue@9.27.0
What did you do?
Configuration
import withNuxt from './.nuxt/eslint.config.mjs'
import pluginVuetify from 'eslint-plugin-vuetify'
import vueParser from 'vue-eslint-parser'
export default withNuxt([{
files: ['**/*.vue'],
languageOptions: {
parser: vueParser,
ecmaVersion: 2020,
sourceType: 'module',
},
plugins: {
vuetify: {
rules: pluginVuetify.rules
}
},
rules: {
...pluginVuetify.configs.base.rules,
}
}]
<template>
<NuxtLayout>
<NuxtPage />
</NuxtLayout>
</template>
What did you expect to happen?
When I run npx eslint .
there should be no errors
What actually happened?
I get the error TypeError: Error while loading rule 'vuetify/no-deprecated-classes': Cannot read properties of undefined (reading 'defineTemplateBodyVisitor')
i.e. context.parserServices
in each rule is undefined (I threw in a console.log()
to verify)
However context.getSourceCode().parserServices
does have a proper parserServices
object complete with a defineTemplateBodyVisitor
etc.
Link to Minimal Reproducible Example
https://github.com/vuetifyjs/eslint-plugin-vuetify
Additional comments
I am attempting to help the vuetify team debug this.
It seems that this was working fine with eslint 8.x and is only and issue with 9.x
context.getSourceCode().parserServices
returns the following
{
program: null,
emitDecoratorMetadata: false,
experimentalDecorators: false,
esTreeNodeToTSNodeMap: WeakMap { <items unknown> },
tsNodeToESTreeNodeMap: WeakMap { <items unknown> },
defineTemplateBodyVisitor: [Function: defineTemplateBodyVisitor],
defineDocumentVisitor: [Function: defineDocumentVisitor],
defineCustomBlocksVisitor: [Function: defineCustomBlocksVisitor],
getTemplateBodyTokenStore: [Function: getTemplateBodyTokenStore],
getDocumentFragment: [Function: getDocumentFragment]
}
But that seems never to be getting injected directly into the context
parameter passed to the create
function. Which is what the expected behavior seems to be based on https://www.npmjs.com/package/vue-eslint-parser#-usage-for-custom-rules--plugins