Exercise: Use Grunt!

Try linting some code using Grunt!

Problem statement

A linting program is used to flag anything that may be wrong with a piece of code. More formally, “lint, or a linter, is a static code analysis tool used to flag programming errors, bugs, stylistic errors, and suspicious constructs.” (Wikipedia).

Linting can save you many hours of work in the long run, especially in a team setting, because your code will be intuitive, bug-free, and will follow common stylistic practices, all of which are usually fixed at the review stage. If they are not fixed at the review stage, then bad code goes into production, and costs the team hours of work when the code needs to be looked at again.

So, it’s a good practice to lint, and linting JavaScript can be automated with Grunt. Hence, in this exercise, use the Grunt ESLint plugin to lint the file app.js. The Gruntfile is currently empty, and running it without filling it will throw an error. Your code is in the /eslint directory. To save your changes, click Run.

Sample input

function alertApp(){
 		 alert("a basic app!");
}

Sample output

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.