As we know that Linting is an important part of daily workflow. Eslint is a great linting tool for your ECMAScript/JavaScript code . You can use the rules defined on it or even though you can create your own custom rules, as i have used this tool in one of my project. Install locally via npm:-
npm install eslint --save-dev
after that setup a configuration file:-
./node_modules/.bin/eslint --init
after that you can run it easily via:-
$ ./node_modules/.bin/eslint yourfile.js
you can install it globally via:-
$ npm install -g eslint
setup a configuration file:-
$ eslint --init
run directly via:-
$ eslint yourfile.js
After installation you can configure your rules in configuration file:- In the .eslintrc file
{
"rules": {
"semi": ["error", "always"],
"quotes": ["error", "double"]
}
}
You can also create your custom rules at runtime a great feature of Eslint if you want to create like:-
1)You need to place all runtime rules in the same directory
2)You need to create a configuration file and need to define your rule Id error level under rules key.
3)Run the command over terminal i.e. --rulesdir (this is an option to specify location of your rules)
Hope it would helps !
Thanks
More From Oodles
Ready to innovate? Let's get in touch
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Parveen Kumar Yadav
Parveen is an experienced Java Developer working on Java, J2EE, Spring, Hibernate, Grails ,Node.js,Meteor,Blaze, Neo4j, MongoDB, Wowza Streaming Server,FFMPEG,Video transcoding,Amazon web services, AngularJs, javascript. He likes to learn new technologies