- Continuous supports and updates.
- Easy to install
- Lots of plugin around it
- Easy to start with
Working with ESLint CLI tool:
There are multiple ways you can use ESLint. Either as plugin in Gulp/Grunt or you can use ESLint as CLI tool. Functionality will be same in both cases. However, working with cli tool is easy. This is because you don’t have to setup Gulp/Grunt.
You need to install npm (a node js based package manager) before installing ESLint.
Table of Contents
$ npm i -g eslint
Once finished with installation, you are all set for running tool. If you are not familiar with the rules of ESLint, ESLint provides you to set up basic configuration. For that you have to just pass --init as command line argument. This will prompt a CLI based option list which will ask for your preferences. You can use arrow and spacebar to select your preferences.For more information read: http://eslint.org/docs/user-guide/configuring
$ cd project_name $ eslint --init
Update ESLint configuration file:
Once you finished initialization, you can remove some of the basic checks which may not requires. Go to ESLint config file, in my case it is .eslintrc.json. Because I had selected JSON as configuration file and remove some of the checks (for lines) which are not required. Like- "valid-jsdoc": "error". Since i dont created any JSDoc. Checkout my gist for basic configuration (https://gist.github.com/deepakshrma/43955f73c09e245cee278723072017cf). For more information read: http://eslint.org/docs/rules/
$ gedit .eslintrc.json
How to run ESLint:
Once you done with update. Running ESLint is very easy. You just have to link to ESLint binary and pass the file name on which you want to run checks. Here ESLint follows file patterns. For more information read: http://eslint.org/docs/user-guide/command-line-interface
For Single JS File
$ eslint file-name.js
For multiple JS files
$ eslint file-name1.js file-name2.js
For multiple JS files inside a directory
$ eslint dirname/** or $ eslint dirname/**.js
Tada!! Now you know how to use ESLint. For more information read ESLint. The contributors have created very nice document to read.