M
M
Maa-Kut2016-11-28 18:09:29
JavaScript
Maa-Kut, 2016-11-28 18:09:29

VSCode, Gulp and Eslint: which one is lying?

Good day everyone.
Please help me with setting up linter in Visual Studio Code and Gulp. So, we have a project that Gulp builds; there is a task for the project:

var gulp = require("gulp");
var eslint = require("gulp-eslint");

gulp.task("lint", function () {
  return gulp.src("js/**")
    .pipe(eslint({ fix: true }))
    .pipe(eslint.format())
    .pipe(eslint.failAfterError());
});

At the root, as expected, is .eslintrc, which contains, say, the following rule:
{
    "extends": "eslint:recommended",

    "parser": "babel-eslint",

    "env": { "browser": true, "jquery": true, "es6": true },

    "parserOptions": {
        "ecmaVersion": 6,
        "sourceType": "module",
        "ecmaFeatures": { "classes": true }
    },

    "rules": { "strict": [2, "function"] }
}

I write a function without "use strict" in some JS file:
function dummy() {
    console.log("dummy");
}

In VSCode this function is underlined as an error by eslint: Use the function for of "use strict". However, if I do gulp lint, then no errors are thrown.
So, the question is: who of all these guys is lying, and who is right?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikita Kit, 2016-11-28
@Maa-Kut


Use the function for "use strict"
This is more of a warn than an error. Therefore, nothing is output to the console. It's just that in VSCode the console shows eslint warnings, but the terminal doesn't seem to. In addition, your code will probably compile, because, unlike error, warn is not a reason to interrupt linting.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question