-
Notifications
You must be signed in to change notification settings - Fork 350
Autofix does not work on .vue files #185
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
Comments
This is because of BenoitZugmeyer/eslint-plugin-html#38. I took a defensive approach here to ensure that this doesn't break code especially when enable during save. I will update the readme to make this more clear. I am still debating whether I should provide different options for different file types. |
@dbaeumer Any estimated time on this? Anyway, great job with the plugin! Thanks for the good work! |
I am working on making this a configuration. However as long as the plugins are not fixing this I can't do much. The vue-eslint-parser is showing the same problem. That auto fix positions are of therefore applying them results in incorrect textual changes: @mysticatea are you aware of this. I tested this with the vue-eslint-parser plugin. |
Oh, I had not aware of that. Thank you for pointing it out! |
Hmm, actually, I could not reproduce it with |
I published version 1.2.2 of the ESLint extension. It allows for selective autoFix configuration. From the readme: Added configuration options to enable code actions and auto fix on save selectively per language. In release 1.2.1 code actions and auto fix on save very still only "eslint.validate": [ "javascript", "javascriptreact", { "language": "html", "autoFix": true } ] |
Thank you so much! |
OK. Let me have a look then. I take the fixes directly from the reported problem. |
@dbaeumer Thank a lot. Instead of fixing doublequote issue, my tag got modified in a weird way: |
@congrady yes, this is why I made this an option and disabled by default. Which ESLint plugin are you using? eslint-pluing-html? If so please follow BenoitZugmeyer/eslint-plugin-html#38 |
@mysticatea I can't reproduce it with an simple example either: Will investigatre further. |
It does reproduce with this example <script src="https://unpkg.com/vue/dist/vue.js"></script>
<html>
<script>
function foo() {
}
foo();;
</script>
</html> |
The reported problem looks like this: And the range [117, 118] reported in the fix denotes "(" of "foo()". The string content is @mysticatea any idea why this is happening ? |
An easier example is <script src="https://unpkg.com/vue/dist/vue.js"></script>
<html>
<script>
foo();;
</script>
</html> The fix denotes position [91,92] in that string which is the ")" of foo() |
Minimal case: <script>
foo();;
</script> |
OK. I found it. It is related to the line ending everything works correct if the line ending is Unix style Since I pass the string with |
@dbaeumer Tried updating eslint-plugin-html to 'BenoitZugmeyer/eslint-plugin-html#v2' Issue still persist (autofix doesn't fix the real problem, but instead does random stuff). And I started getting this error everytime I edit my .vue file |
@congrady can you please open an issue against 'BenoitZugmeyer/eslint-plugin-html with steps to reproduce. There is little I can do to fix this. |
@aeschli would your HTMl parser help here? |
Oh, sorry, that problem has solved in vuejs/vue-eslint-parser@c3150da. |
Great. Thanks a lot. Will give a test today. |
Verified that the problem is gone using vue-eslint-parser 0.1.4 |
@dbaeumer Hello, could you please show me a working .eslintrc config file? For me it stil doesn't work, using this configuration: Doesn't fix the right issue and some issues aren't even shown. |
Works like a charm! 👍 Thank you so much! |
besides the 3 steps,what else I have missed? |
@zzzgit you need to let the eslint extension know that it should autofix your file type. Some like described in comment #185 (comment) |
thanks,it works |
I only add this to settings.json and it works :
|
@dbaeumer Still not working properly,When I try to autofix my elsint issues, I get incorrect textual changes.fix information have incorrect positions.This is my config // 将设置放入此文件中以覆盖默认设置
{
"editor.fontSize": 18,
"eslint.autoFixOnSave": true,
"files.associations": {
"*.vue": "vue"
},
"terminal.integrated.cursorStyle": "line",
"terminal.integrated.shell.windows": "F:\\Git\\bin\\bash.exe",
"eslint.validate": [
"javascript",
"javascriptreact",
{ "language": "html", "autoFix": true },
{ "language": "vue", "autoFix": true }
],
"eslint.options": {
"plugins": ["html"]
},
"workbench.iconTheme": "vscode-icons",
"editor.tabSize": 2,
"telemetry.enableCrashReporter": true,
"workbench.colorTheme": "Material Palenight",
"editor.fontFamily": "Courier New",
"auto-rename-tag.activationOnLanguage": [
"html",
"xml",
"php",
"javascript"
],
"fileheader.Author": "candy",
"fileheader.LastModifiedBy": "candy"
}```
and i was also tried to include parser in my .eslintec.json but didn't work .
```js
{
"env": {
"node": true,
"es6": true,
"browser": true
},
"globals": {
"$": true
},
"parser": "babel-eslint",
"extends": "airbnb",
"plugins": [
"html"
],
"rules": {
...
}
} |
@zp112 can you please open a new issues with steps on how to reproduce your problem (best would be a GitHub repository I can clone). I quickly tested it and autofix does work for me in my simple setup. |
I'm using ESLint with vue-eslint-parser then I enabled
vscode-eslint
for.vue
files.vue-eslint-parser
supports autofix for.vue
files. Buteslint.autoFixOnSave
option andeslint.executeAutofix
command did not work on.vue
files.The text was updated successfully, but these errors were encountered: