Source: Eternus Solutions Blog

Eternus Solutions Blog 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. In order to enables us to leverage our code, ensuring at the same time that we follow the Salesforce recommended best practices, Salesforce has introduced Lightning Command Line Interface(CLI).WHAT IS LIGHTNING CLI?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.HOW TO USE LIGHTNING CLI?Step 1: Heroku InstallationDownload the Heroku toolbelt on your machine from the following link:https://toolbelt.heroku.com/Step 2: Install Salesforce Lightning CLIInstall 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-cliStep 3: Use Salesforce Lightning CLITo display the Code Review on the command prompt in a text format, use:heroku lightning:lintTo display the Code Review on the command prompt in a JSON format, use:heroku lightning:lint . -jTo 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 Component\ContactList\src\aura\campingList" > report.txtORheroku lightning:lint "D:\Lightning Component\ContactList\src\aura\campingList" -j > report.jsonADVANTAGESThere are quite a few advantages of using the Lightning CLI:Scan the code locally on the lightning component implemented before submitting the code for reviewsCheck/discover the issue related to security and unused variablesEnforce 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:Referenceshttp://cloudyworlds.blogspot.in/2016/04/lightning-locker-service-salesforce.htmlhttp://www.jitendrazaa.com/blog/salesforce/lightning-component-code-review-using-cli-video/http://peterknolle.com/salesforce-lightning-cli/Written by Twinkle Panjabi, Sr. Salesforce Developer at Eternus Solutions

Read full article »
Est. Annual Revenue
$5.0-25M
Est. Employees
250-500
Jitendra Tanna's photo - President & CEO of Eternus Solutions

President & CEO

Jitendra Tanna

CEO Approval Rating

86/100

Read more