Closed pengxiaotian closed 5 years ago
same issure in jsx file
In my case, with eslint 1.18.0 and vscode 1.31.1 it's not even working for .js files
@pengxiaotian can you please provide a description in English?
Did you enable auto fix in Vue files as described here for eslint.validate
@dbaeumer okay,I will consider using English in the future. today, I asked my colleague to install my project on his computer. The same problem. here are some of my configurations:
.eslintrc.js file configuration
// https://eslint.org/docs/user-guide/configuring
module.exports = {
root: true,
parserOptions: {
parser: 'babel-eslint'
},
env: {
browser: true,
},
extends: [
// https://github.com/vuejs/eslint-plugin-vue#priority-a-essential-error-prevention
// consider switching to `plugin:vue/strongly-recommended` or `plugin:vue/recommended` for stricter rules.
'plugin:vue/essential',
// https://github.com/standard/standard/blob/master/docs/RULES-en.md
'standard'
],
// required to lint *.vue files
plugins: [
'vue'
],
// add your custom rules here
rules: {
// allow async-await
'generator-star-spacing': 'off',
// allow debugger during development
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'
}
}
Workspace configuration
{
"editor.tabSize": 2,
"files.associations": {
"*.vue": "vue"
},
"eslint.autoFixOnSave": true,
"eslint.options": {
"extensions": [
".js",
".vue"
]
},
"eslint.validate": [
"javascript",
"javascriptreact",
"html",
"vue",
{
"language": "vue",
"autoFix": true
},
{
"language": "html",
"autoFix": true
}
],
"css.validate": false,
"scss.validate": false,
"stylelint.autoFix": true
}
Partial dependence
{
devDependencies: {
"eslint": "^4.19.1",
"eslint-config-standard": "^10.2.1",
"eslint-friendly-formatter": "^3.0.0",
"eslint-import-resolver-node": "^0.3.2",
"eslint-loader": "^1.7.1",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-node": "^5.2.0",
"eslint-plugin-promise": "^3.4.0",
"eslint-plugin-standard": "^3.0.1",
"eslint-plugin-vue": "^4.0.0",
"stylelint": "^9.10.1",
"stylelint-config-standard": "^18.2.0",
"stylelint-order": "^2.0.0",
"stylelint-webpack-plugin": "^0.10.5"
},
"engines": {
"node": ">= 6.0.0",
"npm": ">= 3.0.0"
}
}
VSCode version: 1.31.1 (user setup) 提交: 1b8e8302e405050205e69b59abb3559592bb9e60 日期: 2019-02-12T02:20:54.427Z Electron: 3.1.2 Chrome: 66.0.3359.181 Node.js: 10.2.0 V8: 6.6.346.32 OS: Windows_NT x64 10.0.17763
Do you have an extension instsalled that adds the VUE file type (e.g. https://marketplace.visualstudio.com/items?itemName=octref.vetur) ?
To make sure we are looking at the same problem could your provide me with a GitHub repository I can clone that demos what you see.
I have already installed
That looks OK. Can you provide me with a GitHub repository I can clone that demos what you see.
Please understand that the source code is not uploaded to github for work reasons. However, I have a personal experimental project here, which is the same problem. https://gitee.com/rapex/VCharts-UI.git
If the address cannot be accessed, this is the compressed package of the code. VCharts-UI.zip
I don't think this has anything to do with the code......... All my projects have the same problem
Can you let me know what you expect to see working and it doesn't with a simple example. I tested it locally and for me eslint validating in Vue files does work.
Now only the error is indicated. When I save, the three semicolons should be automatically fixed and deleted.
This actually doesn't look like an error produced by eslint. All errors produced by the eslint extension have a eslint(code) prefix. Something like:
Actually I see this when adding extract semicolons when produced by eslint:
What happens if you run eslint on the command line on that file using the --fix
option
It stands to reason that eslint should be fixed automatically when I save it, but it doesn't actually. type Ctrl + S
These operations are normal in the .js file.
Problem with the --fix
option was successfully fixed
Since I can't reproduce this can you please create a simple project on GitHub that I can clone that demos this. I agree that this is very likely not specific to your code. It is very likely more caused by a setup problem.
I know what went wrong, it is the reason for the configuration. But I don't know what the specific reason is.
correct configuration
wrong configuration
Is this order important?
The problem is that "vue"
is listed two times one as a string and one as a literal. Simply the second one wins
I think this is an invisible rule and should be annotated. I see that many people are configured this way.
We closed this issue because we don't plan to address it in the foreseeable future. You can find more detailed information about our decision-making process here. If you disagree and feel that this issue is crucial: We are happy to listen and to reconsider.
If you wonder what we are up to, please see our roadmap and issue reporting guidelines.
Thanks for your understanding and happy coding!
I find the issue when the .vue file is to big(when the code is more than 1000 lines)
我今天更新了eslint 1.18.0 和 vscode 版本: 1.31.0 (user setup) 然后我发现自动修复功能在 .vue 文件中不生效,只是提示错误, 在 .js 文件中一切正常