Skip to content

Add Vetur settings to "Why doesn't it work on .vue file?" #559

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 18, 2018
Merged

Add Vetur settings to "Why doesn't it work on .vue file?" #559

merged 2 commits into from
Sep 18, 2018

Conversation

adi518
Copy link
Contributor

@adi518 adi518 commented Aug 16, 2018

I had an issue where the plugin works, but red markings of errors remained. So I found out the instructions for this section are missing a note regarding Vetur. You need the following setting to complete the setup:

"vetur.validation.template": false

Note: While it solved my issue, there is something to consider with how it's applied. Eslint is mostly used in a per-project manner. This means, if you apply the rule above to settings.json, it's applied globally, thus Vue projects that do not use this plugin will not show template errors. To solve this, you need to apply the setting locally. In the context of VS Code, it's easy. You just save a "workspace" to your project root and that creates a file, where you can apply the settings, thus locally. See here for details.

I had an issue where the plugin works, but red markings of errors remained. So I found out the instructions for this section are missing a note regarding Vetur. You need the following setting to complete the setup:
```
"vetur.validation.template": false
```

Note:
While it solved my issue, there is something to consider with how it's applied. Eslint is mostly used in a per-project manner. This means, if you apply the rule above to `settings.json`, it is global a rule and Vue projects that do not use this plugin will not show template errors. So to solve this, you need to apply the setting locally. In the context of VS Code, it's easy. You just save a "workspace" to your project root and that creates a file, where you can apply the settings, thus locally. See [here](microsoft/vscode#37519) for details.
README.md Outdated
@@ -286,6 +286,7 @@ The `vue-eslint-parser` uses the parser which is set by `parserOptions.parser` t
2. Make sure your tool is set to lint `.vue` files.
- CLI targets only `.js` files by default. You have to specify additional extensions by `--ext` option or glob patterns. E.g. `eslint "src/**/*.{js,vue}"` or `eslint src --ext .vue`.
- VSCode targets only JavaScript or HTML files by default. You have to add `"vue"` to the `"eslint.validate"` array in vscode settings. e.g. `"eslint.validate": [ "javascript", "javascriptreact", "vue" ]`
- Set VSCode Vetur settings: `"vetur.validation.template": false` to avoid Vetur template validation overriding plugin validation.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should just point to this resource: https://github.com/vuejs/vetur/blob/master/docs/linting-error.md
This contains nice instruction of how to best use and configure vetur to work nicely with eslint-plugin-vue

Copy link
Contributor Author

@adi518 adi518 Sep 25, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea. So we could write something along "If you use Vetur, see here how to configure eslint-plugin-vue for Vetur."

The bottom line, if you use Vetur, which supplies their own default configuration for this plugin, you have to disable their template validation completely and supply your custom configuration, preferably based on theirs to keep it consistent. Alternatively based on what is suggested in our readme.

@michalsnik michalsnik merged commit 562fde1 into vuejs:master Sep 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants