EsLint on VS code

I’ve installed for the first time ESLint, I tried it, and I’m a bit surprised about the error message I get in this picture, for instance:


I was expecting an error kind of “b is not defined”. Instead I’m getting what’s in the picture, which I think is not the right error to display. Any advice suggestion? Is it just the way it is, or am I missing some configuration or so?

Hello there,

Carefully, re-read the first word in line 1.

There is no keyword lat in JavaScript. I think you mean let

Hope this helps

1 Like

:grin: :grin: Well, that is what a linter should be for right? why isn’t it showing me that kind of error? On the other hand, I read somewhere that besides the extension, I have to install it globally with npm, like
npm install -g eslint is that correct?
Now that I have let a = 4 + b; I am not getting any error about b not being defined

Linters do not know your intentions. All they can do is say: “Hey, this code will not be interpreted/compiled correctly, because something around here does not follow syntax”

You can control a fair portion of the ESLint testing, by changing its config:

You do not have to. If you want to use it, then you need to install it, but you might be better off installing it just for the projects/workspaces you are sure you want it - helps with versioning and config.

Hope this helps

Thanks, so one more thing. I have a bunch of extensions on VS code, this is the first one that requires me to install the extension and trough npm aswel. Why is that the case and not with the others?

The difference is that this extension isn’t something that’s specific to the appearance of your code editor but is actually just an integration with another tool that’s specific to your project.

ES Lint is a tool that you can use with or without a code editor. Typically ES Lint gets used as a piece of automation. For example, when you push your code to GitHub, a script will run automatically which runs ES Lint. If there are any errors, you won’t be allowed to deploy your changes.

ES Lint is used to enforce code quality standards across many developers working on the same project regardless of which code editor or IDE they use.

The ES Lint extension in VS Code is just surfacing the information provided by ES Lint directly in your editor as visual feedback as apposed to running the tool from the command line. A lot of extensions like this, will often ship with their own copy of the tool pre-installed so that you don’t have to install it, but the idea is that if you’re working on a project with multiple developers you would eventually install the tool as project dependency yourself.

Hope that helps clarify :slight_smile:

It did! Thanks, appreciate it!

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.