microsoft / vscode-eslint

VSCode extension to integrate eslint into VSCode
MIT License
1.74k stars 335 forks source link

Warn about doubled configured validate rules #623

Closed pengxiaotian closed 5 years ago

pengxiaotian commented 5 years ago

我今天更新了eslint 1.18.0 和 vscode 版本: 1.31.0 (user setup) 然后我发现自动修复功能在 .vue 文件中不生效,只是提示错误, 在 .js 文件中一切正常

282159468 commented 5 years ago

same issure in jsx file

BigsonLvrocha commented 5 years ago

In my case, with eslint 1.18.0 and vscode 1.31.1 it's not even working for .js files

dbaeumer commented 5 years ago

@pengxiaotian can you please provide a description in English?

dbaeumer commented 5 years ago

Did you enable auto fix in Vue files as described here for eslint.validate

dbaeumer commented 5 years ago

See also https://github.com/Microsoft/vscode-eslint/issues/185#issuecomment-307842751

pengxiaotian commented 5 years ago

@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

dbaeumer commented 5 years ago

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.

pengxiaotian commented 5 years ago

I have already installed

image

dbaeumer commented 5 years ago

That looks OK. Can you provide me with a GitHub repository I can clone that demos what you see.

pengxiaotian commented 5 years ago

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

pengxiaotian commented 5 years ago

If the address cannot be accessed, this is the compressed package of the code. VCharts-UI.zip

pengxiaotian commented 5 years ago

I don't think this has anything to do with the code......... All my projects have the same problem

dbaeumer commented 5 years ago

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.

dbaeumer commented 5 years ago

capture

pengxiaotian commented 5 years ago

Now only the error is indicated. When I save, the three semicolons should be automatically fixed and deleted. image

dbaeumer commented 5 years ago

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:

capture

dbaeumer commented 5 years ago

Actually I see this when adding extract semicolons when produced by eslint:

capture

dbaeumer commented 5 years ago

What happens if you run eslint on the command line on that file using the --fix option

pengxiaotian commented 5 years ago

It stands to reason that eslint should be fixed automatically when I save it, but it doesn't actually. type Ctrl + S image image

pengxiaotian commented 5 years ago

These operations are normal in the .js file.

pengxiaotian commented 5 years ago

Problem with the --fix option was successfully fixed

image

dbaeumer commented 5 years ago

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.

pengxiaotian commented 5 years ago

I know what went wrong, it is the reason for the configuration. But I don't know what the specific reason is.

correct configuration image

wrong configuration image

Is this order important?

dbaeumer commented 5 years ago

The problem is that "vue" is listed two times one as a string and one as a literal. Simply the second one wins

pengxiaotian commented 5 years ago

I think this is an invisible rule and should be annotated. I see that many people are configured this way.

vscodebot[bot] commented 5 years ago

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!

Joker0824 commented 4 years ago

I find the issue when the .vue file is to big(when the code is more than 1000 lines)