ESLint is a pluggable linter for JavaScript. It is designed so that all of its rules are completely pluggable and allows developers to customize the linting rules. ESLint is shipped with some built-in rules to make it useful from the start, but you can dynamically load rules at any point in time. For example, ESLint disallows duplicate keys in object literals (no-dupe-keys), and you will get an error for the following code:
var message = {
text: "Hello World",
text: "qux"
}
The correct code under this rule will look like the following:
var message = {
text: "Hello World",
words: "Hello World"
}
ESLint will flag the preceding error and we will have to fix it manually. However, can use the --fix option on the command line to automatically fix problems that are more easily fixed without human intervention. Let's see how to do so in the following steps:
- Install ESLint via npm in your project:
$ npm i eslint --save-dev
- Set...