简体   繁体   中英

EsLint won't work VS 2017

I have Visual Studio Enterprise 2017 with Eslint enabled in the Options. When I rebuild the solution, eslint won't show any errors. I intentionally wrote some broken javascript to test, but it won't show in the VS errors/warnings list.

var x = 3;
if (x == 3) { y = 6 }

If I run eslint from the command line it throws an error because of the above statement violating the eqeqeq rule, but it won't in VS 2017.

Here is my .eslintrc

{
  "parserOptions": {
    "parser": "babel-eslint",
    "sourceType": "module"
   },
   "env": {
   "amd": true,
    "browser": true,
    "jquery": true,
    "node": true,
    "es6": true,
    "worker": true
  },
  "rules": {
    "eqeqeq": 1
  }
}

Also if this is any help under the Options > Web > Code Analysis, I have Clean Errors On Build: True, Ignore Nested Files: False, and Ignore Patterns: "".

In order to leverage a project level .eslinterc file, you have to reference your visual studio "global" level .eslintrc inside your project level .eslintrc using the "extends": property.

docs: https://eslint.org/docs/user-guide/configuring#using-a-configuration-file

how to get to your vs global .eslintrc config: ESLint support Visual studio 2017

ESLint in VS2017 seems to be outdated, so it isn't able to process .eslintrc files in solution root. My current solution to this problem is to use VisualLinter extension which shows warnings/errors in the Error List as expected from built-in ESLint.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM