Contact Us menu-bars menu-close

Lightning Component Code Review using Command Line Interface (CLI)


Twinkle Panjabi

November 17, 2017

The Salesforce world is moving fast with Lightning. Lightning is an efficient and consistent interface to navigate through your org and the Lightning Experience takes things to another level. Salesforce has introduced the Lightning Command Line Interface (CLI) to allow us to leverage our code while also ensuring that we follow the Salesforce recommended best practices.


Lightning CLI is a Heroku Toolbelt plugin that lets you scan your code for general JavaScript coding issues and Lightning-specific issues. This tool is based on the ESLint project and finds the issues within the JavaScript code.  As your Lightning component mostly consists of client-side code in the form of JavaScript, it becomes pertinent to have code review checks on a periodic basis.

Lightning CLI alerts you to specific issues related to LockerService. Issues that are flagged include incorrect Lightning components code, and usage of unsupported or private JavaScript API methods. Lightning CLI installs into the Heroku Toolbelt, and is used on the command line.


Step 1: Heroku Installation
Download the Heroku toolbelt on your machine

Step 2: Install Salesforce Lightning CLI
Install Lightning CLI as a Heroku Toolbelt plugin. Once this is done, update the Heroku Toolbelt to get the latest Lightning CLI rules.
heroku plugins:install salesforce-lightning-cli


Step 3: Use Salesforce Lightning CLI

  1. To display the Code Review on the command prompt in a text format, use:
    heroku lightning:lint
  2. To display the Code Review on the command prompt in a JSON format, use:
    heroku lightning:lint . -j
  3. To get the Code Review as a File in a json or text format, use:
    heroku lightning:lint .(Source Path) > report.txtheroku lightning:lint “D:Lightning ComponentContactListsrcauracampingList” > report.txt
    heroku lightning:lint “D:Lightning ComponentContactListsrcauracampingList” -j > report.json


There are quite a few advantages of using the Lightning CLI:

  1. Scan the code locally on the lightning component implemented before submitting the code for reviews
  2. Check/discover the issue related to security and unused variables
  3. Enforce security and code best practices across implementation
I hope you are all set to use the Lightning CLI. In case you feel the need to reference additional knowledge material, the following links are quite helpful:


Get updates. Sign up for our newsletter.


Let's explore how we can create WOW for you!