jsLint Usage
Introducing jsLint.¶
JavaScript doesn't have a compiler that checks our syntax for us. There are some things about JavaScript, like semicolons, where things will work but it is not the right way to code. Is there a way to check our code? Yes!
jsLint is an online web application that will check your code and help you write JavaScript better and faster.
jsLint Overview¶
- When you go to the jsLint site you have an area to enter your code and a settings area with a lot of check boxes.
-
Here are the steps to using jsLint.
-
Access the site at http://www.jslint.com/
- Add the function list to the Global variables box.
- Set the checkboxes in the settings area.
- Copy and paste your code into the top text area.
- Click on the button labelled jsLint.
- Fix errors and issues that jsLint finds.
- When you no longer get an errors box then you are done!
jsLint Settings¶
- Here are the settings that match our course coding standards.
- Add this string to the Global Variables box. This is a time when you should copy and paste.
prompt, alert, openEmployeePayrollRecords, openStudentExamRecords, openStudentEnrollmentRecords, openInventoryItemsRecords, openCustomerGasUsageRecords, isNumeric
- Select checkboxes so that your settings look like this:
Entering Your Code¶
- After you change the setting then copy your code from your editor and paste it into the large text area at the top. Press
Ctl-A
and copy the entire.js
file. This way the line numbers of error messages will match your code. - Then click on the jsLint button.
- Here's what this looks like:
jsLint Errors¶
- When you click the jsLint button you will a list of errors in your code.
- After fixing your errors, click the jsLint button again.
- Just keep fixing your code until the error list goes away.
Labs
- Lab02: jsLint
- unit03/labs/lab-02-jsLint.html