If you are building a Lightning App/Community by custom components then you must ensure that your components are gonna work after Summer ’17 release. Because Salesforce is going to activate LockerServices in all organization that will enforce your code to follow some guideline and practices @https://developer.salesforce.com/blogs/developer-relations/2016/04/introducing-lockerservice-lightning-components.html.
My team is working on same, we are safeguarding our code from LockerServices through lightning code scanner- Lightning Lint Services (https://lightning-linter.herokuapp.com/) that would help you to develop the lightning components meeting best practices of salesforce. This is actually same as Checkmarx code scanner that we use for apex.
Once you will start the using Lightning Lint Services, you may get very different kinds of error message that may take days to fix it. So I tried to compile here bunch of them, thought should share, may save hours of someone!!!
1. “ruleId”: “no-trailing-spaces”: You must need to ensure that you are not putting any blank space after each the line of code.
2. “ruleId”: “comma-spacing”: You must need to add space after each comma, for example- place a space after comma in below line:
component.set(“v.message”, “a message”);
3. “ruleId”: “camelcase”: Do not place an underscore in variable names. for example: var test_var = ”; will throw error; Use var testVar instead.
4. “ruleId”: “no-unused-vars”: Delete a variable if it is declared but not used anywhere in the code.
5. “”ruleId”: “radix””: Means you are parsing anything integer then pass radix too as parseInt(variable, 10)
6. “ruleId”: “no-console”: You can not put console.log() in code.
7. “ruleId”: “brace-style”: Closing curly braces must be in same line. for example:
- if(){}
else{} will throw error…replace as below:
if(){
}else{
} - Below code will throw error. Use child IF along with parent else like }else if(){..}
if(){
}else{
if(){
}else{
}
}