DEV Community

Ambika
Ambika

Posted on

ESLint Inrtoduction

Linting is identifying problem and syntax error in JS code. JS is dynamic language and loosely typed. we can write as we want. Like that of freeness it gives can be chance of bad code.
eg:--function with no return type, no semicolon. code will work but in edge scenarios it will fails.

ESLint is useful tool for JS application to find bugs and styling. Its the most popular js linter. Its popular because it allows use to write customized rules as per application need.

The term lint is a static code analysis tool used to flag programming error, bugs, stylish errors and suspicious constructs.

Image description

In above example, function returns true only when the number is positive. Variable x is defined but not used in the code.
The code works but it will break through error in edge scenarios.

ESLint will try to find x is used or not anywhere and value is returned in all scenarios in function. ESLint statically analyze your code to quickly find problems. ESLint is built into most text editors, and you can run EsLint as part of your continuous integration pipeline.
Many problems EsLint finds can automatically fixed using the --fix option.

ESLint uses Espree for JS parsing .
ESLint usese an AST to evaluate patterns in code
ESLint is completely pluggable .Every single rule is a plugin, and you can add more at runtime.

Top comments (0)