Reputation: 41
I use the normal error logging in the console...
Following the call stack trace and all. Never had much of a problem.
A friend recommended ESLint. After looking at some screenshots, I don't see much of a difference between what ESLint does and normal error logging.
Could anyone please compare the two, perhaps giving pro's and con's.
Bonus Points: include some use-cases in which one would be better than the other.
Upvotes: 0
Views: 697
Reputation: 4285
A linting tool helps me avoid silly mistakes when writing JavaScript. Despite my many years of experience, I still type variable names incorrectly, make syntax errors and forget to handle my errors properly. A good linting tool, or a linter, will tell me about this before I waste my time—or worse, my client’s time. A good linting tool can also help make sure a project adheres to a coding standard.
There are many linters available for JavaScript like JSLint, JSHint, JSCS and ESLint, Let’s take a look at at pros and cons of alternatives:
Pros
Cons
Examples:
you will get lint error for no strict type checking in below code.
`a == b && foo == null`
with lint error you can resolve to this to avoid
`a === b && foo === null`
you will get lint error for no variable declared in below code.
'foo' is assigned a value but never used. and 'bar' is not defined.
var foo = bar;
Upvotes: 1
Reputation: 2406
ESLint:
ESLint is a linter -a tool that analyzes your code and flags potential errors. This is very helpful to avoid common mistakes that are made while you're coding (using undefined variables, syntactic errors, etc).
Pros:
Cons:
Browser Console:
On the other side, the console is a tool that you can find in all modern browsers. As opposed to a linter, in the console you'll find runtime errors -ie. errors occurred during the execution of your code.
ESLint vs Console:
You don't have to choose between one or the other. Both cover different needs and both can help you deliver better software.
If you're coding Front-End JavaScript, I'm sure you already use your browser console on a daily basis.
On top of that, you can choose to use a linter or not.
Upvotes: 1