How it works...

When you first implement a linter in a project with existing source code, it's very likely that there will be issues in your project. These errors are summarized in the output of the linter, and can help gauge how much effort is needed to bring your code into compliance. One really interesting aspect of ESLint is that it has some support for automatically fixing some types of common linter errors.

For example, here is an the output from ESLint after adding it to our Express project:

 38 problems (38 errors, 0 warnings)
26 errors, 0 warnings potentially fixable with the `--fix` option.

These errors are usually limited to whitespace and formatting issues, but can be a big help when bringing a code base into compliance with your linter. Simply run the --fix command through the global eslint command-line utility in order to apply these fixes to your source code:

eslint . --fix

What will remain are the errors that will require direct intervention on your part to resolve. Sometimes these errors are simple mistakes, such as leaving unused variables in your code, or unnecessary console.log statements you had forgotten about:

 12 problems (12 errors, 0 warnings)

With your linter in place, its now much more difficult to forget these simple mistakes and guarantee that your application's source code is tidy and consistently formatted through your entire code base.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.119.157.17