microsoft / vscode-eslint

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

Numerous red underlines for things being not defined #254

Closed ghost closed 7 years ago

ghost commented 7 years ago

Command line eslint is fine. In VSCode I see hundreds of red underlines with similar messages to, [eslint] 'describe' is not defined. (no-undef) I'm on Windows 10.

Here's our .eslintrc.json file,

{
  "extends": "eslint:recommended",
  "parser": "babel-eslint",
  "env": {
    "browser": true,
    "es6": true
  },
  "ecmaFeatures": {
    "arrowFunctions": true,
    "blockBindings": true,
    "classes": true,
    "defaultParams": true,
    "destructuring": true,
    "forOf": true,
    "generators": false,
    "modules": true,
    "objectLiteralComputedProperties": true,
    "objectLiteralDuplicateProperties": false,
    "objectLiteralShorthandMethods": true,
    "objectLiteralShorthandProperties": true,
    "spread": true,
    "superInFunctions": true,
    "templateStrings": true,
    "jsx": false
  },
  "rules": {
    "indent": ["error", "tab", { "SwitchCase": 1 }],
    "no-console": ["error", { "allow": ["warn", "error"] }],
    "no-unused-vars": ["error", { "args": "none" }]
  },
  "globals": {
    "io": true
  }
}
$ npm run lint

> shell@0.1.0 lint C:\Users\scott\src\GITROOT\PlutoVR\shell
> eslint src
dbaeumer commented 7 years ago

Is both the eslint and the babel-eslint installed locally. ESlint doesn't support having the eslint npm module install locally (e.g in the workspace's node_modules folder) and a plugin globally. I guess when you run it in a shell both is used from the global path.

dbaeumer commented 7 years ago

I that is not the case can I close a repository showing the behavior.

ghost commented 7 years ago

Sorry I don't totally understand your questions. Are you asking are eslint and babel-eslint installed (i.e. npm install)? Looking at my devDependencies in package.json eslint is not in there (it is installed globally on the system).

$ where eslint
C:\Users\scott\AppData\Roaming\npm\eslint
C:\Users\scott\AppData\Roaming\npm\eslint.cmd
  "devDependencies": {
    "aurelia-cli": "0.23.0",
    "aurelia-testing": "1.0.0-beta.2.0.0",
    "aurelia-tools": "0.2.2",
    "babel-eslint": "6.0.4",
    "babel-plugin-syntax-flow": "6.8.0",
    "babel-plugin-transform-decorators-legacy": "1.3.4",
    "babel-plugin-transform-es2015-modules-amd": "6.8.0",
    "babel-plugin-transform-es2015-modules-commonjs": "6.10.3",
    "babel-plugin-transform-flow-strip-types": "6.8.0",
    "babel-polyfill": "6.9.1",
    "babel-preset-es2015": "6.9.0",
    "babel-preset-es2015-loose": "7.0.0",
    "babel-preset-stage-1": "6.5.0",
    "babel-register": "6.9.0",
    "bootstrap-sass": "3.3.7",
    "browser-sync": "2.13.0",
    "connect-history-api-fallback": "1.2.0",
    "gulp": "github:gulpjs/gulp#4.0",
    "gulp-babel": "6.1.2",
    "gulp-changed-in-place": "2.0.3",
    "gulp-eslint": "2.0.0",
    "gulp-notify": "2.2.0",
    "gulp-plumber": "1.1.0",
    "gulp-rename": "1.2.2",
    "gulp-sass": "2.3.2",
    "gulp-sourcemaps": "2.0.0-alpha",
    "jasmine-core": "2.4.1",
    "karma": "0.13.22",
    "karma-babel-preprocessor": "6.0.1",
    "karma-jasmine": "1.0.2",
    "karma-phantomjs-launcher": "1.0.4",
    "minimatch": "3.0.2",
    "phantomjs-prebuilt": "2.1.14",
    "through2": "2.0.1",
    "uglify-js": "2.8.10",
    "vinyl-fs": "2.4.3"
  }
ghost commented 7 years ago

So your recommendation would be to add eslint to my devDependencies?

ghost commented 7 years ago

???

dbaeumer commented 7 years ago

ESLint (https://github.com/eslint/eslint) requires eslint itself and the plugins to both be installed locally or globally. Since the plugins are installed locally you need to install eslint locally as well. This is how ESLint itself works and has nothing to do with the ESLint VS Code extension.

If this is not fixing your problem can you please provide a GitHub repository I could clone to reproduce.

ghost commented 7 years ago

Adding eslint to the package.json did in fact address the bulk of the red lines I was seeing. The other thing I did was to add "jasmine": true to the env section of my .eslintrc.json file. That addressed all the red lines under the describe etc. Thanks for your assistance!