eslint-plugin-vue: valid-v-slot reporting errors on code that works

Tell us about your environment

  • ESLint version: 7.1.0
  • eslint-plugin-vue version: 6.2.2
  • Node version: 12.8.1

Please show your full configuration:

module.exports = {
	root: true,
	parserOptions: {
		parser: `babel-eslint`,
		ecmaVersion: 2017,
		sourceType: `module`,
	},
	env: {
		'node': true,
		'jquery': true,
	},
	extends: [
		`eslint:recommended`,
		`plugin:vue/recommended`,
	],
	ignorePatterns: [
		`!.*`,
		`node_modules/`,
		`wwwroot/`,
	],
	rules: {
		'vue/valid-v-slot': [`error`],
	},
}

What did you do? The below codepen is taken from a code example within Vuetify’s documentation (https://vuetifyjs.com/en/components/data-tables/#slots), where they use modifiers on a v-slot directive and therefore fall foul of the valid-v-slot rule. https://codepen.io/icleolion/pen/ExVJGbv

What did you expect to happen? As I implemented this code before I started using the rule, I knew the code worked as intended and therefore didn’t expect to see the rule to show errors. As per a discussion in Vuetify’s repository, they see this as a valid convention too. https://github.com/vuetifyjs/vuetify/discussions/11486#discussioncomment-18437

What actually happened? eslint-plugin-vue shows an error (as below) on code that works! 'v-slot' directive doesn't support any modifier. eslint(vue/valid-v-slot)

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 21
  • Comments: 21 (6 by maintainers)

Commits related to this issue

Most upvoted comments

Probably it changed to the intended behavior, so I reopen this issue. I think that good to add the allowModifiers option to allow this rule to accept modifiers. We need to see if any changes at the parser are needed.

Also An element cannot have multiple '<template>' elements which are distributed to the same slot when v-slot:body and v-slot:body.prepend are actually different slots.

I’m still getting

'v-slot' directive doesn't support any modifier.eslint-plugin-vue

despite I’ve already added the rule and updated to the latest version (eslint-plugin-vue@7.1.0)

# .eslintrc.js
...
rules: {
  ...
  'vue/valid-v-slot': ['error', { allowModifiers: true }]

I know that ESLint is reading the config file, because if I make a typo it errors in vscode output console. Am I the only one?

your source code probably won’t compile on Vue 3 at this time

add the allowModifiers option

It’s explicitly supported in vue 3 now, it should be allowed by this rule by default.

https://github.com/vuejs/vue-next/issues/1241

Still getting this error on vscode and adding 'vue/valid-v-slot': ['error', { allowModifiers: true }] does not help either.

Only solution so far <!-- eslint-disable-next-line -->

I think this purely a vetur issue trying to use eslint to validate files on top of the default ESLint validation. So to fix this issue I had to set this

// myapp.code_workspace
"settings": {
    "vetur.validation.template": false
}

in the workspace file or the .vscode/settings.json. Using the above solution to change or turn off the vue/valid-v-slot rule inside .eslintrc does not help because I am using eslint-plugin-vue@6.2.2

I know that ESLint is reading the config file, because if I make a typo it errors in vscode output console. Am I the only one?

@redraw No you’re not the only one. VS Code still throws the error, while eslint is doing okay. Still trying to figure out what’s going wrong

this is a solution to the problem. https://stackoverflow.com/questions/61344980/v-slot-directive-doesnt-support-any-modifier

Doesn’t work for me 😦 I have [&#x60;item.actions&#x60;] anyway

PS: I solved my problem. As I sad, I’m using VSCode & Ventur. It was Ventur formatter. Exactly formatter for HTML. I changed prettyhtml to prettier and all works fine. Don’t need .prettier config, I removed it.