Lightning Component Code Review using Command Line Interface (CLI)
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.
WHAT IS LIGHTNING CLI?
HOW TO USE LIGHTNING CLI?
Step 1: Heroku Installation
Download the Heroku toolbelt on your machine from the following link:
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
- To display the Code Review on the command prompt in a text format, use:
- To display the Code Review on the command prompt in a JSON format, use:
heroku lightning:lint . -j
- 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:
- Scan the code locally on the lightning component implemented before submitting the code for reviews
- Check/discover the issue related to security and unused variables
- Enforce security and code best practices across implementation